This approach always rerenders text nodes...
referenceAction = 'after';
}
- if(event.type === 'nodeMoved') {
- actionArg = utils.getElementForNode(event.meta.node, event.meta.parent);
- if(actionArg.sameNode(referenceElement)) {
+ if(event.meta.move) {
+ /* Let's check if this node had its own canvas element and it's accessible. */
+ actionArg = utils.getElementForElementRootNode(event.meta.node);
+ if(actionArg && actionArg.sameNode(referenceElement)) {
referenceElement = this.children()[nodeIndex];
}
- } else {
+ }
+ if(!actionArg) {
actionArg = event.meta.node;
}
referenceElement[referenceAction](actionArg);
},
- onNodeMoved: function(event) {
- return this.onNodeAdded.call(this, event);
- },
onNodeDetached: function(event) {
if(event.meta.node.sameNode(this)) {
this.detach();
return null;
};
+var getElementForElementRootNode = function(node, withParent) {
+ if(node.nodeType === Node.TEXT_NODE) {
+ return _getElementForRootTextNode(node, withParent);
+ }
+ return node.getData('canvasElement');
+};
+
+var _getElementForRootTextNode = function(textNode, withParent) {
+ var parentElement = getElementForNode(withParent || textNode.parent()),
+ toret;
+ parentElement.children().some(function(child) {
+ if(child.wlxmlNode.sameNode(textNode)) {
+ toret = child;
+ return true;
+ }
+ });
+ return toret;
+};
var getElementForNode = function(node, withParent) {
if(node.nodeType === Node.TEXT_NODE) {
ZWS: '\u200B'
},
getElementForNode: getElementForNode,
- getElementForDetachedNode: getElementForDetachedNode
+ getElementForDetachedNode: getElementForDetachedNode,
+ getElementForElementRootNode: getElementForElementRootNode
};
});
containingElement.handle(event);
},
- nodeMoved: function(event) {
- return handlers.nodeAdded.call(this, event); //
- //
- },
nodeDetached: function(event) {
var element = utils.getElementForDetachedNode(event.meta.node, event.meta.parent);
element.handle(event);