X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a5871ab5512d87a33e7e95451d26ee7d3e789742..a22d30b71f012cf8653319e6743440abf7be52a8:/modules/visualEditor.js?ds=inline diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 29506a5..2fecfde 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -1,7 +1,34 @@ rng.modules.visualEditor = function(sandbox) { + var transformations = rng.modules.visualEditor.transformations; + 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; } }