@ -3,7 +3,6 @@
import { useCallback , useRef } from "react" ;
import { Handle , Position , NodeProps , Node } from "@xyflow/react" ;
import { BaseNode } from "./BaseNode" ;
import { useCommentNavigation } from "@/hooks/useCommentNavigation" ;
import { useAnnotationStore } from "@/store/annotationStore" ;
import { useWorkflowStore } from "@/store/workflowStore" ;
import { AnnotationNodeData } from "@/types" ;
@ -12,7 +11,6 @@ type AnnotationNodeType = Node<AnnotationNodeData, "annotation">;
export function AnnotationNode ( { id , data , selected } : NodeProps < AnnotationNodeType > ) {
const nodeData = data ;
const commentNavigation = useCommentNavigation ( id ) ;
const openModal = useAnnotationStore ( ( state ) = > state . openModal ) ;
const updateNodeData = useWorkflowStore ( ( state ) = > state . updateNodeData ) ;
const fileInputRef = useRef < HTMLInputElement > ( null ) ;
@ -95,13 +93,8 @@ export function AnnotationNode({ id, data, selected }: NodeProps<AnnotationNodeT
return (
< BaseNode
id = { id }
title = "Annotate"
customTitle = { nodeData . customTitle }
comment = { nodeData . comment }
onCustomTitleChange = { ( title ) = > updateNodeData ( id , { customTitle : title || undefined } ) }
onCommentChange = { ( comment ) = > updateNodeData ( id , { comment : comment || undefined } ) }
selected = { selected }
commentNavigation = { commentNavigation ? ? undefined }
contentClassName = "flex-1 min-h-0 overflow-clip"
>
< input
ref = { fileInputRef }
@ -126,27 +119,27 @@ export function AnnotationNode({ id, data, selected }: NodeProps<AnnotationNodeT
{ displayImage ? (
< div
className = "relative group cursor-pointer flex-1 flex flex-col min-h-0 "
className = "relative group cursor-pointer w-full h-full "
onClick = { handleEdit }
>
< img
src = { displayImage }
alt = "Annotated"
className = "w-full flex-1 min-h-0 object-contain rounded "
className = "w-full h-full object-cover "
/ >
< button
onClick = { ( e ) = > {
e . stopPropagation ( ) ;
handleRemove ( ) ;
} }
className = "absolute top-1 right-1 w-5 h-5 bg-black/6 0 text-white rounded text-xs opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"
className = "absolute top-2 right-2 w-6 h-6 bg-black/60 hover:bg-black/8 0 text-white rounded text-xs opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"
>
< svg className = "w-3 h-3 " fill = "none" viewBox = "0 0 24 24" stroke = "currentColor" strokeWidth = { 2 } >
< svg className = "w-4 h-4 " fill = "none" viewBox = "0 0 24 24" stroke = "currentColor" strokeWidth = { 2 } >
< path strokeLinecap = "round" strokeLinejoin = "round" d = "M6 18L18 6M6 6l12 12" / >
< / svg >
< / button >
< div className = "absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors rounded flex items-center justify-center pointer-events-none" >
< span className = "text-[10px] font-medium text-white opacity-0 group-hover:opacity-100 transition-opacity bg-black/50 px-2 py-1 rounded" >
< div className = "absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors flex items-center justify-center pointer-events-none" >
< span className = "text-xs font-medium text-white opacity-0 group-hover:opacity-100 transition-opacity bg-black/60 px-3 py-1.5 rounded" >
{ nodeData . annotations . length > 0 ? ` Edit ( ${ nodeData . annotations . length } ) ` : "Add annotations" }
< / span >
< / div >
@ -156,12 +149,12 @@ export function AnnotationNode({ id, data, selected }: NodeProps<AnnotationNodeT
onClick = { ( ) = > fileInputRef . current ? . click ( ) }
onDrop = { handleDrop }
onDragOver = { handleDragOver }
className = "w-full flex-1 min-h-[112px] border border-dashed border-neutral-600 rounded flex flex-col items-center justify-center cursor-pointer hover:border-neutral-500 hover:bg-neutral-700/5 0 transition-colors"
className = "w-full h-full bg-neutral-900/40 flex flex-col items-center justify-center cursor-pointer hover:bg-neutral-800/6 0 transition-colors"
>
< svg className = "w-5 h-5 text-neutral-5 00" fill = "none" viewBox = "0 0 24 24" stroke = "currentColor" strokeWidth = { 1.5 } >
< svg className = "w-8 h-8 text-neutral-6 00" fill = "none" viewBox = "0 0 24 24" stroke = "currentColor" strokeWidth = { 1.5 } >
< path strokeLinecap = "round" strokeLinejoin = "round" d = "M12 4.5v15m7.5-7.5h-15" / >
< / svg >
< span className = "text-[10px] text-neutral-400 mt-1 " >
< span className = "text-xs text-neutral-500 mt-2 " >
Drop , click , or connect
< / span >
< / div >