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;
- }
diff --git a/src/public/app/widgets/dialogs/options/advanced.js b/src/public/app/widgets/dialogs/options/advanced.js
index 84c224fe8..769e52e7b 100644
--- a/src/public/app/widgets/dialogs/options/advanced.js
+++ b/src/public/app/widgets/dialogs/options/advanced.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 = `
@@ -51,7 +51,7 @@ const TPL = `
`;
-export default class AdvancedOptions extends OptionsTab {
+export default class AdvancedOptions extends OptionsWidget {
get tabTitle() { return "Advanced" }
lazyRender() {
diff --git a/src/public/app/widgets/dialogs/options/appearance.js b/src/public/app/widgets/dialogs/options/appearance.js
index 65deeaa31..bb7a0110c 100644
--- a/src/public/app/widgets/dialogs/options/appearance.js
+++ b/src/public/app/widgets/dialogs/options/appearance.js
@@ -1,7 +1,7 @@
import server from "../../../services/server.js";
import utils from "../../../services/utils.js";
import appContext from "../../../components/app_context.js";
-import OptionsTab from "./options_tab.js";
+import OptionsWidget from "../../type_widgets/options/appearance/options_widget.js";
const FONT_FAMILIES = [
{ value: "theme", label: "Theme defined" },
@@ -188,7 +188,7 @@ const TPL = `
`;
-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.
-
-
-
-
-
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($("")
+ .attr("value", theme.val)
+ .attr("data-note-id", theme.noteId)
+ .text(theme.title));
+ }
+
+ this.$themeSelect.val(options.theme);
+
+ this.setCheckboxState(this.$overrideThemeFonts, options.overrideThemeFonts);
+ }
+}
diff --git a/src/public/app/widgets/type_widgets/options/appearance/zoom_factor.js b/src/public/app/widgets/type_widgets/options/appearance/zoom_factor.js
new file mode 100644
index 000000000..d215aa916
--- /dev/null
+++ b/src/public/app/widgets/type_widgets/options/appearance/zoom_factor.js
@@ -0,0 +1,27 @@
+import appContext from "../../../../components/app_context.js";
+import OptionsWidget from "./options_widget.js";
+import utils from "../../../../services/utils.js";
+
+const TPL = `
+
+
Zoom factor (desktop build only)
+
+
+
Zooming can be controlled with CTRL+- and CTRL+= shortcuts as well.
+
`;
+
+export default class ZoomFactorOptions extends OptionsWidget {
+ isEnabled() {
+ return super.isEnabled() && utils.isElectron();
+ }
+
+ doRender() {
+ this.$widget = $(TPL);
+ this.$zoomFactorSelect = this.$widget.find(".zoom-factor-select");
+ this.$zoomFactorSelect.on('change', () => { appContext.triggerCommand('setZoomFactorAndSave', {zoomFactor: this.$zoomFactorSelect.val()}); });
+ }
+
+ async optionsLoaded(options) {
+ this.$zoomFactorSelect.val(options.zoomFactor);
+ }
+}
diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css
index 755fd61f3..911107e23 100644
--- a/src/public/stylesheets/style.css
+++ b/src/public/stylesheets/style.css
@@ -967,3 +967,17 @@ button.close:hover {
top: 1px;
margin-right: 3px;
}
+
+.options-section:first-of-type h4 {
+ margin-top: 0;
+}
+
+.options-section h4 {
+ margin-top: 15px;
+ margin-bottom: 15px;
+}
+
+.options-section h5 {
+ margin-top: 10px;
+ margin-bottom: 10px;
+}
diff --git a/src/services/special_notes.js b/src/services/special_notes.js
index 5f23a3aff..e7cad07a3 100644
--- a/src/services/special_notes.js
+++ b/src/services/special_notes.js
@@ -575,6 +575,17 @@ function createLauncherTemplates() {
const OPTIONS_ROOT = "opt_root";
const OPTIONS_APPEARANCE = "opt_appearance";
+const OPTIONS_ADVANCED = "opt_advanced";
+const OPTIONS_BACKUP = "opt_backup";
+const OPTIONS_CODE_NOTES = "opt_code_notes";
+const OPTIONS_ETAPI = "opt_etapi";
+const OPTIONS_IMAGES = "opt_images";
+const OPTIONS_OTHER = "opt_other";
+const OPTIONS_PASSWORD = "opt_password";
+const OPTIONS_SHORTCUTS = "opt_shortcuts";
+const OPTIONS_SPELLCHECK = "opt_spellcheck";
+const OPTIONS_SYNC = "opt_sync";
+const OPTIONS_TEXT_NOTES = "opt_textnotes";
function createOptionNotes() {
if (!(OPTIONS_ROOT in becca.notes)) {