re-add initialText prop to InlineMentionEditor

This commit is contained in:
CREDO23 2026-03-24 19:26:13 +02:00
parent 71a262b2e7
commit f9be80ab76

View file

@ -47,6 +47,7 @@ interface InlineMentionEditorProps {
disabled?: boolean; disabled?: boolean;
className?: string; className?: string;
initialDocuments?: MentionedDocument[]; initialDocuments?: MentionedDocument[];
initialText?: string;
} }
// Unique data attribute to identify chip elements // Unique data attribute to identify chip elements
@ -96,6 +97,7 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
disabled = false, disabled = false,
className, className,
initialDocuments = [], initialDocuments = [],
initialText,
}, },
ref ref
) => { ) => {
@ -115,6 +117,13 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
} }
}, [initialDocuments]); }, [initialDocuments]);
useEffect(() => {
if (!initialText || !editorRef.current) return;
editorRef.current.textContent = initialText;
setIsEmpty(false);
onChange?.(initialText, Array.from(mentionedDocs.values()));
}, [initialText]); // eslint-disable-line react-hooks/exhaustive-deps
// Focus at the end of the editor // Focus at the end of the editor
const focusAtEnd = useCallback(() => { const focusAtEnd = useCallback(() => {
if (!editorRef.current) return; if (!editorRef.current) return;