+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 = canvasNode.create(pos.textNode);\r
+ var prevNode = this.canvas.getPrecedingNode({node:toRemove});\r
+ this.canvas.nodeRemove({node: toRemove}); // jesli nie ma tekstu, to anchor nie jest tex nodem\r
+ this.selectNode(prevNode, {movecaret: 'end'});\r
+ }\r
+}\r
+\r
+Manager.prototype.command = function(command, meta) {\r
+ var pos = getCursorPosition();\r
+ \r
+ if(command === 'createList') {\r
+ var node = canvasNode.create(pos.parentNode);\r
+ if(window.getSelection().getRangeAt().collapsed && this.canvas.nodeInsideList({node: node})) {\r
+ this.canvas.listRemove({pointer: node});\r
+ this.selectNode(node, {movecaret: 'end'});\r
+ this.sandbox.publish('contentChanged');\r
+ }\r
+ else {\r
+ //if(!this.canvas.nodeInsideList({node: node})) {\r
+ this.canvas.listCreate({start: node, end: canvasNode.create(pos.focusNode), type: meta});\r
+ this.selectNode(node, {movecaret: 'end'});\r
+ this.sandbox.publish('contentChanged');\r
+ //}\r
+ }\r
+ }\r
+\r
+}\r
+\r
+\r