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

@@ -2,20 +2,20 @@ import { IChunk } from '@/interfaces/database/knowledge';
import { UploadFile } from 'antd';
import { v4 as uuid } from 'uuid';
export const buildChunkHighlights = (selectedChunk: IChunk) => {
export const buildChunkHighlights = (
selectedChunk: IChunk,
size: { width: number; height: number },
) => {
return Array.isArray(selectedChunk?.positions) &&
selectedChunk.positions.every((x) => Array.isArray(x))
? selectedChunk?.positions?.map((x) => {
const actualPositions = x.map((y, index) =>
index !== 0 ? y / 0.7 : y,
);
const boundingRect = {
width: 849,
height: 1200,
x1: actualPositions[1],
x2: actualPositions[2],
y1: actualPositions[3],
y2: actualPositions[4],
width: size.width,
height: size.height,
x1: x[1],
x2: x[2],
y1: x[3],
y2: x[4],
};
return {
id: uuid(),