\r
}\r
\r
+Canvas.prototype.insideList = function(options) {\r
+ if(options.pointer) {\r
+ if(options.pointer.klass === 'list-items' || options.pointer.klass === 'item')\r
+ return true;\r
+ var pointerElement = $(this.content.find('#' + options.pointer.id));\r
+ return pointerElement.parents('list-items').length > 0;\r
+ }\r
+ return false;\r
+}\r
+\r
\r
return {Canvas: Canvas, Node: Node};\r
\r
textNodeOffset: selection.anchorOffset,\r
textNodeIndex: parent.contents().index(anchorNode),\r
parentNode: parent,\r
+ focusNode: $(selection.focusNode).parent(),\r
isAtEnd: selection.anchorOffset === anchorNode.text().length\r
}\r
};\r
}\r
}\r
\r
+Manager.prototype.command = function(command, meta) {\r
+ var pos = getCursorPosition();\r
+ \r
+ if(command === 'createList') {\r
+ var node = new wlxmlNode.Node(pos.parentNode);\r
+ if(window.getSelection().getRangeAt().collapsed && this.canvas.insideList({pointer: node})) {\r
+ this.canvas.removeList({pointer: node});\r
+ this.selectNode(node, {movecaret: 'end'});\r
+ this.sandbox.publish('contentChanged');\r
+ }\r
+ else {\r
+ if(!this.canvas.insideList({pointer: node})) {\r
+ this.canvas.createList({start: new wlxmlNode.Node(pos.parentNode), end: new wlxmlNode.Node(pos.focusNode)});\r
+ this.selectNode(new wlxmlNode.Node(pos.parentNode), {movecaret: 'end'});\r
+ this.sandbox.publish('contentChanged');\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
\r
\r
return Manager;\r
},\r
wrapSelectionWithNewNode: function(wlxmlTag, wlxmlClass) {\r
manager.wrapSelectionWithNewNode(wlxmlTag, wlxmlClass);\r
+ },\r
+ command: function(command, meta) {\r
+ manager.command(command, meta);\r
}\r
}\r
\r
transform(toBlock, 'div');\r
transform(toInline, 'span');\r
\r
+ toret.find(":not(iframe)").addBack().contents().filter(function() {\r
+ return this.nodeType == 3} ).each(function() {\r
+ var n = $(this); \r
+ var hasText = /\S/g.test(n.text());\r
+ if(!hasText) {\r
+ n.remove();\r
+ return;\r
+ }\r
+ var startSpace = /\s/g.test(n.text().substr(0,1));\r
+ var endSpace = /\s/g.test(n.text().substr(-1)) && n.text().length > 1;\r
+ var trimmed = $.trim(n.text());\r
+ n.get(0).data = (startSpace ? ' ' : '') + trimmed + (endSpace ? ' ' : '');\r
+ });\r
+ \r
return toret.children();\r
},\r
getMetaData: function(xml) {\r
//this.wrapWithNodeRequest(wlxmlTag, wlxmlClass);\r
}\r
sandbox.publish('newNodeRequested', wlxmlTag, wlxmlClass);\r
+ } else {\r
+ sandbox.publish('command', btn.attr('data-btn'), btn.attr('data-meta'));\r
}\r
- //sandbox.publish('command', btn.attr('data-btn'), btn.attr('data-meta'));\r
}\r
});\r
},\r
<button data-btn="grid" data-btn-type="toggle" class="btn btn-mini"><i class="icon-th-large"></i></button>\r
<button data-btn="tags" data-btn-type="toggle" class="btn btn-mini"><i class="icon-tag"></i></button>\r
</div>\r
+ <div class="rng-module-documentToolbar-toolbarGroup">\r
+ <button data-btn="createList" data-btn-type="cmd" class="btn btn-mini"><i class="icon-list"></i></button>\r
+ </div>\r
<div style="clear: both;"></div>\r
</div>
\ No newline at end of file
} else {\r
sandbox.getModule('documentCanvas').wrapSelectionWithNewNode(wlxmlTag, wlxmlClass);\r
}\r
+ },\r
+ command: function(cmd, meta) {\r
+ sandbox.getModule('documentCanvas').command(cmd, meta);\r
}\r
};\r
\r