1 // Module that implements main WYSIWIG edit area
8 'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, template) {
12 return function(sandbox) {
14 var canvas = Canvas.create();
15 var manager = new CanvasManager(canvas, sandbox);
19 start: function() { sandbox.publish('ready'); },
23 setDocument: function(xml) {
24 canvas.setHTML(transformations.fromXML.getHTMLTree(xml));
25 sandbox.publish('documentSet');
27 getDocument: function() {
28 return transformations.toXML.getXML(canvas.getContent());
30 modifyCurrentNode: function(attr, value) {
31 if(manager.currentNode) {
32 if(_.contains(['tag', 'class'], attr)) {
33 manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
35 // changing node meta attr
36 manager.currentNode.setMetaAttr(attr, value);
38 sandbox.publish('contentChanged');
39 sandbox.publish('currentNodeChanged', manager.currentNode);
42 highlightNode: function(canvasNode) {
43 manager.highlightNode(canvasNode);
45 dimNode: function(canvasNode) {
46 manager.dimNode(canvasNode);
48 selectNode: function(canvasNode) {
49 if(!canvasNode.isSame(manager.currentNode))
50 manager.selectNode(canvasNode, {movecaret: true});
52 toggleGrid: function(toggle) {
53 manager.toggleGrid(toggle);
55 insertNewNode: function(wlxmlTag, wlxmlClass) {
56 manager.insertNewNode(wlxmlTag, wlxmlClass);
58 command: function(command, meta) {
59 manager.command(command, meta);