mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-22 06:40:01 +08:00
Upgraded app to Laravel 5.7
This commit is contained in:
43
resources/js/vues/code-editor.js
Normal file
43
resources/js/vues/code-editor.js
Normal file
@ -0,0 +1,43 @@
|
||||
import codeLib from "../services/code";
|
||||
|
||||
const methods = {
|
||||
show() {
|
||||
if (!this.editor) this.editor = codeLib.popupEditor(this.$refs.editor, this.language);
|
||||
this.$refs.overlay.components.overlay.show();
|
||||
},
|
||||
hide() {
|
||||
this.$refs.overlay.components.overlay.hide();
|
||||
},
|
||||
updateEditorMode(language) {
|
||||
codeLib.setMode(this.editor, language);
|
||||
},
|
||||
updateLanguage(lang) {
|
||||
this.language = lang;
|
||||
this.updateEditorMode(lang);
|
||||
},
|
||||
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
|
||||
};
|
||||
|
||||
export default {
|
||||
methods,
|
||||
data
|
||||
};
|
Reference in New Issue
Block a user