Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(options): seamless transition when switching CK toolbar
Elian Doran9d585913be43
diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.tsx b/apps/client/src/widgets/type_widgets/options/text_notes.tsxindex f5660db3e2..8074e34bde 100644--- a/apps/client/src/widgets/type_widgets/options/text_notes.tsx+++ b/apps/client/src/widgets/type_widgets/options/text_notes.tsx@@ -46,8 +46,8 @@ export default function TextNoteSettings() {}function FormattingToolbar() {- const [ textNoteEditorType, setTextNoteEditorType ] = useTriliumOption("textNoteEditorType", true);- const [ textNoteEditorMultilineToolbar, setTextNoteEditorMultilineToolbar ] = useTriliumOptionBool("textNoteEditorMultilineToolbar", true);+ const [ textNoteEditorType, setTextNoteEditorType ] = useTriliumOption("textNoteEditorType");+ const [ textNoteEditorMultilineToolbar, setTextNoteEditorMultilineToolbar ] = useTriliumOptionBool("textNoteEditorMultilineToolbar");return (<OptionsSection title={t("editing.editor_type.label")}>diff --git a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsxindex 2ed4935d7d..d575633392 100644--- a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx+++ b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx@@ -5,7 +5,7 @@ import { HTMLProps, RefObject, useEffect, useImperativeHandle, useRef, useStateimport froca from "../../../services/froca";import link from "../../../services/link";import linkEmbedService, { type EmbedMetadata } from "../../../services/link_embed";-import { useKeyboardShortcuts, useLegacyImperativeHandlers, useNoteContext, useSyncedRef, useTriliumOption } from "../../react/hooks";+import { useKeyboardShortcuts, useLegacyImperativeHandlers, useNoteContext, useSyncedRef, useTriliumOption, useTriliumOptionBool } from "../../react/hooks";import { buildConfig, BuildEditorOptions } from "./config";export type BoxSize = "small" | "medium" | "full" | "expandable";@@ -42,6 +42,9 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerReconst containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);const watchdogRef = useRef<EditorWatchdog>(null);const [ uiLanguage ] = useTriliumOption("locale");+ // Read purely as a rebuild trigger: the value is consumed by buildToolbarConfig() via options.get() at+ // editor-creation time, so the editor must be recreated when it changes.+ const [ multilineToolbar ] = useTriliumOptionBool("textNoteEditorMultilineToolbar");const [ editor, setEditor ] = useState<CKTextEditor>();const { parentComponent, ntxId } = useNoteContext();@@ -260,7 +263,7 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRereturn () => {isStale = true;};- }, [ contentLanguage, templates, uiLanguage ]);+ }, [ contentLanguage, templates, uiLanguage, isClassicEditor, multilineToolbar ]);// React to notification warning callback.