canvas.dom.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
if(e.which === 13) { \r
e.preventDefault();\r
- //view.insertNewNode(null, null);\r
+ manager.insertNewNode(null, null);\r
}\r
if(e.which === 8) {\r
var anchor = window.getSelection().anchorNode;\r
this.gridToggled = toggle;\r
};\r
\r
+Manager.prototype.insertNewNode = function(wlxmlTag, wlxmlClass) {\r
+ //TODO: Insert inline\r
+ var anchor = $(window.getSelection().anchorNode);\r
+ var anchorOffset = window.getSelection().anchorOffset;\r
+ \r
+ var parent = anchor.parent();\r
+ var idx = parent.contents().index(anchor);\r
+ \r
+ if(anchorOffset < anchor.text().length) {\r
+ var newNode = this.canvas.splitNode({node: {id: parent.attr('id')}, textNodeIdx: idx, offset: anchorOffset});\r
+ this.selectNode(new wlxmlNode.Node(newNode), {movecaret: true});\r
+ }\r
+\r
+ \r
+ \r
+ this.sandbox.publish('contentChanged');\r
+};\r
+\r
return Manager;\r
\r
});
\ No newline at end of file