refactoring setting text on a node
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / documentElement.js
index 277d70a..3073e72 100644 (file)
@@ -81,6 +81,7 @@ DocumentNodeElement.prototype = Object.create(DocumentElement.prototype);
 
 $.extend(DocumentNodeElement.prototype, {
     defaultDisplayStyle: 'block',
+    init: function() {},
     addWidget: function(widget) {
         this.dom.children('.canvas-widgets').append(widget.DOM ? widget.DOM : widget);
     },
@@ -189,7 +190,12 @@ $.extend(DocumentTextElement.prototype, {
         return this;
     },
     setText: function(text) {
-        this.dom.contents()[0].data = text;
+        if(text === '') {
+            text = utils.unicode.ZWS;
+        }
+        if(text !== this.getText()) {
+            this.dom.contents()[0].data = text;
+        }
     },
     getText: function(options) {
         options = _.extend({raw: false}, options || {});