1 // Module that implements main WYSIWIG edit area
8 'libs/text!./template.html'], function($, _, canvas3, commands, template) {
12 return function(sandbox) {
14 var canvas = canvas3.fromXMLDocument(null, sandbox.publish);
15 var canvasWrapper = $(template);
16 var shownAlready = false;
17 var scrollbarPosition = 0,
20 canvasWrapper.onShow = function() {
23 canvas.setCurrentElement(canvas.doc().getVerticallyFirstTextElement());
25 canvas.setCursorPosition(cursorPosition);
26 this.find('#rng-module-documentCanvas-contentWrapper').scrollTop(scrollbarPosition);
30 canvasWrapper.onHide = function() {
31 scrollbarPosition = this.find('#rng-module-documentCanvas-contentWrapper').scrollTop();
32 cursorPosition = canvas.getCursor().getPosition();
37 start: function() { sandbox.publish('ready'); },
41 setDocument: function(wlxmlDocument) {
42 canvas.loadWlxmlDocument(wlxmlDocument);
43 canvasWrapper.find('#rng-module-documentCanvas-content').empty().append(canvas.view());
45 getDocument: function() {
46 return canvas.toXML();
48 modifyCurrentNodeElement: function(attr, value) {
49 var currentNodeElement = canvas.getCurrentNodeElement();
50 if(attr === 'class' || attr === 'tag') {
51 currentNodeElement['setWlxml'+(attr[0].toUpperCase() + attr.substring(1))](value);
53 currentNodeElement.setWlxmlMetaAttr(attr, value);
55 sandbox.publish('currentNodeElementChanged', currentNodeElement);
57 highlightElement: function(node) {
58 canvas.toggleElementHighlight(node, true);
60 dimElement: function(node) {
61 canvas.toggleElementHighlight(node, false);
63 jumpToElement: function(node) {
64 canvas.setCurrentElement(node);
66 command: function(command, params) {
67 commands.run(command, params, canvas);
68 sandbox.publish('contentChanged');