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');
41 highlightNode: function(canvasNode) {
42 manager.highlightNode(canvasNode);
44 dimNode: function(canvasNode) {
45 manager.dimNode(canvasNode);
47 selectNode: function(canvasNode) {
48 if(!canvasNode.isSame(manager.currentNode))
49 manager.selectNode(canvasNode, {movecaret: true});
51 toggleGrid: function(toggle) {
52 manager.toggleGrid(toggle);
54 insertNewNode: function(wlxmlTag, wlxmlClass) {
55 manager.insertNewNode(wlxmlTag, wlxmlClass);
57 command: function(command, meta) {
58 manager.command(command, meta);