import {
Box,
Button,
Flex,
Textarea,
ModalFooter,
HStack,
Icon,
ModalBody
} from '@chakra-ui/react';
import MyIcon from '../../Icon/index';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'next-i18next';
import MyModal from '../../MyModal';
const CustomLightTip = () => {
const { t } = useTranslation();
return (
{t('common:core.app.QG.Custom prompt tip1')}
{t('common:core.app.QG.Custom prompt tip2')}
{t('common:core.app.QG.Custom prompt tip3')}
);
};
const FixBox = ({ children }: { children: React.ReactNode }) => {
return (
{children}
);
};
const CustomPromptEditor = ({
defaultValue = '',
defaultPrompt,
footerPrompt,
onChange,
onClose
}: {
defaultValue?: string;
defaultPrompt: string;
footerPrompt?: string;
onChange: (e: string) => void;
onClose: () => void;
}) => {
const ref = useRef(null);
const { t } = useTranslation();
const [value, setValue] = useState(defaultValue || defaultPrompt);
const adjustHeight = useCallback(() => {
const textarea = ref.current;
if (!textarea) return;
textarea.style.height = '22px';
textarea.style.height = `${textarea.scrollHeight}px`;
}, []);
useEffect(() => {
adjustHeight();
const timer = setTimeout(adjustHeight, 0);
return () => clearTimeout(timer);
}, [value, adjustHeight]);
return (
{t('common:core.ai.Prompt')}
}
px={2}
onClick={() => setValue(defaultPrompt)}
>
{t('common:common.Reset')}
);
};
export default CustomPromptEditor;