editor: fixing nodeMoved event handling in Canvas
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 11 Feb 2014 11:02:34 +0000 (12:02 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 11 Feb 2014 11:07:07 +0000 (12:07 +0100)
Currently finding canvas element for a document node that
was moved to a different place requires knowing its original parent.

src/editor/modules/documentCanvas/canvas/utils.js
src/editor/modules/documentCanvas/canvas/wlxmlListener.js

index ae20a09..337f4d3 100644 (file)
@@ -20,12 +20,12 @@ var nearestInDocumentOrder = function(selector, direction, element) {
     return null;
 };
 
-var findCanvasElement = function(node) {
+var findCanvasElement = function(node, childOf) {
     if(node.nodeType === Node.ELEMENT_NODE) {
         return node.getData('canvasElement');
     }
     if(node.nodeType === Node.TEXT_NODE) {
-        return findCanvasElementInParent(node, node.parent());
+        return findCanvasElementInParent(node, childOf || node.parent());
     }
 };
 
index 0b23021..8275751 100644 (file)
@@ -64,7 +64,7 @@ var handlers = {
             referenceAction = 'after';
         }
 
-        actionArg = (checkForExistence && utils.findCanvasElement(event.meta.node)) || event.meta.node;
+        actionArg = (checkForExistence && utils.findCanvasElement(event.meta.node, event.meta.parent)) || event.meta.node;
         referenceElement[referenceAction](actionArg);
     },
     nodeMoved: function(event) {