X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/981e87b8a8d4dfca0c816d8bcedcd7c4dbdab9f4..7411943f320a29c7b2bf7086a26a0a477eea68cc:/src/editor/plugins/core/lists.js diff --git a/src/editor/plugins/core/lists.js b/src/editor/plugins/core/lists.js index 662dc53..65b6e69 100644 --- a/src/editor/plugins/core/lists.js +++ b/src/editor/plugins/core/lists.js @@ -8,10 +8,14 @@ var getBoundriesForAList = function(fragment) { 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(); + if(node.isContextRoot()) { + node = fragment.node; + } + return { node1: node, node2: node @@ -45,8 +49,9 @@ var toggleListAction = function(type) { item1 = list.object.getItem(0), text = item1 ? item1.contents()[0] : undefined, // doc = boundries.node1.document; - - return doc.createFragment(doc.CaretFragment, {node: text, offset:0}); + if(text) { + return doc.createFragment(doc.CaretFragment, {node: text, offset:0}); + } }, { metadata: { description: action.getState().description, @@ -151,7 +156,7 @@ var toggleListAction = function(type) { } 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))]),