smartxml: Document.transaction now returns value from a callback
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / documentElement.js
index a0da233..60e79de 100644 (file)
@@ -29,10 +29,6 @@ $.extend(DocumentElement, {
         return elementTypeFromWlxmlNode(node).create(node, canvas);
     },
 
         return elementTypeFromWlxmlNode(node).create(node, canvas);
     },
 
-    createDOM: function(wlxmlNode) {
-        return elementTypeFromParams(wlxmlNode).createDOM(params);
-    },
-
     fromHTMLElement: function(htmlElement, canvas) {
         var $element = $(htmlElement);
         if(htmlElement.nodeType === Node.ELEMENT_NODE && $element.attr('document-node-element') !== undefined) {
     fromHTMLElement: function(htmlElement, canvas) {
         var $element = $(htmlElement);
         if(htmlElement.nodeType === Node.ELEMENT_NODE && $element.attr('document-node-element') !== undefined) {
@@ -176,7 +172,7 @@ $.extend(DocumentNodeElement, {
         element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()});
 
         wlxmlNode.contents().forEach(function(node) {
         element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()});
 
         wlxmlNode.contents().forEach(function(node) {
-            container.append(DocumentElement.create(node).dom());
+            container.append(DocumentElement.create(node, canvas).dom());
         }.bind(this));
 
         return dom;
         }.bind(this));
 
         return dom;
@@ -233,19 +229,11 @@ $.extend(DocumentNodeElement.prototype, {
 
         var elementContent = this._container().contents();
         var element = this;
 
         var elementContent = this._container().contents();
         var element = this;
-        elementContent.each(function(idx) {
+        elementContent.each(function() {
             var childElement = DocumentElement.fromHTMLElement(this, element.canvas);
             if(childElement === undefined) {
                 return true;
             }
             var childElement = DocumentElement.fromHTMLElement(this, element.canvas);
             if(childElement === undefined) {
                 return true;
             }
-            if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && (childElement instanceof DocumentTextElement) && $.trim($(this).text()) === '') {
-                return true;
-            }
-            if(idx > 0 && childElement instanceof DocumentTextElement) {
-                if(toret[toret.length-1] instanceof DocumentNodeElement && $.trim($(this).text()) === '') {
-                    return true;
-                }
-            }
             toret.push(childElement);
         });
         return toret;
             toret.push(childElement);
         });
         return toret;
@@ -343,17 +331,17 @@ var DocumentTextElement = function(htmlElement, canvas) {
 };
 
 $.extend(DocumentTextElement, {
 };
 
 $.extend(DocumentTextElement, {
-    createDOM: function(wlxmlTextNode) {
+    createDOM: function(wlxmlTextNode, canvas) {
         var dom = $('<div>')
             .attr('document-text-element', '')
             .text(wlxmlTextNode.getText() || utils.unicode.ZWS),
         var dom = $('<div>')
             .attr('document-text-element', '')
             .text(wlxmlTextNode.getText() || utils.unicode.ZWS),
-        element = this.fromHTMLElement(dom[0], this);
+        element = this.fromHTMLElement(dom[0], canvas);
         element.data('wlxmlNode', wlxmlTextNode);
         return dom;
     },
 
     create: function(wlxmlTextNode, canvas) {
         element.data('wlxmlNode', wlxmlTextNode);
         return dom;
     },
 
     create: function(wlxmlTextNode, canvas) {
-        return this.fromHTMLElement(this.createDOM(wlxmlTextNode)[0]);
+        return this.fromHTMLElement(this.createDOM(wlxmlTextNode, canvas)[0], canvas);
     },
 
     fromHTMLElement: function(htmlElement, canvas) {
     },
 
     fromHTMLElement: function(htmlElement, canvas) {