From 06f085a7b35932bcf2c83b3279d5adc687de908c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Wed, 17 Apr 2013 09:46:08 +0200 Subject: [PATCH 1/1] Introducing Ace as the source editor --- editor.css | 5 +++++ modules/sourceEditor.js | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) 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; -- 2.20.1