From cd84e6ba0827f7f6965f82aa5ba5e6e912f80ac4 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 14 Apr 2026 23:10:57 +0300 Subject: [PATCH] fix(text): tab width is reset when component is re-rendered --- .../src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx | 6 +++--- apps/client/src/widgets/type_widgets/text/EditableText.tsx | 5 ++++- apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx index 40fd8f55f6..dd4d9d02c9 100644 --- a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx +++ b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx @@ -20,7 +20,7 @@ export interface CKEditorApi { addImage(noteId: string): Promise; } -interface CKEditorWithWatchdogProps extends Pick, "className" | "tabIndex" | "style"> { +interface CKEditorWithWatchdogProps extends Pick, "className" | "tabIndex"> { contentLanguage: string | null | undefined; isClassicEditor?: boolean; watchdogRef: RefObject; @@ -35,7 +35,7 @@ interface CKEditorWithWatchdogProps extends Pick, "cla containerRef?: RefObject; } -export default function CKEditorWithWatchdog({ containerRef: externalContainerRef, contentLanguage, className, style, tabIndex, isClassicEditor, watchdogRef: externalWatchdogRef, watchdogConfig, onNotificationWarning, onWatchdogStateChange, onChange, onEditorInitialized, editorApi, templates }: CKEditorWithWatchdogProps) { +export default function CKEditorWithWatchdog({ containerRef: externalContainerRef, contentLanguage, className, tabIndex, isClassicEditor, watchdogRef: externalWatchdogRef, watchdogConfig, onNotificationWarning, onWatchdogStateChange, onChange, onEditorInitialized, editorApi, templates }: CKEditorWithWatchdogProps) { const containerRef = useSyncedRef(externalContainerRef, null); const watchdogRef = useRef(null); const [ uiLanguage ] = useTriliumOption("locale"); @@ -232,7 +232,7 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRe }, [ editor, onChange ]); return ( -
+
); } diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsx index e7cb326553..2caf37c661 100644 --- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx +++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx @@ -220,12 +220,15 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext const onWatchdogStateChange = useWatchdogCrashHandling(); + useEffect(() => { + document.body.style.setProperty("--code-block-tab-width", codeBlockTabWidth ?? "4"); + }, [codeBlockTabWidth]); + return ( <> {note && !!templates && { + document.body.style.setProperty("--code-block-tab-width", codeBlockTabWidth ?? "4"); + }, [codeBlockTabWidth]); + // Apply necessary transforms. useEffect(() => { const container = contentRef.current; @@ -60,7 +64,6 @@ export default function ReadOnlyText({ note, noteContext, ntxId }: TypeWidgetPro