1 // Module that implements main WYSIWIG edit area
9 'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, canvas3, template) {
13 return function(sandbox) {
15 var canvas = canvas3.fromXML(''); //canvasCanvas.create();
17 var canvasWrapper = $(template);
21 start: function() { sandbox.publish('ready'); },
25 setDocument: function(xml) {
26 canvas.loadWlxml(xml); //canvas.setHTML(transformations.fromXML.getHTMLTree(xml));
27 canvasWrapper.find('#rng-module-documentCanvas-content').empty().append(canvas.view());
28 manager = new CanvasManager(canvas, sandbox);
29 sandbox.publish('documentSet');
31 getDocument: function() {
32 return transformations.toXML.getXML(canvas.getContent());
34 modifyCurrentNode: function(attr, value) {
35 if(manager.currentNode) {
37 manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
39 else if(attr === 'class') {
40 manager.currentNode.setClass(value);
42 // changing node meta attr
43 manager.currentNode.setMetaAttr(attr, value);
45 sandbox.publish('contentChanged');
46 sandbox.publish('currentNodeChanged', manager.currentNode);
49 highlightNode: function(canvasNode) {
50 manager.highlightNode(canvasNode);
52 dimNode: function(canvasNode) {
53 manager.dimNode(canvasNode);
55 selectNode: function(canvasNode) {
56 if(!canvasNode.isSame(manager.currentNode))
57 manager.selectNode(canvasNode, {movecaret: true});
59 command: function(command, params) {
60 manager.command(command, params);