import React, { useCallback, useEffect, useRef } from 'react' import { useAtom } from 'jotai' import { X } from 'lucide-react' import { selectedTextAtom } from '@/containers/Providers/Jotai' const SelectedText = ({ onCleared }: { onCleared?: () => void }) => { const [text, setText] = useAtom(selectedTextAtom) const containerRef = useRef(null) useEffect(() => { if (text.trim().length === 0) { window.core?.api?.quickAskSizeUpdated(0) } else { window.core?.api?.quickAskSizeUpdated( (containerRef.current?.offsetHeight ?? 0) + 14 ) } }) const onClearClicked = useCallback(() => { setText('') onCleared?.() }, [setText, onCleared]) const shouldShowSelectedText = text.trim().length > 0 return shouldShowSelectedText ? (

{text}

) : (
) } export default SelectedText