diff options
author | matthewsotoudeh <matthewsot@outlook.com> | 2016-01-24 01:04:41 -0800 |
---|---|---|
committer | matthewsotoudeh <matthewsot@outlook.com> | 2016-01-24 01:04:41 -0800 |
commit | 922b6f0ff412b16ea4a3cd59d030f22c2262caa3 (patch) | |
tree | 7fcd358921a42515905522dd63cd3d68ce7540f7 | |
parent | 36318155229380e22395839b9f455abb201cfa97 (diff) |
added a type property to Node
-rw-r--r-- | dist/core.js | 13 | ||||
-rw-r--r-- | src/Document/Document.js | 2 | ||||
-rw-r--r-- | src/Document/Nodes/Paragraph.js | 2 | ||||
-rw-r--r-- | src/Document/Nodes/TextSpan.js | 6 | ||||
-rw-r--r-- | src/Node.js | 3 |
5 files changed, 14 insertions, 12 deletions
diff --git a/dist/core.js b/dist/core.js index e67d8c9..0a9cacb 100644 --- a/dist/core.js +++ b/dist/core.js @@ -39,7 +39,8 @@ ecrit.NodeHistory.prototype.betweenTimestamps = function (afterStamp, beforeStam } return ret; }; -ecrit.Node = function (parent, id, nodes) { +ecrit.Node = function (type, parent, id, nodes) { + this.type = type; this.parent = parent; this.id = id; this.document = parent.document; @@ -165,7 +166,7 @@ ecrit.Document = function () { this.document = this; this.id = "root"; - ecrit.Node.call(this, this, "root", []); + ecrit.Node.call(this, "Document", this, "root", []); }; ecrit.Document.prototype = Object.create(ecrit.Node.prototype); @@ -240,7 +241,7 @@ ecrit.Document.prototype.applyTransformation = function (transformation, clone) }; ecrit.Paragraph = function (parent, id, nodes) { - ecrit.Node.call(this, parent, id, nodes); + ecrit.Node.call(this, "Paragraph", parent, id, nodes); }; ecrit.Paragraph.prototype = Object.create(ecrit.Node.prototype); @@ -317,7 +318,7 @@ ecrit.TextSpan = function (parent, id, options) { this.text = options.text || ""; this.formatting = options.formatting || []; - ecrit.Node.call(this, parent, id); + ecrit.Node.call(this, "TextSpan", parent, id); }; ecrit.TextSpan.prototype = Object.create(ecrit.Node.prototype); @@ -329,11 +330,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); + this._emit("textModified", transformation); return; case "insertText": this.text = this.text.slice(0, transformation.index) + transformation.text + this.text.slice(transformation.index); - this._emit("modifiedText", transformation); + this._emit("textModified", transformation); return; } }; diff --git a/src/Document/Document.js b/src/Document/Document.js index f86ac0e..51bae84 100644 --- a/src/Document/Document.js +++ b/src/Document/Document.js @@ -6,7 +6,7 @@ ecrit.Document = function () { this.document = this; this.id = "root"; - ecrit.Node.call(this, this, "root", []); + ecrit.Node.call(this, "Document", this, "root", []); }; ecrit.Document.prototype = Object.create(ecrit.Node.prototype); diff --git a/src/Document/Nodes/Paragraph.js b/src/Document/Nodes/Paragraph.js index de6b19e..480a020 100644 --- a/src/Document/Nodes/Paragraph.js +++ b/src/Document/Nodes/Paragraph.js @@ -1,5 +1,5 @@ ecrit.Paragraph = function (parent, id, nodes) { - ecrit.Node.call(this, parent, id, nodes); + ecrit.Node.call(this, "Paragraph", parent, id, nodes); }; ecrit.Paragraph.prototype = Object.create(ecrit.Node.prototype); diff --git a/src/Document/Nodes/TextSpan.js b/src/Document/Nodes/TextSpan.js index 7beec6f..0f80f1b 100644 --- a/src/Document/Nodes/TextSpan.js +++ b/src/Document/Nodes/TextSpan.js @@ -3,7 +3,7 @@ ecrit.TextSpan = function (parent, id, options) { this.text = options.text || ""; this.formatting = options.formatting || []; - ecrit.Node.call(this, parent, id); + ecrit.Node.call(this, "TextSpan", parent, id); }; ecrit.TextSpan.prototype = Object.create(ecrit.Node.prototype); @@ -15,11 +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); + this._emit("textModified", transformation); return; case "insertText": this.text = this.text.slice(0, transformation.index) + transformation.text + this.text.slice(transformation.index); - this._emit("modifiedText", transformation); + this._emit("textModified", transformation); return; } }; diff --git a/src/Node.js b/src/Node.js index 30fdb6a..121d72e 100644 --- a/src/Node.js +++ b/src/Node.js @@ -1,4 +1,5 @@ -ecrit.Node = function (parent, id, nodes) { +ecrit.Node = function (type, parent, id, nodes) { + this.type = type; this.parent = parent; this.id = id; this.document = parent.document; |