X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/9eb5d6423cea01acb7589519480465394882ab7c..e816ae7584e8b11a1e24efb2f743ac744d80485b:/modules/documentCanvas/documentCanvas.js?ds=inline diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index fb67c0d..4ca0a4d 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -3,16 +3,15 @@ define([ 'libs/underscore-min', './transformations', -'./wlxmlNode', './canvas', './canvasManager', -'libs/text!./template.html'], function(_, transformations, wlxmlNode, Canvas, CanvasManager, template) { +'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, template) { 'use strict'; return function(sandbox) { - var canvas = new Canvas.Canvas(); + var canvas = Canvas.create(); var manager = new CanvasManager(canvas, sandbox); /* public api */ @@ -22,11 +21,11 @@ return function(sandbox) { return canvas.dom; }, setDocument: function(xml) { - canvas.setXML(xml); + canvas.setHTML(transformations.fromXML.getHTMLTree(xml)); sandbox.publish('documentSet'); }, getDocument: function() { - return canvas.toXML(); + return transformations.toXML.getXML(canvas.getContent()) }, modifyCurrentNode: function(attr, value) { if(manager.currentNode) { @@ -34,15 +33,15 @@ return function(sandbox) { sandbox.publish('contentChanged'); } }, - highlightNode: function(wlxmlNode) { - manager.highlightNode(wlxmlNode); + highlightNode: function(canvasNode) { + manager.highlightNode(canvasNode); }, - dimNode: function(wlxmlNode) { - manager.dimNode(wlxmlNode); + dimNode: function(canvasNode) { + manager.dimNode(canvasNode); }, - selectNode: function(wlxmlNode) { - if(!wlxmlNode.is(manager.currentNode)) - manager.selectNode(wlxmlNode, {movecaret: true}); + selectNode: function(canvasNode) { + if(!canvasNode.isSame(manager.currentNode)) + manager.selectNode(canvasNode, {movecaret: true}); }, toggleGrid: function(toggle) { manager.toggleGrid(toggle); @@ -50,8 +49,8 @@ return function(sandbox) { insertNewNode: function(wlxmlTag, wlxmlClass) { manager.insertNewNode(wlxmlTag, wlxmlClass); }, - wrapSelectionWithNewNode: function(wlxmlTag, wlxmlClass) { - manager.wrapSelectionWithNewNode(wlxmlTag, wlxmlClass); + command: function(command, meta) { + manager.command(command, meta); } }