X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a09318d74185278fa556af4a997e94b0d6999193..06f085a7b35932bcf2c83b3279d5adc687de908c:/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;