@konfuzio/document-validation-ui 0.1.19-dev.2 → 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/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 -558
- 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 -152
- 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
package/src/store/selection.js
CHANGED
|
@@ -1,210 +1,210 @@
|
|
|
1
|
-
import myImports from "../api";
|
|
2
|
-
|
|
3
|
-
const HTTP = myImports.HTTP;
|
|
4
|
-
|
|
5
|
-
const selectionPadding = 1;
|
|
6
|
-
|
|
7
|
-
const state = {
|
|
8
|
-
selection: {
|
|
9
|
-
pageNumber: null,
|
|
10
|
-
start: null,
|
|
11
|
-
end: null,
|
|
12
|
-
custom: false, // if the box was created by user in document or it comes from an annotation
|
|
13
|
-
},
|
|
14
|
-
isSelecting: false,
|
|
15
|
-
spanSelection: null,
|
|
16
|
-
elementSelected: null, // selected element id
|
|
17
|
-
selectedEntities: null,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getters = {
|
|
21
|
-
isElementSelected: (state) => {
|
|
22
|
-
return state.elementSelected;
|
|
23
|
-
},
|
|
24
|
-
isSelecting: (state) => {
|
|
25
|
-
return state.isSelecting;
|
|
26
|
-
},
|
|
27
|
-
isSelectionValid: (state) => {
|
|
28
|
-
/**
|
|
29
|
-
* `endSelection` will reset everything in case of invalid selection.
|
|
30
|
-
* Check the existence of `selection.end` before requesting the
|
|
31
|
-
* content from the backend.
|
|
32
|
-
* */
|
|
33
|
-
return state.selection && state.selection.end;
|
|
34
|
-
},
|
|
35
|
-
getSelectionForPage: (state) => (pageNumber) => {
|
|
36
|
-
if (state.selection.pageNumber === pageNumber) {
|
|
37
|
-
return state.selection;
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const actions = {
|
|
44
|
-
selectElement: ({ commit }, value) => {
|
|
45
|
-
commit("RESET_SELECTION");
|
|
46
|
-
commit("SET_SPAN_SELECTION", null);
|
|
47
|
-
commit("ELEMENT_SELECTED", value);
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
disableSelection: ({ commit }) => {
|
|
51
|
-
commit("ELEMENT_SELECTED", null);
|
|
52
|
-
commit("RESET_SELECTION");
|
|
53
|
-
commit("SET_SPAN_SELECTION", null);
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
startSelection: ({ commit }, { pageNumber, start }) => {
|
|
57
|
-
commit("START_SELECTION", {
|
|
58
|
-
pageNumber,
|
|
59
|
-
start,
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
moveSelection: ({ commit, state, dispatch }, points) => {
|
|
64
|
-
// only apply when we have a large enough selection, otherwise we risk counting misclicks
|
|
65
|
-
const xDiff = Math.abs(state.selection.start.x - points.end.x);
|
|
66
|
-
const yDiff = Math.abs(state.selection.start.y - points.end.y);
|
|
67
|
-
if (xDiff > 5 && yDiff > 5) {
|
|
68
|
-
commit("MOVE_SELECTION", points);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
commit("SET_SELECTED_ENTITIES", null);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
endSelection: ({ commit, state }, end) => {
|
|
75
|
-
let xDiff;
|
|
76
|
-
let yDiff;
|
|
77
|
-
|
|
78
|
-
if (end) {
|
|
79
|
-
xDiff = Math.abs(state.selection.start.x - end.x);
|
|
80
|
-
yDiff = Math.abs(state.selection.start.y - end.y);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// if "end" is not provided, start and end points are the same, or if we have a selection smaller than 5x5,
|
|
84
|
-
// just reset
|
|
85
|
-
if (
|
|
86
|
-
!end ||
|
|
87
|
-
(yDiff <= 5 && xDiff <= 5) ||
|
|
88
|
-
(state.selection.start.x === end.x && state.selection.start.y == end.y)
|
|
89
|
-
) {
|
|
90
|
-
commit("RESET_SELECTION");
|
|
91
|
-
} else {
|
|
92
|
-
state.selection.start.x = state.selection.start.x - selectionPadding;
|
|
93
|
-
state.selection.start.y = state.selection.start.y - selectionPadding;
|
|
94
|
-
|
|
95
|
-
end.x = end.x + selectionPadding;
|
|
96
|
-
end.y = end.y + selectionPadding;
|
|
97
|
-
|
|
98
|
-
commit("END_SELECTION", end);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
setSelection: ({ commit }, { span, selection }) => {
|
|
103
|
-
commit("SET_SELECTION", selection);
|
|
104
|
-
commit("SET_SPAN_SELECTION", span);
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
setSelectedEntities: ({ commit }, entities) => {
|
|
108
|
-
commit("SET_SELECTED_ENTITIES", entities);
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
getTextFromBboxes: ({ commit, rootState }, { box, entities }) => {
|
|
112
|
-
let span;
|
|
113
|
-
|
|
114
|
-
if (entities) {
|
|
115
|
-
span = box.flatMap((s) => {
|
|
116
|
-
return s.original;
|
|
117
|
-
});
|
|
118
|
-
} else {
|
|
119
|
-
span = [box];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return HTTP.post(`documents/${rootState.document.documentId}/bbox/`, {
|
|
123
|
-
span,
|
|
124
|
-
})
|
|
125
|
-
.then((response) => {
|
|
126
|
-
if (response.data.span.length && response.data.span.length > 0) {
|
|
127
|
-
/**
|
|
128
|
-
* If we have a non-empty bboxes list, we assume there
|
|
129
|
-
* is text here on the backend, so we just set
|
|
130
|
-
* spanSelection to the response.
|
|
131
|
-
*/
|
|
132
|
-
commit("SET_SPAN_SELECTION", response.data.span);
|
|
133
|
-
} else {
|
|
134
|
-
/**
|
|
135
|
-
* Otherwise, we assume the backend can't identify text
|
|
136
|
-
* on this area, so we set our bbox into spanSelection
|
|
137
|
-
* ready to be passed back to the backend when creating
|
|
138
|
-
* an annotation on this empty area, adding the offset_string
|
|
139
|
-
* attribute, ready to be filled.
|
|
140
|
-
*/
|
|
141
|
-
commit("SET_SPAN_SELECTION", span);
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
.catch((error) => {
|
|
145
|
-
alert("Could not fetch the selected text from the backend");
|
|
146
|
-
});
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
getTextFromEntities: ({ commit, dispatch }, selectedEntities) => {
|
|
150
|
-
if (!selectedEntities) return;
|
|
151
|
-
|
|
152
|
-
return dispatch("getTextFromBboxes", {
|
|
153
|
-
box: selectedEntities,
|
|
154
|
-
entities: true,
|
|
155
|
-
});
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
setSpanSelection: ({ commit }, span) => {
|
|
159
|
-
commit("SET_SPAN_SELECTION", span);
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const mutations = {
|
|
164
|
-
ELEMENT_SELECTED: (state, value) => {
|
|
165
|
-
state.elementSelected = value;
|
|
166
|
-
},
|
|
167
|
-
START_SELECTION: (state, { pageNumber, start }) => {
|
|
168
|
-
state.selection.end = null;
|
|
169
|
-
state.isSelecting = true;
|
|
170
|
-
state.selection.pageNumber = pageNumber;
|
|
171
|
-
state.selection.custom = true;
|
|
172
|
-
state.selection.start = start;
|
|
173
|
-
},
|
|
174
|
-
MOVE_SELECTION: (state, points) => {
|
|
175
|
-
const { start, end } = points;
|
|
176
|
-
if (start) {
|
|
177
|
-
state.selection.start = start;
|
|
178
|
-
}
|
|
179
|
-
if (end) {
|
|
180
|
-
state.selection.end = end;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
END_SELECTION: (state, end) => {
|
|
184
|
-
state.selection.end = end;
|
|
185
|
-
state.isSelecting = false;
|
|
186
|
-
},
|
|
187
|
-
RESET_SELECTION: (state) => {
|
|
188
|
-
state.isSelecting = false;
|
|
189
|
-
state.selection.pageNumber = null;
|
|
190
|
-
state.selection.start = null;
|
|
191
|
-
state.selection.end = null;
|
|
192
|
-
},
|
|
193
|
-
SET_SPAN_SELECTION: (state, span) => {
|
|
194
|
-
state.spanSelection = span;
|
|
195
|
-
},
|
|
196
|
-
SET_SELECTION: (state, selection) => {
|
|
197
|
-
state.selection = selection;
|
|
198
|
-
},
|
|
199
|
-
SET_SELECTED_ENTITIES: (state, entities) => {
|
|
200
|
-
state.selectedEntities = entities;
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export default {
|
|
205
|
-
namespaced: true,
|
|
206
|
-
state,
|
|
207
|
-
getters,
|
|
208
|
-
actions,
|
|
209
|
-
mutations,
|
|
210
|
-
};
|
|
1
|
+
import myImports from "../api";
|
|
2
|
+
|
|
3
|
+
const HTTP = myImports.HTTP;
|
|
4
|
+
|
|
5
|
+
const selectionPadding = 1;
|
|
6
|
+
|
|
7
|
+
const state = {
|
|
8
|
+
selection: {
|
|
9
|
+
pageNumber: null,
|
|
10
|
+
start: null,
|
|
11
|
+
end: null,
|
|
12
|
+
custom: false, // if the box was created by user in document or it comes from an annotation
|
|
13
|
+
},
|
|
14
|
+
isSelecting: false,
|
|
15
|
+
spanSelection: null,
|
|
16
|
+
elementSelected: null, // selected element id
|
|
17
|
+
selectedEntities: null,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getters = {
|
|
21
|
+
isElementSelected: (state) => {
|
|
22
|
+
return state.elementSelected;
|
|
23
|
+
},
|
|
24
|
+
isSelecting: (state) => {
|
|
25
|
+
return state.isSelecting;
|
|
26
|
+
},
|
|
27
|
+
isSelectionValid: (state) => {
|
|
28
|
+
/**
|
|
29
|
+
* `endSelection` will reset everything in case of invalid selection.
|
|
30
|
+
* Check the existence of `selection.end` before requesting the
|
|
31
|
+
* content from the backend.
|
|
32
|
+
* */
|
|
33
|
+
return state.selection && state.selection.end;
|
|
34
|
+
},
|
|
35
|
+
getSelectionForPage: (state) => (pageNumber) => {
|
|
36
|
+
if (state.selection.pageNumber === pageNumber) {
|
|
37
|
+
return state.selection;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const actions = {
|
|
44
|
+
selectElement: ({ commit }, value) => {
|
|
45
|
+
commit("RESET_SELECTION");
|
|
46
|
+
commit("SET_SPAN_SELECTION", null);
|
|
47
|
+
commit("ELEMENT_SELECTED", value);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
disableSelection: ({ commit }) => {
|
|
51
|
+
commit("ELEMENT_SELECTED", null);
|
|
52
|
+
commit("RESET_SELECTION");
|
|
53
|
+
commit("SET_SPAN_SELECTION", null);
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
startSelection: ({ commit }, { pageNumber, start }) => {
|
|
57
|
+
commit("START_SELECTION", {
|
|
58
|
+
pageNumber,
|
|
59
|
+
start,
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
moveSelection: ({ commit, state, dispatch }, points) => {
|
|
64
|
+
// only apply when we have a large enough selection, otherwise we risk counting misclicks
|
|
65
|
+
const xDiff = Math.abs(state.selection.start.x - points.end.x);
|
|
66
|
+
const yDiff = Math.abs(state.selection.start.y - points.end.y);
|
|
67
|
+
if (xDiff > 5 && yDiff > 5) {
|
|
68
|
+
commit("MOVE_SELECTION", points);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
commit("SET_SELECTED_ENTITIES", null);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
endSelection: ({ commit, state }, end) => {
|
|
75
|
+
let xDiff;
|
|
76
|
+
let yDiff;
|
|
77
|
+
|
|
78
|
+
if (end) {
|
|
79
|
+
xDiff = Math.abs(state.selection.start.x - end.x);
|
|
80
|
+
yDiff = Math.abs(state.selection.start.y - end.y);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// if "end" is not provided, start and end points are the same, or if we have a selection smaller than 5x5,
|
|
84
|
+
// just reset
|
|
85
|
+
if (
|
|
86
|
+
!end ||
|
|
87
|
+
(yDiff <= 5 && xDiff <= 5) ||
|
|
88
|
+
(state.selection.start.x === end.x && state.selection.start.y == end.y)
|
|
89
|
+
) {
|
|
90
|
+
commit("RESET_SELECTION");
|
|
91
|
+
} else {
|
|
92
|
+
state.selection.start.x = state.selection.start.x - selectionPadding;
|
|
93
|
+
state.selection.start.y = state.selection.start.y - selectionPadding;
|
|
94
|
+
|
|
95
|
+
end.x = end.x + selectionPadding;
|
|
96
|
+
end.y = end.y + selectionPadding;
|
|
97
|
+
|
|
98
|
+
commit("END_SELECTION", end);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
setSelection: ({ commit }, { span, selection }) => {
|
|
103
|
+
commit("SET_SELECTION", selection);
|
|
104
|
+
commit("SET_SPAN_SELECTION", span);
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
setSelectedEntities: ({ commit }, entities) => {
|
|
108
|
+
commit("SET_SELECTED_ENTITIES", entities);
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
getTextFromBboxes: ({ commit, rootState }, { box, entities }) => {
|
|
112
|
+
let span;
|
|
113
|
+
|
|
114
|
+
if (entities) {
|
|
115
|
+
span = box.flatMap((s) => {
|
|
116
|
+
return s.original;
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
span = [box];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return HTTP.post(`documents/${rootState.document.documentId}/bbox/`, {
|
|
123
|
+
span,
|
|
124
|
+
})
|
|
125
|
+
.then((response) => {
|
|
126
|
+
if (response.data.span.length && response.data.span.length > 0) {
|
|
127
|
+
/**
|
|
128
|
+
* If we have a non-empty bboxes list, we assume there
|
|
129
|
+
* is text here on the backend, so we just set
|
|
130
|
+
* spanSelection to the response.
|
|
131
|
+
*/
|
|
132
|
+
commit("SET_SPAN_SELECTION", response.data.span);
|
|
133
|
+
} else {
|
|
134
|
+
/**
|
|
135
|
+
* Otherwise, we assume the backend can't identify text
|
|
136
|
+
* on this area, so we set our bbox into spanSelection
|
|
137
|
+
* ready to be passed back to the backend when creating
|
|
138
|
+
* an annotation on this empty area, adding the offset_string
|
|
139
|
+
* attribute, ready to be filled.
|
|
140
|
+
*/
|
|
141
|
+
commit("SET_SPAN_SELECTION", span);
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
.catch((error) => {
|
|
145
|
+
alert("Could not fetch the selected text from the backend");
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
getTextFromEntities: ({ commit, dispatch }, selectedEntities) => {
|
|
150
|
+
if (!selectedEntities) return;
|
|
151
|
+
|
|
152
|
+
return dispatch("getTextFromBboxes", {
|
|
153
|
+
box: selectedEntities,
|
|
154
|
+
entities: true,
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
setSpanSelection: ({ commit }, span) => {
|
|
159
|
+
commit("SET_SPAN_SELECTION", span);
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const mutations = {
|
|
164
|
+
ELEMENT_SELECTED: (state, value) => {
|
|
165
|
+
state.elementSelected = value;
|
|
166
|
+
},
|
|
167
|
+
START_SELECTION: (state, { pageNumber, start }) => {
|
|
168
|
+
state.selection.end = null;
|
|
169
|
+
state.isSelecting = true;
|
|
170
|
+
state.selection.pageNumber = pageNumber;
|
|
171
|
+
state.selection.custom = true;
|
|
172
|
+
state.selection.start = start;
|
|
173
|
+
},
|
|
174
|
+
MOVE_SELECTION: (state, points) => {
|
|
175
|
+
const { start, end } = points;
|
|
176
|
+
if (start) {
|
|
177
|
+
state.selection.start = start;
|
|
178
|
+
}
|
|
179
|
+
if (end) {
|
|
180
|
+
state.selection.end = end;
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
END_SELECTION: (state, end) => {
|
|
184
|
+
state.selection.end = end;
|
|
185
|
+
state.isSelecting = false;
|
|
186
|
+
},
|
|
187
|
+
RESET_SELECTION: (state) => {
|
|
188
|
+
state.isSelecting = false;
|
|
189
|
+
state.selection.pageNumber = null;
|
|
190
|
+
state.selection.start = null;
|
|
191
|
+
state.selection.end = null;
|
|
192
|
+
},
|
|
193
|
+
SET_SPAN_SELECTION: (state, span) => {
|
|
194
|
+
state.spanSelection = span;
|
|
195
|
+
},
|
|
196
|
+
SET_SELECTION: (state, selection) => {
|
|
197
|
+
state.selection = selection;
|
|
198
|
+
},
|
|
199
|
+
SET_SELECTED_ENTITIES: (state, entities) => {
|
|
200
|
+
state.selectedEntities = entities;
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export default {
|
|
205
|
+
namespaced: true,
|
|
206
|
+
state,
|
|
207
|
+
getters,
|
|
208
|
+
actions,
|
|
209
|
+
mutations,
|
|
210
|
+
};
|
package/src/utils/utils.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
export function sleep(duration) {
|
|
2
|
-
new Promise((resolve) => setTimeout(resolve, duration));
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function getURLQueryParam(param) {
|
|
6
|
-
const queryString = window.location.search;
|
|
7
|
-
const urlParams = new URLSearchParams(queryString);
|
|
8
|
-
|
|
9
|
-
if (urlParams.has(param)) {
|
|
10
|
-
return urlParams.get(param);
|
|
11
|
-
}
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getURLPath(value) {
|
|
16
|
-
const path = window.location.pathname;
|
|
17
|
-
|
|
18
|
-
if (!path.includes(`/${value}/`)) return;
|
|
19
|
-
|
|
20
|
-
const id = path.split(value)[1].split("/")[1];
|
|
21
|
-
|
|
22
|
-
if (id === "") return;
|
|
23
|
-
|
|
24
|
-
return id;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function navigateToNewDocumentURL(oldId, newId) {
|
|
28
|
-
const url = window.location.href;
|
|
29
|
-
const newUrl = url.replace(oldId, newId);
|
|
30
|
-
window.location.replace(newUrl);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function navigateToDocumentsList(path, projectId, userId) {
|
|
34
|
-
if (!path) return;
|
|
35
|
-
|
|
36
|
-
const lastCharOfString = path.charAt(path.length - 1);
|
|
37
|
-
let slash = "/";
|
|
38
|
-
|
|
39
|
-
if (lastCharOfString === slash) {
|
|
40
|
-
slash = "";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const parameters = `?project=${projectId}&is_reviewed__exact=0&assignee__id__exact=${userId}`;
|
|
44
|
-
|
|
45
|
-
const newPath = `${path}${slash}${parameters}`;
|
|
46
|
-
|
|
47
|
-
window.location.href = newPath;
|
|
48
|
-
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function isElementArray(element) {
|
|
53
|
-
return Array.isArray(element);
|
|
54
|
-
}
|
|
1
|
+
export function sleep(duration) {
|
|
2
|
+
new Promise((resolve) => setTimeout(resolve, duration));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function getURLQueryParam(param) {
|
|
6
|
+
const queryString = window.location.search;
|
|
7
|
+
const urlParams = new URLSearchParams(queryString);
|
|
8
|
+
|
|
9
|
+
if (urlParams.has(param)) {
|
|
10
|
+
return urlParams.get(param);
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getURLPath(value) {
|
|
16
|
+
const path = window.location.pathname;
|
|
17
|
+
|
|
18
|
+
if (!path.includes(`/${value}/`)) return;
|
|
19
|
+
|
|
20
|
+
const id = path.split(value)[1].split("/")[1];
|
|
21
|
+
|
|
22
|
+
if (id === "") return;
|
|
23
|
+
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function navigateToNewDocumentURL(oldId, newId) {
|
|
28
|
+
const url = window.location.href;
|
|
29
|
+
const newUrl = url.replace(oldId, newId);
|
|
30
|
+
window.location.replace(newUrl);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function navigateToDocumentsList(path, projectId, userId) {
|
|
34
|
+
if (!path) return;
|
|
35
|
+
|
|
36
|
+
const lastCharOfString = path.charAt(path.length - 1);
|
|
37
|
+
let slash = "/";
|
|
38
|
+
|
|
39
|
+
if (lastCharOfString === slash) {
|
|
40
|
+
slash = "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const parameters = `?project=${projectId}&is_reviewed__exact=0&assignee__id__exact=${userId}`;
|
|
44
|
+
|
|
45
|
+
const newPath = `${path}${slash}${parameters}`;
|
|
46
|
+
|
|
47
|
+
window.location.href = newPath;
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function isElementArray(element) {
|
|
53
|
+
return Array.isArray(element);
|
|
54
|
+
}
|
package/vue.config.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
runtimeCompiler: true,
|
|
3
|
-
pluginOptions: {
|
|
4
|
-
i18n: {
|
|
5
|
-
locale: "en",
|
|
6
|
-
fallbackLocale: "en",
|
|
7
|
-
localeDir: "locales",
|
|
8
|
-
enableInSFC: true,
|
|
9
|
-
includeLocales: false,
|
|
10
|
-
enableBridge: true,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
css: {
|
|
14
|
-
extract: {
|
|
15
|
-
filename: "css/[name].css?_hash=[contenthash:8]",
|
|
16
|
-
chunkFilename: "css/[name].css?_hash=[contenthash:8]",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
configureWebpack: {
|
|
20
|
-
output: {
|
|
21
|
-
filename: "js/[name].js",
|
|
22
|
-
chunkFilename: "js/[name].js",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
runtimeCompiler: true,
|
|
3
|
+
pluginOptions: {
|
|
4
|
+
i18n: {
|
|
5
|
+
locale: "en",
|
|
6
|
+
fallbackLocale: "en",
|
|
7
|
+
localeDir: "locales",
|
|
8
|
+
enableInSFC: true,
|
|
9
|
+
includeLocales: false,
|
|
10
|
+
enableBridge: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
css: {
|
|
14
|
+
extract: {
|
|
15
|
+
filename: "css/[name].css?_hash=[contenthash:8]",
|
|
16
|
+
chunkFilename: "css/[name].css?_hash=[contenthash:8]",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
configureWebpack: {
|
|
20
|
+
output: {
|
|
21
|
+
filename: "js/[name].js",
|
|
22
|
+
chunkFilename: "js/[name].js",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|