diff options
-rw-r--r-- | dist/core.js | 9 | ||||
-rw-r--r-- | src/Document/Nodes/TextSpan.js | 7 | ||||
-rw-r--r-- | src/Node.js | 2 |
3 files changed, 8 insertions, 10 deletions
diff --git a/dist/core.js b/dist/core.js index 0a9cacb..bf56e1a 100644 --- a/dist/core.js +++ b/dist/core.js @@ -150,7 +150,7 @@ ecrit.Node.prototype.insertNode = function (node, afterId, beforeId) { * @param {Node} node - The node to remove */ ecrit.Node.prototype.removeNode = function (node) { - var foundNode = this.getChildNodebyId(node.id, false); + var foundNode = this.getChildNodeById(node.id); if (foundNode === null || foundNode === this) return; var index = this.children.indexOf(foundNode); @@ -330,13 +330,12 @@ ecrit.TextSpan.prototype._applyTransformation = function (transformation) { var newStr = this.text.substring(0, transformation.index); newStr += this.text.substring((transformation.index + transformation.text.length)); this.text = newStr; - this._emit("textModified", transformation); - return; + break; case "insertText": this.text = this.text.slice(0, transformation.index) + transformation.text + this.text.slice(transformation.index); - this._emit("textModified", transformation); - return; + break; } + this._emit("textModified", { node: this, transformation: transformation }); }; ecrit.TextSpan.prototype._undo = function (transformation) { diff --git a/src/Document/Nodes/TextSpan.js b/src/Document/Nodes/TextSpan.js index 0f80f1b..5a5eebc 100644 --- a/src/Document/Nodes/TextSpan.js +++ b/src/Document/Nodes/TextSpan.js @@ -15,13 +15,12 @@ ecrit.TextSpan.prototype._applyTransformation = function (transformation) { var newStr = this.text.substring(0, transformation.index); newStr += this.text.substring((transformation.index + transformation.text.length)); this.text = newStr; - this._emit("textModified", transformation); - return; + break; case "insertText": this.text = this.text.slice(0, transformation.index) + transformation.text + this.text.slice(transformation.index); - this._emit("textModified", transformation); - return; + break; } + this._emit("textModified", { node: this, transformation: transformation }); }; ecrit.TextSpan.prototype._undo = function (transformation) { diff --git a/src/Node.js b/src/Node.js index 121d72e..218f89a 100644 --- a/src/Node.js +++ b/src/Node.js @@ -109,7 +109,7 @@ ecrit.Node.prototype.insertNode = function (node, afterId, beforeId) { * @param {Node} node - The node to remove */ ecrit.Node.prototype.removeNode = function (node) { - var foundNode = this.getChildNodebyId(node.id, false); + var foundNode = this.getChildNodeById(node.id); if (foundNode === null || foundNode === this) return; var index = this.children.indexOf(foundNode); |