From: Aleksander Ɓukasz Date: Tue, 11 Feb 2014 11:02:34 +0000 (+0100) Subject: editor: fixing nodeMoved event handling in Canvas X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/4ff93211ebf44be111ae2c00b7ee9c843ff6d7c9?ds=sidebyside editor: fixing nodeMoved event handling in Canvas Currently finding canvas element for a document node that was moved to a different place requires knowing its original parent. --- diff --git a/src/editor/modules/documentCanvas/canvas/utils.js b/src/editor/modules/documentCanvas/canvas/utils.js index ae20a09..337f4d3 100644 --- a/src/editor/modules/documentCanvas/canvas/utils.js +++ b/src/editor/modules/documentCanvas/canvas/utils.js @@ -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()); } }; diff --git a/src/editor/modules/documentCanvas/canvas/wlxmlListener.js b/src/editor/modules/documentCanvas/canvas/wlxmlListener.js index 0b23021..8275751 100644 --- a/src/editor/modules/documentCanvas/canvas/wlxmlListener.js +++ b/src/editor/modules/documentCanvas/canvas/wlxmlListener.js @@ -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) {