@searpent/react-image-annotate 2.0.65 → 2.0.67
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.
|
@@ -55,7 +55,8 @@ function () {
|
|
|
55
55
|
block: this.api.styles.block,
|
|
56
56
|
settingsButton: this.api.styles.settingsButton,
|
|
57
57
|
settingsButtonActive: this.api.styles.settingsButtonActive,
|
|
58
|
-
wrapper: 'ce-header'
|
|
58
|
+
wrapper: 'ce-header',
|
|
59
|
+
backgroundColor: (data === null || data === void 0 ? void 0 : data.highlighted) && (data === null || data === void 0 ? void 0 : data.clsColor) ? data.clsColor : undefined
|
|
59
60
|
};
|
|
60
61
|
/**
|
|
61
62
|
* Tool's settings passed from Editor
|
|
@@ -273,8 +274,8 @@ function () {
|
|
|
273
274
|
*/
|
|
274
275
|
var tag = document.createElement(this.currentLabel.tag);
|
|
275
276
|
|
|
276
|
-
if (this.
|
|
277
|
-
tag.style.backgroundColor = this.
|
|
277
|
+
if (this._CSS.backgroundColor) {
|
|
278
|
+
tag.style.backgroundColor = this._CSS.backgroundColor;
|
|
278
279
|
}
|
|
279
280
|
/**
|
|
280
281
|
* Add text to block
|
|
@@ -505,60 +506,73 @@ function () {
|
|
|
505
506
|
var availableLabels = [{
|
|
506
507
|
labelName: 'title',
|
|
507
508
|
tag: 'h1',
|
|
508
|
-
name: 'title'
|
|
509
|
-
|
|
509
|
+
name: 'title',
|
|
510
|
+
backgroundColor: '#ffcccc'
|
|
510
511
|
}, {
|
|
511
512
|
labelName: 'subtitle',
|
|
512
513
|
tag: 'h2',
|
|
513
|
-
name: 'subtitle'
|
|
514
|
+
name: 'subtitle',
|
|
515
|
+
backgroundColor: '#ffccff'
|
|
514
516
|
}, {
|
|
515
517
|
labelName: 'text',
|
|
516
518
|
tag: 'p',
|
|
517
|
-
name: 'text'
|
|
519
|
+
name: 'text',
|
|
520
|
+
backgroundColor: '#14deef'
|
|
518
521
|
}, {
|
|
519
522
|
labelName: 'author',
|
|
520
523
|
tag: 'i',
|
|
521
|
-
name: 'author'
|
|
524
|
+
name: 'author',
|
|
525
|
+
backgroundColor: '#00bb00'
|
|
522
526
|
}, {
|
|
523
527
|
labelName: 'appendix',
|
|
524
528
|
tag: 'p',
|
|
525
|
-
name: 'appendix'
|
|
529
|
+
name: 'appendix',
|
|
530
|
+
backgroundColor: '#dcfcec'
|
|
526
531
|
}, {
|
|
527
532
|
labelName: 'photo_author',
|
|
528
533
|
tag: 'p',
|
|
529
|
-
name: 'photo_author'
|
|
534
|
+
name: 'photo_author',
|
|
535
|
+
backgroundColor: '#bb0000'
|
|
530
536
|
}, {
|
|
531
537
|
labelName: 'photo_caption',
|
|
532
538
|
tag: 'p',
|
|
533
|
-
name: 'photo_caption'
|
|
539
|
+
name: 'photo_caption',
|
|
540
|
+
backgroundColor: '#ccffff'
|
|
534
541
|
}, {
|
|
535
542
|
labelName: 'advertisement',
|
|
536
543
|
tag: 'p',
|
|
537
|
-
name: 'advertisement'
|
|
544
|
+
name: 'advertisement',
|
|
545
|
+
backgroundColor: '#ffeccc'
|
|
538
546
|
}, {
|
|
539
547
|
labelName: 'other_graphics',
|
|
540
548
|
tag: 'p',
|
|
541
|
-
name: 'other_graphics'
|
|
549
|
+
name: 'other_graphics',
|
|
550
|
+
backgroundColor: '#ff5400'
|
|
542
551
|
}, {
|
|
543
552
|
labelName: 'unknown',
|
|
544
553
|
tag: 's',
|
|
545
|
-
name: 'unknown'
|
|
554
|
+
name: 'unknown',
|
|
555
|
+
backgroundColor: '#cccccc'
|
|
546
556
|
}, {
|
|
547
557
|
labelName: 'about_author',
|
|
548
558
|
tag: 'p',
|
|
549
|
-
name: 'about_author'
|
|
559
|
+
name: 'about_author',
|
|
560
|
+
backgroundColor: '#ecffec'
|
|
550
561
|
}, {
|
|
551
562
|
labelName: 'image',
|
|
552
563
|
tag: 'p',
|
|
553
|
-
name: 'image'
|
|
564
|
+
name: 'image',
|
|
565
|
+
backgroundColor: '#ffffcc'
|
|
554
566
|
}, {
|
|
555
567
|
labelName: 'interview',
|
|
556
568
|
tag: 'p',
|
|
557
|
-
name: 'interview'
|
|
569
|
+
name: 'interview',
|
|
570
|
+
backgroundColor: '#23b20f'
|
|
558
571
|
}, {
|
|
559
572
|
labelName: 'table',
|
|
560
573
|
tag: 'p',
|
|
561
|
-
name: 'table'
|
|
574
|
+
name: 'table',
|
|
575
|
+
backgroundColor: '#0000bb'
|
|
562
576
|
}];
|
|
563
577
|
return this._settings.labels ? availableLabels.filter(function (l) {
|
|
564
578
|
return _this5._settings.labels.includes(l.labelName);
|
package/Editor/index.js
CHANGED
|
@@ -12,7 +12,8 @@ function Editor(_ref) {
|
|
|
12
12
|
var _ref$blocks = _ref.blocks,
|
|
13
13
|
blocks = _ref$blocks === void 0 ? [] : _ref$blocks,
|
|
14
14
|
onChange = _ref.onChange,
|
|
15
|
-
imageIndex = _ref.imageIndex
|
|
15
|
+
imageIndex = _ref.imageIndex,
|
|
16
|
+
selectedFrame = _ref.selectedFrame;
|
|
16
17
|
|
|
17
18
|
var _useState = useState(false),
|
|
18
19
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -84,7 +85,8 @@ function Editor(_ref) {
|
|
|
84
85
|
},
|
|
85
86
|
tools: EDITOR_JS_TOOLS,
|
|
86
87
|
onChange: handleChange,
|
|
87
|
-
enableReInitialize: true
|
|
88
|
+
enableReInitialize: true,
|
|
89
|
+
key: selectedFrame
|
|
88
90
|
}));
|
|
89
91
|
}
|
|
90
92
|
|
package/MainLayout/index.js
CHANGED
|
@@ -39,7 +39,8 @@ import regionsGroups from '../utils/regions-groups';
|
|
|
39
39
|
import RightSidebarItemsWrapper from './RightSidebarItemsWrapper';
|
|
40
40
|
import Locker from '../Locker';
|
|
41
41
|
import { reacalcActionsEnum } from "../utils/saveable-actions-enum";
|
|
42
|
-
import intersection from "lodash/intersection";
|
|
42
|
+
import intersection from "lodash/intersection";
|
|
43
|
+
import useColors from '../hooks/use-colors'; // import Fullscreen from "../Fullscreen"
|
|
43
44
|
|
|
44
45
|
var emptyArr = [];
|
|
45
46
|
var theme = createTheme();
|
|
@@ -87,7 +88,7 @@ var EditorWrapper = styled("div")(function (_ref4) {
|
|
|
87
88
|
};
|
|
88
89
|
});
|
|
89
90
|
export var MainLayout = function MainLayout(_ref5) {
|
|
90
|
-
var _state$images$state$s, _state$images$state$s2, _state$images$state$s3;
|
|
91
|
+
var _state$images$state$s, _state$images$state$s2, _state$images$state$s3, _state$images$state$s4, _state$images$state$s5;
|
|
91
92
|
|
|
92
93
|
var state = _ref5.state,
|
|
93
94
|
dispatch = _ref5.dispatch,
|
|
@@ -133,6 +134,10 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
133
134
|
var classes = useStyles();
|
|
134
135
|
var settings = useSettings();
|
|
135
136
|
var fullScreenHandle = useFullScreenHandle();
|
|
137
|
+
|
|
138
|
+
var _useColors = useColors(),
|
|
139
|
+
clsColor = _useColors.clsColor;
|
|
140
|
+
|
|
136
141
|
var memoizedActionFns = useRef({});
|
|
137
142
|
|
|
138
143
|
var action = function action(type) {
|
|
@@ -268,7 +273,7 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
268
273
|
var extractionEngineRegions = (((_state$images$state$s2 = state.images[state.selectedImage]) === null || _state$images$state$s2 === void 0 ? void 0 : _state$images$state$s2.regions) || []).filter(function (r) {
|
|
269
274
|
return r.cls !== 'metadata';
|
|
270
275
|
});
|
|
271
|
-
var editorBlocks = regionsToBlocks(extractionEngineRegions);
|
|
276
|
+
var editorBlocks = regionsToBlocks(extractionEngineRegions, clsColor);
|
|
272
277
|
var blocks = editorBlocks.filter(function (i) {
|
|
273
278
|
var _i$data;
|
|
274
279
|
|
|
@@ -317,6 +322,9 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
317
322
|
};
|
|
318
323
|
|
|
319
324
|
var isSelectedImageLocked = ((_state$images$state$s3 = state.images[state.selectedImage]) === null || _state$images$state$s3 === void 0 ? void 0 : _state$images$state$s3.lockedUntil) ? true : false;
|
|
325
|
+
var selectedFrame = ((_state$images$state$s4 = state.images[state.selectedImage]) === null || _state$images$state$s4 === void 0 ? void 0 : (_state$images$state$s5 = _state$images$state$s4.regions.find(function (i) {
|
|
326
|
+
return i.highlighted === true;
|
|
327
|
+
})) === null || _state$images$state$s5 === void 0 ? void 0 : _state$images$state$s5.id) || '';
|
|
320
328
|
return React.createElement(ThemeProvider, {
|
|
321
329
|
theme: theme
|
|
322
330
|
}, React.createElement(FullScreenContainer, null, React.createElement(FullScreen, {
|
|
@@ -498,6 +506,7 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
498
506
|
blocks: blocks,
|
|
499
507
|
imageIndex: state.selectedImage,
|
|
500
508
|
key: "".concat(state.selectedImage, "#").concat(selectedGroupId),
|
|
509
|
+
selectedFrame: selectedFrame,
|
|
501
510
|
onChange: handleEditorChange
|
|
502
511
|
}))), React.createElement(SettingsDialog, {
|
|
503
512
|
open: state.settingsOpen,
|
package/package.json
CHANGED
package/utils/regions-groups.js
CHANGED
|
@@ -6,6 +6,8 @@ function regionsGroups(regions) {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
var groups = regions.reduce(function (acc, curr) {
|
|
9
|
+
var _curr$text;
|
|
10
|
+
|
|
9
11
|
var groupId = curr.groupId;
|
|
10
12
|
|
|
11
13
|
if (acc.some(function (e) {
|
|
@@ -16,7 +18,7 @@ function regionsGroups(regions) {
|
|
|
16
18
|
|
|
17
19
|
acc.push({
|
|
18
20
|
id: groupId,
|
|
19
|
-
label: curr.text.substring(0, MAX_GROUP_LENGTH)
|
|
21
|
+
label: (curr === null || curr === void 0 ? void 0 : (_curr$text = curr.text) === null || _curr$text === void 0 ? void 0 : _curr$text.substring(0, MAX_GROUP_LENGTH)) || groupId
|
|
20
22
|
});
|
|
21
23
|
return acc;
|
|
22
24
|
}, []);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function regionsToBlocks(regions) {
|
|
1
|
+
function regionsToBlocks(regions, clsColor) {
|
|
2
2
|
return regions.map(function (r) {
|
|
3
3
|
return {
|
|
4
4
|
id: r.id,
|
|
@@ -7,7 +7,9 @@ function regionsToBlocks(regions) {
|
|
|
7
7
|
text: r.text || '',
|
|
8
8
|
labelName: r.cls,
|
|
9
9
|
groupColor: r.groupColor,
|
|
10
|
-
groupId: r.groupId
|
|
10
|
+
groupId: r.groupId,
|
|
11
|
+
clsColor: clsColor(r.cls),
|
|
12
|
+
highlighted: r.highlighted
|
|
11
13
|
}
|
|
12
14
|
};
|
|
13
15
|
});
|