} 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));
+ }
}
});
return;
- var range = nodeElement.unwrapContents();
+ var range = nodeElement.data('wlxmlNode').unwrapContent();
if(element) {
var elementIsFirstChild = nodeElement.childIndex(element);
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'});
}
});