mirror of
https://github.com/zadam/trilium.git
synced 2025-11-26 02:24:23 +01:00
fix(text): note with empty table carries over to new notes
This commit is contained in:
parent
9b3ca65492
commit
6040eea3bd
@ -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>, "cla
|
||||
containerRef?: 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: externalContainerRe
|
||||
return () => 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;
|
||||
|
||||
@ -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, noteContext
|
||||
containerRef={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 });
|
||||
}}
|
||||
/>}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user