canvas api: fixing list adding
[fnpeditor.git] / modules / documentCanvas / documentCanvas.js
1 // Module that implements main WYSIWIG edit area\r
2 \r
3 define([\r
4 'libs/underscore-min',\r
5 './transformations', \r
6 './wlxmlNode',\r
7 './canvas',\r
8 './canvasManager',\r
9 'libs/text!./template.html'], function(_, transformations, wlxmlNode, Canvas, CanvasManager, template) {\r
10 \r
11 'use strict';\r
12 \r
13 return function(sandbox) {\r
14 \r
15     var canvas = new Canvas.Canvas();\r
16     var manager = new CanvasManager(canvas, sandbox);\r
17 \r
18     /* public api */\r
19     return {\r
20         start: function() { sandbox.publish('ready'); },\r
21         getView: function() { \r
22             return canvas.dom;\r
23         },\r
24         setDocument: function(xml) {\r
25             canvas.setXML(xml);\r
26             sandbox.publish('documentSet');\r
27         },\r
28         getDocument: function() {\r
29             return canvas.toXML();\r
30         },\r
31         modifyCurrentNode: function(attr, value) {\r
32             if(manager.currentNode) {\r
33                 manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);\r
34                 sandbox.publish('contentChanged');\r
35             }\r
36         },\r
37         highlightNode: function(wlxmlNode) {\r
38             manager.highlightNode(wlxmlNode);\r
39         },\r
40         dimNode: function(wlxmlNode) {\r
41             manager.dimNode(wlxmlNode);\r
42         },\r
43         selectNode: function(wlxmlNode) {\r
44             if(!wlxmlNode.is(manager.currentNode))\r
45                 manager.selectNode(wlxmlNode, {movecaret: true});\r
46         },\r
47         toggleGrid: function(toggle) {\r
48             manager.toggleGrid(toggle);\r
49         },\r
50         insertNewNode: function(wlxmlTag, wlxmlClass) {\r
51             manager.insertNewNode(wlxmlTag, wlxmlClass);\r
52         },\r
53         wrapSelectionWithNewNode: function(wlxmlTag, wlxmlClass) {\r
54             manager.wrapSelectionWithNewNode(wlxmlTag, wlxmlClass);\r
55         }\r
56     }\r
57     \r
58 };\r
59 \r
60 });