mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-29 22:56:36 +08:00
### What problem does this PR solve? Feat: Add TagFeatureItem #4368 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -7,11 +7,11 @@ import React, { useEffect, useRef, useState } from 'react';
|
||||
import styles from './index.less';
|
||||
|
||||
interface EditTagsProps {
|
||||
tags?: string[];
|
||||
setTags?: (tags: string[]) => void;
|
||||
value?: string[];
|
||||
onChange?: (tags: string[]) => void;
|
||||
}
|
||||
|
||||
const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
||||
const EditTag = ({ value = [], onChange }: EditTagsProps) => {
|
||||
const { token } = theme.useToken();
|
||||
const [inputVisible, setInputVisible] = useState(false);
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
@ -24,8 +24,8 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
||||
}, [inputVisible]);
|
||||
|
||||
const handleClose = (removedTag: string) => {
|
||||
const newTags = tags?.filter((tag) => tag !== removedTag);
|
||||
setTags?.(newTags ?? []);
|
||||
const newTags = value?.filter((tag) => tag !== removedTag);
|
||||
onChange?.(newTags ?? []);
|
||||
};
|
||||
|
||||
const showInput = () => {
|
||||
@ -37,12 +37,12 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
||||
};
|
||||
|
||||
const handleInputConfirm = () => {
|
||||
if (inputValue && tags) {
|
||||
if (inputValue && value) {
|
||||
const newTags = inputValue
|
||||
.split(';')
|
||||
.map((tag) => tag.trim())
|
||||
.filter((tag) => tag && !tags.includes(tag));
|
||||
setTags?.([...tags, ...newTags]);
|
||||
.filter((tag) => tag && !value.includes(tag));
|
||||
onChange?.([...value, ...newTags]);
|
||||
}
|
||||
setInputVisible(false);
|
||||
setInputValue('');
|
||||
@ -64,7 +64,7 @@ const EditTag = ({ tags, setTags }: EditTagsProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
const tagChild = tags?.map(forMap);
|
||||
const tagChild = value?.map(forMap);
|
||||
|
||||
const tagPlusStyle: React.CSSProperties = {
|
||||
background: token.colorBgContainer,
|
||||
|
||||
@ -18,8 +18,6 @@ const EntityTypesItem = () => {
|
||||
label={t('entityTypes')}
|
||||
rules={[{ required: true }]}
|
||||
initialValue={initialEntityTypes}
|
||||
valuePropName="tags"
|
||||
trigger="setTags"
|
||||
>
|
||||
<EditTag></EditTag>
|
||||
</Form.Item>
|
||||
|
||||
Reference in New Issue
Block a user