X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4aeab46723e464d604ced64f9bddb8fa0921df5a..cff9718672752da4840cb0b5bd62c60e7d9c7a30:/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 e43ea89..19f77b9 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -413,6 +413,28 @@ var keyEventHandlers = [ s.canvas.setCurrentElement(utils.getElementForNode(goto), gotoOptions); } + }, + { + applies: function (e, s) { + return s.type === 'nodeSelection' && e.key === KEYS.ENTER && !s.element.isRootElement(); + }, + run: function (e, s) { + var parent = s.element.parent(), + children = parent.children(), + result, goto, gotoOptions; + e.preventDefault(); + + s.canvas.wlxmlDocument.transaction(function() { + result = s.element.wlxmlNode.insertNewNode(); + }, { + metadata: { + description: gettext('Inserting node'), + fragment: s.toDocumentFragment() + } + }); + + s.canvas.setCurrentElement(utils.getElementForNode(result), {caretTo: 'start'}); + } } ];