5 return function(sandbox) {
7 var view = $(sandbox.getTemplate('main')()),
8 documentIsDirty = true,
9 documentEditedHere = false,
12 view.onShow = function() {
14 editor.setValue(wlxmlDocument.toXML());
16 sandbox.publish('documentSet');
17 documentIsDirty = false;
21 view.onHide = function() {
22 if(documentEditedHere) {
23 documentEditedHere = false;
24 wlxmlDocument.loadXML(editor.getValue());
28 var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]),
29 session = editor.getSession();
30 editor.setTheme("ace/theme/chrome");
31 session.setMode("ace/mode/xml")
32 session.setUseWrapMode(true);
34 $('textarea', view).on('keyup', function() {
35 documentEditedHere = true;
38 editor.getSession().on('change', function() {
39 documentEditedHere = true;
43 sandbox.publish('ready');
48 setDocument: function(document) {
49 wlxmlDocument = document;
50 wlxmlDocument.on('change', function() {
51 documentIsDirty = true;
54 getDocument: function() {
55 return editor.getValue();