@konfuzio/document-validation-ui 0.2.1-dev.0 → 0.2.1-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 +1 -1
- package/dist/js/chunk-vendors.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DocumentAnnotations/AnnotationContent.vue +0 -1
- package/src/components/DocumentPage/DocumentPage.vue +3 -6
- package/src/components/DocumentPage/ScrollingDocument.vue +2 -5
- package/src/components/DocumentPage/SpanSelection.vue +11 -9
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +6 -23
- package/src/store/display.js +5 -1
- package/src/store/selection.js +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konfuzio/document-validation-ui",
|
|
3
|
-
"version": "0.2.1-dev.
|
|
3
|
+
"version": "0.2.1-dev.2",
|
|
4
4
|
"repository": "https://github.com/konfuzio-ai/document-validation-ui",
|
|
5
5
|
"main": "dist/app.js",
|
|
6
6
|
"scripts": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"splitpanes": "^3.1.8",
|
|
37
37
|
"vue": "^3.5.13",
|
|
38
38
|
"vue-i18n": "^10.0.6",
|
|
39
|
-
"vue-konva": "^3.2.
|
|
39
|
+
"vue-konva": "^3.2.1",
|
|
40
40
|
"vue3-observe-visibility": "^1.0.3",
|
|
41
41
|
"vuedraggable": "^4.1.0",
|
|
42
42
|
"vuex": "^4.1.0"
|
|
@@ -554,21 +554,18 @@ export default {
|
|
|
554
554
|
},
|
|
555
555
|
getAnnotationLabelPosition(annotation) {
|
|
556
556
|
if (annotation && this.$refs.stage) {
|
|
557
|
-
const padding = 8;
|
|
558
557
|
const maxCharacters = 10;
|
|
559
558
|
const minimumSpaceTopY = 50;
|
|
560
|
-
const rect = this.bboxToRect(this.page, annotation.span
|
|
559
|
+
const rect = this.bboxToRect(this.page, annotation.span);
|
|
561
560
|
|
|
562
561
|
if (
|
|
563
562
|
annotation.labelName.length > maxCharacters &&
|
|
564
563
|
rect.y < minimumSpaceTopY
|
|
565
564
|
) {
|
|
566
|
-
return `left: ${rect.x}px; top: ${
|
|
567
|
-
rect.y + rect.height * 3 + padding
|
|
568
|
-
}px`;
|
|
565
|
+
return `left: ${rect.x}px; top: ${rect.y + rect.height}px`;
|
|
569
566
|
} else {
|
|
570
567
|
return `left: ${rect.x}px; bottom: ${
|
|
571
|
-
this.$refs.stage.$el.clientHeight - rect.y
|
|
568
|
+
this.$refs.stage.$el.clientHeight - rect.y
|
|
572
569
|
}px`;
|
|
573
570
|
}
|
|
574
571
|
} else {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="scrolling-document">
|
|
3
|
-
<div
|
|
4
|
-
ref="scrollingDocument"
|
|
5
|
-
v-scroll.immediate="updateScrollBounds"
|
|
6
|
-
class="scrolling-document"
|
|
7
|
-
>
|
|
3
|
+
<div ref="scrollingDocument" class="scrolling-document">
|
|
8
4
|
<transition :name="searchEnabled ? 'slide-down' : 'slide-up'">
|
|
9
5
|
<SearchBar v-if="searchEnabled" />
|
|
10
6
|
</transition>
|
|
@@ -114,6 +110,7 @@ export default {
|
|
|
114
110
|
this.$refs.scrollingDocument.scroll(scrollX, scrollY);
|
|
115
111
|
},
|
|
116
112
|
handleScroll() {
|
|
113
|
+
this.updateScrollBounds();
|
|
117
114
|
if (this.pages.length === 1) return;
|
|
118
115
|
|
|
119
116
|
this.isScrolling = true;
|
|
@@ -121,15 +121,17 @@ export default {
|
|
|
121
121
|
|
|
122
122
|
moveSelection(points) {
|
|
123
123
|
// only apply when we have a large enough selection, otherwise we risk counting misclicks
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
if (this.selection) {
|
|
125
|
+
const xDiff = Math.abs(this.selection.start.x - points.end.x);
|
|
126
|
+
const yDiff = Math.abs(this.selection.start.y - points.end.y);
|
|
127
|
+
if (xDiff > 5 && yDiff > 5) {
|
|
128
|
+
const { start, end } = points;
|
|
129
|
+
if (start) {
|
|
130
|
+
this.selection.start = start;
|
|
131
|
+
}
|
|
132
|
+
if (end) {
|
|
133
|
+
this.selection.end = end;
|
|
134
|
+
}
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
},
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="document-pages" ref="documentThumbnails">
|
|
3
|
-
<div v-if="selectedDocument">
|
|
3
|
+
<div v-if="selectedDocument" ref="docPage">
|
|
4
4
|
<div
|
|
5
5
|
v-for="page in selectedDocument.pages"
|
|
6
|
-
ref="docPage"
|
|
7
6
|
:key="page.id"
|
|
8
7
|
:class="[
|
|
9
8
|
'document-thumbnail',
|
|
@@ -76,21 +75,12 @@ export default {
|
|
|
76
75
|
},
|
|
77
76
|
watch: {
|
|
78
77
|
currentPage(newPage) {
|
|
79
|
-
if (!newPage) return;
|
|
78
|
+
if (!newPage || newPage == this.thumbnailClicked) return;
|
|
80
79
|
|
|
81
80
|
// handle thumbnail selection when scrolling the document
|
|
82
81
|
this.scrollToThumbnail(newPage);
|
|
83
82
|
},
|
|
84
83
|
},
|
|
85
|
-
mounted() {
|
|
86
|
-
const scrollingPage = document.querySelector(".scrolling-document");
|
|
87
|
-
|
|
88
|
-
if (scrollingPage) {
|
|
89
|
-
scrollingPage.addEventListener("scroll", () => {
|
|
90
|
-
this.scrollToThumbnail();
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
84
|
|
|
95
85
|
methods: {
|
|
96
86
|
/* Change page if not the currently open and not in modal */
|
|
@@ -109,17 +99,10 @@ export default {
|
|
|
109
99
|
|
|
110
100
|
scrollToThumbnail(page) {
|
|
111
101
|
// select only the active thumbnail
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (page == this.thumbnailClicked) {
|
|
117
|
-
this.thumbnailClicked = null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (!this.thumbnailClicked && selectedPage && selectedPage[0]) {
|
|
121
|
-
selectedPage[0].scrollIntoView();
|
|
122
|
-
}
|
|
102
|
+
this.thumbnailClicked = null;
|
|
103
|
+
this.$refs.docPage.children[page - 1].scrollIntoView({
|
|
104
|
+
behavior: "smooth",
|
|
105
|
+
});
|
|
123
106
|
},
|
|
124
107
|
},
|
|
125
108
|
};
|
package/src/store/display.js
CHANGED
|
@@ -270,7 +270,11 @@ const actions = {
|
|
|
270
270
|
commit("SET_SCALE", autoScale);
|
|
271
271
|
break;
|
|
272
272
|
case "all": {
|
|
273
|
-
const widthScale = getters.pageWidthScale(
|
|
273
|
+
const widthScale = getters.pageWidthScale(
|
|
274
|
+
elementsWidth,
|
|
275
|
+
client.width,
|
|
276
|
+
viewport.width
|
|
277
|
+
);
|
|
274
278
|
commit("SET_SCALE", widthScale);
|
|
275
279
|
break;
|
|
276
280
|
}
|
package/src/store/selection.js
CHANGED
|
@@ -75,10 +75,12 @@ const actions = {
|
|
|
75
75
|
|
|
76
76
|
moveSelection: ({ commit, state, dispatch }, points) => {
|
|
77
77
|
// only apply when we have a large enough selection, otherwise we risk counting misclicks
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
if (state.selection && state.selection.start) {
|
|
79
|
+
const xDiff = Math.abs(state.selection.start.x - points.end.x);
|
|
80
|
+
const yDiff = Math.abs(state.selection.start.y - points.end.y);
|
|
81
|
+
if (xDiff > 5 && yDiff > 5) {
|
|
82
|
+
commit("MOVE_SELECTION", points);
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
},
|
|
84
86
|
|