@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/Annotator/examplePhotos.js +6976 -0
- package/Annotator/index.js +104 -11
- package/Annotator/reducers/general-reducer.js +95 -1
- package/Editor/annotation-plugin/annotation.js +613 -0
- package/Editor/index.js +57 -0
- package/Editor/tools.js +5 -0
- package/ImageCanvas/index.js +7 -2
- package/MainLayout/index.js +146 -43
- package/MetadataEditorSidebarBox/index.js +126 -0
- package/PageSelector/index.js +67 -0
- package/RegionLabel/index.js +16 -2
- package/RegionShapes/index.js +31 -11
- package/RegionTags/index.js +6 -2
- package/SettingsProvider/index.js +8 -3
- package/hooks/use-colors.js +101 -0
- package/package.json +4 -1
- package/utils/filter-only-unique.js +5 -0
- package/utils/photosToImages.js +53 -0
- package/utils/regions-to-blocks.js +16 -0
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searpent/react-image-annotate",
|
|
3
|
-
"version": "2.0.
|
|
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,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;
|