fix copying element on insert bug

This commit is contained in:
Peter Savchenko 2016-07-01 18:52:38 +03:00
parent 30f5ba0cf7
commit cb7f92e0a3

View file

@ -516,7 +516,7 @@ cEditor.callback = {
cEditor.content.workingNodeChanged(); cEditor.content.workingNodeChanged();
var isEnterPressedOnToolbar = cEditor.toolbar.opened && var isEnterPressedOnToolbar = cEditor.toolbar.opened &&
cEditor.toolbar.current && cEditor.toolbar.current &&
event.target == cEditor.content.currentNode; event.target == cEditor.content.currentNode;
@ -1023,9 +1023,9 @@ cEditor.content = {
/** /**
* Replaces blocks with saving content * Replaces blocks with saving content
* @param {Element} noteToReplace * @param {Element} noteToReplace
* @param {Element} newNode * @param {Element} newNode
* @param {Element} blockType * @param {Element} blockType
*/ */
switchBlock : function(nodeToReplace, newNode, blockType){ switchBlock : function(nodeToReplace, newNode, blockType){
@ -1037,7 +1037,7 @@ cEditor.content = {
/** Add event listeners */ /** Add event listeners */
cEditor.ui.addBlockHandlers(newNode); cEditor.ui.addBlockHandlers(newNode);
}, },
@ -1358,19 +1358,21 @@ cEditor.toolbar = {
appendCallback, appendCallback,
newBlock; newBlock;
/**
* Copy plugin 'append' Element
*/
newBlock = tool.append.cloneNode(true);
/** Can replace? */ /** Can replace? */
if (REPLACEBLE_TOOLS.indexOf(tool.type) != -1 && workingNode) { if (REPLACEBLE_TOOLS.indexOf(tool.type) != -1 && workingNode) {
/**
* Copy plugin 'append' Element
*/
newBlock = tool.append.cloneNode(true);
/** Replace current block */ /** Replace current block */
cEditor.content.switchBlock(workingNode, newBlock, tool.type); cEditor.content.switchBlock(workingNode, newBlock, tool.type);
} else { } else {
newBlock = tool.append;
/** Insert new Block from plugin */ /** Insert new Block from plugin */
cEditor.content.insertBlock(newBlock, tool.type); cEditor.content.insertBlock(newBlock, tool.type);