0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-17 05:42:06 +00:00

Connected md editor settings to logic for functionality

This commit is contained in:
Dan Brown 2022-11-28 12:12:36 +00:00
parent 9fd5190c70
commit ec3713bc74
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
10 changed files with 99 additions and 28 deletions
resources/js/components

View file

@ -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');