X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/3eaf5e66203b1afafc81dfb1214660b20a11739f..ccd0a4f745a6fab17a228d822e80d8bbb6fa7d5d:/modules/sourceEditor/sourceEditor.js diff --git a/modules/sourceEditor/sourceEditor.js b/modules/sourceEditor/sourceEditor.js new file mode 100644 index 0000000..248c02d --- /dev/null +++ b/modules/sourceEditor/sourceEditor.js @@ -0,0 +1,43 @@ +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 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