From: Aleksander Ɓukasz Date: Wed, 17 Apr 2013 07:46:08 +0000 (+0200) Subject: Introducing Ace as the source editor X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/06f085a7b35932bcf2c83b3279d5adc687de908c?hp=a09318d74185278fa556af4a997e94b0d6999193 Introducing Ace as the source editor --- diff --git a/editor.css b/editor.css index 18dfc16..667db19 100644 --- a/editor.css +++ b/editor.css @@ -60,6 +60,11 @@ body { float:right; } +#rng-sourceEditor-editor { + width: 940px; + height: 500px; +} + .rng { float: none !important; /* temporaty workaround for Bootstrap's influence via [class*="span"] { float: left; } */ border-color: white; 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;