File size: 1,044 Bytes
f28c040
 
 
 
 
 
2bdad3e
f28c040
 
2bdad3e
f28c040
 
 
 
 
 
2bdad3e
 
 
 
 
 
 
f28c040
 
 
 
 
 
 
 
 
 
 
bec7e87
f28c040
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Form, Input } from 'antd';
import { useTranslation } from 'react-i18next';

interface IProps {
  value?: string | undefined;
  onChange?: (val: string | undefined) => void;
  maxLength?: number;
}

export const DelimiterInput = ({ value, onChange, maxLength }: IProps) => {
  const nextValue = value?.replaceAll('\n', '\\n');
  const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    const val = e.target.value;
    const nextValue = val.replaceAll('\\n', '\n');
    onChange?.(nextValue);
  };
  return (
    <Input
      value={nextValue}
      onChange={handleInputChange}
      maxLength={maxLength}
    ></Input>
  );
};

const Delimiter = () => {
  const { t } = useTranslation();

  return (
    <Form.Item
      name={['parser_config', 'delimiter']}
      label={t('knowledgeDetails.delimiter')}
      initialValue={`\\n!?;。;!?`}
      rules={[{ required: true }]}
      tooltip={t('knowledgeDetails.delimiterTip')}
    >
      <DelimiterInput />
    </Form.Item>
  );
};

export default Delimiter;