diff --git a/web/src/components/image/index.tsx b/web/src/components/image/index.tsx index c7fef47cb..bbf858701 100644 --- a/web/src/components/image/index.tsx +++ b/web/src/components/image/index.tsx @@ -1,11 +1,10 @@ import { api_host } from '@/utils/api'; import classNames from 'classnames'; +import React from 'react'; import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'; -interface IImage { +interface IImage extends React.ImgHTMLAttributes { id: string; - className?: string; - onClick?(): void; t?: string | number; } diff --git a/web/src/interfaces/database/knowledge.ts b/web/src/interfaces/database/knowledge.ts index 602748669..2dabbb931 100644 --- a/web/src/interfaces/database/knowledge.ts +++ b/web/src/interfaces/database/knowledge.ts @@ -116,12 +116,15 @@ export interface ITenantInfo { tts_id: string; } +export type ChunkDocType = 'image' | 'table'; + export interface IChunk { available_int: number; // Whether to enable, 0: not enabled, 1: enabled chunk_id: string; content_with_weight: string; doc_id: string; doc_name: string; + doc_type_kwd?: ChunkDocType; image_id: string; important_kwd?: string[]; question_kwd?: string[]; // keywords diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 5116f359a..7cb5d9985 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -604,6 +604,12 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s 'The document being parsed cannot be deleted', }, chunk: { + type: 'Type', + docType: { + image: 'Image', + table: 'Table', + text: 'Text', + }, chunk: 'Chunk', bulk: 'Bulk', selectAll: 'Select all', diff --git a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.less b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.less index aac7724af..622e3b9e5 100644 --- a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.less +++ b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.less @@ -4,6 +4,8 @@ } .imagePreview { + width: 100%; + height: 100%; max-width: 50vw; max-height: 50vh; object-fit: contain; diff --git a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx index 98d3d3595..a2e9bac40 100644 --- a/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx +++ b/web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx @@ -2,17 +2,19 @@ import Image from '@/components/image'; import { useTheme } from '@/components/theme-provider'; import { Card } from '@/components/ui/card'; import { Checkbox } from '@/components/ui/checkbox'; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from '@/components/ui/popover'; import { Switch } from '@/components/ui/switch'; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from '@/components/ui/tooltip'; import { IChunk } from '@/interfaces/database/knowledge'; +import { cn } from '@/lib/utils'; import { CheckedState } from '@radix-ui/react-checkbox'; import classNames from 'classnames'; import DOMPurify from 'dompurify'; import { useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; import { ChunkTextMode } from '../../constant'; import styles from './index.less'; @@ -39,6 +41,7 @@ const ChunkCard = ({ textMode, t: imageCacheKey, }: IProps) => { + const { t } = useTranslation(); const available = Number(item.available_int); const [enabled, setEnabled] = useState(false); const { theme } = useTheme(); @@ -63,51 +66,59 @@ const ChunkCard = ({ useEffect(() => { setEnabled(available === 1); }, [available]); - const [open, setOpen] = useState(false); + return ( + + {t( + `chunk.docType.${item.doc_type_kwd ? String(item.doc_type_kwd).toLowerCase() : 'text'}`, + )} + +
+ + {/* Using instead of to avoid flickering when hovering over the image */} {item.image_id && ( - - setOpen(true)} - onMouseLeave={() => setOpen(false)} - > -
- -
-
- + + + + -
- -
-
-
+ + +
)} +
-
+ +
& kFProps> = ({ const { removeChunk } = useDeleteChunkByIds(); const { data } = useFetchChunk(chunkId); const { t } = useTranslation(); + const isEditMode = !!chunkId; const isTagParser = parserId === 'tag'; const onSubmit = useCallback( @@ -144,6 +146,28 @@ const ChunkCreatingModal: React.FC & kFProps> = ({ )} /> + {/* Do not display the type field in create mode */} + {isEditMode && ( + ( + + {t(`chunk.type`)} + + + + + )} + /> + )} + { }, [selectedChunkIds]); return ( -
+