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:
parent
9fd5190c70
commit
ec3713bc74
10 changed files with 99 additions and 28 deletions
resources/js/components
|
@ -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue