1 // Module that implements main WYSIWIG edit area
\r
4 'libs/underscore-min',
\r
5 './transformations',
\r
8 'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, template) {
\r
12 return function(sandbox) {
\r
14 var canvas = Canvas.create();
\r
15 var manager = new CanvasManager(canvas, sandbox);
\r
19 start: function() { sandbox.publish('ready'); },
\r
20 getView: function() {
\r
23 setDocument: function(xml) {
\r
24 canvas.setHTML(transformations.fromXML.getHTMLTree(xml));
\r
25 sandbox.publish('documentSet');
\r
27 getDocument: function() {
\r
28 return canvas.toXML();
\r
30 modifyCurrentNode: function(attr, value) {
\r
31 if(manager.currentNode) {
\r
32 manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
\r
33 sandbox.publish('contentChanged');
\r
36 highlightNode: function(canvasNode) {
\r
37 manager.highlightNode(canvasNode);
\r
39 dimNode: function(canvasNode) {
\r
40 manager.dimNode(canvasNode);
\r
42 selectNode: function(canvasNode) {
\r
43 if(!canvasNode.isSame(manager.currentNode))
\r
44 manager.selectNode(canvasNode, {movecaret: true});
\r
46 toggleGrid: function(toggle) {
\r
47 manager.toggleGrid(toggle);
\r
49 insertNewNode: function(wlxmlTag, wlxmlClass) {
\r
50 manager.insertNewNode(wlxmlTag, wlxmlClass);
\r
52 command: function(command, meta) {
\r
53 manager.command(command, meta);
\r