mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-04 11:24:00 +08:00

* feat: Remove duplicate \n from record.progress_msg * feat: add DocumentPreviewer for chunk of chat reference
22 lines
654 B
TypeScript
22 lines
654 B
TypeScript
import { IChunk } from '@/interfaces/database/knowledge';
|
|
import { api_host } from '@/utils/api';
|
|
import { buildChunkHighlights } from '@/utils/documentUtils';
|
|
import { useMemo } from 'react';
|
|
import { IHighlight } from 'react-pdf-highlighter';
|
|
|
|
export const useGetDocumentUrl = (documentId: string) => {
|
|
const url = useMemo(() => {
|
|
return `${api_host}/document/get/${documentId}`;
|
|
}, [documentId]);
|
|
|
|
return url;
|
|
};
|
|
|
|
export const useGetChunkHighlights = (selectedChunk: IChunk): IHighlight[] => {
|
|
const highlights: IHighlight[] = useMemo(() => {
|
|
return buildChunkHighlights(selectedChunk);
|
|
}, [selectedChunk]);
|
|
|
|
return highlights;
|
|
};
|