X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/412e60ded1457ec0f408e2234c9dd60122929bac..efe36f4f1b5df351eeb4d40a54c3900cf9a7079b:/src/editor/modules/sourceEditor/sourceEditor.js diff --git a/src/editor/modules/sourceEditor/sourceEditor.js b/src/editor/modules/sourceEditor/sourceEditor.js new file mode 100644 index 0000000..e88e5e1 --- /dev/null +++ b/src/editor/modules/sourceEditor/sourceEditor.js @@ -0,0 +1,40 @@ +define(function() { + +'use strict'; + +return function(sandbox) { + + var view = $(sandbox.getTemplate('main')()); + + var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]), + session = editor.getSession(); + editor.setTheme("ace/theme/chrome"); + session.setMode("ace/mode/xml") + session.setUseWrapMode(true); + + $('textarea', view).on('keyup', function() { + sandbox.publish('xmlChanged'); + }); + + editor.getSession().on('change', function() { + sandbox.publish('xmlChanged'); + }); + return { + start: function() { + sandbox.publish('ready'); + }, + getView: function() { + return view; + }, + setDocument: function(document) { + editor.setValue(document); + editor.gotoLine(0); + sandbox.publish('documentSet'); + }, + getDocument: function() { + return editor.getValue(); + } + }; +}; + +}); \ No newline at end of file