editor: canvas fix
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / documentElement.js
index 277d70a..45592ef 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);
     },
@@ -101,7 +102,7 @@ $.extend(DocumentNodeElement.prototype, {
             contentContainer = $('<div>')
                 .attr('document-element-content', '');
         
-        wrapper.append(widgetsContainer, contentContainer);
+        wrapper.append(contentContainer, widgetsContainer);
         widgetsContainer.find('*').add(widgetsContainer).attr('tabindex', -1);
         return wrapper;
     },
@@ -111,7 +112,6 @@ $.extend(DocumentNodeElement.prototype, {
     detach: function() {
         var parents = this.parents();
         this.dom.detach();
-        this.canvas = null;
         if(parents[0]) {
             parents[0].refreshPath();
         }
@@ -132,6 +132,8 @@ $.extend(DocumentNodeElement.prototype, {
         this.toggleHighlight(toggle);
     },
 
+    markAsCurrent: function() {},
+
     toggleHighlight: function(toggle) {
         this._container().toggleClass('highlighted-element', toggle);
     },
@@ -185,11 +187,15 @@ $.extend(DocumentTextElement.prototype, {
     },
     detach: function() {
         this.dom.detach();
-        this.canvas = null;
         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 || {});