toDocumentFragment: function() {
var doc = this.canvas.wlxmlDocument,
anchorNode = this.anchorElement ? this.anchorElement.wlxmlNode : null,
- focusNode = this.focusElement ? this.focusElement.wlxmlNode : null;
+ focusNode = this.focusElement ? this.focusElement.wlxmlNode : null,
+ node1, node2;
if(!anchorNode || !focusNode) {
return;
});
}
else {
- var siblingParents = doc.getSiblingParents({node1: anchorNode, node2: focusNode});
+ if(anchorNode.hasSameContextRoot(focusNode)) {
+ var siblingParents = doc.getSiblingParents({node1: anchorNode, node2: focusNode});
+ node1 = siblingParents.node1;
+ node2 = siblingParents.node2;
+ } else {
+ node1 = focusNode;
+ node2 = anchorNode;
+ }
return doc.createFragment(doc.RangeFragment, {
- node1: siblingParents.node1,
- node2: siblingParents.node2
+ node1: node1,
+ node2: node2
});
}
},
var node;
if(fragment instanceof fragment.RangeFragment && fragment.hasSiblingBoundries()) {
- return fragment.boundriesSiblingParents();
+ return fragment.startNode.hasSameContextRoot(fragment.endNode) && fragment.boundriesSiblingParents();
}
if(fragment instanceof fragment.NodeFragment) {
node = fragment.node.getNearestElementNode();
}
var boundries = getBoundriesForAList(params.fragment);
- if(boundries) {
+ if(boundries && boundries.node1.hasSameContextRoot(boundries.node2)) {
return {
allowed: true,
description: interpolate(gettext('Make %s fragment(s) into list'), [countItems(getBoundriesForAList(params.fragment))]),