2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 01:14:03 +00:00
books/client/view/controls/code.js

35 lines
957 B
JavaScript
Raw Normal View History

2018-02-20 14:11:44 +00:00
const BaseControl = require('./base');
// const frappe = require('frappejs');
const CodeMirror = require('codemirror');
const modeHTML = require('codemirror/mode/htmlmixed/htmlmixed'); // eslint-disable-line
const modeJavascript = require('codemirror/mode/javascript/javascript'); // eslint-disable-line
class CodeControl extends BaseControl {
makeInput() {
if (!this.options) {
this.options = {};
}
this.options.theme = 'default';
this.input = new CodeMirror(this.getInputParent(), this.options);
}
setInputValue(value) {
if (value !== this.input.getValue()) {
this.input.setValue(value || '');
}
}
getInputValue(value) {
return this.input.getValue();
}
addChangeHandler() {
this.input.on('blur', () => {
if (this.skipChangeEvent) return;
this.handleChange();
});
}
};
module.exports = CodeControl;