From: Aleksander Ɓukasz Date: Mon, 12 May 2014 09:10:51 +0000 (+0200) Subject: editor: plugins/core - remove & type change list actions return new document fragment X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/b5db2e60c7ee08a0ccd0b8ded776730996c46aeb editor: plugins/core - remove & type change list actions return new document fragment --- diff --git a/src/editor/plugins/core/lists.js b/src/editor/plugins/core/lists.js index 0c017f8..5a1b875 100644 --- a/src/editor/plugins/core/lists.js +++ b/src/editor/plugins/core/lists.js @@ -67,7 +67,14 @@ var toggleListAction = function(type) { toSearch.some(function(node) { if(node.is('list')) { node.document.transaction(function() { - node.object.extractListItems(); + var firstItem = node.object.extractListItems(), + toret; + if(params.fragment.isValid()) { + toret = params.fragment; + } else { + toret = node.document.createFragment(node.document.NodeFragment, {node: firstItem}); + } + return toret; }, { metadata: { description: action.getState().description @@ -83,7 +90,13 @@ var toggleListAction = function(type) { var node = params.fragment.node, action = this; node.document.transaction(function() { - node.getParent('list').setClass(type === 'Bullet' ? 'list' : 'list.enum'); + var list = node.getParent('list'); + list.setClass(type === 'Bullet' ? 'list' : 'list.enum'); + if(params.fragment.isValid()) { + return params.fragment; + } else { + return node.document.createFragment(node.document.NodeFragment, {node: list.contents()[0]}); + } }, { metadata: { description: action.getState().description