X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ee24635e06a8c01d751f80caba47c57f76e8989d..refs/pull/4002/head:/resources/js/components/code-editor.js diff --git a/resources/js/components/code-editor.js b/resources/js/components/code-editor.js index 2d8031205..205cbd8fd 100644 --- a/resources/js/components/code-editor.js +++ b/resources/js/components/code-editor.js @@ -1,10 +1,8 @@ import {onChildEvent, onEnterPress, onSelect} from "../services/dom"; +import {Component} from "./component"; -/** - * Code Editor - * @extends {Component} - */ -class CodeEditor { + +export class CodeEditor extends Component { setup() { this.container = this.$refs.container; @@ -73,7 +71,7 @@ class CodeEditor { isFavorite ? this.favourites.add(language) : this.favourites.delete(language); button.setAttribute('data-favourite', isFavorite ? 'true' : 'false'); - window.$http.patch('/settings/users/update-code-language-favourite', { + window.$http.patch('/preferences/update-code-language-favourite', { language: language, active: isFavorite }); @@ -128,7 +126,7 @@ class CodeEditor { } this.loadHistory(); - this.popup.components.popup.show(() => { + this.getPopup().show(() => { Code.updateLayout(this.editor); this.editor.focus(); }, () => { @@ -137,10 +135,17 @@ class CodeEditor { } hide() { - this.popup.components.popup.hide(); + this.getPopup().hide(); this.addHistory(); } + /** + * @returns {Popup} + */ + getPopup() { + return window.$components.firstOnElement(this.popup, 'popup'); + } + async updateEditorMode(language) { const Code = await window.importVersioned('code'); Code.setMode(this.editor, language, this.editor.getValue()); @@ -184,6 +189,4 @@ class CodeEditor { window.sessionStorage.setItem(this.historyKey, historyString); } -} - -export default CodeEditor; \ No newline at end of file +} \ No newline at end of file