1 // Module that implements main WYSIWIG edit area
9 'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, canvas3, template) {
13 return function(sandbox) {
15 var canvas = canvas3.fromXML('', sandbox.publish); //canvasCanvas.create();
17 var canvasWrapper = $(template);
18 var shownAlready = false;
19 var scrollbarPosition = 0,
22 canvasWrapper.onShow = function() {
25 canvas.setCurrentElement(canvas.doc().getVerticallyFirstTextElement());
27 canvas.setCursorPosition(cursorPosition);
28 this.find('#rng-module-documentCanvas-contentWrapper').scrollTop(scrollbarPosition);
32 canvasWrapper.onHide = function() {
33 scrollbarPosition = this.find('#rng-module-documentCanvas-contentWrapper').scrollTop();
34 cursorPosition = canvas.getCursor().getPosition();
39 start: function() { sandbox.publish('ready'); },
43 setDocument: function(xml) {
44 canvas.loadWlxml(xml); //canvas.setHTML(transformations.fromXML.getHTMLTree(xml));
45 canvasWrapper.find('#rng-module-documentCanvas-content').empty().append(canvas.view());
46 manager = new CanvasManager(canvas, sandbox);
47 sandbox.publish('documentSet');
49 getDocument: function() {
50 return transformations.toXML.getXML(canvas.getContent());
52 modifyCurrentNodeElement: function(attr, value) {
53 if(attr === 'class' || attr === 'tag') {
54 canvas.getCurrentNodeElement()['setWlxml'+(attr[0].toUpperCase() + attr.substring(1))](value);
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 manager.command(command, params);