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 manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
33 sandbox.publish('contentChanged');
36 highlightNode: function(canvasNode) {
37 manager.highlightNode(canvasNode);
39 dimNode: function(canvasNode) {
40 manager.dimNode(canvasNode);
42 selectNode: function(canvasNode) {
43 if(!canvasNode.isSame(manager.currentNode))
44 manager.selectNode(canvasNode, {movecaret: true});
46 toggleGrid: function(toggle) {
47 manager.toggleGrid(toggle);
49 insertNewNode: function(wlxmlTag, wlxmlClass) {
50 manager.insertNewNode(wlxmlTag, wlxmlClass);
52 command: function(command, meta) {
53 manager.command(command, meta);