fix: by obtaining the width and height of the pdf and passing it to b… (#151)

* fix: by obtaining the width and height of the pdf and passing it to boundingRect, the problem of inaccurate positioning of file highlighting is fixed

* feat: remove actualPositions from buildChunkHighlights
This commit is contained in:
balibabu
2024-03-26 14:51:34 +08:00
committed by GitHub
parent 0dd5b58d03
commit 75f7c6da2f
6 changed files with 167 additions and 129 deletions

View File

@ -36,16 +36,24 @@ export const useGetSelectedChunk = (selectedChunkId: string) => {
);
};
export const useGetChunkHighlights = (
selectedChunkId: string,
): IHighlight[] => {
export const useGetChunkHighlights = (selectedChunkId: string) => {
const [size, setSize] = useState({ width: 849, height: 1200 });
const selectedChunk: IChunk = useGetSelectedChunk(selectedChunkId);
const highlights: IHighlight[] = useMemo(() => {
return buildChunkHighlights(selectedChunk);
}, [selectedChunk]);
return buildChunkHighlights(selectedChunk, size);
}, [selectedChunk, size]);
return highlights;
const setWidthAndHeight = (width: number, height: number) => {
setSize((pre) => {
if (pre.height !== height || pre.width !== width) {
return { height, width };
}
return pre;
});
};
return { highlights, setWidthAndHeight };
};
export const useSelectChunkListLoading = () => {