X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a5871ab5512d87a33e7e95451d26ee7d3e789742..ad5230bb4e14bbc859fdc5b1b31efab6bf43d122:/modules/sourceEditor.js

diff --git a/modules/sourceEditor.js b/modules/sourceEditor.js
index 59b663e..5a62eaf 100644
--- a/modules/sourceEditor.js
+++ b/modules/sourceEditor.js
@@ -1,7 +1,38 @@
 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');
+        },
+        getView: function() {
+            return view;
+        },
+        setDocument: function(document) {
+            editor.setValue(document);
+            editor.gotoLine(0)
+            isDirty = false;
+        },
+        getDocument: function() {
+            return editor.getValue();
+        },
+        isDirty: function() {
+            return isDirty;
+        },
+        setDirty: function(dirty) {
+            isDirty = dirty;
         }
     
     }