diff options
author | matthewsotoudeh <matthewsot@outlook.com> | 2016-01-24 00:53:52 -0800 |
---|---|---|
committer | matthewsotoudeh <matthewsot@outlook.com> | 2016-01-24 00:53:52 -0800 |
commit | 36318155229380e22395839b9f455abb201cfa97 (patch) | |
tree | 65cc5acd9b80ace7b318307d64465021fde8604a | |
parent | e943b82bcab137756b66992230dcaa6d6da672de (diff) |
emit on text modification
-rw-r--r-- | dist/core.js | 6 | ||||
-rw-r--r-- | src/Document/Nodes/TextSpan.js | 4 | ||||
-rw-r--r-- | src/Node.js | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/dist/core.js b/dist/core.js index d8413f0..e67d8c9 100644 --- a/dist/core.js +++ b/dist/core.js @@ -155,7 +155,7 @@ ecrit.Node.prototype.removeNode = function (node) { var index = this.children.indexOf(foundNode); this.children.splice(index, 1); - this._emit("childRemoved", foundNode); + this._emit("nodeRemoved", foundNode); }; /** * Represents an ecrit Document. @@ -329,9 +329,11 @@ 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("modifiedText", transformation); return; case "insertText": this.text = this.text.slice(0, transformation.index) + transformation.text + this.text.slice(transformation.index); + this._emit("modifiedText", transformation); return; } }; @@ -390,6 +392,8 @@ ecrit.TextSpan.prototype.applyTransformation = function (transformation, clone) i--; } } + + this._emit("appliedTransformation", transformation) }; /** * Represents a transformation to a Document. diff --git a/src/Document/Nodes/TextSpan.js b/src/Document/Nodes/TextSpan.js index ce00808..7beec6f 100644 --- a/src/Document/Nodes/TextSpan.js +++ b/src/Document/Nodes/TextSpan.js @@ -15,9 +15,11 @@ 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("modifiedText", transformation); return; case "insertText": this.text = this.text.slice(0, transformation.index) + transformation.text + this.text.slice(transformation.index); + this._emit("modifiedText", transformation); return; } }; @@ -76,4 +78,6 @@ ecrit.TextSpan.prototype.applyTransformation = function (transformation, clone) i--; } } + + this._emit("appliedTransformation", transformation) };
\ No newline at end of file diff --git a/src/Node.js b/src/Node.js index cb3334c..30fdb6a 100644 --- a/src/Node.js +++ b/src/Node.js @@ -114,5 +114,5 @@ ecrit.Node.prototype.removeNode = function (node) { var index = this.children.indexOf(foundNode); this.children.splice(index, 1); - this._emit("childRemoved", foundNode); + this._emit("nodeRemoved", foundNode); };
\ No newline at end of file |