X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4ddf36452af460dbc26fd181f2ba3640a7c71374..20b9b567165ee10532a441f809a2a718b5b5e570:/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 16f2f68..418dc93 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -74,22 +74,33 @@ handlers.push({key: KEYS.ENTER, return false; // top level element is unsplittable } - var nodes = position.element.data('wlxmlNode').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').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; - 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);