mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: add DocumentPreviewer for chunk of chat reference and remove duplicate \n from record.progress_msg (#97)
* feat: Remove duplicate \n from record.progress_msg * feat: add DocumentPreviewer for chunk of chat reference
This commit is contained in:
21
web/src/hooks/documentHooks.ts
Normal file
21
web/src/hooks/documentHooks.ts
Normal file
@ -0,0 +1,21 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user