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 modifyCurrentNodeElement: function(attr, value) {
46 var currentNodeElement = canvas.getCurrentNodeElement();
47 if(attr === 'class' || attr === 'tag') {
48 currentNodeElement['setWlxml'+(attr[0].toUpperCase() + attr.substring(1))](value);
50 currentNodeElement.setWlxmlMetaAttr(attr, value);
52 sandbox.publish('currentNodeElementChanged', currentNodeElement);
54 highlightElement: function(node) {
55 canvas.toggleElementHighlight(node, true);
57 dimElement: function(node) {
58 canvas.toggleElementHighlight(node, false);
60 jumpToElement: function(node) {
61 canvas.setCurrentElement(node);
63 command: function(command, params) {
64 commands.run(command, params, canvas, sandbox.getConfig().user);
65 sandbox.publish('contentChanged');