]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/markdown-editor.js
Added md editor ui dropdown options & their back-end storage
[bookstack] / resources / js / components / markdown-editor.js
index 671aa4e65fc6e78351d8c51934b7b224d6227837..162dd6771f920d96ad7c20318589de8fd1054bdd 100644 (file)
@@ -14,6 +14,7 @@ export class MarkdownEditor extends Component {
 
         this.display = this.$refs.display;
         this.input = this.$refs.input;
+        this.settingContainer = this.$refs.settingContainer;
 
         this.editor = null;
         initEditor({
@@ -74,6 +75,15 @@ export class MarkdownEditor extends Component {
             toolbarLabel.closest('.markdown-editor-wrap').classList.add('active');
         });
 
+        // Setting changes
+        this.settingContainer.addEventListener('change', e => {
+            const actualInput = e.target.parentNode.querySelector('input[type="hidden"]');
+            const name = actualInput.getAttribute('name');
+            const value = actualInput.getAttribute('value');
+            window.$http.patch('/preferences/update-boolean', {name, value});
+            // TODO - Update state locally
+        });
+
         // Refresh CodeMirror on container resize
         const resizeDebounced = debounce(() => this.editor.cm.refresh(), 100, false);
         const observer = new ResizeObserver(resizeDebounced);