|
|
|
@ -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; |
|
|
|
}, |
|
|
|
|