X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a3899fd80710d7faee391844c6cb10a67df4f6cb..3030a9e:/src/editor/modules/documentCanvas/canvas/keyboard.js diff --git a/src/editor/modules/documentCanvas/canvas/keyboard.js b/src/editor/modules/documentCanvas/canvas/keyboard.js index 0871199..99201bc 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -238,26 +238,21 @@ var keyEventHandlers = [ ); }, run: function(e,s) { - var direction, caretTo, cursorAtOperationEdge, goto, element; + var goto, element; if(e.key === KEYS.BACKSPACE) { - direction = 'above'; - caretTo = 'end'; - cursorAtOperationEdge = s.isAtBeginning(); // always true? element = s.element; } else { - direction = 'below'; - caretTo = 'start'; - cursorAtOperationEdge = s.isAtEnd(); // always true? - element = cursorAtOperationEdge && s.canvas.getNearestTextElement(direction, s.element); + element = s.canvas.getNearestTextElement('below', s.element); } - if(!cursorAtOperationEdge || !element) { + e.preventDefault(); + + if(!element) { return; } - var parent = element.wlxmlNode.parent(); if(element.wlxmlNode.getIndex() === 0 && parent.isContextRoot() && (!parent.is('item') || parent.getIndex() === 0)) { // Don't even try to do anything at the edge of a context root, except for non-first items @@ -265,8 +260,6 @@ var keyEventHandlers = [ return; } - e.preventDefault(); - s.canvas.wlxmlDocument.transaction(function() { if(element.wlxmlNode.getIndex() === 0) { goto = element.wlxmlNode.parent().moveUp();