mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
feat(web): add initialText prop to InlineMentionEditor
This commit is contained in:
parent
275fa86ecd
commit
5ab534511c
1 changed files with 12 additions and 0 deletions
|
|
@ -47,6 +47,7 @@ interface InlineMentionEditorProps {
|
|||
disabled?: boolean;
|
||||
className?: string;
|
||||
initialDocuments?: MentionedDocument[];
|
||||
initialText?: string;
|
||||
}
|
||||
|
||||
// Unique data attribute to identify chip elements
|
||||
|
|
@ -96,6 +97,7 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
|
|||
disabled = false,
|
||||
className,
|
||||
initialDocuments = [],
|
||||
initialText,
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
|
|
@ -115,6 +117,16 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
|
|||
}
|
||||
}, [initialDocuments]);
|
||||
|
||||
// Seed editor with initialText on mount (e.g. clipboard content from Electron tray)
|
||||
const initialTextAppliedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (!initialText || initialTextAppliedRef.current || !editorRef.current) return;
|
||||
initialTextAppliedRef.current = true;
|
||||
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
|
||||
const focusAtEnd = useCallback(() => {
|
||||
if (!editorRef.current) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue