From: Aleksander Ɓukasz Date: Tue, 6 May 2014 09:58:05 +0000 (+0200) Subject: refactoring setting text on a node X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/4dae03fed5ec90a39dea2473a3e3f0188df90ffe?ds=inline;hp=--cc refactoring setting text on a node --- 4dae03fed5ec90a39dea2473a3e3f0188df90ffe diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index a08788b..3073e72 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -189,18 +189,14 @@ $.extend(DocumentTextElement.prototype, { this.canvas = null; return this; }, - handle: function(event) { - var toSet = event.meta.node.getText(); - if(toSet === '') { - toSet = utils.unicode.ZWS; + setText: function(text) { + if(text === '') { + text = utils.unicode.ZWS; } - if(toSet !== this.getText()) { - this.setText(toSet); + if(text !== this.getText()) { + this.dom.contents()[0].data = text; } }, - setText: function(text) { - this.dom.contents()[0].data = text; - }, getText: function(options) { options = _.extend({raw: false}, options || {}); var toret = this.dom.text(); diff --git a/src/editor/modules/documentCanvas/canvas/wlxmlListener.js b/src/editor/modules/documentCanvas/canvas/wlxmlListener.js index 54d6134..760208f 100644 --- a/src/editor/modules/documentCanvas/canvas/wlxmlListener.js +++ b/src/editor/modules/documentCanvas/canvas/wlxmlListener.js @@ -79,7 +79,7 @@ var handlers = { }, nodeTextChange: function(event) { var element = utils.getElementForNode(event.meta.node); - element.handle(event); + element.setText(event.meta.node.getText()); }, metadataChanged: _metadataEventHandler,