this.sandbox.publish('nodeSelected', wlxmlNode);\r
};\r
\r
+Manager.prototype.insertNewNode = function(wlxmlTag, wlxmlClass) {\r
+ var selection = window.getSelection();\r
+\r
+ if(selection.getRangeAt(0).collapsed) {\r
+ \r
+ } else {\r
+ var offsetStart = selection.anchorOffset;\r
+ var offsetEnd = selection.focusOffset;\r
+ if(offsetStart > offsetEnd) {\r
+ var tmp = offsetStart;\r
+ offsetStart = offsetEnd;\r
+ offsetEnd = tmp;\r
+ }\r
+ var node = new wlxmlNode.Node($(selection.anchorNode).parent());\r
+ var newNode = this.canvas.insertNode({place: 'wrapText', context: node, tag: wlxmlTag, klass: wlxmlClass, offsetStart: offsetStart, offsetEnd: offsetEnd});\r
+ this.selectNode(new wlxmlNode.Node(newNode), {movecaret: 'end'});\r
+ }\r
+ \r
+ \r
+}\r
+\r
Manager.prototype.getNodeElement = function(wlxmlNode) {\r
return this.canvas.dom.find('#'+wlxmlNode.id);\r
};\r
insertNewNode: function(wlxmlTag, wlxmlClass) {\r
manager.insertNewNode(wlxmlTag, wlxmlClass);\r
},\r
- wrapSelectionWithNewNode: function(wlxmlTag, wlxmlClass) {\r
- manager.wrapSelectionWithNewNode(wlxmlTag, wlxmlClass);\r
- },\r
command: function(command, meta) {\r
manager.command(command, meta);\r
}\r
sandbox.getModule('documentCanvas').toggleGrid(toggle);\r
},\r
newNodeRequested: function(wlxmlTag, wlxmlClass) {\r
- if(window.getSelection().isCollapsed) {\r
sandbox.getModule('documentCanvas').insertNewNode(wlxmlTag, wlxmlClass);\r
- } else {\r
- sandbox.getModule('documentCanvas').wrapSelectionWithNewNode(wlxmlTag, wlxmlClass);\r
- }\r
},\r
command: function(cmd, meta) {\r
sandbox.getModule('documentCanvas').command(cmd, meta);\r