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
fix(text): note with empty table carries over to new notes
Elian Doran6040eea3bd96
diff --git a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsxindex fd68145289..1c3a85e235 100644--- a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx+++ b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx@@ -20,7 +20,6 @@ export interface CKEditorApi {}interface CKEditorWithWatchdogProps extends Pick<HTMLProps<HTMLDivElement>, "className" | "tabIndex"> {- content: string | undefined;contentLanguage: string | null | undefined;isClassicEditor?: boolean;watchdogRef: RefObject<EditorWatchdog>;@@ -35,7 +34,7 @@ interface CKEditorWithWatchdogProps extends Pick<HTMLProps<HTMLDivElement>, "clacontainerRef?: RefObject<HTMLDivElement>;}-export default function CKEditorWithWatchdog({ containerRef: externalContainerRef, content, contentLanguage, className, 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<HTMLDivElement>(externalContainerRef, null);const watchdogRef = useRef<EditorWatchdog>(null);const [ uiLanguage ] = useTriliumOption("locale");@@ -185,9 +184,6 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRereturn () => watchdog.destroy();}, [ contentLanguage, templates, uiLanguage ]);- // React to content changes.- useEffect(() => editor?.setData(content ?? ""), [ editor, content ]);-// React to notification warning callback.useEffect(() => {if (!onNotificationWarning || !editor) return;diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsxindex 9b3915abd1..e3fa1eceee 100644--- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx+++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx@@ -27,7 +27,7 @@ import { deferred } from "@triliumnext/commons";*/export default function EditableText({ note, parentComponent, ntxId, noteContext }: TypeWidgetProps) {const containerRef = useRef<HTMLDivElement>(null);- const [ content, setContent ] = useState<string>();+ const contentRef = useRef<string>("");const watchdogRef = useRef<EditorWatchdog>(null);const editorApiRef = useRef<CKEditorApi>(null);const refreshTouchBarRef = useRef<() => void>(null);@@ -55,7 +55,8 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext};},onContentChange(newContent) {- setContent(newContent);+ contentRef.current = newContent;+ watchdogRef.current?.editor?.setData(newContent);}});const templates = useTemplates();@@ -215,7 +216,6 @@ export default function EditableText({ note, parentComponent, ntxId, noteContextcontainerRef={containerRef}className={`note-detail-editable-text-editor use-tn-links ${codeBlockWordWrap ? "word-wrap" : ""}`}tabIndex={300}- content={content}contentLanguage={language}isClassicEditor={isClassicEditor}editorApi={editorApiRef}@@ -245,6 +245,7 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext}initialized.current.resolve();+ editor.setData(contentRef.current ?? "");parentComponent?.triggerEvent("textEditorRefreshed", { ntxId, editor });}}/>}