X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/fea8fda1a2f6a07eac7bb37c3c40a053d398ef92..b2afd91d9ec91ebcf2779b6cbd36f62eba871d69:/src/editor/modules/documentCanvas/commands.js?ds=sidebyside diff --git a/src/editor/modules/documentCanvas/commands.js b/src/editor/modules/documentCanvas/commands.js index 1981429..ac56a31 100644 --- a/src/editor/modules/documentCanvas/commands.js +++ b/src/editor/modules/documentCanvas/commands.js @@ -35,7 +35,9 @@ commands.register('unwrap-node', function(canvas) { } else if(!cursor.isSelecting()) { var nodeToUnwrap = cursor.getPosition().element.data('wlxmlNode'), parentNode = nodeToUnwrap.unwrap(); - canvas.setCurrentElement(utils.findCanvasElement(parentNode)); + if(parentNode) { + canvas.setCurrentElement(utils.findCanvasElement(parentNode)); + } } }); @@ -149,7 +151,7 @@ commands.register('take-away-node', function(canvas) { return; - var range = nodeElement.unwrapContents(); + var range = nodeElement.data('wlxmlNode').unwrapContent(); if(element) { var elementIsFirstChild = nodeElement.childIndex(element); @@ -157,13 +159,13 @@ commands.register('take-away-node', function(canvas) { canvas.setCurrentElement(element, {caretTo: position.offset}); } else { if(elementIsFirstChild) { - canvas.setCurrentElement(range.element1, {caretTo: 'end'}); + canvas.setCurrentElement(findCanvasElement(range.element1), {caretTo: 'end'}); } else { - canvas.setCurrentElement(range.element2, {caretTo: 'end'}); + canvas.setCurrentElement(findCanvasElement(range.element2), {caretTo: 'end'}); } } } else { - canvas.setCurrentElement(range.element1, {caretTo: 'start'}); + canvas.setCurrentElement(findCanvasElement(range.element1), {caretTo: 'start'}); } });