offsetStart = offsetEnd;\r
offsetEnd = tmp;\r
}\r
+ \r
+ \r
var wrapper = canvasNode.create({tag: wlxmlTag, klass: wlxmlClass});\r
- this.canvas.nodeWrap({inside: canvasNode.create($(selection.anchorNode).parent()),\r
+ var parent = $(selection.anchorNode).parent();\r
+ \r
+ var textNodeIdx = parent.contents().index($(selection.anchorNode));\r
+ if(selection.anchorNode != selection.focusNode) {\r
+ textNodeIdx = [textNodeIdx, parent.contents().index($(selection.focusNode))];\r
+ }\r
+ this.canvas.nodeWrap({inside: canvasNode.create(parent),\r
_with: wrapper,\r
offsetStart: offsetStart,\r
- offsetEnd: offsetEnd\r
+ offsetEnd: offsetEnd,\r
+ textNodeIdx: textNodeIdx\r
});\r
this.selectNode(wrapper, {movecaret: 'end'});\r
}\r
\r
if(command === 'createList') {\r
var node = canvasNode.create(pos.parentNode);\r
- if(window.getSelection().getRangeAt().collapsed && this.canvas.nodeInsideList({node: node})) {\r
+ if(window.getSelection().getRangeAt(0).collapsed && this.canvas.nodeInsideList({node: node})) {\r
this.canvas.listRemove({pointer: node});\r
this.selectNode(node, {movecaret: 'end'});\r
this.sandbox.publish('contentChanged');\r