wip: storing wlxmlNode-canvasNode references
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 10 Oct 2013 14:07:06 +0000 (16:07 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 2 Dec 2013 13:50:52 +0000 (14:50 +0100)
src/editor/modules/documentCanvas/canvas/documentElement.js

index 374d5c7..cd6b3d8 100644 (file)
@@ -169,6 +169,9 @@ $.extend(DocumentNodeElement, {
 
         var element = this.fromHTMLElement(dom[0], canvas);
 
+        element.data('wlxmlNode', wlxmlNode);
+        wlxmlNode.setData('canvasElement', element);
+
         element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()});
 
         _.keys(wlxmlNode.getMetaAttributes()).forEach(function(key) {
@@ -477,9 +480,12 @@ var DocumentTextElement = function(htmlElement, canvas) {
 
 $.extend(DocumentTextElement, {
     createDOM: function(wlxmlTextNode) {
-        return $('<div>')
+        var dom = $('<div>')
             .attr('document-text-element', '')
-            .text(wlxmlTextNode.getText() || utils.unicode.ZWS);
+            .text(wlxmlTextNode.getText() || utils.unicode.ZWS),
+        element = this.fromHTMLElement(dom[0], this);
+        element.data('wlxmlNode', wlxmlTextNode);
+        return dom;
     },
 
     create: function(wlxmlTextNode, canvas) {