X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a398f2a96740ebe6dd60559d90e74c648e7009af..8254ff82e19d41b2a66a4549165b924084ed6a52:/modules/documentCanvas/documentCanvas.js?ds=sidebyside diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index deebfca..7500e35 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -5,23 +5,27 @@ define([ './transformations', './canvas', './canvasManager', -'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, template) { +'./canvas/canvas', +'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, canvas3, template) { 'use strict'; return function(sandbox) { - var canvas = Canvas.create(); - var manager = new CanvasManager(canvas, sandbox); + var canvas = canvas3.fromXML(''); //canvasCanvas.create(); + var manager; + var canvasWrapper = $(template); /* public api */ return { start: function() { sandbox.publish('ready'); }, getView: function() { - return canvas.dom; + return canvasWrapper; }, setDocument: function(xml) { - canvas.setHTML(transformations.fromXML.getHTMLTree(xml)); + canvas.loadWlxml(xml); //canvas.setHTML(transformations.fromXML.getHTMLTree(xml)); + canvasWrapper.find('#rng-module-documentCanvas-content').empty().append(canvas.doc().dom()); + manager = new CanvasManager(canvas, sandbox); sandbox.publish('documentSet'); }, getDocument: function() { @@ -29,8 +33,17 @@ return function(sandbox) { }, modifyCurrentNode: function(attr, value) { if(manager.currentNode) { - manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value); + if(attr === 'tag') { + manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value); + } + else if(attr === 'class') { + manager.currentNode.setClass(value); + } else { + // changing node meta attr + manager.currentNode.setMetaAttr(attr, value); + } sandbox.publish('contentChanged'); + sandbox.publish('currentNodeChanged', manager.currentNode); } }, highlightNode: function(canvasNode) {