mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
39 lines
900 B
JavaScript
39 lines
900 B
JavaScript
|
const codeLib = require('../code');
|
||
|
|
||
|
const methods = {
|
||
|
show() {
|
||
|
if (!this.editor) this.editor = codeLib.popupEditor(this.$refs.editor, this.language);
|
||
|
this.$refs.overlay.style.display = 'flex';
|
||
|
},
|
||
|
hide() {
|
||
|
this.$refs.overlay.style.display = 'none';
|
||
|
},
|
||
|
updateEditorMode(language) {
|
||
|
codeLib.setMode(this.editor, language);
|
||
|
},
|
||
|
open(code, language, callback) {
|
||
|
this.show();
|
||
|
this.updateEditorMode(language);
|
||
|
this.language = language;
|
||
|
codeLib.setContent(this.editor, code);
|
||
|
this.code = code;
|
||
|
this.callback = callback;
|
||
|
},
|
||
|
save() {
|
||
|
if (!this.callback) return;
|
||
|
this.callback(this.editor.getValue(), this.language);
|
||
|
this.hide();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
const data = {
|
||
|
editor: null,
|
||
|
language: '',
|
||
|
code: '',
|
||
|
callback: null
|
||
|
};
|
||
|
|
||
|
module.exports = {
|
||
|
methods,
|
||
|
data
|
||
|
};
|