client, server: Create option to control word wrapping for code blocks

This commit is contained in:
Elian Doran 2024-10-27 21:51:56 +02:00
parent 52bc28def7
commit b8569ea243
No known key found for this signature in database
3 changed files with 15 additions and 1 deletions

View File

@ -23,6 +23,13 @@ const TPL = `
<label>${t("highlighting.color-scheme")}</label>
<select class="theme-select form-select"></select>
</div>
<div class="col-6">
<label>Word wrapping</label>
<div class="form-check">
<input type="checkbox" class="word-wrap form-check-input" />
</div>
</div>
</div>
<div class="form-group row">
@ -52,6 +59,9 @@ export default class CodeBlockOptions extends OptionsWidget {
await server.put(`options/codeBlockTheme/${newTheme}`);
});
this.$wordWrap = this.$widget.find(".word-wrap");
this.$wordWrap.on("change", () => this.updateCheckboxOption("codeBlockWordWrap", this.$wordWrap));
// Set up preview
const sampleEl = this.$widget.find(".code-sample");
library_loader
@ -74,5 +84,6 @@ export default class CodeBlockOptions extends OptionsWidget {
.text(theme.title));
}
this.$themeSelect.val(options.codeBlockTheme);
this.setCheckboxState(this.$wordWrap, options.codeBlockWordWrap);
}
}

View File

@ -17,6 +17,7 @@ const ALLOWED_OPTIONS = new Set([
'zoomFactor',
'theme',
'codeBlockTheme',
"codeBlockWordWrap",
'syncServerHost',
'syncServerTimeout',
'syncProxy',

View File

@ -100,7 +100,9 @@ const defaultOptions: DefaultOption[] = [
// Internationalization
{ name: 'locale', value: 'en', isSynced: true },
{ name: 'firstDayOfWeek', value: '1', isSynced: true }
{ name: 'firstDayOfWeek', value: '1', isSynced: true },
{ name: "codeBlockWordWrap", value: "false", isSynced: true }
];
function initStartupOptions() {