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> <label>${t("highlighting.color-scheme")}</label>
<select class="theme-select form-select"></select> <select class="theme-select form-select"></select>
</div> </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>
<div class="form-group row"> <div class="form-group row">
@ -51,6 +58,9 @@ export default class CodeBlockOptions extends OptionsWidget {
library_loader.loadHighlightingTheme(newTheme); library_loader.loadHighlightingTheme(newTheme);
await server.put(`options/codeBlockTheme/${newTheme}`); 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 // Set up preview
const sampleEl = this.$widget.find(".code-sample"); const sampleEl = this.$widget.find(".code-sample");
@ -74,5 +84,6 @@ export default class CodeBlockOptions extends OptionsWidget {
.text(theme.title)); .text(theme.title));
} }
this.$themeSelect.val(options.codeBlockTheme); this.$themeSelect.val(options.codeBlockTheme);
this.setCheckboxState(this.$wordWrap, options.codeBlockWordWrap);
} }
} }

View File

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

View File

@ -100,7 +100,9 @@ const defaultOptions: DefaultOption[] = [
// Internationalization // Internationalization
{ name: 'locale', value: 'en', isSynced: true }, { 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() { function initStartupOptions() {