X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/969ec45041c117313a69c01d49edcc971d46d4b8..56ab6eadd6887a63a83c768abf3c02393d1f4a28:/modules/visualEditor.js?ds=inline diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 5e503bb..2fecfde 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -1,15 +1,34 @@ rng.modules.visualEditor = function(sandbox) { + var transformations = rng.modules.visualEditor.transformations; - var data = sandbox.getBootstrappedData(); - var view = $(sandbox.getTemplate('main')({title: data.title, content: data.text})); + var view = $(sandbox.getTemplate('main')()); + var isDirty = false; + + + $('#rng-visualEditor-content', view).on('keyup', function() { + isDirty = true; + }); - return { start: function() { sandbox.publish('ready'); }, getView: function() { return view; + }, + setDocument: function(xml) { + var transformed = transformations.fromXML.getDocumentDescription(xml); + $('#rng-visualEditor-content', view).html(transformed.HTMLTree); + isDirty = false; + }, + getDocument: function() { + return transformations.toXML.getXML({HTMLTree: $('#rng-visualEditor-content').text(), metadata: {}}); + }, + isDirty: function() { + return isDirty; + }, + setDirty: function(dirty) { + isDirty = dirty; } }