From cb7f92e0a3b13cfb832932d7d85d5a7dbad92d23 Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Fri, 1 Jul 2016 18:52:38 +0300 Subject: [PATCH] fix copying element on insert bug --- codex-editor.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/codex-editor.js b/codex-editor.js index d6080737..f6270cb1 100644 --- a/codex-editor.js +++ b/codex-editor.js @@ -516,7 +516,7 @@ cEditor.callback = { cEditor.content.workingNodeChanged(); - var isEnterPressedOnToolbar = cEditor.toolbar.opened && + var isEnterPressedOnToolbar = cEditor.toolbar.opened && cEditor.toolbar.current && event.target == cEditor.content.currentNode; @@ -1023,9 +1023,9 @@ cEditor.content = { /** * Replaces blocks with saving content - * @param {Element} noteToReplace - * @param {Element} newNode - * @param {Element} blockType + * @param {Element} noteToReplace + * @param {Element} newNode + * @param {Element} blockType */ switchBlock : function(nodeToReplace, newNode, blockType){ @@ -1037,7 +1037,7 @@ cEditor.content = { /** Add event listeners */ cEditor.ui.addBlockHandlers(newNode); - + }, @@ -1358,19 +1358,21 @@ cEditor.toolbar = { appendCallback, newBlock; - /** - * Copy plugin 'append' Element - */ - newBlock = tool.append.cloneNode(true); - /** Can replace? */ if (REPLACEBLE_TOOLS.indexOf(tool.type) != -1 && workingNode) { + /** + * Copy plugin 'append' Element + */ + newBlock = tool.append.cloneNode(true); + /** Replace current block */ cEditor.content.switchBlock(workingNode, newBlock, tool.type); } else { + newBlock = tool.append; + /** Insert new Block from plugin */ cEditor.content.insertBlock(newBlock, tool.type);