From aba92db36cedd657b0c8c0637aa4aae7b573f023 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 26 Jun 2014 11:40:44 +0200 Subject: [PATCH 1/1] editor: fix splitting text when its parent contains comments --- src/editor/plugins/core/core.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/editor/plugins/core/core.js b/src/editor/plugins/core/core.js index c12405b..450f147 100644 --- a/src/editor/plugins/core/core.js +++ b/src/editor/plugins/core/core.js @@ -18,22 +18,27 @@ plugin.documentExtension.textNode.transformations = { breakContent: { impl: function(args) { var node = this, + parentDescribingNodes = [], newNodes, emptyText; newNodes = node.split({offset: args.offset}); - [newNodes.first, newNodes.second].some(function(newNode) { - if(!(newNode.contents().length)) { - emptyText = newNode.append({text: ''}); - return true; // break - } - }); newNodes.second.contents() .filter(function(child) { return child.object.describesParent; }) .forEach(function(child) { //child.detach(); - newNodes.first.append(child); + parentDescribingNodes.push(child); + child.detach(); }); + [newNodes.first, newNodes.second].some(function(newNode) { + if(!(newNode.contents().length)) { + emptyText = newNode.append({text: ''}); + return true; // break + } + }); + parentDescribingNodes.forEach(function(node) { + newNodes.first.append(node); + }); return _.extend(newNodes, {emptyText: emptyText}); }, getChangeRoot: function() { -- 2.20.1