diff --git a/app/w/components/workflow-block/components/sub-block/components/long-input.tsx b/app/w/components/workflow-block/components/sub-block/components/long-input.tsx index 60ed7c785..385b256a5 100644 --- a/app/w/components/workflow-block/components/sub-block/components/long-input.tsx +++ b/app/w/components/workflow-block/components/sub-block/components/long-input.tsx @@ -1,26 +1,107 @@ import { Textarea } from '@/components/ui/textarea' import { useSubBlockValue } from '../hooks/use-sub-block-value' +import { cn } from '@/lib/utils' +import { useState, useRef, useEffect } from 'react' interface LongInputProps { placeholder?: string blockId: string subBlockId: string + isConnecting: boolean } export function LongInput({ placeholder, blockId, subBlockId, + isConnecting, }: LongInputProps) { const [value, setValue] = useSubBlockValue(blockId, subBlockId) + const textareaRef = useRef(null) + const overlayRef = useRef(null) + + // Sync scroll position between textarea and overlay + const handleScroll = (e: React.UIEvent) => { + if (overlayRef.current) { + overlayRef.current.scrollTop = e.currentTarget.scrollTop + overlayRef.current.scrollLeft = e.currentTarget.scrollLeft + } + } + + // Drag and Drop handlers + const handleDrop = (e: React.DragEvent) => { + e.preventDefault() + try { + const data = JSON.parse(e.dataTransfer.getData('application/json')) + + const isValidConnectionBlock = + data.type === 'connectionBlock' && + data.connectionData.sourceBlockId === blockId + + if (!isValidConnectionBlock) return + + const currentValue = value?.toString() ?? '' + const connectionName = data.connectionData.name + .replace(/\s+/g, '') + .toLowerCase() + const outputSuffix = + data.connectionData.outputType === 'any' + ? 'res' + : data.connectionData.outputType + + const newValue = `${currentValue}<${connectionName}.${outputSuffix}>` + setValue(newValue) + } catch (error) { + console.error('Failed to parse drop data:', error) + } + } + + const handleDragOver = (e: React.DragEvent) => { + e.preventDefault() + } + + const formatDisplayText = (text: string) => { + if (!text) return null + + // Split the text by tag pattern + const parts = text.split(/(<[^>]+>)/g) + + return parts.map((part, index) => { + // Check if the part matches tag pattern + if (part.match(/^<[^>]+>$/)) { + return ( + + {part} + + ) + } + return {part} + }) + } return ( -