feat: input var ui

This commit is contained in:
Joel
2024-03-29 16:19:00 +08:00
parent b50e897aa0
commit 950a52f4fc
6 changed files with 20 additions and 17 deletions

View File

@ -61,6 +61,7 @@ import { useEventEmitterContextContext } from '@/context/event-emitter'
export type PromptEditorProps = {
className?: string
placeholder?: string
placeholderClassName?: string
style?: React.CSSProperties
value?: string
editable?: boolean
@ -78,6 +79,7 @@ export type PromptEditorProps = {
const PromptEditor: FC<PromptEditorProps> = ({
className,
placeholder,
placeholderClassName,
style,
value,
editable = true,
@ -136,7 +138,7 @@ const PromptEditor: FC<PromptEditorProps> = ({
<div className='relative'>
<RichTextPlugin
contentEditable={<ContentEditable className={`${className} outline-none text-sm text-gray-700 leading-6`} style={style || {}} />}
placeholder={<Placeholder value={placeholder} />}
placeholder={<Placeholder value={placeholder} className={placeholderClassName} />}
ErrorBoundary={LexicalErrorBoundary}
/>
<ComponentPickerBlock

View File

@ -1,14 +1,17 @@
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
const Placeholder = ({
value,
className,
}: {
value?: string
className?: string
}) => {
const { t } = useTranslation()
return (
<div className='absolute top-0 left-0 h-full w-full text-sm text-gray-300 select-none pointer-events-none leading-6'>
<div className={cn(className, 'absolute top-0 left-0 h-full w-full text-sm text-gray-300 select-none pointer-events-none leading-6')}>
{value || t('common.promptEditor.placeholder')}
</div>
)