From 6b06b64b40cd570ab02227cc913a5204d9562f37 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Tue, 28 Feb 2017 16:46:42 +0100 Subject: [PATCH 1/1] small refactor + fix brackets --- src/editor/plugins/core/core.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/editor/plugins/core/core.js b/src/editor/plugins/core/core.js index d2791d0..9a10066 100644 --- a/src/editor/plugins/core/core.js +++ b/src/editor/plugins/core/core.js @@ -194,7 +194,7 @@ plugin.documentExtension.documentNode.transformations = { node: ret, offset: ret.getText().length - len }; - } else if(!toret) { + } else { toret = { node: ret.getFirstTextNode(), offset: 0 @@ -236,10 +236,12 @@ plugin.documentExtension.documentNode.transformations = { return toMerge.is({tagName: 'div', 'klass': 'p'}) || (toMerge.is({tagName: 'div'}) && toMerge.getClass() === ''); }, run: function() { - if(prev && (prev.is('p') || prev.is({tagName: 'header'}))) { + if (!prev) + return; + if(prev.is('p') || prev.is({tagName: 'header'})) { return merge(toMerge, prev); } - if(prev && prev.is('list')) { + if(prev.is('list')) { var items = prev.contents().filter(function(n) { return n.is('item');}); return merge(toMerge, items[items.length-1]); } @@ -296,7 +298,7 @@ plugin.documentExtension.documentNode.transformations = { return toMerge.is({tagName: 'header'}); }, run: function() { - if(prev && prev.is('p') || prev.is({tagName: 'header'})) { + if(prev && (prev.is('p') || prev.is({tagName: 'header'}))) { return merge(toMerge, prev); } } -- 2.20.1