@konfuzio/document-validation-ui 0.2.6-dev.0 → 0.2.6-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/app.css +1 -1
- package/dist/index.html +1 -1
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/dist/js/chunk-vendors.js +17 -17
- package/dist/js/chunk-vendors.js.map +1 -1
- package/package.json +8 -4
- package/src/components/DocumentPage/DocumentPage.vue +45 -1
- package/src/store/display.js +5 -5
- package/src/store/document.js +59 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konfuzio/document-validation-ui",
|
|
3
|
-
"version": "0.2.6-dev.
|
|
3
|
+
"version": "0.2.6-dev.2",
|
|
4
4
|
"repository": "https://github.com/konfuzio-ai/document-validation-ui",
|
|
5
5
|
"main": "dist/app.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
|
25
25
|
"@fortawesome/vue-fontawesome": "^3.0.8",
|
|
26
26
|
"@sentry/tracing": "^6.19.4",
|
|
27
|
-
"@sentry/vue": "^
|
|
27
|
+
"@sentry/vue": "^8.35.0",
|
|
28
28
|
"@vue/compat": "^3.5.13",
|
|
29
|
-
"axios": "^1.
|
|
29
|
+
"axios": "^1.12.0",
|
|
30
30
|
"bignumber.js": "^9.1.2",
|
|
31
31
|
"buefy": "npm:@ntohq/buefy-next@^0.2.0",
|
|
32
32
|
"keycloak-js": "^25.0.6",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@4tw/cypress-drag-drop": "^2.3.0",
|
|
46
46
|
"@babel/preset-env": "^7.26.9",
|
|
47
|
-
"@vue/cli-service": "^5.0.
|
|
47
|
+
"@vue/cli-service": "^5.0.9",
|
|
48
48
|
"@vue/compiler-sfc": "^3.1.0",
|
|
49
49
|
"@vue/test-utils": "^2.4.6",
|
|
50
50
|
"@vue/vue3-jest": "^29.2.6",
|
|
@@ -57,5 +57,9 @@
|
|
|
57
57
|
"jest": "^29.2.6",
|
|
58
58
|
"jest-environment-jsdom": "^29.7.0",
|
|
59
59
|
"prettier": "2.8.1"
|
|
60
|
+
},
|
|
61
|
+
"overrides": {
|
|
62
|
+
"postcss": "8.4.31",
|
|
63
|
+
"webpack-dev-server": "5.2.1"
|
|
60
64
|
}
|
|
61
65
|
}
|
|
@@ -74,6 +74,11 @@
|
|
|
74
74
|
@mouseleave="onElementLeave"
|
|
75
75
|
/>
|
|
76
76
|
</v-group>
|
|
77
|
+
<template v-for="annotationSet in pageAnnotationSets">
|
|
78
|
+
<v-group>
|
|
79
|
+
<v-rect :config="groupAnnotationRect(annotationSet)" />
|
|
80
|
+
</v-group>
|
|
81
|
+
</template>
|
|
77
82
|
<template v-for="annotation in pageAnnotations">
|
|
78
83
|
<template
|
|
79
84
|
v-for="(bbox, index) in annotation.span.filter(
|
|
@@ -217,6 +222,7 @@ export default {
|
|
|
217
222
|
"isDocumentReadyToBeReviewed",
|
|
218
223
|
"isDocumentReviewed",
|
|
219
224
|
"labelOfAnnotation",
|
|
225
|
+
"annotationSetBoxForPageNumber",
|
|
220
226
|
]),
|
|
221
227
|
selectionPage() {
|
|
222
228
|
return this.selection && this.selection.pageNumber;
|
|
@@ -275,6 +281,31 @@ export default {
|
|
|
275
281
|
return annotations;
|
|
276
282
|
},
|
|
277
283
|
|
|
284
|
+
pageAnnotationSets() {
|
|
285
|
+
const annotationSets = [];
|
|
286
|
+
|
|
287
|
+
if (this.getAnnotationsFiltered.annotationSets) {
|
|
288
|
+
this.getAnnotationsFiltered.annotationSets.forEach((annotationSet) => {
|
|
289
|
+
let samePage = false;
|
|
290
|
+
annotationSet.labels.forEach((label) => {
|
|
291
|
+
label.annotations.forEach((annotation) => {
|
|
292
|
+
if (
|
|
293
|
+
annotation.span.find(
|
|
294
|
+
(span) => span.page_index + 1 === this.page.number
|
|
295
|
+
)
|
|
296
|
+
) {
|
|
297
|
+
samePage = true;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
if (samePage) {
|
|
302
|
+
annotationSets.push(annotationSet);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return annotationSets;
|
|
307
|
+
},
|
|
308
|
+
|
|
278
309
|
selection() {
|
|
279
310
|
return this.$store.getters["selection/getSelectionForPage"](
|
|
280
311
|
this.page.number
|
|
@@ -551,7 +582,20 @@ export default {
|
|
|
551
582
|
name: "annotation",
|
|
552
583
|
draggable,
|
|
553
584
|
cornerRadius: 2,
|
|
554
|
-
...this.bboxToRect(this.page, bbox, focused),
|
|
585
|
+
...this.bboxToRect(this.page, bbox, focused ? 2 : 0),
|
|
586
|
+
};
|
|
587
|
+
},
|
|
588
|
+
groupAnnotationRect(annotationSet) {
|
|
589
|
+
const box = this.annotationSetBoxForPageNumber(annotationSet);
|
|
590
|
+
return {
|
|
591
|
+
fill: "#2f80ed",
|
|
592
|
+
globalCompositeOperation: "multiply",
|
|
593
|
+
strokeWidth: 0.2,
|
|
594
|
+
stroke: "black",
|
|
595
|
+
name: "annotationSet",
|
|
596
|
+
cornerRadius: 4,
|
|
597
|
+
opacity: 0.3,
|
|
598
|
+
...this.bboxToRect(this.page, box, 4),
|
|
555
599
|
};
|
|
556
600
|
},
|
|
557
601
|
getAnnotationLabelPosition(annotation) {
|
package/src/store/display.js
CHANGED
|
@@ -153,7 +153,7 @@ const getters = {
|
|
|
153
153
|
},
|
|
154
154
|
bboxToRect:
|
|
155
155
|
(state, getters) =>
|
|
156
|
-
(page, bbox, hasPadding =
|
|
156
|
+
(page, bbox, hasPadding = 0) => {
|
|
157
157
|
const imageScale = getters.imageScale(page);
|
|
158
158
|
if (bbox.x0 && bbox.y0) {
|
|
159
159
|
const { x0, x1, y0, y1 } = bbox;
|
|
@@ -161,7 +161,7 @@ const getters = {
|
|
|
161
161
|
const rect = {
|
|
162
162
|
// left
|
|
163
163
|
x: new BigNumber(x0)
|
|
164
|
-
.minus(hasPadding
|
|
164
|
+
.minus(hasPadding)
|
|
165
165
|
.times(state.scale)
|
|
166
166
|
.times(imageScale)
|
|
167
167
|
.div(PIXEL_RATIO)
|
|
@@ -169,14 +169,14 @@ const getters = {
|
|
|
169
169
|
// top
|
|
170
170
|
y: pageHeight
|
|
171
171
|
.minus(new BigNumber(y1))
|
|
172
|
-
.minus(hasPadding
|
|
172
|
+
.minus(hasPadding)
|
|
173
173
|
.times(state.scale)
|
|
174
174
|
.times(imageScale)
|
|
175
175
|
.div(PIXEL_RATIO)
|
|
176
176
|
.toNumber(),
|
|
177
177
|
width: new BigNumber(x1)
|
|
178
178
|
.minus(x0)
|
|
179
|
-
.plus(hasPadding
|
|
179
|
+
.plus(hasPadding * 2)
|
|
180
180
|
.abs()
|
|
181
181
|
.times(state.scale)
|
|
182
182
|
.times(imageScale)
|
|
@@ -184,7 +184,7 @@ const getters = {
|
|
|
184
184
|
.toNumber(),
|
|
185
185
|
height: new BigNumber(y1)
|
|
186
186
|
.minus(y0)
|
|
187
|
-
.plus(hasPadding
|
|
187
|
+
.plus(hasPadding * 2)
|
|
188
188
|
.times(state.scale)
|
|
189
189
|
.times(imageScale)
|
|
190
190
|
.div(PIXEL_RATIO)
|
package/src/store/document.js
CHANGED
|
@@ -278,6 +278,65 @@ const getters = {
|
|
|
278
278
|
return foundAnnotationSet;
|
|
279
279
|
},
|
|
280
280
|
|
|
281
|
+
/* Get annotation set box to cover all annotations */
|
|
282
|
+
annotationSetBoxForPageNumber: (state) => (annotationSet) => {
|
|
283
|
+
let box = {
|
|
284
|
+
x0: null,
|
|
285
|
+
y0: null,
|
|
286
|
+
x1: null,
|
|
287
|
+
y1: null,
|
|
288
|
+
};
|
|
289
|
+
const annotationIdsOfAnnSet = [];
|
|
290
|
+
annotationSet.labels.forEach((label) => {
|
|
291
|
+
label.annotations.forEach((annotation) => {
|
|
292
|
+
annotationIdsOfAnnSet.push(annotation.id);
|
|
293
|
+
annotation.span.forEach((span) => {
|
|
294
|
+
if (!box.x0 || box.x0 > span.x0) {
|
|
295
|
+
box.x0 = span.x0;
|
|
296
|
+
}
|
|
297
|
+
if (!box.x1 || box.x1 < span.x1) {
|
|
298
|
+
box.x1 = span.x1;
|
|
299
|
+
}
|
|
300
|
+
if (!box.y0 || box.y0 > span.y0) {
|
|
301
|
+
box.y0 = span.y0;
|
|
302
|
+
}
|
|
303
|
+
if (!box.y1 || box.y1 < span.y1) {
|
|
304
|
+
box.y1 = span.y1;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// check if doesn't cover any other annotation
|
|
311
|
+
if (box.x0) {
|
|
312
|
+
state.annotations.forEach((annotation) => {
|
|
313
|
+
// don't check for annotations of the intended annotation set
|
|
314
|
+
if (!annotationIdsOfAnnSet.includes(annotation.id)) {
|
|
315
|
+
annotation.span.forEach((span) => {
|
|
316
|
+
if (
|
|
317
|
+
span.x0 >= box.x0 &&
|
|
318
|
+
span.x1 <= box.x1 &&
|
|
319
|
+
span.y0 >= box.y0 &&
|
|
320
|
+
span.y1 <= box.y1
|
|
321
|
+
) {
|
|
322
|
+
box = {
|
|
323
|
+
x0: null,
|
|
324
|
+
y0: null,
|
|
325
|
+
x1: null,
|
|
326
|
+
y1: null,
|
|
327
|
+
};
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
if (!box.x0) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
return box;
|
|
338
|
+
},
|
|
339
|
+
|
|
281
340
|
/* Get label for a given annotation */
|
|
282
341
|
labelOfAnnotation: (state) => (annotationToFind) => {
|
|
283
342
|
let foundLabel = null;
|