Browse Source

Add onChange to CodeEditor

pull/1800/head
Artur Arseniev 8 years ago
parent
commit
bad140fa1c
  1. 9
      src/code_manager/model/CodeMirrorEditor.js

9
src/code_manager/model/CodeMirrorEditor.js

@ -1,3 +1,4 @@
import { bindAll } from 'underscore';
import Backbone from 'backbone';
var CodeMirror = require('codemirror/lib/codemirror');
var htmlMode = require('codemirror/mode/htmlmixed/htmlmixed');
@ -9,13 +10,14 @@ module.exports = Backbone.Model.extend({
input: '',
label: '',
codeName: '',
theme: '',
theme: 'hopscotch',
readOnly: true,
lineNumbers: true
},
/** @inheritdoc */
init(el) {
bindAll(this, 'onChange');
this.editor = CodeMirror.fromTextArea(el, {
dragDrop: false,
lineWrapping: true,
@ -23,10 +25,15 @@ module.exports = Backbone.Model.extend({
...this.attributes
});
this.element = el;
this.editor.on('change', this.onChange);
return this;
},
onChange() {
this.trigger('update', this);
},
getEditor() {
return this.editor;
},

Loading…
Cancel
Save