@konfuzio/document-validation-ui 0.1.19-dev.1 → 0.1.19
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/.eslintrc.js +10 -10
- package/.prettierrc.json +1 -1
- package/LICENSE +21 -21
- package/README.md +24 -24
- package/cypress.config.js +13 -13
- 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/jest.config.js +4 -4
- package/package.json +66 -66
- package/src/api.js +82 -82
- package/src/assets/images/AcceptedCheckMark.vue +8 -8
- package/src/assets/images/AcceptedUser.vue +8 -8
- package/src/assets/images/ActionIcon.vue +60 -60
- package/src/assets/images/ArrowDownKey.vue +11 -11
- package/src/assets/images/ArrowUpKey.vue +11 -11
- package/src/assets/images/CategoryIconImg.vue +13 -13
- package/src/assets/images/CheckMark.vue +8 -8
- package/src/assets/images/DraggableIcon.vue +14 -14
- package/src/assets/images/EditDocIcon.vue +12 -12
- package/src/assets/images/EmptyStateImg.vue +129 -129
- package/src/assets/images/ErrorIcon.vue +28 -28
- package/src/assets/images/EyeIcon.vue +11 -11
- package/src/assets/images/FileNameNotSavedImage.vue +26 -26
- package/src/assets/images/FileNameSavedImage.vue +14 -14
- package/src/assets/images/FitZoomIcon.vue +16 -16
- package/src/assets/images/GridIcon.vue +16 -16
- package/src/assets/images/KeyboardIcon.vue +16 -16
- package/src/assets/images/MagicWandIcon.vue +16 -16
- package/src/assets/images/MinusIcon.vue +13 -13
- package/src/assets/images/NotFoundIcon.vue +16 -16
- package/src/assets/images/NotOptimizedIllustration.vue +651 -651
- package/src/assets/images/PlusIcon.vue +13 -13
- package/src/assets/images/QuestionMark.vue +12 -12
- package/src/assets/images/ServerImage.vue +73 -73
- package/src/assets/images/SettingsIcon.vue +14 -14
- package/src/assets/images/SplitLines.vue +18 -18
- package/src/assets/images/SplitZigZag.vue +49 -49
- package/src/assets/images/StarIcon.vue +16 -16
- package/src/assets/images/StatusImg.vue +14 -14
- package/src/assets/images/TranslateArrows.vue +33 -33
- package/src/assets/scss/ann_set_table_options.scss +26 -26
- package/src/assets/scss/annotation_details.scss +141 -141
- package/src/assets/scss/choose_label_set_modal.scss +65 -65
- package/src/assets/scss/document_action_bar.scss +37 -37
- package/src/assets/scss/document_annotations.scss +558 -537
- package/src/assets/scss/document_category.scss +85 -85
- package/src/assets/scss/document_dashboard.scss +52 -52
- package/src/assets/scss/document_edit.scss +410 -410
- package/src/assets/scss/document_error.scss +81 -81
- package/src/assets/scss/document_name.scss +60 -60
- package/src/assets/scss/document_page.scss +12 -12
- package/src/assets/scss/document_thumbnails.scss +41 -41
- package/src/assets/scss/document_toolbar.scss +111 -111
- package/src/assets/scss/document_top_bar.scss +171 -171
- package/src/assets/scss/document_viewport_modal.scss +25 -25
- package/src/assets/scss/documents_list.scss +141 -141
- package/src/assets/scss/edit_page_thumbnail.scss +53 -53
- package/src/assets/scss/empty_state.scss +34 -34
- package/src/assets/scss/extracting_data.scss +35 -35
- package/src/assets/scss/imports.scss +1 -1
- package/src/assets/scss/multi_ann_table_overlay.scss +38 -38
- package/src/assets/scss/multi_ann_table_popup.scss +12 -12
- package/src/assets/scss/new_annotation.scss +102 -102
- package/src/assets/scss/scrolling_document.scss +19 -19
- package/src/assets/scss/theme.scss +801 -801
- package/src/assets/scss/variables.scss +66 -66
- package/src/components/App.cy.js +7 -7
- package/src/components/App.vue +187 -187
- package/src/components/DocumentAnnotations/AnnotationActionButtons.vue +152 -168
- package/src/components/DocumentAnnotations/AnnotationContent.vue +210 -210
- package/src/components/DocumentAnnotations/AnnotationDetails.vue +251 -251
- package/src/components/DocumentAnnotations/AnnotationRow.vue +752 -752
- package/src/components/DocumentAnnotations/AnnotationSetActionButtons.vue +89 -89
- package/src/components/DocumentAnnotations/ChooseLabelSetModal.vue +186 -186
- package/src/components/DocumentAnnotations/DocumentAnnotations.cy.js +441 -441
- package/src/components/DocumentAnnotations/DocumentAnnotations.vue +534 -534
- package/src/components/DocumentAnnotations/DocumentLabel.vue +189 -189
- package/src/components/DocumentAnnotations/EmptyAnnotation.vue +193 -193
- package/src/components/DocumentAnnotations/EmptyState.vue +21 -21
- package/src/components/DocumentAnnotations/ExtractingData.vue +41 -41
- package/src/components/DocumentAnnotations/LoadingAnnotations.vue +43 -43
- package/src/components/DocumentAnnotations/LoadingLabels.vue +43 -43
- package/src/components/DocumentAnnotations/MultiAnnotationTableOverlay.vue +338 -338
- package/src/components/DocumentAnnotations/index.js +8 -8
- package/src/components/DocumentCategory.vue +281 -281
- package/src/components/DocumentDashboard.vue +170 -170
- package/src/components/DocumentEdit/DocumentEdit.cy.js +541 -541
- package/src/components/DocumentEdit/DocumentEdit.vue +503 -503
- package/src/components/DocumentEdit/EditConfirmationModal.vue +55 -55
- package/src/components/DocumentEdit/EditPageThumbnail.vue +114 -114
- package/src/components/DocumentEdit/EditPages.vue +161 -161
- package/src/components/DocumentEdit/EditSidebar.vue +154 -154
- package/src/components/DocumentEdit/RenameAndCategorize.vue +184 -184
- package/src/components/DocumentEdit/SidebarButtons.vue +53 -53
- package/src/components/DocumentEdit/SplitInfoBar.vue +21 -21
- package/src/components/DocumentEdit/index.js +4 -4
- package/src/components/DocumentModals/DocumentErrorModal.vue +58 -58
- package/src/components/DocumentModals/NotOptimizedViewportModal.vue +51 -51
- package/src/components/DocumentPage/ActionBar.vue +48 -48
- package/src/components/DocumentPage/AnnSetTableOptions.vue +111 -111
- package/src/components/DocumentPage/BoxSelection.vue +152 -152
- package/src/components/DocumentPage/DocumentPage.cy.js +92 -92
- package/src/components/DocumentPage/DocumentPage.vue +568 -568
- package/src/components/DocumentPage/DocumentToolbar.cy.js +215 -215
- package/src/components/DocumentPage/DocumentToolbar.vue +228 -228
- package/src/components/DocumentPage/DummyPage.vue +55 -55
- package/src/components/DocumentPage/MultiAnnSelection.vue +371 -371
- package/src/components/DocumentPage/NewAnnotation.vue +308 -308
- package/src/components/DocumentPage/ScrollingDocument.vue +149 -149
- package/src/components/DocumentPage/ScrollingPage.vue +179 -179
- package/src/components/DocumentPage/index.js +5 -5
- package/src/components/DocumentThumbnails/DocumentThumbnails.cy.js +67 -67
- package/src/components/DocumentThumbnails/DocumentThumbnails.vue +132 -132
- package/src/components/DocumentThumbnails/LoadingThumbnail.vue +25 -25
- package/src/components/DocumentThumbnails/index.js +1 -1
- package/src/components/DocumentTopBar/DocumentName.vue +236 -236
- package/src/components/DocumentTopBar/DocumentTopBar.cy.js +222 -222
- package/src/components/DocumentTopBar/DocumentTopBar.vue +202 -202
- package/src/components/DocumentTopBar/DocumentTopBarButtons.vue +183 -183
- package/src/components/DocumentTopBar/KeyboardActionsDescription.vue +74 -74
- package/src/components/DocumentTopBar/index.js +3 -3
- package/src/components/DocumentsList/DocumentsList.vue +121 -121
- package/src/components/DocumentsList/index.js +1 -1
- package/src/components/ErrorMessage.vue +40 -40
- package/src/components/index.js +1 -1
- package/src/constants.js +5 -5
- package/src/directives/scroll.js +28 -28
- package/src/i18n.js +22 -22
- package/src/icons.js +45 -45
- package/src/locales/de.json +148 -148
- package/src/locales/en.json +148 -148
- package/src/main.js +26 -26
- package/src/store/category.js +191 -191
- package/src/store/display.js +311 -311
- package/src/store/document.js +1438 -1438
- package/src/store/edit.js +316 -316
- package/src/store/index.js +21 -21
- package/src/store/project.js +143 -143
- package/src/store/selection.js +210 -210
- package/src/utils/utils.js +54 -54
- package/vue.config.js +25 -25
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="ann-set-table-header"
|
|
4
|
-
:style="{ left: `${coordinates.x}px`, top: `${coordinates.y}px` }"
|
|
5
|
-
>
|
|
6
|
-
<b-dropdown
|
|
7
|
-
aria-role="list"
|
|
8
|
-
class="ann-set-table-header-dropdown"
|
|
9
|
-
position="is-top-right"
|
|
10
|
-
scrollable
|
|
11
|
-
>
|
|
12
|
-
<template #trigger>
|
|
13
|
-
<span class="ann-set-label-set-name">{{ labelSetName }}</span>
|
|
14
|
-
<SettingsIcon />
|
|
15
|
-
</template>
|
|
16
|
-
<b-dropdown-item
|
|
17
|
-
aria-role="listitem"
|
|
18
|
-
class="delete-action"
|
|
19
|
-
@click="handleDelete()"
|
|
20
|
-
>
|
|
21
|
-
<span>{{ $t("delete_table") }}</span></b-dropdown-item
|
|
22
|
-
>
|
|
23
|
-
</b-dropdown>
|
|
24
|
-
</div>
|
|
25
|
-
</template>
|
|
26
|
-
|
|
27
|
-
<script>
|
|
28
|
-
import { mapGetters, mapState } from "vuex";
|
|
29
|
-
import SettingsIcon from "../../assets/images/SettingsIcon";
|
|
30
|
-
|
|
31
|
-
export default {
|
|
32
|
-
name: "AnnSetTableOptions",
|
|
33
|
-
components: {
|
|
34
|
-
SettingsIcon,
|
|
35
|
-
},
|
|
36
|
-
props: {
|
|
37
|
-
page: {
|
|
38
|
-
type: Object,
|
|
39
|
-
required: true,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
computed: {
|
|
43
|
-
...mapGetters("document", [
|
|
44
|
-
"annotationSetsInTable",
|
|
45
|
-
"annotationsInAnnotationsSets",
|
|
46
|
-
]),
|
|
47
|
-
...mapGetters("display", ["bboxToPoint"]),
|
|
48
|
-
...mapState("display", ["showAnnSetTable"]),
|
|
49
|
-
labelSetName() {
|
|
50
|
-
return this.showAnnSetTable[0].label_set.name;
|
|
51
|
-
},
|
|
52
|
-
coordinates() {
|
|
53
|
-
let xFinal = 0;
|
|
54
|
-
let yFinal = 0;
|
|
55
|
-
const paddingTop = 40;
|
|
56
|
-
|
|
57
|
-
this.showAnnSetTable.forEach((annotationSet) => {
|
|
58
|
-
if (annotationSet.labels) {
|
|
59
|
-
annotationSet.labels.forEach((label) => {
|
|
60
|
-
label.annotations.forEach((annotation) => {
|
|
61
|
-
annotation.span.forEach((span) => {
|
|
62
|
-
const { x, y } = this.bboxToPoint(this.page, {
|
|
63
|
-
x: span.x0,
|
|
64
|
-
y: span.y0,
|
|
65
|
-
});
|
|
66
|
-
if (xFinal === 0 || x < xFinal) {
|
|
67
|
-
xFinal = x;
|
|
68
|
-
}
|
|
69
|
-
if (yFinal === 0 || y < yFinal) {
|
|
70
|
-
yFinal = y - paddingTop;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return { x: xFinal, y: yFinal };
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
methods: {
|
|
81
|
-
handleDelete() {
|
|
82
|
-
const annotationsToDelete = this.annotationsInAnnotationsSets(
|
|
83
|
-
this.showAnnSetTable
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
for (let i = 0; i < annotationsToDelete.length; i++) {
|
|
87
|
-
const annotationToDelete = annotationsToDelete[i];
|
|
88
|
-
this.$store
|
|
89
|
-
.dispatch("document/deleteAnnotation", {
|
|
90
|
-
annotationId: annotationToDelete.id,
|
|
91
|
-
annotationSet: null, // TODO: test if annotation set should be added if the feature is available again
|
|
92
|
-
})
|
|
93
|
-
.catch((error) => {
|
|
94
|
-
this.$store.dispatch("document/createErrorMessage", {
|
|
95
|
-
error,
|
|
96
|
-
serverErrorMessage: this.$t("server_error"),
|
|
97
|
-
defaultErrorMessage: this.$t("edit_error"),
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
this.$store.dispatch("display/showAnnSetTable", null);
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
</script>
|
|
106
|
-
|
|
107
|
-
<style
|
|
108
|
-
scoped
|
|
109
|
-
lang="scss"
|
|
110
|
-
src="../../assets/scss/ann_set_table_options.scss"
|
|
111
|
-
></style>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="ann-set-table-header"
|
|
4
|
+
:style="{ left: `${coordinates.x}px`, top: `${coordinates.y}px` }"
|
|
5
|
+
>
|
|
6
|
+
<b-dropdown
|
|
7
|
+
aria-role="list"
|
|
8
|
+
class="ann-set-table-header-dropdown"
|
|
9
|
+
position="is-top-right"
|
|
10
|
+
scrollable
|
|
11
|
+
>
|
|
12
|
+
<template #trigger>
|
|
13
|
+
<span class="ann-set-label-set-name">{{ labelSetName }}</span>
|
|
14
|
+
<SettingsIcon />
|
|
15
|
+
</template>
|
|
16
|
+
<b-dropdown-item
|
|
17
|
+
aria-role="listitem"
|
|
18
|
+
class="delete-action"
|
|
19
|
+
@click="handleDelete()"
|
|
20
|
+
>
|
|
21
|
+
<span>{{ $t("delete_table") }}</span></b-dropdown-item
|
|
22
|
+
>
|
|
23
|
+
</b-dropdown>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
import { mapGetters, mapState } from "vuex";
|
|
29
|
+
import SettingsIcon from "../../assets/images/SettingsIcon";
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
name: "AnnSetTableOptions",
|
|
33
|
+
components: {
|
|
34
|
+
SettingsIcon,
|
|
35
|
+
},
|
|
36
|
+
props: {
|
|
37
|
+
page: {
|
|
38
|
+
type: Object,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
computed: {
|
|
43
|
+
...mapGetters("document", [
|
|
44
|
+
"annotationSetsInTable",
|
|
45
|
+
"annotationsInAnnotationsSets",
|
|
46
|
+
]),
|
|
47
|
+
...mapGetters("display", ["bboxToPoint"]),
|
|
48
|
+
...mapState("display", ["showAnnSetTable"]),
|
|
49
|
+
labelSetName() {
|
|
50
|
+
return this.showAnnSetTable[0].label_set.name;
|
|
51
|
+
},
|
|
52
|
+
coordinates() {
|
|
53
|
+
let xFinal = 0;
|
|
54
|
+
let yFinal = 0;
|
|
55
|
+
const paddingTop = 40;
|
|
56
|
+
|
|
57
|
+
this.showAnnSetTable.forEach((annotationSet) => {
|
|
58
|
+
if (annotationSet.labels) {
|
|
59
|
+
annotationSet.labels.forEach((label) => {
|
|
60
|
+
label.annotations.forEach((annotation) => {
|
|
61
|
+
annotation.span.forEach((span) => {
|
|
62
|
+
const { x, y } = this.bboxToPoint(this.page, {
|
|
63
|
+
x: span.x0,
|
|
64
|
+
y: span.y0,
|
|
65
|
+
});
|
|
66
|
+
if (xFinal === 0 || x < xFinal) {
|
|
67
|
+
xFinal = x;
|
|
68
|
+
}
|
|
69
|
+
if (yFinal === 0 || y < yFinal) {
|
|
70
|
+
yFinal = y - paddingTop;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return { x: xFinal, y: yFinal };
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
methods: {
|
|
81
|
+
handleDelete() {
|
|
82
|
+
const annotationsToDelete = this.annotationsInAnnotationsSets(
|
|
83
|
+
this.showAnnSetTable
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
for (let i = 0; i < annotationsToDelete.length; i++) {
|
|
87
|
+
const annotationToDelete = annotationsToDelete[i];
|
|
88
|
+
this.$store
|
|
89
|
+
.dispatch("document/deleteAnnotation", {
|
|
90
|
+
annotationId: annotationToDelete.id,
|
|
91
|
+
annotationSet: null, // TODO: test if annotation set should be added if the feature is available again
|
|
92
|
+
})
|
|
93
|
+
.catch((error) => {
|
|
94
|
+
this.$store.dispatch("document/createErrorMessage", {
|
|
95
|
+
error,
|
|
96
|
+
serverErrorMessage: this.$t("server_error"),
|
|
97
|
+
defaultErrorMessage: this.$t("edit_error"),
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
this.$store.dispatch("display/showAnnSetTable", null);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<style
|
|
108
|
+
scoped
|
|
109
|
+
lang="scss"
|
|
110
|
+
src="../../assets/scss/ann_set_table_options.scss"
|
|
111
|
+
></style>
|
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-group>
|
|
3
|
-
<v-rect
|
|
4
|
-
v-if="isSelectionValid"
|
|
5
|
-
ref="boxSelection"
|
|
6
|
-
:config="config"
|
|
7
|
-
:stroke-scale-enabled="false"
|
|
8
|
-
@dragend="onChange"
|
|
9
|
-
@transformend="onChange"
|
|
10
|
-
/>
|
|
11
|
-
<v-transformer ref="boxTransformer" :config="transformerConfig" />
|
|
12
|
-
</v-group>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import { mapGetters, mapState, mapActions } from "vuex";
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
props: {
|
|
20
|
-
page: {
|
|
21
|
-
required: true,
|
|
22
|
-
type: Object,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
computed: {
|
|
26
|
-
/**
|
|
27
|
-
* Konva options of the selection rectangle, based on the
|
|
28
|
-
* `selection` object.
|
|
29
|
-
*/
|
|
30
|
-
config() {
|
|
31
|
-
return {
|
|
32
|
-
x: this.selection.start.x,
|
|
33
|
-
y: this.selection.start.y,
|
|
34
|
-
width: this.selection.end.x - this.selection.start.x,
|
|
35
|
-
height: this.selection.end.y - this.selection.start.y,
|
|
36
|
-
fill: this.isSelecting ? "#7B61FFB3" : "transparent",
|
|
37
|
-
stroke: this.isSelecting ? "transparent" : "#7B61FFB3",
|
|
38
|
-
strokeWidth: 1,
|
|
39
|
-
globalCompositeOperation: "multiply",
|
|
40
|
-
shadowForStrokeEnabled: false,
|
|
41
|
-
name: "boxSelection",
|
|
42
|
-
draggable: true,
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
transformerConfig() {
|
|
46
|
-
return {
|
|
47
|
-
borderEnabled: false,
|
|
48
|
-
rotateEnabled: false,
|
|
49
|
-
ignoreStroke: true,
|
|
50
|
-
keepRatio: false,
|
|
51
|
-
anchorStroke: "#7B61FF",
|
|
52
|
-
anchorSize: 6,
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
...mapState("selection", ["selection", "isSelecting"]),
|
|
56
|
-
...mapGetters("display", ["clientToBbox"]),
|
|
57
|
-
...mapGetters("selection", ["isSelectionValid"]),
|
|
58
|
-
},
|
|
59
|
-
mounted() {
|
|
60
|
-
this.updateTransformer();
|
|
61
|
-
|
|
62
|
-
if (this.selection.custom) {
|
|
63
|
-
this.getBoxSelectionContent();
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
methods: {
|
|
67
|
-
updateTransformer() {
|
|
68
|
-
// here we need to manually attach or detach Transformer node
|
|
69
|
-
const transformer = this.$refs.boxTransformer;
|
|
70
|
-
|
|
71
|
-
// maybe we're out of sync and the transformer is not available, just return
|
|
72
|
-
if (!transformer) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const transformerNode = transformer.getNode();
|
|
77
|
-
const stage = transformerNode.getStage();
|
|
78
|
-
let selectedNode;
|
|
79
|
-
if (stage) {
|
|
80
|
-
selectedNode = stage.findOne(".boxSelection");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// do nothing if selected node is already attached
|
|
84
|
-
if (selectedNode === transformerNode.node()) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (selectedNode) {
|
|
89
|
-
// attach to another node
|
|
90
|
-
transformerNode.nodes([selectedNode]);
|
|
91
|
-
} else {
|
|
92
|
-
// remove transformer
|
|
93
|
-
transformerNode.nodes([]);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
transformerNode.getLayer().batchDraw();
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
getBoxSelectionContent() {
|
|
100
|
-
const box = this.clientToBbox(
|
|
101
|
-
this.page,
|
|
102
|
-
this.selection.start,
|
|
103
|
-
this.selection.end
|
|
104
|
-
);
|
|
105
|
-
this.$store.dispatch("selection/getTextFromBboxes", {
|
|
106
|
-
box,
|
|
107
|
-
entities: false,
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* This method is used for both transforms and drags since it just
|
|
113
|
-
* retrieves the rect's new attributes from the event and uses those
|
|
114
|
-
* to set the new selection state.
|
|
115
|
-
*/
|
|
116
|
-
onChange(event) {
|
|
117
|
-
const { x, y, scaleX, scaleY, skewX, width, height } = event.target.attrs;
|
|
118
|
-
const realWidth = width * scaleX;
|
|
119
|
-
const realHeight = height * scaleY;
|
|
120
|
-
let start;
|
|
121
|
-
let end;
|
|
122
|
-
|
|
123
|
-
// we need to figure out if there's skewing going on, to fix start/end points
|
|
124
|
-
// (other cases appear to fix themselves automatically)
|
|
125
|
-
if (skewX >= 0) {
|
|
126
|
-
start = { x, y };
|
|
127
|
-
end = {
|
|
128
|
-
x: start.x + realWidth,
|
|
129
|
-
y: start.y + realHeight,
|
|
130
|
-
};
|
|
131
|
-
} else {
|
|
132
|
-
end = { x, y };
|
|
133
|
-
start = { x: end.x - realWidth, y: end.y - realHeight };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
this.moveSelection({ start, end });
|
|
137
|
-
|
|
138
|
-
// reset node's everything after transform (we don't want to deal with that,
|
|
139
|
-
// just with regular x/y/width/height)
|
|
140
|
-
const node = this.$refs.boxSelection.getNode();
|
|
141
|
-
node.skewX(0);
|
|
142
|
-
node.skewY(0);
|
|
143
|
-
node.rotation(0);
|
|
144
|
-
node.scaleX(1);
|
|
145
|
-
node.scaleY(1);
|
|
146
|
-
|
|
147
|
-
this.getBoxSelectionContent();
|
|
148
|
-
},
|
|
149
|
-
...mapActions("selection", ["moveSelection"]),
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<v-group>
|
|
3
|
+
<v-rect
|
|
4
|
+
v-if="isSelectionValid"
|
|
5
|
+
ref="boxSelection"
|
|
6
|
+
:config="config"
|
|
7
|
+
:stroke-scale-enabled="false"
|
|
8
|
+
@dragend="onChange"
|
|
9
|
+
@transformend="onChange"
|
|
10
|
+
/>
|
|
11
|
+
<v-transformer ref="boxTransformer" :config="transformerConfig" />
|
|
12
|
+
</v-group>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { mapGetters, mapState, mapActions } from "vuex";
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
props: {
|
|
20
|
+
page: {
|
|
21
|
+
required: true,
|
|
22
|
+
type: Object,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
/**
|
|
27
|
+
* Konva options of the selection rectangle, based on the
|
|
28
|
+
* `selection` object.
|
|
29
|
+
*/
|
|
30
|
+
config() {
|
|
31
|
+
return {
|
|
32
|
+
x: this.selection.start.x,
|
|
33
|
+
y: this.selection.start.y,
|
|
34
|
+
width: this.selection.end.x - this.selection.start.x,
|
|
35
|
+
height: this.selection.end.y - this.selection.start.y,
|
|
36
|
+
fill: this.isSelecting ? "#7B61FFB3" : "transparent",
|
|
37
|
+
stroke: this.isSelecting ? "transparent" : "#7B61FFB3",
|
|
38
|
+
strokeWidth: 1,
|
|
39
|
+
globalCompositeOperation: "multiply",
|
|
40
|
+
shadowForStrokeEnabled: false,
|
|
41
|
+
name: "boxSelection",
|
|
42
|
+
draggable: true,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
transformerConfig() {
|
|
46
|
+
return {
|
|
47
|
+
borderEnabled: false,
|
|
48
|
+
rotateEnabled: false,
|
|
49
|
+
ignoreStroke: true,
|
|
50
|
+
keepRatio: false,
|
|
51
|
+
anchorStroke: "#7B61FF",
|
|
52
|
+
anchorSize: 6,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
...mapState("selection", ["selection", "isSelecting"]),
|
|
56
|
+
...mapGetters("display", ["clientToBbox"]),
|
|
57
|
+
...mapGetters("selection", ["isSelectionValid"]),
|
|
58
|
+
},
|
|
59
|
+
mounted() {
|
|
60
|
+
this.updateTransformer();
|
|
61
|
+
|
|
62
|
+
if (this.selection.custom) {
|
|
63
|
+
this.getBoxSelectionContent();
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
updateTransformer() {
|
|
68
|
+
// here we need to manually attach or detach Transformer node
|
|
69
|
+
const transformer = this.$refs.boxTransformer;
|
|
70
|
+
|
|
71
|
+
// maybe we're out of sync and the transformer is not available, just return
|
|
72
|
+
if (!transformer) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const transformerNode = transformer.getNode();
|
|
77
|
+
const stage = transformerNode.getStage();
|
|
78
|
+
let selectedNode;
|
|
79
|
+
if (stage) {
|
|
80
|
+
selectedNode = stage.findOne(".boxSelection");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// do nothing if selected node is already attached
|
|
84
|
+
if (selectedNode === transformerNode.node()) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (selectedNode) {
|
|
89
|
+
// attach to another node
|
|
90
|
+
transformerNode.nodes([selectedNode]);
|
|
91
|
+
} else {
|
|
92
|
+
// remove transformer
|
|
93
|
+
transformerNode.nodes([]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
transformerNode.getLayer().batchDraw();
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
getBoxSelectionContent() {
|
|
100
|
+
const box = this.clientToBbox(
|
|
101
|
+
this.page,
|
|
102
|
+
this.selection.start,
|
|
103
|
+
this.selection.end
|
|
104
|
+
);
|
|
105
|
+
this.$store.dispatch("selection/getTextFromBboxes", {
|
|
106
|
+
box,
|
|
107
|
+
entities: false,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This method is used for both transforms and drags since it just
|
|
113
|
+
* retrieves the rect's new attributes from the event and uses those
|
|
114
|
+
* to set the new selection state.
|
|
115
|
+
*/
|
|
116
|
+
onChange(event) {
|
|
117
|
+
const { x, y, scaleX, scaleY, skewX, width, height } = event.target.attrs;
|
|
118
|
+
const realWidth = width * scaleX;
|
|
119
|
+
const realHeight = height * scaleY;
|
|
120
|
+
let start;
|
|
121
|
+
let end;
|
|
122
|
+
|
|
123
|
+
// we need to figure out if there's skewing going on, to fix start/end points
|
|
124
|
+
// (other cases appear to fix themselves automatically)
|
|
125
|
+
if (skewX >= 0) {
|
|
126
|
+
start = { x, y };
|
|
127
|
+
end = {
|
|
128
|
+
x: start.x + realWidth,
|
|
129
|
+
y: start.y + realHeight,
|
|
130
|
+
};
|
|
131
|
+
} else {
|
|
132
|
+
end = { x, y };
|
|
133
|
+
start = { x: end.x - realWidth, y: end.y - realHeight };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.moveSelection({ start, end });
|
|
137
|
+
|
|
138
|
+
// reset node's everything after transform (we don't want to deal with that,
|
|
139
|
+
// just with regular x/y/width/height)
|
|
140
|
+
const node = this.$refs.boxSelection.getNode();
|
|
141
|
+
node.skewX(0);
|
|
142
|
+
node.skewY(0);
|
|
143
|
+
node.rotation(0);
|
|
144
|
+
node.scaleX(1);
|
|
145
|
+
node.scaleY(1);
|
|
146
|
+
|
|
147
|
+
this.getBoxSelectionContent();
|
|
148
|
+
},
|
|
149
|
+
...mapActions("selection", ["moveSelection"]),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
</script>
|