@searpent/react-image-annotate 2.0.54 → 2.0.56
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.
|
@@ -431,7 +431,7 @@ var examplePhotos = [{
|
|
|
431
431
|
"Y1": 0.784579,
|
|
432
432
|
"Y2": 0.95930564
|
|
433
433
|
},
|
|
434
|
-
"text": "[{\"label\":\"text\",\"text\":\"
|
|
434
|
+
"text": "[{\"label\":\"text\",\"text\":\"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer rutrum, orci vestibulum ullamcorper ultricies, lacus quam ultricies odio, vitae placerat pede sem sit amet enim. Aliquam in lorem sit amet leo accumsan lacinia. In rutrum. Phasellus rhoncus. In convallis. Nulla non arcu lacinia neque faucibus fringilla. Integer tempor. Nullam rhoncus aliquam metus. Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Nullam rhoncus aliquam metus. Etiam dictum tincidunt diam. In sem justo, commodo ut, suscipit at, pharetra vitae, orci.\"}]",
|
|
435
435
|
"groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
|
|
436
436
|
"id": "346807503780052993"
|
|
437
437
|
}, {
|
|
@@ -455,8 +455,8 @@ var examplePhotos = [{
|
|
|
455
455
|
"Y1": 0.7462519,
|
|
456
456
|
"Y2": 0.7778154
|
|
457
457
|
},
|
|
458
|
-
"text": "[{\"label\":\"title\",\"text\":\"
|
|
459
|
-
"groupId": "
|
|
458
|
+
"text": "[{\"label\":\"title\",\"text\":\"Lorem ipsum NOT dolor sit amet, consectetuer adipiscing elit.\"}]",
|
|
459
|
+
"groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
|
|
460
460
|
"id": "346807503993962496"
|
|
461
461
|
}, {
|
|
462
462
|
"label": "text",
|
|
@@ -479,7 +479,7 @@ var examplePhotos = [{
|
|
|
479
479
|
"Y1": 0.52305263,
|
|
480
480
|
"Y2": 0.61999774
|
|
481
481
|
},
|
|
482
|
-
"text": "[{\"label\":\"
|
|
482
|
+
"text": "[{\"label\":\"text\",\"text\":\"Extraliga. Nová pravidla pro brankáře i vysokou hůl\"}]",
|
|
483
483
|
"groupId": "2",
|
|
484
484
|
"id": "346807504648273920"
|
|
485
485
|
}, {
|
|
@@ -599,7 +599,7 @@ var examplePhotos = [{
|
|
|
599
599
|
"Y1": 0.38327134,
|
|
600
600
|
"Y2": 0.5264345
|
|
601
601
|
},
|
|
602
|
-
"text": "[{\"label\":\"
|
|
602
|
+
"text": "[{\"label\":\"text\",\"text\":\"Už popáté se v Karlových Varech uskuteční Světový pohár v triatlonu. Třídenní akce s bohatým doprovodným programem vyvrcholí nedělními závody mužů a žen elitní kategorie.\"}]",
|
|
603
603
|
"groupId": "4",
|
|
604
604
|
"id": "346807505487134721"
|
|
605
605
|
}, {
|
|
@@ -611,7 +611,7 @@ var examplePhotos = [{
|
|
|
611
611
|
"Y1": 0.38327134,
|
|
612
612
|
"Y2": 0.5264345
|
|
613
613
|
},
|
|
614
|
-
"text": "[{\"label\":\"text\",\"text\":\"
|
|
614
|
+
"text": "[{\"label\":\"text\",\"text\":\"Vedle domácí špičky nebude chybět řada účastníků OH v Tokiu, nad plánovanou účastí dvojnásobné vítězky Venduly Frintové visí otazník. Nejlepší česká triatlonistka měla žaludeční problémy a o jejím startu se rozhodne na poslední chvíli. Vedle Frintové je přihlášena i druhá česká olympionička Petra Kuříková, jejímž karlovarským maximem je předloňské čtvrté místo. Mezi devítkou domácích závodníků je též Jan Čelůstka i nadějní Tereza Zimovjanová (na snímku) s Radimem Grebíkem.\"}]",
|
|
615
615
|
"groupId": "4",
|
|
616
616
|
"id": "346807505487134722"
|
|
617
617
|
}, {
|
|
@@ -778,7 +778,7 @@ var examplePhotos = [{
|
|
|
778
778
|
"key": "mutation",
|
|
779
779
|
"value": "hřensko"
|
|
780
780
|
}],
|
|
781
|
-
"lockedUntil":
|
|
781
|
+
"lockedUntil": null
|
|
782
782
|
}, {
|
|
783
783
|
"id": "431fc636-d6d1-4e20-a35b-cc7a201c1833",
|
|
784
784
|
"fullsize": {
|
|
@@ -2640,7 +2640,7 @@ var examplePhotos = [{
|
|
|
2640
2640
|
"Y1": 0.37425318,
|
|
2641
2641
|
"Y2": 0.48585278
|
|
2642
2642
|
},
|
|
2643
|
-
"text": "[{\"label\":\"
|
|
2643
|
+
"text": "[{\"label\":\"text\",\"text\":\"Běloruský vůdce Alexandr Lukašenko včera pohrozil Evropské unii tvrdou odplatou za úterní uvalení nových sankcí proti Minsku. Ve hře je podle něj i přerušení tranzitu ruského zemního plynu a přepravy dalšího zboží přes Bělorusko. EU se chystá postihnout Lukašenkův režim za vyostřování migrační krize na hranicích s Polskem a pobaltskými státy. „Zahříváme Evropu, ale ještě nám vyhrožují, že uzavřou hranice. A co když my jim přerušíme zemní plyn?“ řekl doslova Lukašenko. AP\"}]",
|
|
2644
2644
|
"groupId": "3",
|
|
2645
2645
|
"id": "346807630221541376"
|
|
2646
2646
|
}, {
|
|
@@ -6714,7 +6714,7 @@ var examplePhotos = [{
|
|
|
6714
6714
|
"Y1": 0.043963477,
|
|
6715
6715
|
"Y2": 0.18149026
|
|
6716
6716
|
},
|
|
6717
|
-
"text": "[{\"label\":\"
|
|
6717
|
+
"text": "[{\"label\":\"text\",\"text\":\"komerční příloha čtvrtek 29. dubna 2021 Robotické sekačky na trávu - nový pohled na sekání trávy\"}]",
|
|
6718
6718
|
"groupId": "0",
|
|
6719
6719
|
"id": "346807698131517440"
|
|
6720
6720
|
}, {
|
package/Editor/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import React, { useState } from 'react';
|
|
4
5
|
import { createReactEditorJS } from 'react-editor-js';
|
|
6
|
+
import blocksToArticle from '../utils/blocks-to-article';
|
|
5
7
|
import { EDITOR_JS_TOOLS } from './tools';
|
|
8
|
+
import ReadOnly from './readOnly';
|
|
6
9
|
var ReactEditorJS = createReactEditorJS();
|
|
7
10
|
|
|
8
11
|
function Editor(_ref) {
|
|
@@ -10,6 +13,11 @@ function Editor(_ref) {
|
|
|
10
13
|
onChange = _ref.onChange,
|
|
11
14
|
imageIndex = _ref.imageIndex;
|
|
12
15
|
|
|
16
|
+
var _useState = useState(false),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
isReadOnly = _useState2[0],
|
|
19
|
+
setIsReadOnly = _useState2[1];
|
|
20
|
+
|
|
13
21
|
var handleChange =
|
|
14
22
|
/*#__PURE__*/
|
|
15
23
|
function () {
|
|
@@ -44,14 +52,33 @@ function Editor(_ref) {
|
|
|
44
52
|
};
|
|
45
53
|
}();
|
|
46
54
|
|
|
47
|
-
|
|
55
|
+
var toggleIsReadOnly = function toggleIsReadOnly() {
|
|
56
|
+
setIsReadOnly(function (prev) {
|
|
57
|
+
return !prev;
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return React.createElement("div", null, React.createElement("div", {
|
|
62
|
+
className: "show-metadata-wrapper"
|
|
63
|
+
}, React.createElement("label", {
|
|
64
|
+
className: "switch mr-2"
|
|
65
|
+
}, React.createElement("input", {
|
|
66
|
+
id: "show-metadata",
|
|
67
|
+
type: "checkbox",
|
|
68
|
+
value: isReadOnly,
|
|
69
|
+
onChange: toggleIsReadOnly
|
|
70
|
+
}), React.createElement("span", {
|
|
71
|
+
className: "slider round"
|
|
72
|
+
})), React.createElement("label", null, "Preview")), isReadOnly ? React.createElement(ReadOnly, {
|
|
73
|
+
article: blocksToArticle(blocks)
|
|
74
|
+
}) : React.createElement(ReactEditorJS, {
|
|
48
75
|
defaultValue: {
|
|
49
76
|
blocks: blocks
|
|
50
77
|
},
|
|
51
78
|
tools: EDITOR_JS_TOOLS,
|
|
52
79
|
onChange: handleChange,
|
|
53
80
|
enableReInitialize: true
|
|
54
|
-
});
|
|
81
|
+
}));
|
|
55
82
|
}
|
|
56
83
|
|
|
57
84
|
export default Editor;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
function ReadOnly(_ref) {
|
|
4
|
+
var article = _ref.article;
|
|
5
|
+
return React.createElement("div", null, React.createElement("h1", null, article.title), React.createElement("h2", null, article.subtitle), React.createElement("p", null, article.text), React.createElement("p", null, article.author), React.createElement("p", null, article.about_author), React.createElement("div", null, article.appendix), React.createElement("div", null, article.photo_author), React.createElement("div", null, article.photo_caption), React.createElement("div", null, article.advertisement), React.createElement("div", null, article.other_graphics), React.createElement("div", null, article.unknown), React.createElement("div", null, article.table));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default ReadOnly;
|
package/MainLayout/index.js
CHANGED
|
@@ -297,7 +297,7 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
297
297
|
|
|
298
298
|
return {
|
|
299
299
|
id: "".concat(i.id),
|
|
300
|
-
src: i.
|
|
300
|
+
src: i.thumbnail,
|
|
301
301
|
isActive: idx === state.selectedImage,
|
|
302
302
|
pageNumber: (i === null || i === void 0 ? void 0 : (_i$metadata = i.metadata) === null || _i$metadata === void 0 ? void 0 : (_i$metadata$find = _i$metadata.find(function (md) {
|
|
303
303
|
return md.key === "pageNumber";
|
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
+
|
|
3
|
+
function sanitizedText(text) {
|
|
4
|
+
// remove whitespaces
|
|
5
|
+
var trimmed = text.trim(); // replace dashes at the end of sentence
|
|
6
|
+
|
|
7
|
+
var noTrailingDash = trimmed.replace(/-$/, "");
|
|
8
|
+
return noTrailingDash;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function blocksToArticle(blocks) {
|
|
12
|
+
var renamedBlocks = blocks.map(function (b) {
|
|
13
|
+
if (b.data.labelName === 'interview') {
|
|
14
|
+
b.data.labelName = 'text';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return _objectSpread({}, b);
|
|
18
|
+
});
|
|
19
|
+
var article = renamedBlocks.reduce(function (acc, curr) {
|
|
20
|
+
var _ref = curr === null || curr === void 0 ? void 0 : curr.data,
|
|
21
|
+
labelName = _ref.labelName,
|
|
22
|
+
text = _ref.text;
|
|
23
|
+
|
|
24
|
+
if (acc[labelName] === undefined) {
|
|
25
|
+
acc[labelName] = "";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var connectingSymbol = ""; // if last symbol is dot, next sentence should start with space
|
|
29
|
+
|
|
30
|
+
if (acc[labelName].charAt(acc[labelName].length - 1) === ".") {
|
|
31
|
+
connectingSymbol = " ";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
acc[labelName] = acc[labelName] + connectingSymbol + sanitizedText(text);
|
|
35
|
+
return acc;
|
|
36
|
+
}, {
|
|
37
|
+
title: "",
|
|
38
|
+
text: ""
|
|
39
|
+
});
|
|
40
|
+
return article;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default blocksToArticle;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import blocksToArticle from "./blocks-to-article";
|
|
2
|
+
var blocks = [{
|
|
3
|
+
id: "a1",
|
|
4
|
+
type: "annotation",
|
|
5
|
+
data: {
|
|
6
|
+
groupColor: "",
|
|
7
|
+
groupId: "0",
|
|
8
|
+
labelName: "text",
|
|
9
|
+
text: "First part of text."
|
|
10
|
+
}
|
|
11
|
+
}, {
|
|
12
|
+
id: "a2",
|
|
13
|
+
type: "annotation",
|
|
14
|
+
data: {
|
|
15
|
+
groupColor: "",
|
|
16
|
+
groupId: "0",
|
|
17
|
+
labelName: "interview",
|
|
18
|
+
text: "First part of interview."
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
id: "a3",
|
|
22
|
+
type: "annotation",
|
|
23
|
+
data: {
|
|
24
|
+
groupColor: "",
|
|
25
|
+
groupId: "0",
|
|
26
|
+
labelName: "title",
|
|
27
|
+
text: "Tohle je jeden kus title."
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
id: "a4",
|
|
31
|
+
type: "annotation",
|
|
32
|
+
data: {
|
|
33
|
+
groupColor: "",
|
|
34
|
+
groupId: "0",
|
|
35
|
+
labelName: "text",
|
|
36
|
+
text: "Second part of text. Hippo-"
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
id: "a5",
|
|
40
|
+
type: "annotation",
|
|
41
|
+
data: {
|
|
42
|
+
groupColor: "",
|
|
43
|
+
groupId: "0",
|
|
44
|
+
labelName: "text",
|
|
45
|
+
text: "potamus is a big animal."
|
|
46
|
+
}
|
|
47
|
+
}];
|
|
48
|
+
test('blocksToArticle', function () {
|
|
49
|
+
var article = blocksToArticle(blocks);
|
|
50
|
+
expect(article).toEqual({
|
|
51
|
+
title: "Tohle je jeden kus title.",
|
|
52
|
+
text: "First part of text. First part of interview. Second part of text. Hippopotamus is a big animal."
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var reacalcActionsEnum = ["MOUSE_UP_RESIZE_BOX", "DELETE_REGION", "DELETE_GROUP", "MOUSE_UP_MOVE_REGION"];
|
|
2
|
-
var saveableActionsEnum = [reacalcActionsEnum, "
|
|
1
|
+
var reacalcActionsEnum = ["MOUSE_UP_RESIZE_BOX", "DELETE_REGION", "DELETE_GROUP", "MOUSE_UP_MOVE_REGION", "SELECT_CLASSIFICATION", "CHANGE_REGION"];
|
|
2
|
+
var saveableActionsEnum = [reacalcActionsEnum, "UPDATE_REGIONS", "UPDATE_METADATA", "UPDATE_ALBUM_METADATA"];
|
|
3
3
|
export { saveableActionsEnum, reacalcActionsEnum };
|