mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-10-07 14:06:44 +00:00
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;
|
||
|
};
|