smartxml: fix
[fnpeditor.git] / src / editor / 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         session = editor.getSession();
11     editor.setTheme("ace/theme/chrome");
12     session.setMode("ace/mode/xml")
13     session.setUseWrapMode(true);
14     
15     $('textarea', view).on('keyup', function() {
16         sandbox.publish('xmlChanged');
17     });
18     
19     editor.getSession().on('change', function() {
20         sandbox.publish('xmlChanged');
21     });
22     return {
23         start: function() {
24             sandbox.publish('ready');
25         },
26         getView: function() {
27             return view;
28         },
29         setDocument: function(document) {
30             editor.setValue(document);
31             editor.gotoLine(0);
32             sandbox.publish('documentSet');
33         },
34         getDocument: function() {
35             return editor.getValue();
36         }
37     };
38 };
39
40 });