-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patheditor.js
38 lines (38 loc) · 1.12 KB
/
editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
CM = function(gene) {
return {
$type: "textarea",
id: gene.id ? gene.id : null,
_ed: null,
_out: gene._out,
_in: function(message) {
if(this._ed) this._ed.setValue(message);
},
_default: {
mode: "xml", htmlMode: true, lineNumbers: true, lineWrapping: true, lint: true, styleActiveLine: true, autoCloseBrackets: true, matchBrackets: true, viewportMargin: true, theme: "neo", gutters: ["CodeMirror-lint-markers"]
},
$init: function(){
var self = this;
for(var key in gene.options) {
this._default[key] = gene.options[key];
}
this._ed = CodeMirror.fromTextArea(this, this._default);
this._wrapper = this._ed.getWrapperElement();
for(var key in gene.style) {
this._wrapper.style[key] = gene.style[key];
}
try{
this._ed.on("change", function(e){
if(self._out) self._out(self._ed.getValue())
})
} catch (e) {}
if(gene.value) {
self._ed.setValue(gene.value);
if(self._out) {
setTimeout(function(){
self._out(gene.value);
},0)
}
}
}
}
}