diff --git a/src/public/app/widgets/dialogs/options.js b/src/public/app/widgets/dialogs/options.js index 4a3e82eb3..93d338693 100644 --- a/src/public/app/widgets/dialogs/options.js +++ b/src/public/app/widgets/dialogs/options.js @@ -15,20 +15,6 @@ const TPL = ` overflow-y: auto; max-height: 85vh; } - - .options-dialog .options-section:first-of-type h4 { - margin-top: 0; - } - - .options-dialog .options-section h4 { - margin-top: 15px; - margin-bottom: 15px; - } - - .options-dialog .options-section h5 { - margin-top: 10px; - margin-bottom: 10px; - } `; -export default class AppearanceOptions extends OptionsTab { +export default class AppearanceOptions extends OptionsWidget { get tabTitle() { return "Appearance" } lazyRender() { diff --git a/src/public/app/widgets/dialogs/options/backup.js b/src/public/app/widgets/dialogs/options/backup.js index d8c955ea6..128be6d0d 100644 --- a/src/public/app/widgets/dialogs/options/backup.js +++ b/src/public/app/widgets/dialogs/options/backup.js @@ -1,6 +1,6 @@ import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; -import OptionsTab from "./options_tab.js"; +import OptionsWidget from "../../type_widgets/options/appearance/options_widget.js"; const TPL = `
@@ -35,7 +35,7 @@ const TPL = `
`; -export default class BackupOptions extends OptionsTab { +export default class BackupOptions extends OptionsWidget { get tabTitle() { return "Backup" } lazyRender() { diff --git a/src/public/app/widgets/dialogs/options/code_notes.js b/src/public/app/widgets/dialogs/options/code_notes.js index d603ab396..035fcea29 100644 --- a/src/public/app/widgets/dialogs/options/code_notes.js +++ b/src/public/app/widgets/dialogs/options/code_notes.js @@ -2,7 +2,7 @@ import mimeTypesService from "../../../services/mime_types.js"; import options from "../../../services/options.js"; import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; -import OptionsTab from "./options_tab.js"; +import OptionsWidget from "../../type_widgets/options/appearance/options_widget.js"; const TPL = `
@@ -38,7 +38,7 @@ const TPL = `
`; -export default class CodeNotesOptions extends OptionsTab { +export default class CodeNotesOptions extends OptionsWidget { get tabTitle() { return "Code notes" } lazyRender() { diff --git a/src/public/app/widgets/dialogs/options/etapi.js b/src/public/app/widgets/dialogs/options/etapi.js index 0c662b467..e60c97a8f 100644 --- a/src/public/app/widgets/dialogs/options/etapi.js +++ b/src/public/app/widgets/dialogs/options/etapi.js @@ -1,7 +1,7 @@ import server from "../../../services/server.js"; import dialogService from "../../../services/dialog.js"; import toastService from "../../../services/toast.js"; -import OptionsTab from "./options_tab.js"; +import OptionsWidget from "../../type_widgets/options/appearance/options_widget.js"; const TPL = `
@@ -46,7 +46,7 @@ const TPL = ` } `; -export default class EtapiOptions extends OptionsTab { +export default class EtapiOptions extends OptionsWidget { get tabTitle() { return "ETAPI" } lazyRender() { diff --git a/src/public/app/widgets/dialogs/options/images.js b/src/public/app/widgets/dialogs/options/images.js index 993b89c89..61bb3defa 100644 --- a/src/public/app/widgets/dialogs/options/images.js +++ b/src/public/app/widgets/dialogs/options/images.js @@ -1,4 +1,4 @@ -import OptionsTab from "./options_tab.js"; +import OptionsWidget from "../../type_widgets/options/appearance/options_widget.js"; const TPL = ` -
-
-
- - - -
- -
- - - -
-
- -

Zooming can be controlled with CTRL+- and CTRL+= shortcuts as well.

-
- -
-

Theme

- -
-
- - -
- -
- - -
-
-
- -

Fonts

Main font
@@ -163,46 +113,17 @@ const TPL = `

Note that tree and detail font sizing is relative to the main font size setting.

Not all listed fonts may be available on your system.

-
- -

- To apply font changes, click on - -

- -
-

Content width

- -

Trilium by default limits max content width to improve readability for maximized screens on wide screens.

- -
-
- - -
-

- To content width changes, click on + To apply font changes, click on

-
`; -export default class AppearanceOptions extends OptionsTab { - get tabTitle() { return "Appearance" } - +export default class FontsOptions extends OptionsWidget { doRender() { this.$widget = $(TPL); - this.$zoomFactorSelect = this.$widget.find(".zoom-factor-select"); - this.$nativeTitleBarSelect = this.$widget.find(".native-title-bar-select"); - - this.$themeSelect = this.$widget.find(".theme-select"); - this.$overrideThemeFonts = this.$widget.find(".override-theme-fonts"); - - this.$overridenFontSettings = this.$widget.find(".overriden-font-settings"); - this.$mainFontSize = this.$widget.find(".main-font-size"); this.$mainFontFamily = this.$widget.find(".main-font-family"); @@ -216,87 +137,15 @@ export default class AppearanceOptions extends OptionsTab { this.$monospaceFontFamily = this.$widget.find(".monospace-font-family"); this.$widget.find(".reload-frontend-button").on("click", () => utils.reloadFrontendApp("changes from appearance options")); - - this.$body = this.$widget.find("body"); - - this.$themeSelect.on('change', async () => { - const newTheme = this.$themeSelect.val(); - - await server.put('options/theme/' + newTheme); - - utils.reloadFrontendApp("theme change"); - }); - - this.$overrideThemeFonts.on('change', async () => { - this.updateCheckboxOption('overrideThemeFonts', this.$overrideThemeFonts); - - this.$overridenFontSettings.toggle(this.$overrideThemeFonts.is(":checked")); - }); - - this.$zoomFactorSelect.on('change', () => { appContext.triggerCommand('setZoomFactorAndSave', {zoomFactor: this.$zoomFactorSelect.val()}); }); - - this.$nativeTitleBarSelect.on('change', () => { - const nativeTitleBarVisible = this.$nativeTitleBarSelect.val() === 'show' ? 'true' : 'false'; - - this.updateOption('nativeTitleBarVisible', nativeTitleBarVisible); - }); - - const optionsToSave = [ - 'mainFontFamily', 'mainFontSize', - 'treeFontFamily', 'treeFontSize', - 'detailFontFamily', 'detailFontSize', - 'monospaceFontFamily', 'monospaceFontSize' - ]; - - for (const optionName of optionsToSave) { - this['$' + optionName].on('change', () => - this.updateOption(optionName, this['$' + optionName].val())); - } - - this.$maxContentWidth = this.$widget.find(".max-content-width"); - - this.$maxContentWidth.on('change', async () => - this.updateOption('maxContentWidth', this.$maxContentWidth.val())) - } - - toggleBodyClass(prefix, value) { - for (const clazz of Array.from(this.$body[0].classList)) { // create copy to safely iterate over while removing classes - if (clazz.startsWith(prefix)) { - this.$body.removeClass(clazz); - } - } - - this.$body.addClass(prefix + value); } async optionsLoaded(options) { - if (utils.isElectron()) { - this.$zoomFactorSelect.val(options.zoomFactor); - } - else { - this.$zoomFactorSelect.prop('disabled', true); + if (options.overrideThemeFonts !== 'true') { + this.toggleInt(false); + return; } - this.$nativeTitleBarSelect.val(options.nativeTitleBarVisible === 'true' ? 'show' : 'hide'); - - const themes = [ - { val: 'light', title: 'Light' }, - { val: 'dark', title: 'Dark' } - ].concat(await server.get('options/user-themes')); - - this.$themeSelect.empty(); - - for (const theme of themes) { - this.$themeSelect.append($("