-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
+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