X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/ff17619a4071364ea15383c696cb7e84b6c83089..4310156c7c3713b31e159c76d8ba2657a7421ead:/modules/documentCanvas/documentCanvas.js diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index 50a3777..39b2610 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,11 @@ return function(sandbox) { }, modifyCurrentNode: function(attr, value) { if(manager.currentNode) { - if(_.contains(['tag', 'class'], attr)) { + 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); @@ -49,14 +56,8 @@ return function(sandbox) { if(!canvasNode.isSame(manager.currentNode)) manager.selectNode(canvasNode, {movecaret: true}); }, - toggleGrid: function(toggle) { - manager.toggleGrid(toggle); - }, - insertNewNode: function(wlxmlTag, wlxmlClass) { - manager.insertNewNode(wlxmlTag, wlxmlClass); - }, - command: function(command, meta) { - manager.command(command, meta); + command: function(command, params) { + manager.command(command, params); } };