mirror of
https://github.com/frappe/books.git
synced 2024-12-24 11:55:46 +00:00
35 lines
957 B
JavaScript
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; |