+ var start = cursor.getSelectionStart(),
+ end = cursor.getSelectionEnd();
+
+ if(direction === 'above') {
+ if(start.offsetAtBeginning) {
+ goto = canvas.getNearestTextElement('above', start.element);
+ caretTo = 'end';
+ } else {
+ goto = start.element;
+ caretTo = start.offset;
+ }
+ } else {
+ if(end.offsetAtEnd) {
+ goto = canvas.getNearestTextElement('below', start.element);
+ caretTo = 'start';
+ } else {
+ goto = end.element;
+ caretTo = 0;
+ }
+ }
+
+ canvas.wlxmlDocument.deleteText({
+ from: {
+ node: start.element.wlxmlNode,
+ offset: start.offset
+ },
+ to: {
+ node: end.element.wlxmlNode,
+ offset: end.offset
+ }
+ });
+ if(goto) {
+ canvas.setCurrentElement(goto, {caretTo: caretTo});
+ }