Converting end of lines from crlf to lf
[fnpeditor.git] / modules / sourceEditor / sourceEditor.js
1 define(function() {
2
3 'use strict';
4
5 return function(sandbox) {
6
7     var view = $(sandbox.getTemplate('main')());
8     
9     var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]);
10     editor.setTheme("ace/theme/chrome");
11     editor.getSession().setMode("ace/mode/xml");
12     $('textarea', view).on('keyup', function() {
13         sandbox.publish('xmlChanged');
14     });
15     
16     editor.getSession().on('change', function() {
17         sandbox.publish('xmlChanged');
18     });
19     return {
20         start: function() {
21             sandbox.publish('ready');
22         },
23         getView: function() {
24             return view;
25         },
26         setDocument: function(document) {
27             editor.setValue(document);
28             editor.gotoLine(0);
29             sandbox.publish('documentSet');
30         },
31         getDocument: function() {
32             return editor.getValue();
33         }
34     };
35 };
36
37 });