X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/969ec45041c117313a69c01d49edcc971d46d4b8..1aba836313d1513bbe0ca947e01176806c900233:/modules/visualEditor.js diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 5e503bb..b22aa7d 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -1,15 +1,39 @@ rng.modules.visualEditor = function(sandbox) { - var data = sandbox.getBootstrappedData(); - var view = $(sandbox.getTemplate('main')({title: data.title, content: data.text})); + var view = $(sandbox.getTemplate('main')()); + var isDirty = false; + + var document2html = function(document) { + return document; + } + + var html2document = function() { + return $('#rng-visualEditor-content').text(); + } + + $('#rng-visualEditor-content', view).on('keyup', function() { + isDirty = true; + }); - return { start: function() { sandbox.publish('ready'); }, getView: function() { return view; + }, + setDocument: function(document) { + $('#rng-visualEditor-content', view).html(document2html(document)); + isDirty = false; + }, + getDocument: function() { + return html2document(); + }, + isDirty: function() { + return isDirty; + }, + setDirty: function(dirty) { + isDirty = dirty; } }