@searpent/react-image-annotate 2.0.3 → 2.0.6

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,7 +1,9 @@
1
1
  {
2
2
  "name": "@searpent/react-image-annotate",
3
- "version": "2.0.3",
3
+ "version": "2.0.6",
4
4
  "dependencies": {
5
+ "@editorjs/editorjs": "^2.25.0",
6
+ "@editorjs/paragraph": "^2.8.0",
5
7
  "@emotion/react": "^11.7.0",
6
8
  "@emotion/styled": "^11.6.0",
7
9
  "@fortawesome/fontawesome-svg-core": "^1.2.12",
@@ -20,6 +22,7 @@
20
22
  "moment": "^2.23.0",
21
23
  "react": "^17.0.2",
22
24
  "react-dom": "^17.0.2",
25
+ "react-editor-js": "^2.0.6",
23
26
  "react-full-screen": "^0.3.1",
24
27
  "react-hotkeys": "^2.0.0",
25
28
  "react-json-view": "^1.19.1",
@@ -0,0 +1,5 @@
1
+ function onlyUnique(value, index, self) {
2
+ return self.indexOf(value) === index;
3
+ }
4
+
5
+ export default onlyUnique;
@@ -0,0 +1,53 @@
1
+ function labelAndTextFromResultText(resultText) {
2
+ if (!resultText) {
3
+ return {};
4
+ }
5
+
6
+ var parsedResultText = JSON.parse(resultText);
7
+ var label = parsedResultText[0].label;
8
+ var text = parsedResultText[0].text;
9
+ return {
10
+ label: label,
11
+ text: text
12
+ };
13
+ }
14
+
15
+ function modelResultsToRegions(modelResults) {
16
+ return modelResults.map(function (r) {
17
+ var _labelAndTextFromResu = labelAndTextFromResultText(r.text),
18
+ label = _labelAndTextFromResu.label,
19
+ text = _labelAndTextFromResu.text;
20
+
21
+ return {
22
+ id: r.id,
23
+ type: "box",
24
+ visible: true,
25
+ cls: label,
26
+ highlighted: false,
27
+ groupHighlighted: false,
28
+ x: r.box.X1,
29
+ y: r.box.Y1,
30
+ w: r.box.X2 - r.box.X1,
31
+ h: r.box.Y2 - r.box.Y1,
32
+ groupId: r.groupId,
33
+ text: text
34
+ };
35
+ });
36
+ }
37
+
38
+ function photosToImages(photos) {
39
+ return photos.map(function (photo) {
40
+ return {
41
+ id: photo.id,
42
+ src: photo.fullsize.key,
43
+ thumbnail: photo.thumbnail.key,
44
+ name: photo.fullsize.key,
45
+ regions: modelResultsToRegions(photo.modelResults.v1.filter(function (mr) {
46
+ return mr.name === 'extraction-engine';
47
+ })[0].results),
48
+ metadata: photo.metadata
49
+ };
50
+ });
51
+ }
52
+
53
+ export default photosToImages;
@@ -0,0 +1,16 @@
1
+ function regionsToBlocks(regions) {
2
+ return regions.map(function (r) {
3
+ return {
4
+ id: r.id,
5
+ type: "annotation",
6
+ data: {
7
+ text: r.text || '',
8
+ labelName: r.cls,
9
+ groupColor: r.groupColor,
10
+ groupId: r.groupId
11
+ }
12
+ };
13
+ });
14
+ }
15
+
16
+ export default regionsToBlocks;