From f249570f54956c87ef7585c718e6d4c090a2a5d5 Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Wed, 27 Apr 2016 20:47:02 +0300 Subject: [PATCH] debug --- codex-editor.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/codex-editor.js b/codex-editor.js index 45eff357..dc53cb70 100644 --- a/codex-editor.js +++ b/codex-editor.js @@ -268,10 +268,10 @@ cEditor.callback = { if (cEditor.toolbar.opened && event.target == cEditor.nodes.redactor) { - // event.preventDefault(); + event.preventDefault(); cEditor.toolbar.toolClicked(event); - cEditor.toolbar.close(); + // cEditor.toolbar.close(); }; @@ -289,7 +289,7 @@ cEditor.callback = { cEditor.content.workingNodeChanged(); - cEditor.toolbar.close(); + // cEditor.toolbar.close(); cEditor.toolbar.move(); }, @@ -355,13 +355,26 @@ cEditor.content = { focused; if (selection.anchorNode != null) { - focused = selection.anchorNode.tagName ? selection.anchorNode : selection.focusNode.parentElement; + + if ( selection.anchorNode.nodeType == cEditor.core.nodeTypes.TAG ) { + focused = selection.anchorNode; + } else { + focused = selection.focusNode.parentElement; + } } + if ( !cEditor.parser.isFirstLevelBlock(focused) ) { + focused = focused.parentElement; + } + + console.log('focused' , focused); + if (focused != cEditor.nodes.redactor){ return focused; } + + return null; }, @@ -408,6 +421,9 @@ cEditor.content = { * Set new node as current */ cEditor.content.workingNodeChanged(nodeCreated); + setTimeout(function() { + cEditor.content.currentNode.focus(); + }, 100); return; } @@ -433,6 +449,9 @@ cEditor.content = { * Set new node as current */ cEditor.content.workingNodeChanged(nodeCreated); + setTimeout(function() { + cEditor.content.currentNode.focus(); + }, 100); }