X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/9fd5190c702c4ef755efdf91edd24420e5a8bb75..refs/pull/3878/head:/resources/js/components/markdown-editor.js diff --git a/resources/js/components/markdown-editor.js b/resources/js/components/markdown-editor.js index 162dd6771..373fedf48 100644 --- a/resources/js/components/markdown-editor.js +++ b/resources/js/components/markdown-editor.js @@ -26,7 +26,8 @@ export class MarkdownEditor extends Component { text: { serverUploadLimit: this.serverUploadLimitText, imageUploadError: this.imageUploadErrorText, - } + }, + settings: this.loadSettings(), }).then(editor => { this.editor = editor; this.setupListeners(); @@ -81,7 +82,7 @@ export class MarkdownEditor extends Component { const name = actualInput.getAttribute('name'); const value = actualInput.getAttribute('value'); window.$http.patch('/preferences/update-boolean', {name, value}); - // TODO - Update state locally + this.editor.settings.set(name, value === 'true'); }); // Refresh CodeMirror on container resize @@ -90,6 +91,17 @@ export class MarkdownEditor extends Component { observer.observe(this.elem); } + loadSettings() { + const settings = {}; + const inputs = this.settingContainer.querySelectorAll('input[type="hidden"]'); + + for (const input of inputs) { + settings[input.getAttribute('name')] = input.value === 'true'; + } + + return settings; + } + scrollToTextIfNeeded() { const queryParams = (new URL(window.location)).searchParams; const scrollText = queryParams.get('content-text');