diff --git a/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx b/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx index f8d191f9e0..d7a9c98c26 100644 --- a/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx +++ b/app/w/[id]/components/workflow-block/components/sub-block/components/long-input.tsx @@ -1,9 +1,10 @@ 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' +import { useState, useRef } from 'react' import { SubBlockConfig } from '@/blocks/types' import { formatDisplayText } from '@/components/ui/formatted-text' +import { EnvVarDropdown, checkEnvVarTrigger } from '@/components/ui/env-var-dropdown' interface LongInputProps { placeholder?: string @@ -21,9 +22,23 @@ export function LongInput({ config, }: LongInputProps) { const [value, setValue] = useSubBlockValue(blockId, subBlockId) + const [showEnvVars, setShowEnvVars] = useState(false) + const [searchTerm, setSearchTerm] = useState('') + const [cursorPosition, setCursorPosition] = useState(0) const textareaRef = useRef(null) const overlayRef = useRef(null) + // Handle input changes + const handleChange = (e: React.ChangeEvent) => { + const newValue = e.target.value + const newCursorPosition = e.target.selectionStart ?? 0 + setValue(newValue) + setCursorPosition(newCursorPosition) + const { show, searchTerm } = checkEnvVarTrigger(newValue, newCursorPosition) + setShowEnvVars(show) + setSearchTerm(searchTerm) + } + // Sync scroll position between textarea and overlay const handleScroll = (e: React.UIEvent) => { if (overlayRef.current) { @@ -64,6 +79,13 @@ export function LongInput({ e.preventDefault() } + // Handle key combinations + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Escape') { + setShowEnvVars(false) + } + } + return (