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) {
33 manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
35 else if(attr === 'class') {
36 manager.currentNode.setClass(value);
38 // changing node meta attr
39 manager.currentNode.setMetaAttr(attr, value);
41 sandbox.publish('contentChanged');
42 sandbox.publish('currentNodeChanged', manager.currentNode);
45 highlightNode: function(canvasNode) {
46 manager.highlightNode(canvasNode);
48 dimNode: function(canvasNode) {
49 manager.dimNode(canvasNode);
51 selectNode: function(canvasNode) {
52 if(!canvasNode.isSame(manager.currentNode))
53 manager.selectNode(canvasNode, {movecaret: true});
55 toggleGrid: function(toggle) {
56 manager.toggleGrid(toggle);
58 insertNewNode: function(wlxmlTag, wlxmlClass) {
59 manager.insertNewNode(wlxmlTag, wlxmlClass);
61 command: function(command, meta) {
62 manager.command(command, meta);