X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/efe36f4f1b5df351eeb4d40a54c3900cf9a7079b..24e73bdbeb5e83ff18d2f9b359e7b41fe8230c1a:/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 1830017..57a245e 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -44,9 +44,19 @@ handlers.push({key: KEYS.ENTER, position = cursor.getPosition(), element = position.element; + if(Object.keys(cursor.getPosition()).length === 0) { + var currentElement = canvas.getCurrentNodeElement(); + if(currentElement) { + var added = currentElement.after({tag: currentElement.getWlxmlTag() || 'div', klass: currentElement.getWlxmlClass() || 'p'}); + added.append({text:''}); + canvas.setCurrentElement(added, {caretTo: 'start'}); + } + return; + } + if(!cursor.isSelecting()) { if(event.ctrlKey) { - var added = element.after({tag: 'block'}); + var added = element.after({tag: element.getWlxmlTag() || 'div', klass: element.getWlxmlClass() || 'p'}); added.append({text:''}); canvas.setCurrentElement(added, {caretTo: 'start'});