text: {
serverUploadLimit: this.serverUploadLimitText,
imageUploadError: this.imageUploadErrorText,
- }
+ },
+ settings: this.loadSettings(),
}).then(editor => {
this.editor = editor;
this.setupListeners();
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
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');