Files
dify/web/app/components/workflow/nodes/trigger-webhook/components/paragraph-input.tsx
Yeuoly b76e17b25d feat: introduce trigger functionality (#27644)
Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: Stream <Stream_2@qq.com>
Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: zhsama <torvalds@linux.do>
Co-authored-by: Harry <xh001x@hotmail.com>
Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com>
Co-authored-by: yessenia <yessenia.contact@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: WTW0313 <twwu@dify.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-12 17:59:37 +08:00

58 lines
1.7 KiB
TypeScript

'use client'
import type { FC } from 'react'
import React, { useRef } from 'react'
import cn from '@/utils/classnames'
type ParagraphInputProps = {
value: string
onChange: (value: string) => void
placeholder?: string
disabled?: boolean
className?: string
}
const ParagraphInput: FC<ParagraphInputProps> = ({
value,
onChange,
placeholder,
disabled = false,
className,
}) => {
const textareaRef = useRef<HTMLTextAreaElement>(null)
const lines = value ? value.split('\n') : ['']
const lineCount = Math.max(3, lines.length)
return (
<div className={cn('rounded-xl bg-components-input-bg-normal px-3 pb-2 pt-3', className)}>
<div className="relative">
<div className="pointer-events-none absolute left-0 top-0 flex flex-col">
{Array.from({ length: lineCount }, (_, index) => (
<span
key={index}
className="flex h-[20px] select-none items-center font-mono text-xs leading-[20px] text-text-quaternary"
>
{String(index + 1).padStart(2, '0')}
</span>
))}
</div>
<textarea
ref={textareaRef}
value={value}
onChange={e => onChange(e.target.value)}
placeholder={placeholder}
disabled={disabled}
className="w-full resize-none border-0 bg-transparent pl-6 font-mono text-xs leading-[20px] text-text-secondary outline-none placeholder:text-text-quaternary"
style={{
minHeight: `${Math.max(3, lineCount) * 20}px`,
lineHeight: '20px',
}}
rows={Math.max(3, lineCount)}
/>
</div>
</div>
)
}
export default React.memo(ParagraphInput)