X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/0add3b13ce4ef42557d9ca33342a159b80a4f42f..a9da2ddb356fb313c1a5b45b073eec2c5a282649:/modules/sourceEditor.js diff --git a/modules/sourceEditor.js b/modules/sourceEditor.js index 787bfb9..5a62eaf 100644 --- a/modules/sourceEditor.js +++ b/modules/sourceEditor.js @@ -3,10 +3,16 @@ rng.modules.sourceEditor = 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 +21,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;