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:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user