diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx index 1ba91a0f6..6d6c5f4f3 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatInput.tsx @@ -74,11 +74,9 @@ export const ChatInput = memo(({ onSend, variant, ref: forwardedRef }: ChatInput const handleEditorChange = useCallback((editorState: EditorState, editor: LexicalEditor) => { setCurrentEditor(editor) - // Update isEmpty state based on editor content + editorState.read(() => { - const root = $getRoot() - const textContent = root.getTextContent().trim() - setIsEmpty(textContent === "") + setIsEmpty($getRoot().isEmpty()) }) }, []) diff --git a/packages/internal/components/src/ui/input/TextAreaWrapper.tsx b/packages/internal/components/src/ui/input/TextAreaWrapper.tsx index 5c78a6e17..a3989dc3d 100644 --- a/packages/internal/components/src/ui/input/TextAreaWrapper.tsx +++ b/packages/internal/components/src/ui/input/TextAreaWrapper.tsx @@ -1,6 +1,5 @@ import { cn } from "@follow/utils" import clsx from "clsx" -import { useMotionValue } from "motion/react" import type { PropsWithChildren } from "react" import { useCallback, useState } from "react" @@ -72,18 +71,6 @@ export const TextAreaWrapper = ({ const [internalIsFocused, setInternalIsFocused] = useState(false) const isFocused = externalIsFocused ?? internalIsFocused - const mouseX = useMotionValue(0) - const mouseY = useMotionValue(0) - - const handleMouseMove = useCallback( - ({ clientX, clientY, currentTarget }: React.MouseEvent) => { - const bounds = currentTarget.getBoundingClientRect() - mouseX.set(clientX - bounds.left) - mouseY.set(clientY - bounds.top) - }, - [mouseX, mouseY], - ) - const handleFocus = useCallback(() => { if (externalIsFocused === undefined) { setInternalIsFocused(true) @@ -115,7 +102,6 @@ export const TextAreaWrapper = ({ paddingClassName, wrapperClassName, )} - onMouseMove={handleMouseMove} onFocus={handleFocus} onBlur={handleBlur} onPointerDown={onPointerDown} diff --git a/packages/internal/components/src/ui/lexical-rich-editor/LexicalRichEditor.tsx b/packages/internal/components/src/ui/lexical-rich-editor/LexicalRichEditor.tsx index f779f6557..28142e430 100644 --- a/packages/internal/components/src/ui/lexical-rich-editor/LexicalRichEditor.tsx +++ b/packages/internal/components/src/ui/lexical-rich-editor/LexicalRichEditor.tsx @@ -75,12 +75,7 @@ export const LexicalRichEditor = function LexicalRichEditor({ root.clear() }) }, - isEmpty: () => - editorRef?.getEditorState().read(() => { - const root = $getRoot() - const textContent = root.getTextContent().trim() - return textContent === "" - }) || false, + isEmpty: () => editorRef?.getEditorState().read(() => $getRoot().isEmpty()) || false, })) return (