mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: add Preview with react-pdf-highlighter (#89)
* feat: add selected style to chunk item * feat: hightlight pdf * feat: add Preview with react-pdf-highlighter
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useSelector } from 'umi';
|
||||
|
||||
export const useSelectDocumentInfo = () => {
|
||||
@ -7,3 +8,25 @@ export const useSelectDocumentInfo = () => {
|
||||
);
|
||||
return documentInfo;
|
||||
};
|
||||
|
||||
export const useSelectChunkList = () => {
|
||||
const chunkList: IChunk[] = useSelector(
|
||||
(state: any) => state.chunkModel.data,
|
||||
);
|
||||
return chunkList;
|
||||
};
|
||||
|
||||
export const useHandleChunkCardClick = () => {
|
||||
const [selectedChunkId, setSelectedChunkId] = useState<string>('');
|
||||
|
||||
const handleChunkCardClick = useCallback((chunkId: string) => {
|
||||
setSelectedChunkId(chunkId);
|
||||
}, []);
|
||||
|
||||
return { handleChunkCardClick, selectedChunkId };
|
||||
};
|
||||
|
||||
export const useGetSelectedChunk = (selectedChunkId: string) => {
|
||||
const chunkList: IChunk[] = useSelectChunkList();
|
||||
return chunkList.find((x) => x.chunk_id === selectedChunkId);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user