diff --git a/knip.jsonc b/knip.jsonc index 9b24f0888..b26f5336e 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -29,7 +29,6 @@ "src/chat/preferences.functions.ts", "src/chat/server/semantic-history.ts", "src/chat/skill-identifiers.ts", - "src/components/BlockWithFeedback.tsx", "src/components/BlogAuthorFilter.tsx", "src/components/BlogSearchFilter.tsx", "src/components/BottomCTA.tsx", diff --git a/src/components/BlockWithFeedback.tsx b/src/components/BlockWithFeedback.tsx deleted file mode 100644 index b8d84a29c..000000000 --- a/src/components/BlockWithFeedback.tsx +++ /dev/null @@ -1,120 +0,0 @@ -import * as React from 'react' -import { twMerge } from 'tailwind-merge' -import { DocFeedbackFloatingButton } from './DocFeedbackFloatingButton' -import { DocFeedbackNote } from './DocFeedbackNote' -import { useDocFeedbackRequired } from './DocFeedbackContext' -import { getBlockIdentifier } from '~/utils/docFeedback' - -interface BlockWithFeedbackProps { - children: React.ReactNode - className?: string -} - -export function BlockWithFeedback({ - children, - className, -}: BlockWithFeedbackProps) { - const blockRef = React.useRef(null) - const [isHovered, setIsHovered] = React.useState(false) - const [blockSelector, setBlockSelector] = React.useState(null) - const [contentHash, setContentHash] = React.useState() - - const feedback = useDocFeedbackRequired() - - // Generate block selector on mount - React.useEffect(() => { - if (blockRef.current) { - // Get the first child element (the actual content block, not our wrapper) - const contentElement = blockRef.current.firstElementChild as HTMLElement - if (contentElement) { - getBlockIdentifier(contentElement).then((identifier) => { - setBlockSelector(identifier.selector) - setContentHash(identifier.contentHash) - }) - } - } - }, []) - - // Find note for this block - const note = React.useMemo(() => { - if (!blockSelector) return null - return feedback.userNotes.find((n) => n.blockSelector === blockSelector) - }, [feedback.userNotes, blockSelector]) - - const hasNote = !!note - - const handleAddNote = React.useCallback(() => { - if (blockSelector) { - feedback.onAddFeedback(blockSelector, contentHash, 'note') - } - }, [blockSelector, contentHash, feedback]) - - const handleAddFeedback = React.useCallback(() => { - if (blockSelector) { - feedback.onAddFeedback(blockSelector, contentHash, 'improvement') - } - }, [blockSelector, contentHash, feedback]) - - const handleShowNote = React.useCallback(() => { - if (note) { - feedback.onShowNote(note.id) - } - }, [note, feedback]) - - const handleMouseEnter = React.useCallback(() => { - setIsHovered(true) - }, []) - - const handleMouseLeave = React.useCallback(() => { - setIsHovered(false) - }, []) - - return ( - <> -
- {children} - - {/* Floating button */} - {blockSelector && ( -
- -
- )} -
- - {/* Note display - inline in document flow */} - {note && blockSelector && ( -
- -
- )} - - ) -}