2
0
mirror of https://github.com/frappe/books.git synced 2024-12-25 12:10:06 +00:00
books/client/view/controls/code.js
2018-02-20 19:41:44 +05:30

35 lines
957 B
JavaScript

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;