+Manager.prototype.onEnterKey = function(e) {\r
+ e.preventDefault();\r
+ var pos = getCursorPosition();\r
+ var insertedNode;\r
+ if(pos.isAtEnd) {\r
+ insertedNode = this.canvas.insertNode({place: 'after', context: {id: pos.parentNode.attr('id')}, tag: pos.parentNode.attr('wlxml-tag'), klass: pos.parentNode.attr('wlxml-class')});\r
+ } else {\r
+ insertedNode = this.canvas.splitNode({node: {id: pos.parentNode.attr('id')}, textNodeIdx: pos.textNodeIndex, offset: pos.textNodeOffset});\r
+ }\r
+ if(insertedNode.length)\r
+ this.selectNode(new wlxmlNode.Node(insertedNode), {movecaret: true});\r
+ this.sandbox.publish('contentChanged');\r
+};\r
+\r
+Manager.prototype.onBackspaceKey = function(e) {\r
+ var pos = getCursorPosition();\r
+ var len = pos.textNode.text().length;\r
+ if(len === 1) {\r
+ // Prevent deleting node by browser after last character removed;\r
+ e.preventDefault();\r
+ pos.parentNode.text('');\r
+ }\r
+ if(len === 0) {\r
+ e.preventDefault();\r
+ var toRemove = new wlxmlNode.Node(pos.textNode);\r
+ var prevNode = this.canvas.getPreviousNode({node:toRemove});\r
+ this.canvas.removeNode({node: toRemove}); // jesli nie ma tekstu, to anchor nie jest tex nodem\r
+ this.selectNode(prevNode, {movecaret: 'end'});\r
+ }\r
+}\r
+\r
+\r
+\r