From b5db2e60c7ee08a0ccd0b8ded776730996c46aeb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 12 May 2014 11:10:51 +0200 Subject: [PATCH] editor: plugins/core - remove & type change list actions return new document fragment --- src/editor/plugins/core/lists.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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 -- 2.20.1