1 // Module that implements main WYSIWIG edit area
7 'libs/text!./template.html'], function(_, canvas3, commands, template) {
11 return function(sandbox) {
13 var canvas = canvas3.fromXML('', sandbox.publish);
14 var canvasWrapper = $(template);
15 var shownAlready = false;
16 var scrollbarPosition = 0,
19 canvasWrapper.onShow = function() {
22 canvas.setCurrentElement(canvas.doc().getVerticallyFirstTextElement());
24 canvas.setCursorPosition(cursorPosition);
25 this.find('#rng-module-documentCanvas-contentWrapper').scrollTop(scrollbarPosition);
29 canvasWrapper.onHide = function() {
30 scrollbarPosition = this.find('#rng-module-documentCanvas-contentWrapper').scrollTop();
31 cursorPosition = canvas.getCursor().getPosition();
36 start: function() { sandbox.publish('ready'); },
40 setDocument: function(xml) {
41 canvas.loadWlxml(xml);
42 canvasWrapper.find('#rng-module-documentCanvas-content').empty().append(canvas.view());
43 sandbox.publish('documentSet');
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(element) {
58 canvas.highlightElement(element);
60 dimElement: function(element) {
61 canvas.dimElement(element);
63 jumpToElement: function(element) {
64 canvas.setCurrentElement(element);
66 command: function(command, params) {
67 commands.run(command, params, canvas);
68 sandbox.publish('contentChanged');