1 // Module that implements main WYSIWIG edit area
\r
4 'libs/underscore-min',
\r
5 './transformations',
\r
9 'libs/text!./template.html'], function(_, transformations, wlxmlNode, Canvas, CanvasManager, template) {
\r
13 return function(sandbox) {
\r
15 var canvas = new Canvas.Canvas();
\r
16 var manager = new CanvasManager(canvas, sandbox);
\r
20 start: function() { sandbox.publish('ready'); },
\r
21 getView: function() {
\r
24 setDocument: function(xml) {
\r
26 sandbox.publish('documentSet');
\r
28 getDocument: function() {
\r
29 return canvas.toXML();
\r
31 modifyCurrentNode: function(attr, value) {
\r
32 if(manager.currentNode) {
\r
33 manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
\r
34 sandbox.publish('contentChanged');
\r
37 highlightNode: function(wlxmlNode) {
\r
38 manager.highlightNode(wlxmlNode);
\r
40 dimNode: function(wlxmlNode) {
\r
41 manager.dimNode(wlxmlNode);
\r
43 selectNode: function(wlxmlNode) {
\r
44 if(!wlxmlNode.is(manager.currentNode))
\r
45 manager.selectNode(wlxmlNode, {movecaret: true});
\r
47 toggleGrid: function(toggle) {
\r
48 manager.toggleGrid(toggle);
\r
50 insertNewNode: function(wlxmlTag, wlxmlClass) {
\r
51 manager.insertNewNode(wlxmlTag, wlxmlClass);
\r
53 wrapSelectionWithNewNode: function(wlxmlTag, wlxmlClass) {
\r
54 manager.wrapSelectionWithNewNode(wlxmlTag, wlxmlClass);
\r