@konfuzio/document-validation-ui 0.1.38-dev.0 → 0.1.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konfuzio/document-validation-ui",
3
- "version": "0.1.38-dev.0",
3
+ "version": "0.1.38",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -148,6 +148,17 @@ export default {
148
148
  custom: false,
149
149
  };
150
150
 
151
+ // check if this is part of a group of spans to show the whole bounding box as a placeholder
152
+ if (
153
+ this.annotation.selection_bbox &&
154
+ this.annotation.span.length > 1
155
+ ) {
156
+ selection.placeholderBox = this.bboxToRect(
157
+ page,
158
+ this.annotation.selection_bbox
159
+ );
160
+ }
161
+
151
162
  this.$store.dispatch("selection/setSelection", {
152
163
  selection,
153
164
  span: this.span,
@@ -8,7 +8,16 @@
8
8
  @dragend="onChange"
9
9
  @transformend="onChange"
10
10
  />
11
- <v-transformer ref="boxTransformer" :config="transformerConfig" />
11
+ <v-transformer
12
+ v-if="editable"
13
+ ref="boxTransformer"
14
+ :config="transformerConfig"
15
+ />
16
+ <v-rect
17
+ v-if="selection.placeholderBox"
18
+ ref="placeholderSelection"
19
+ :config="placeholderConfig"
20
+ />
12
21
  </v-group>
13
22
  </template>
14
23
 
@@ -21,6 +30,11 @@ export default {
21
30
  required: true,
22
31
  type: Object,
23
32
  },
33
+ editable: {
34
+ required: false,
35
+ type: Boolean,
36
+ default: true,
37
+ },
24
38
  },
25
39
  computed: {
26
40
  /**
@@ -42,6 +56,21 @@ export default {
42
56
  draggable: true,
43
57
  };
44
58
  },
59
+ placeholderConfig() {
60
+ return {
61
+ x: this.selection.placeholderBox.x,
62
+ y: this.selection.placeholderBox.y,
63
+ width: this.selection.placeholderBox.width,
64
+ height: this.selection.placeholderBox.height,
65
+ fill: "transparent",
66
+ stroke: "#41af85",
67
+ strokeWidth: 3,
68
+ globalCompositeOperation: "multiply",
69
+ shadowForStrokeEnabled: false,
70
+ name: "placeholderSelection",
71
+ draggable: false,
72
+ };
73
+ },
45
74
  transformerConfig() {
46
75
  return {
47
76
  borderEnabled: false,
@@ -16,6 +16,7 @@
16
16
  :new-annotation="newAnnotation"
17
17
  :container-width="scaledViewport.width"
18
18
  :container-height="scaledViewport.height"
19
+ :page="page"
19
20
  @close="closePopups"
20
21
  />
21
22
  <EditAnnotation
@@ -118,7 +118,7 @@
118
118
  <script>
119
119
  /**
120
120
  * This component is used to show a popup
121
- * for creating a new annotation.
121
+ * for editing an annotation.
122
122
  */
123
123
  const heightOfPopup = 142;
124
124
  const margin = 12;
@@ -179,7 +179,7 @@ export default {
179
179
 
180
180
  //check if the popup will not go off the container on the top
181
181
  return this.selection.start.y > heightOfPopup
182
- ? top
182
+ ? top - margin
183
183
  : this.selection.start.y + height + margin;
184
184
  },
185
185
  left() {
@@ -149,6 +149,10 @@ export default {
149
149
  type: Number,
150
150
  required: true,
151
151
  },
152
+ page: {
153
+ required: true,
154
+ type: Object,
155
+ },
152
156
  },
153
157
  data() {
154
158
  return {
@@ -167,6 +171,7 @@ export default {
167
171
  "labelsFilteredForAnnotationCreation",
168
172
  "isNegative",
169
173
  ]),
174
+ ...mapGetters("display", ["clientToBbox"]),
170
175
  ...mapState("selection", ["spanSelection", "selection"]),
171
176
  top() {
172
177
  if (this.selection && this.selection.end) {
@@ -259,12 +264,19 @@ export default {
259
264
  };
260
265
  });
261
266
 
267
+ const selection_bbox = this.clientToBbox(
268
+ this.page,
269
+ this.selection.start,
270
+ this.selection.end
271
+ );
272
+
262
273
  const annotationToCreate = {
263
274
  document: this.documentId,
264
275
  span: span,
265
276
  label: this.selectedLabel.id,
266
277
  is_correct: true,
267
278
  revised: false,
279
+ selection_bbox,
268
280
  };
269
281
 
270
282
  if (this.selectedSet.id) {
@@ -10,6 +10,7 @@ const state = {
10
10
  start: null,
11
11
  end: null,
12
12
  custom: false, // if the box was created by user in document or it comes from an annotation
13
+ placeholderBox: null, // show a not editable placeholder box
13
14
  },
14
15
  isSelecting: false,
15
16
  spanSelection: null,
@@ -183,6 +184,7 @@ const mutations = {
183
184
  state.selection.pageNumber = pageNumber;
184
185
  state.selection.custom = true;
185
186
  state.selection.start = start;
187
+ state.selection.placeholderBox = null;
186
188
  },
187
189
  MOVE_SELECTION: (state, points) => {
188
190
  const { start, end } = points;
@@ -202,6 +204,7 @@ const mutations = {
202
204
  state.selection.pageNumber = null;
203
205
  state.selection.start = null;
204
206
  state.selection.end = null;
207
+ state.selection.placeholderBox = null;
205
208
  },
206
209
  SET_SPAN_SELECTION: (state, span) => {
207
210
  state.spanSelection = span;