diff --git a/codex-editor.js b/codex-editor.js index b25bee30..5bc201bf 100644 --- a/codex-editor.js +++ b/codex-editor.js @@ -850,13 +850,19 @@ cEditor.callback = { var clipboardData, pastedData, nodeContent; + /** Prevent Default Browser behaviour */ event.preventDefault(); clipboardData = event.clipboardData || window.clipboardData; pastedData = clipboardData.getData('Text'); nodeContent = document.createTextNode(pastedData); - block.appendChild(nodeContent); + + var index = cEditor.caret.getCurrentInputIndex(); + + /** Insert parsed content to the editable block */ + var editableElement = cEditor.state.inputs[index]; + editableElement.appendChild(nodeContent); }, /** @@ -1031,84 +1037,6 @@ cEditor.content = { cEditor.content.workingNodeChanged(newBlock); }, - /** - * @deprecated with replaceBlock() - */ - _switchBlock : function (targetBlock, newBlockTagname) { - - if (!targetBlock || !newBlockTagname) return; - - var nodeToReplace; - - /** - * First-level nodes replaces as-is, - * otherwise we need to replace parent node - */ - if (cEditor.parser.isFirstLevelBlock(targetBlock)) { - nodeToReplace = targetBlock; - } else { - nodeToReplace = targetBlock.parentNode; - } - - /** - * Make new node with original content - */ - var nodeCreated = cEditor.draw.block(newBlockTagname, targetBlock.innerHTML); - - /** Mark node as redactor block */ - nodeCreated.contentEditable = "true"; - nodeCreated.classList.add(cEditor.ui.BLOCK_CLASSNAME); - - /** - * If it is a first-level node, replace as-is. - */ - if (cEditor.parser.isFirstLevelBlock(nodeCreated)) { - - cEditor.nodes.redactor.replaceChild(nodeCreated, nodeToReplace); - - /** - * Set new node as current - */ - - cEditor.content.workingNodeChanged(nodeCreated); - - /** - * Setting caret - */ - cEditor.caret.set(nodeCreated); - - /** Add event listeners for created node */ - cEditor.ui.addBlockHandlers(nodeCreated); - - return; - - } - - /** - * If it is not a first-level node, for example LI or IMG - * we need to wrap it in block-tag (

or