From d04897e011b8e75f8d651f63d1ac413bb24d8baf Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 14 Aug 2025 22:05:45 +0300 Subject: [PATCH] feat(react/settings): port related settings --- .../src/translations/en/translation.json | 7 ++ .../type_widgets/options/appearance.tsx | 11 +++ .../options/appearance/related_settings.ts | 71 ------------------- .../options/components/RelatedSettings.tsx | 24 +++++++ 4 files changed, 42 insertions(+), 71 deletions(-) delete mode 100644 apps/client/src/widgets/type_widgets/options/appearance/related_settings.ts create mode 100644 apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 37b8436f5..645b13e35 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -2000,5 +2000,12 @@ "background_effects_title": "Background effects are now stable", "background_effects_message": "On Windows devices, background effects are now fully stable. The background effects adds a touch of color to the user interface by blurring the background behind it. This technique is also used in other applications such as Windows Explorer.", "background_effects_button": "Enable background effects" + }, + "settings": { + "related_settings": "Related settings" + }, + "settings_appearance": { + "related_code_blocks": "Color scheme for code blocks in text notes", + "related_code_notes": "Color scheme for code notes" } } diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx index b63628569..59e08f444 100644 --- a/apps/client/src/widgets/type_widgets/options/appearance.tsx +++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx @@ -13,6 +13,7 @@ import { FontFamily, OptionNames } from "@triliumnext/commons"; import FormTextBox, { FormTextBoxWithUnit } from "../../react/FormTextBox"; import FormText from "../../react/FormText"; import Button from "../../react/Button"; +import RelatedSettings from "./components/RelatedSettings"; const MIN_CONTENT_WIDTH = 640; @@ -88,6 +89,16 @@ export default function AppearanceSettings() { {overrideThemeFonts === "true" && } {isElectron() && } + ) } diff --git a/apps/client/src/widgets/type_widgets/options/appearance/related_settings.ts b/apps/client/src/widgets/type_widgets/options/appearance/related_settings.ts deleted file mode 100644 index e05f3d0d2..000000000 --- a/apps/client/src/widgets/type_widgets/options/appearance/related_settings.ts +++ /dev/null @@ -1,71 +0,0 @@ -import type { OptionPages } from "../../content_widget"; -import OptionsWidget from "../options_widget"; - -const TPL = `\ -
-

Related settings

- - - - -
-`; - -interface RelatedSettingsConfig { - items: { - title: string; - targetPage: OptionPages; - }[]; -} - -const RELATED_SETTINGS: Record = { - "_optionsAppearance": { - items: [ - { - title: "Color scheme for code blocks in text notes", - targetPage: "_optionsTextNotes" - }, - { - title: "Color scheme for code notes", - targetPage: "_optionsCodeNotes" - } - ] - } -}; - -export default class RelatedSettings extends OptionsWidget { - - doRender() { - this.$widget = $(TPL); - - const config = this.noteId && RELATED_SETTINGS[this.noteId]; - if (!config) { - return; - } - - const $relatedSettings = this.$widget.find(".related-settings"); - $relatedSettings.empty(); - for (const item of config.items) { - const $item = $("
  • "); - const $link = $("").text(item.title); - - $item.append($link); - $link.attr("href", `#root/_hidden/_options/${item.targetPage}`); - $relatedSettings.append($item); - } - } - - isEnabled() { - return (!!this.noteId && this.noteId in RELATED_SETTINGS); - } - -} diff --git a/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx b/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx new file mode 100644 index 000000000..9ba1b1064 --- /dev/null +++ b/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx @@ -0,0 +1,24 @@ +import OptionsSection from "./OptionsSection"; +import type { OptionPages } from "../../content_widget"; +import { t } from "../../../../services/i18n"; + +interface RelatedSettingsProps { + items: { + title: string; + targetPage: OptionPages; + }[]; +} + +export default function RelatedSettings({ items }: RelatedSettingsProps) { + return ( + + + + ); +} \ No newline at end of file