@searpent/react-image-annotate 2.0.59 → 2.0.61
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.
|
@@ -599,7 +599,7 @@ var examplePhotos = [{
|
|
|
599
599
|
"Y1": 0.38327134,
|
|
600
600
|
"Y2": 0.5264345
|
|
601
601
|
},
|
|
602
|
-
"text": "[{\"label\":\"text\",\"text\":\"
|
|
602
|
+
"text": "[{\"label\":\"text\",\"text\":\"\\tUž popáté se \\n\\nv 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
|
}, {
|
|
@@ -51,4 +51,44 @@ button.MuiButtonBase-root {
|
|
|
51
51
|
|
|
52
52
|
button.MuiButtonBase-root.expanded {
|
|
53
53
|
opacity: 1 !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.ro-title {}
|
|
57
|
+
|
|
58
|
+
.ro-subtitle {}
|
|
59
|
+
|
|
60
|
+
.ro-text {}
|
|
61
|
+
|
|
62
|
+
.ro-author {
|
|
63
|
+
font-style: italic;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ro-about-author {
|
|
67
|
+
font-style: italic;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ro-appendix {}
|
|
71
|
+
|
|
72
|
+
.ro-photo-author {}
|
|
73
|
+
|
|
74
|
+
.ro-photo-caption {}
|
|
75
|
+
|
|
76
|
+
.ro-advertisment {}
|
|
77
|
+
|
|
78
|
+
.ro-other-graphics {}
|
|
79
|
+
|
|
80
|
+
.ro-unknown {}
|
|
81
|
+
|
|
82
|
+
.ro-table {}
|
|
83
|
+
|
|
84
|
+
.instructions {
|
|
85
|
+
height: 100%;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
align-items: center;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.instructions h1 {
|
|
93
|
+
color: #707684;
|
|
54
94
|
}
|
|
@@ -5,8 +5,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
5
5
|
* Build styles
|
|
6
6
|
*/
|
|
7
7
|
import './annotation.css';
|
|
8
|
-
|
|
9
|
-
function whitespaceCharactersToHTML() {
|
|
8
|
+
export function whitespaceCharactersToHTML() {
|
|
10
9
|
var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
11
10
|
return str // new line whitespace
|
|
12
11
|
.replaceAll(/[ ]\n[ ]/gm, ' <br> ') // space both sides adds
|
package/Editor/index.js
CHANGED
|
@@ -9,14 +9,15 @@ import ReadOnly from './readOnly';
|
|
|
9
9
|
var ReactEditorJS = createReactEditorJS();
|
|
10
10
|
|
|
11
11
|
function Editor(_ref) {
|
|
12
|
-
var blocks = _ref.blocks,
|
|
12
|
+
var _ref$blocks = _ref.blocks,
|
|
13
|
+
blocks = _ref$blocks === void 0 ? [] : _ref$blocks,
|
|
13
14
|
onChange = _ref.onChange,
|
|
14
15
|
imageIndex = _ref.imageIndex;
|
|
15
16
|
|
|
16
17
|
var _useState = useState(false),
|
|
17
18
|
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
editMode = _useState2[0],
|
|
20
|
+
setEditMode = _useState2[1];
|
|
20
21
|
|
|
21
22
|
var handleChange =
|
|
22
23
|
/*#__PURE__*/
|
|
@@ -52,12 +53,18 @@ function Editor(_ref) {
|
|
|
52
53
|
};
|
|
53
54
|
}();
|
|
54
55
|
|
|
55
|
-
var
|
|
56
|
-
|
|
56
|
+
var toggleEditMode = function toggleEditMode() {
|
|
57
|
+
setEditMode(function (prev) {
|
|
57
58
|
return !prev;
|
|
58
59
|
});
|
|
59
60
|
};
|
|
60
61
|
|
|
62
|
+
if (blocks.length < 1) {
|
|
63
|
+
return React.createElement("div", {
|
|
64
|
+
className: "instructions"
|
|
65
|
+
}, React.createElement("h1", null, "Click article to display text."));
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
return React.createElement("div", null, React.createElement("div", {
|
|
62
69
|
className: "show-metadata-wrapper"
|
|
63
70
|
}, React.createElement("label", {
|
|
@@ -65,11 +72,11 @@ function Editor(_ref) {
|
|
|
65
72
|
}, React.createElement("input", {
|
|
66
73
|
id: "show-metadata",
|
|
67
74
|
type: "checkbox",
|
|
68
|
-
value:
|
|
69
|
-
onChange:
|
|
75
|
+
value: editMode,
|
|
76
|
+
onChange: toggleEditMode
|
|
70
77
|
}), React.createElement("span", {
|
|
71
78
|
className: "slider round"
|
|
72
|
-
})), React.createElement("label", null, "
|
|
79
|
+
})), React.createElement("label", null, "Edit mode")), !editMode ? React.createElement(ReadOnly, {
|
|
73
80
|
article: blocksToArticle(blocks)
|
|
74
81
|
}) : React.createElement(ReactEditorJS, {
|
|
75
82
|
defaultValue: {
|
package/Editor/readOnly.js
CHANGED
|
@@ -2,7 +2,67 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
function ReadOnly(_ref) {
|
|
4
4
|
var article = _ref.article;
|
|
5
|
-
return React.createElement("div", null, React.createElement("h1",
|
|
5
|
+
return React.createElement("div", null, React.createElement("h1", {
|
|
6
|
+
className: "ro-title",
|
|
7
|
+
dangerouslySetInnerHTML: {
|
|
8
|
+
__html: article.title
|
|
9
|
+
}
|
|
10
|
+
}), React.createElement("h2", {
|
|
11
|
+
className: "ro-subtitle",
|
|
12
|
+
dangerouslySetInnerHTML: {
|
|
13
|
+
__html: article.subtitle
|
|
14
|
+
}
|
|
15
|
+
}), React.createElement("p", {
|
|
16
|
+
className: "ro-text",
|
|
17
|
+
dangerouslySetInnerHTML: {
|
|
18
|
+
__html: article.text
|
|
19
|
+
}
|
|
20
|
+
}), React.createElement("p", {
|
|
21
|
+
className: "ro-author",
|
|
22
|
+
dangerouslySetInnerHTML: {
|
|
23
|
+
__html: article.author
|
|
24
|
+
}
|
|
25
|
+
}), React.createElement("p", {
|
|
26
|
+
className: "ro-about-author",
|
|
27
|
+
dangerouslySetInnerHTML: {
|
|
28
|
+
__html: article.about_author
|
|
29
|
+
}
|
|
30
|
+
}), React.createElement("p", {
|
|
31
|
+
className: "ro-appendix",
|
|
32
|
+
dangerouslySetInnerHTML: {
|
|
33
|
+
__html: article.appendix
|
|
34
|
+
}
|
|
35
|
+
}), React.createElement("p", {
|
|
36
|
+
className: "ro-photo-author",
|
|
37
|
+
dangerouslySetInnerHTML: {
|
|
38
|
+
__html: article.photo_author
|
|
39
|
+
}
|
|
40
|
+
}), React.createElement("p", {
|
|
41
|
+
className: "ro-photo-caption",
|
|
42
|
+
dangerouslySetInnerHTML: {
|
|
43
|
+
__html: article.photo_caption
|
|
44
|
+
}
|
|
45
|
+
}), React.createElement("p", {
|
|
46
|
+
className: "ro-advertisment",
|
|
47
|
+
dangerouslySetInnerHTML: {
|
|
48
|
+
__html: article.advertisement
|
|
49
|
+
}
|
|
50
|
+
}), React.createElement("p", {
|
|
51
|
+
className: "ro-other-graphics",
|
|
52
|
+
dangerouslySetInnerHTML: {
|
|
53
|
+
__html: article.other_graphics
|
|
54
|
+
}
|
|
55
|
+
}), React.createElement("p", {
|
|
56
|
+
className: "ro-unknown",
|
|
57
|
+
dangerouslySetInnerHTML: {
|
|
58
|
+
__html: article.unknown
|
|
59
|
+
}
|
|
60
|
+
}), React.createElement("p", {
|
|
61
|
+
className: "ro-table",
|
|
62
|
+
dangerouslySetInnerHTML: {
|
|
63
|
+
__html: article.table
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
6
66
|
}
|
|
7
67
|
|
|
8
68
|
export default ReadOnly;
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
+
import { whitespaceCharactersToHTML } from '../Editor/annotation-plugin/annotation';
|
|
2
3
|
|
|
3
4
|
function sanitizedText(text) {
|
|
4
|
-
// remove whitespaces
|
|
5
|
-
|
|
5
|
+
var escapedWhitespaces = whitespaceCharactersToHTML(text); // remove whitespaces
|
|
6
|
+
|
|
7
|
+
var trimmed = escapedWhitespaces.trim(); // replace dashes at the end of sentence
|
|
6
8
|
|
|
7
9
|
var noTrailingDash = trimmed.replace(/-$/, "");
|
|
8
10
|
return noTrailingDash;
|
|
@@ -10,13 +12,13 @@ function sanitizedText(text) {
|
|
|
10
12
|
|
|
11
13
|
function blocksToArticle(blocks) {
|
|
12
14
|
var renamedBlocks = blocks.map(function (b) {
|
|
13
|
-
var newBlock = _objectSpread({}, b
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
15
|
+
var newBlock = _objectSpread({}, b, {
|
|
16
|
+
data: _objectSpread({}, b.data, {
|
|
17
|
+
labelName: b.data.labelName === 'interview' ? 'text' : b.data.labelName
|
|
18
|
+
})
|
|
19
|
+
});
|
|
18
20
|
|
|
19
|
-
return
|
|
21
|
+
return newBlock;
|
|
20
22
|
});
|
|
21
23
|
var article = renamedBlocks.reduce(function (acc, curr) {
|
|
22
24
|
var _ref = curr === null || curr === void 0 ? void 0 : curr.data,
|