X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6757e2f4fe80bfdc197d4963c464bf2b3a47f66b..0f5cbf957bc0bbdcff93bdb33c227f78041e332b:/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 dfe3f66..418dc93 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -75,22 +75,32 @@ handlers.push({key: KEYS.ENTER, } //var nodes = position.element.data('wlxmlNode').split({offset: position.offset}), - var nodes = position.element.data('wlxmlNode').transform('split', {offset: position.offset}), - newEmpty, - goto, - gotoOptions; - - if(position.offsetAtBeginning) - newEmpty = nodes.first; - else if(position.offsetAtEnd) - newEmpty = nodes.second; + // var nodes = position.element.data('wlxmlNode').transform('split', {offset: position.offset}), + // newEmpty, + // goto, + // gotoOptions; + + // if(position.offsetAtBeginning) + // newEmpty = nodes.first; + // else if(position.offsetAtEnd) + // newEmpty = nodes.second; - if(newEmpty) { - //goto = newEmpty.append({text: ''}); + // if(newEmpty) { + // //goto = newEmpty.append({text: ''}); + // gotoOptions = {}; + // } else { + // goto = nodes.second; + // gotoOptions = {caretTo: 'start'}; + // } + + var result = position.element.data('wlxmlNode').transform('rng.breakContent', {offset: position.offset}), + goto, gotoOptions; + if(result.emptyText) { + goto = result.createdEmpty; gotoOptions = {}; } else { - goto = nodes.second; - gotoOptions = {caretTo: 'start'}; + goto = result.second; + gotoOptions = {caretTo: 'start'}; } canvas.setCurrentElement(utils.findCanvasElement(goto), gotoOptions);