- 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});
- }
- return;
- }
-
- var cursorAtOperationEdge = position.offsetAtBeginning;
- if(event.which === KEYS.DELETE) {
- cursorAtOperationEdge = position.offsetAtEnd;
- }
-
- var willDeleteWholeText = function() {
- return element.getText().length === 1 || selectsWholeTextElement(cursor);
- };
-
- canvas.wlxmlDocument.transaction(function() {
- if(willDeleteWholeText()) {
- event.preventDefault();
- node.setText('');
- }
- else if(element.isEmpty()) {
- event.preventDefault();
- var parent = element.parent(),
- grandParent = parent ? parent.parent() : null;
- if(!grandParent && parent.children().length === 1) {
- return;
- }
- if(parent.children().length === 1 && parent.children()[0].sameNode(element)) {
- if(grandParent && grandParent.children().length === 1) {
- goto = grandParent.wlxmlNode.append({text: ''});
- } else {
- goto = canvas.getNearestTextElement(direction, element);
+ var doc = s.canvas.wlxmlDocument;
+ doc.transaction(function() {
+
+ doc.deleteText({
+ from: {
+ node: s.startElement.wlxmlNode,
+ offset: s.startOffset
+ },
+ to: {
+ node: s.endElement.wlxmlNode,
+ offset: s.endOffset