X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/5fbecb65c701a7680aae9258ff16df6a1e9f35f5..e47b0769de4853ef9c027592533804e39f247f44:/modules/sourceEditor.js?ds=sidebyside diff --git a/modules/sourceEditor.js b/modules/sourceEditor.js index ea84ee3..248c02d 100644 --- a/modules/sourceEditor.js +++ b/modules/sourceEditor.js @@ -1,12 +1,43 @@ -rng.modules.sourceEditor = function(sandbox) { +define(function() { +return function(sandbox) { + + var view = $(sandbox.getTemplate('main')()); + var isDirty = false; + + var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]); + editor.setTheme("ace/theme/chrome"); + editor.getSession().setMode("ace/mode/xml"); + $('textarea', view).on('keyup', function() { + isDirty = true; + }); + + editor.getSession().on('change', function() { + isDirty = true; + }) return { start: function() { sandbox.publish('ready'); }, getView: function() { - return $('
source editor
'); + return view; + }, + setDocument: function(document) { + editor.setValue(document); + editor.gotoLine(0) + isDirty = false; + }, + getDocument: function() { + return editor.getValue(); + }, + isDirty: function() { + return isDirty; + }, + setDirty: function(dirty) { + isDirty = dirty; } } -}; \ No newline at end of file +}; + +}); \ No newline at end of file