X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/0add3b13ce4ef42557d9ca33342a159b80a4f42f..a98948280a27e20a66c70d51c814956d2850c357:/modules/sourceEditor.js diff --git a/modules/sourceEditor.js b/modules/sourceEditor.js index 787bfb9..248c02d 100644 --- a/modules/sourceEditor.js +++ b/modules/sourceEditor.js @@ -1,12 +1,20 @@ -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'); @@ -15,11 +23,12 @@ rng.modules.sourceEditor = function(sandbox) { return view; }, setDocument: function(document) { - $('textarea', view).val(document); + editor.setValue(document); + editor.gotoLine(0) isDirty = false; }, getDocument: function() { - return $('textarea', view).val(); + return editor.getValue(); }, isDirty: function() { return isDirty; @@ -29,4 +38,6 @@ rng.modules.sourceEditor = function(sandbox) { } } -}; \ No newline at end of file +}; + +}); \ No newline at end of file