@searpent/react-image-annotate 2.0.24 → 2.0.26
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/index.js +75 -89
- package/Annotator/reducers/general-reducer.js +69 -21
- package/HelpSidebarBox/index.js +58 -0
- package/HighlightBox/index.js +3 -1
- package/MainLayout/index.js +12 -4
- package/PageSelector/page-selector.css +1 -1
- package/package.json +1 -1
- package/utils/next-group-id.js +13 -0
- package/utils/regions-groups.js +19 -0
package/Annotator/index.js
CHANGED
|
@@ -13,83 +13,70 @@ import historyHandler from "./reducers/history-handler.js";
|
|
|
13
13
|
import imageReducer from "./reducers/image-reducer.js";
|
|
14
14
|
import useEventCallback from "use-event-callback";
|
|
15
15
|
import videoReducer from "./reducers/video-reducer.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_ref2$fullImageSegmen = _ref2.fullImageSegmentationMode,
|
|
57
|
-
fullImageSegmentationMode = _ref2$fullImageSegmen === void 0 ? false : _ref2$fullImageSegmen,
|
|
58
|
-
RegionEditLabel = _ref2.RegionEditLabel,
|
|
59
|
-
videoSrc = _ref2.videoSrc,
|
|
60
|
-
_ref2$videoTime = _ref2.videoTime,
|
|
61
|
-
videoTime = _ref2$videoTime === void 0 ? 0 : _ref2$videoTime,
|
|
62
|
-
videoName = _ref2.videoName,
|
|
63
|
-
onExit = _ref2.onExit,
|
|
64
|
-
onNextImage = _ref2.onNextImage,
|
|
65
|
-
onPrevImage = _ref2.onPrevImage,
|
|
66
|
-
keypointDefinitions = _ref2.keypointDefinitions,
|
|
67
|
-
_ref2$autoSegmentatio = _ref2.autoSegmentationOptions,
|
|
68
|
-
autoSegmentationOptions = _ref2$autoSegmentatio === void 0 ? {
|
|
16
|
+
export var Annotator = function Annotator(_ref) {
|
|
17
|
+
var images = _ref.images,
|
|
18
|
+
allowedArea = _ref.allowedArea,
|
|
19
|
+
_ref$selectedImage = _ref.selectedImage,
|
|
20
|
+
selectedImage = _ref$selectedImage === void 0 ? images && images.length > 0 ? 0 : undefined : _ref$selectedImage,
|
|
21
|
+
showPointDistances = _ref.showPointDistances,
|
|
22
|
+
pointDistancePrecision = _ref.pointDistancePrecision,
|
|
23
|
+
_ref$showTags = _ref.showTags,
|
|
24
|
+
showTags = _ref$showTags === void 0 ? getFromLocalStorage("showTags", true) : _ref$showTags,
|
|
25
|
+
_ref$enabledTools = _ref.enabledTools,
|
|
26
|
+
enabledTools = _ref$enabledTools === void 0 ? ["select", "create-point", "create-box", "create-polygon", "create-line", "create-expanding-line", "show-mask"] : _ref$enabledTools,
|
|
27
|
+
_ref$selectedTool = _ref.selectedTool,
|
|
28
|
+
selectedTool = _ref$selectedTool === void 0 ? "select" : _ref$selectedTool,
|
|
29
|
+
_ref$regionTagList = _ref.regionTagList,
|
|
30
|
+
regionTagList = _ref$regionTagList === void 0 ? [] : _ref$regionTagList,
|
|
31
|
+
_ref$regionClsList = _ref.regionClsList,
|
|
32
|
+
regionClsList = _ref$regionClsList === void 0 ? [] : _ref$regionClsList,
|
|
33
|
+
_ref$imageTagList = _ref.imageTagList,
|
|
34
|
+
imageTagList = _ref$imageTagList === void 0 ? [] : _ref$imageTagList,
|
|
35
|
+
_ref$imageClsList = _ref.imageClsList,
|
|
36
|
+
imageClsList = _ref$imageClsList === void 0 ? [] : _ref$imageClsList,
|
|
37
|
+
_ref$keyframes = _ref.keyframes,
|
|
38
|
+
keyframes = _ref$keyframes === void 0 ? {} : _ref$keyframes,
|
|
39
|
+
_ref$taskDescription = _ref.taskDescription,
|
|
40
|
+
taskDescription = _ref$taskDescription === void 0 ? "" : _ref$taskDescription,
|
|
41
|
+
_ref$help = _ref.help,
|
|
42
|
+
help = _ref$help === void 0 ? "" : _ref$help,
|
|
43
|
+
_ref$fullImageSegment = _ref.fullImageSegmentationMode,
|
|
44
|
+
fullImageSegmentationMode = _ref$fullImageSegment === void 0 ? false : _ref$fullImageSegment,
|
|
45
|
+
RegionEditLabel = _ref.RegionEditLabel,
|
|
46
|
+
videoSrc = _ref.videoSrc,
|
|
47
|
+
_ref$videoTime = _ref.videoTime,
|
|
48
|
+
videoTime = _ref$videoTime === void 0 ? 0 : _ref$videoTime,
|
|
49
|
+
videoName = _ref.videoName,
|
|
50
|
+
onExit = _ref.onExit,
|
|
51
|
+
onNextImage = _ref.onNextImage,
|
|
52
|
+
onPrevImage = _ref.onPrevImage,
|
|
53
|
+
keypointDefinitions = _ref.keypointDefinitions,
|
|
54
|
+
_ref$autoSegmentation = _ref.autoSegmentationOptions,
|
|
55
|
+
autoSegmentationOptions = _ref$autoSegmentation === void 0 ? {
|
|
69
56
|
type: "autoseg"
|
|
70
|
-
} :
|
|
71
|
-
hideHeader =
|
|
72
|
-
hideHeaderText =
|
|
73
|
-
hideNext =
|
|
74
|
-
hidePrev =
|
|
75
|
-
hideClone =
|
|
76
|
-
hideSettings =
|
|
77
|
-
hideFullScreen =
|
|
78
|
-
hideSave =
|
|
79
|
-
allowComments =
|
|
80
|
-
onImagesChange =
|
|
81
|
-
groups =
|
|
82
|
-
onGroupSelect =
|
|
83
|
-
hideHistory =
|
|
84
|
-
hideNotEditingLabel =
|
|
85
|
-
showEditor =
|
|
86
|
-
showPageSelector =
|
|
87
|
-
|
|
88
|
-
clsColors =
|
|
89
|
-
groupColors =
|
|
90
|
-
onRecalc =
|
|
91
|
-
onSave =
|
|
92
|
-
metadata =
|
|
57
|
+
} : _ref$autoSegmentation,
|
|
58
|
+
hideHeader = _ref.hideHeader,
|
|
59
|
+
hideHeaderText = _ref.hideHeaderText,
|
|
60
|
+
hideNext = _ref.hideNext,
|
|
61
|
+
hidePrev = _ref.hidePrev,
|
|
62
|
+
hideClone = _ref.hideClone,
|
|
63
|
+
hideSettings = _ref.hideSettings,
|
|
64
|
+
hideFullScreen = _ref.hideFullScreen,
|
|
65
|
+
hideSave = _ref.hideSave,
|
|
66
|
+
allowComments = _ref.allowComments,
|
|
67
|
+
onImagesChange = _ref.onImagesChange,
|
|
68
|
+
groups = _ref.groups,
|
|
69
|
+
onGroupSelect = _ref.onGroupSelect,
|
|
70
|
+
hideHistory = _ref.hideHistory,
|
|
71
|
+
hideNotEditingLabel = _ref.hideNotEditingLabel,
|
|
72
|
+
showEditor = _ref.showEditor,
|
|
73
|
+
showPageSelector = _ref.showPageSelector,
|
|
74
|
+
_ref$clsColors = _ref.clsColors,
|
|
75
|
+
clsColors = _ref$clsColors === void 0 ? {} : _ref$clsColors,
|
|
76
|
+
groupColors = _ref.groupColors,
|
|
77
|
+
onRecalc = _ref.onRecalc,
|
|
78
|
+
onSave = _ref.onSave,
|
|
79
|
+
metadata = _ref.metadata;
|
|
93
80
|
|
|
94
81
|
if (typeof selectedImage === "string") {
|
|
95
82
|
selectedImage = (images || []).findIndex(function (img) {
|
|
@@ -98,7 +85,6 @@ export var Annotator = function Annotator(_ref2) {
|
|
|
98
85
|
if (selectedImage === -1) selectedImage = undefined;
|
|
99
86
|
}
|
|
100
87
|
|
|
101
|
-
var allowedGroups = extractAllowedGroups(images);
|
|
102
88
|
var annotationType = images ? "image" : "video";
|
|
103
89
|
|
|
104
90
|
var _useReducer = useReducer(historyHandler(combineReducers(annotationType === "image" ? imageReducer : videoReducer, generalReducer)), makeImmutable(_objectSpread({
|
|
@@ -112,6 +98,7 @@ export var Annotator = function Annotator(_ref2) {
|
|
|
112
98
|
autoSegmentationOptions: autoSegmentationOptions,
|
|
113
99
|
mode: null,
|
|
114
100
|
taskDescription: taskDescription,
|
|
101
|
+
help: help,
|
|
115
102
|
showMask: true,
|
|
116
103
|
labelImages: imageClsList.length > 0 || imageTagList.length > 0,
|
|
117
104
|
regionClsList: regionClsList,
|
|
@@ -134,8 +121,7 @@ export var Annotator = function Annotator(_ref2) {
|
|
|
134
121
|
}, {
|
|
135
122
|
imagesUpdatedAt: null,
|
|
136
123
|
imagesSavedAt: null,
|
|
137
|
-
metadata: metadata
|
|
138
|
-
allowedGroups: allowedGroups || []
|
|
124
|
+
metadata: metadata
|
|
139
125
|
}))),
|
|
140
126
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
141
127
|
state = _useReducer2[0],
|
|
@@ -164,7 +150,7 @@ export var Annotator = function Annotator(_ref2) {
|
|
|
164
150
|
var handleSaveClick =
|
|
165
151
|
/*#__PURE__*/
|
|
166
152
|
function () {
|
|
167
|
-
var
|
|
153
|
+
var _ref2 = _asyncToGenerator(
|
|
168
154
|
/*#__PURE__*/
|
|
169
155
|
_regeneratorRuntime.mark(function _callee(e) {
|
|
170
156
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -196,7 +182,7 @@ export var Annotator = function Annotator(_ref2) {
|
|
|
196
182
|
}));
|
|
197
183
|
|
|
198
184
|
return function handleSaveClick(_x) {
|
|
199
|
-
return
|
|
185
|
+
return _ref2.apply(this, arguments);
|
|
200
186
|
};
|
|
201
187
|
}();
|
|
202
188
|
|
|
@@ -208,10 +194,10 @@ export var Annotator = function Annotator(_ref2) {
|
|
|
208
194
|
}
|
|
209
195
|
};
|
|
210
196
|
|
|
211
|
-
var handleMetadataChange = function handleMetadataChange(
|
|
212
|
-
var name =
|
|
213
|
-
value =
|
|
214
|
-
imageIndex =
|
|
197
|
+
var handleMetadataChange = function handleMetadataChange(_ref3) {
|
|
198
|
+
var name = _ref3.name,
|
|
199
|
+
value = _ref3.value,
|
|
200
|
+
imageIndex = _ref3.imageIndex;
|
|
215
201
|
dispatchToReducer({
|
|
216
202
|
type: "UPDATE_METADATA",
|
|
217
203
|
name: name,
|
|
@@ -252,10 +238,10 @@ export var Annotator = function Annotator(_ref2) {
|
|
|
252
238
|
}, [onImagesChange, selectedImage]);
|
|
253
239
|
if (!images && !videoSrc) return 'Missing required prop "images" or "videoSrc"';
|
|
254
240
|
|
|
255
|
-
var
|
|
256
|
-
|
|
257
|
-
recalcActive =
|
|
258
|
-
saveActive =
|
|
241
|
+
var _ref4 = state.imagesSavedAt < state.imagesUpdatedAt ? [true, true] : [false, false],
|
|
242
|
+
_ref5 = _slicedToArray(_ref4, 2),
|
|
243
|
+
recalcActive = _ref5[0],
|
|
244
|
+
saveActive = _ref5[1];
|
|
259
245
|
|
|
260
246
|
return React.createElement(SettingsProvider, {
|
|
261
247
|
clsColors: clsColors,
|
|
@@ -14,6 +14,8 @@ import clamp from "clamp";
|
|
|
14
14
|
import getLandmarksWithTransform from "../../utils/get-landmarks-with-transform";
|
|
15
15
|
import setInLocalStorage from "../../utils/set-in-local-storage";
|
|
16
16
|
import onlyUnique from "../../utils/filter-only-unique";
|
|
17
|
+
import regionsGroups from '../../utils/regions-groups';
|
|
18
|
+
import nextGroupId from "../../utils/next-group-id";
|
|
17
19
|
|
|
18
20
|
var getRandomId = function getRandomId() {
|
|
19
21
|
return Math.random().toString().split(".")[1];
|
|
@@ -128,6 +130,26 @@ export default (function (state, action) {
|
|
|
128
130
|
|
|
129
131
|
case "SELECT_CLASSIFICATION":
|
|
130
132
|
{
|
|
133
|
+
var _state$images$state$s;
|
|
134
|
+
|
|
135
|
+
// if there is selected region, set its cls
|
|
136
|
+
var selectedRegionId = (_state$images$state$s = state.images[state.selectedImage].regions.find(function (r) {
|
|
137
|
+
return r.highlighted === true;
|
|
138
|
+
})) === null || _state$images$state$s === void 0 ? void 0 : _state$images$state$s.id;
|
|
139
|
+
|
|
140
|
+
if (selectedRegionId) {
|
|
141
|
+
var newRegions = activeImage.regions.map(function (r) {
|
|
142
|
+
if (r.id === selectedRegionId) {
|
|
143
|
+
return _objectSpread({}, r, {
|
|
144
|
+
cls: action.cls
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
return r;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
state = setIn(state, [].concat(_toConsumableArray(pathToActiveImage), ["regions"]), newRegions);
|
|
151
|
+
}
|
|
152
|
+
|
|
131
153
|
return setIn(state, ["selectedCls"], action.cls);
|
|
132
154
|
}
|
|
133
155
|
|
|
@@ -185,7 +207,7 @@ export default (function (state, action) {
|
|
|
185
207
|
return _objectSpread({}, r, {
|
|
186
208
|
highlighted: r.id === region.id,
|
|
187
209
|
groupHighlighted: r.groupId && r.groupId === region.groupId ? true : false,
|
|
188
|
-
editingLabels: r.id === region.id
|
|
210
|
+
editingLabels: region.ctrlKey ? r.id === region.id : false
|
|
189
211
|
});
|
|
190
212
|
});
|
|
191
213
|
|
|
@@ -516,6 +538,8 @@ export default (function (state, action) {
|
|
|
516
538
|
|
|
517
539
|
case "MOUSE_DOWN":
|
|
518
540
|
{
|
|
541
|
+
var _state$regionClsList;
|
|
542
|
+
|
|
519
543
|
if (!activeImage) return state;
|
|
520
544
|
var _x = action.x,
|
|
521
545
|
_y = action.y;
|
|
@@ -610,7 +634,7 @@ export default (function (state, action) {
|
|
|
610
634
|
}
|
|
611
635
|
|
|
612
636
|
var newRegion;
|
|
613
|
-
var defaultRegionCls = state.selectedCls,
|
|
637
|
+
var defaultRegionCls = state.selectedCls || ((_state$regionClsList = state.regionClsList) === null || _state$regionClsList === void 0 ? void 0 : _state$regionClsList[0]),
|
|
614
638
|
defaultRegionColor = "#ff0000";
|
|
615
639
|
|
|
616
640
|
var _clsIndex = (state.regionClsList || []).indexOf(defaultRegionCls);
|
|
@@ -638,6 +662,21 @@ export default (function (state, action) {
|
|
|
638
662
|
|
|
639
663
|
case "create-box":
|
|
640
664
|
{
|
|
665
|
+
var _state4, _state4$images$state$, _state4$images$state$2, _state4$images$state$3;
|
|
666
|
+
|
|
667
|
+
var groupId = (_state4 = state) === null || _state4 === void 0 ? void 0 : (_state4$images$state$ = _state4.images[state.selectedImage]) === null || _state4$images$state$ === void 0 ? void 0 : (_state4$images$state$2 = _state4$images$state$.regions) === null || _state4$images$state$2 === void 0 ? void 0 : (_state4$images$state$3 = _state4$images$state$2.find(function (r) {
|
|
668
|
+
return r.highlighted === true;
|
|
669
|
+
})) === null || _state4$images$state$3 === void 0 ? void 0 : _state4$images$state$3.groupId;
|
|
670
|
+
var groupSelected = true;
|
|
671
|
+
|
|
672
|
+
if (isNaN(groupId)) {
|
|
673
|
+
var _state5, _state5$images$state$;
|
|
674
|
+
|
|
675
|
+
var groupIds = regionsGroups((_state5 = state) === null || _state5 === void 0 ? void 0 : (_state5$images$state$ = _state5.images[state.selectedImage]) === null || _state5$images$state$ === void 0 ? void 0 : _state5$images$state$.regions);
|
|
676
|
+
groupId = nextGroupId(groupIds);
|
|
677
|
+
groupSelected = false;
|
|
678
|
+
}
|
|
679
|
+
|
|
641
680
|
state = saveToHistory(state, "Create Box");
|
|
642
681
|
newRegion = {
|
|
643
682
|
type: "box",
|
|
@@ -649,11 +688,13 @@ export default (function (state, action) {
|
|
|
649
688
|
editingLabels: false,
|
|
650
689
|
color: defaultRegionColor,
|
|
651
690
|
cls: defaultRegionCls,
|
|
652
|
-
id: getRandomId()
|
|
691
|
+
id: getRandomId(),
|
|
692
|
+
groupHighlighted: true,
|
|
693
|
+
groupId: groupId
|
|
653
694
|
};
|
|
654
695
|
state = setIn(state, ["mode"], {
|
|
655
696
|
mode: "RESIZE_BOX",
|
|
656
|
-
editLabelEditorAfter:
|
|
697
|
+
editLabelEditorAfter: !groupSelected,
|
|
657
698
|
regionId: newRegion.id,
|
|
658
699
|
freedom: [1, 1],
|
|
659
700
|
original: {
|
|
@@ -778,7 +819,7 @@ export default (function (state, action) {
|
|
|
778
819
|
}
|
|
779
820
|
|
|
780
821
|
var _regions = _toConsumableArray(getIn(state, pathToActiveImage).regions || []).map(function (r) {
|
|
781
|
-
return setIn(r, ["editingLabels"], false).setIn(["highlighted"], false).setIn([
|
|
822
|
+
return setIn(r, ["editingLabels"], false).setIn(["highlighted"], false).setIn([state.selectedTool === 'create-box' ? undefined : 'groupHighlighted'], false);
|
|
782
823
|
}).concat(newRegion ? [newRegion] : []);
|
|
783
824
|
|
|
784
825
|
state = setIn(state, [].concat(_toConsumableArray(pathToActiveImage), ["selectedGroupId"]), null);
|
|
@@ -790,12 +831,12 @@ export default (function (state, action) {
|
|
|
790
831
|
var _x2 = action.x,
|
|
791
832
|
_y2 = action.y;
|
|
792
833
|
|
|
793
|
-
var
|
|
794
|
-
|
|
795
|
-
_mouseDownAt2 =
|
|
834
|
+
var _state6 = state,
|
|
835
|
+
_state6$mouseDownAt = _state6.mouseDownAt,
|
|
836
|
+
_mouseDownAt2 = _state6$mouseDownAt === void 0 ? {
|
|
796
837
|
x: _x2,
|
|
797
838
|
y: _y2
|
|
798
|
-
} :
|
|
839
|
+
} : _state6$mouseDownAt;
|
|
799
840
|
|
|
800
841
|
if (!state.mode) return state;
|
|
801
842
|
state = setIn(state, ["mouseDownAt"], null);
|
|
@@ -892,7 +933,8 @@ export default (function (state, action) {
|
|
|
892
933
|
var _regionIndex16 = getRegionIndex(action.region);
|
|
893
934
|
|
|
894
935
|
if (_regionIndex16 === null) return state;
|
|
895
|
-
|
|
936
|
+
|
|
937
|
+
var _newRegions = setIn(activeImage.regions.map(function (r) {
|
|
896
938
|
return _objectSpread({}, r, {
|
|
897
939
|
highlighted: false,
|
|
898
940
|
editingLabels: false
|
|
@@ -901,7 +943,8 @@ export default (function (state, action) {
|
|
|
901
943
|
highlighted: true,
|
|
902
944
|
editingLabels: true
|
|
903
945
|
}));
|
|
904
|
-
|
|
946
|
+
|
|
947
|
+
return setIn(state, [].concat(_toConsumableArray(pathToActiveImage), ["regions"]), _newRegions);
|
|
905
948
|
}
|
|
906
949
|
|
|
907
950
|
case "CLOSE_REGION_EDITOR":
|
|
@@ -928,10 +971,10 @@ export default (function (state, action) {
|
|
|
928
971
|
|
|
929
972
|
case "DELETE_GROUP":
|
|
930
973
|
{
|
|
931
|
-
var
|
|
932
|
-
if (
|
|
974
|
+
var _groupId = action.groupId;
|
|
975
|
+
if (_groupId === null || _groupId === undefined) return state;
|
|
933
976
|
return setIn(state, [].concat(_toConsumableArray(pathToActiveImage), ["regions"]), (activeImage.regions || []).filter(function (r) {
|
|
934
|
-
return r.groupId !==
|
|
977
|
+
return r.groupId !== _groupId;
|
|
935
978
|
}));
|
|
936
979
|
}
|
|
937
980
|
|
|
@@ -1029,8 +1072,8 @@ export default (function (state, action) {
|
|
|
1029
1072
|
|
|
1030
1073
|
case "CANCEL":
|
|
1031
1074
|
{
|
|
1032
|
-
var
|
|
1033
|
-
mode =
|
|
1075
|
+
var _state7 = state,
|
|
1076
|
+
mode = _state7.mode;
|
|
1034
1077
|
|
|
1035
1078
|
if (mode) {
|
|
1036
1079
|
switch (mode.mode) {
|
|
@@ -1079,9 +1122,9 @@ export default (function (state, action) {
|
|
|
1079
1122
|
case "UPDATE_REGIONS":
|
|
1080
1123
|
{
|
|
1081
1124
|
var imageIndex = action.imageIndex,
|
|
1082
|
-
|
|
1125
|
+
_newRegions2 = action.regions;
|
|
1083
1126
|
var updatedRegions = state.images[imageIndex].regions.map(function (r) {
|
|
1084
|
-
var updatedRegion =
|
|
1127
|
+
var updatedRegion = _newRegions2.find(function (i) {
|
|
1085
1128
|
return i.id === r.id;
|
|
1086
1129
|
});
|
|
1087
1130
|
|
|
@@ -1155,9 +1198,14 @@ export default (function (state, action) {
|
|
|
1155
1198
|
|
|
1156
1199
|
case "ADD_GROUP":
|
|
1157
1200
|
{
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1201
|
+
// FIXME: remove this branch
|
|
1202
|
+
return state; // const { group } = action;
|
|
1203
|
+
// const newAllowedGroups = []
|
|
1204
|
+
// return setIn(
|
|
1205
|
+
// state,
|
|
1206
|
+
// ["allowedGroups"],
|
|
1207
|
+
// newAllowedGroups
|
|
1208
|
+
// )
|
|
1161
1209
|
}
|
|
1162
1210
|
|
|
1163
1211
|
default:
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { memo } from "react";
|
|
2
|
+
import SidebarBoxContainer from "../SidebarBoxContainer";
|
|
3
|
+
import HelpIcon from '@mui/icons-material/Help';
|
|
4
|
+
import { styled } from "@mui/material/styles";
|
|
5
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
6
|
+
import { grey } from "@mui/material/colors";
|
|
7
|
+
import Markdown from "react-markdown";
|
|
8
|
+
var theme = createTheme();
|
|
9
|
+
var MarkdownContainer = styled("div")(function (_ref) {
|
|
10
|
+
var theme = _ref.theme;
|
|
11
|
+
return {
|
|
12
|
+
paddingLeft: 16,
|
|
13
|
+
paddingRight: 16,
|
|
14
|
+
fontSize: 12,
|
|
15
|
+
"& h1": {
|
|
16
|
+
fontSize: 18
|
|
17
|
+
},
|
|
18
|
+
"& h2": {
|
|
19
|
+
fontSize: 14
|
|
20
|
+
},
|
|
21
|
+
"& h3": {
|
|
22
|
+
fontSize: 12
|
|
23
|
+
},
|
|
24
|
+
"& h4": {
|
|
25
|
+
fontSize: 12
|
|
26
|
+
},
|
|
27
|
+
"& h5": {
|
|
28
|
+
fontSize: 12
|
|
29
|
+
},
|
|
30
|
+
"& h6": {
|
|
31
|
+
fontSize: 12
|
|
32
|
+
},
|
|
33
|
+
"& p": {
|
|
34
|
+
fontSize: 12
|
|
35
|
+
},
|
|
36
|
+
"& a": {},
|
|
37
|
+
"& img": {
|
|
38
|
+
width: "100%"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
export var HelpSidebarBox = function HelpSidebarBox(_ref2) {
|
|
43
|
+
var help = _ref2.help;
|
|
44
|
+
return React.createElement(ThemeProvider, {
|
|
45
|
+
theme: theme
|
|
46
|
+
}, React.createElement(SidebarBoxContainer, {
|
|
47
|
+
title: "Help",
|
|
48
|
+
icon: React.createElement(HelpIcon, {
|
|
49
|
+
style: {
|
|
50
|
+
color: grey[700]
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
expandedByDefault: help && help !== "" ? false : true
|
|
54
|
+
}, React.createElement(MarkdownContainer, null, React.createElement(Markdown, {
|
|
55
|
+
source: help
|
|
56
|
+
}))));
|
|
57
|
+
};
|
|
58
|
+
export default memo(HelpSidebarBox);
|
package/HighlightBox/index.js
CHANGED
|
@@ -79,7 +79,9 @@ export var HighlightBox = function HighlightBox(_ref) {
|
|
|
79
79
|
return onBeginMovePoint(r);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
if (e.button === 0 && !createWithPrimary) return onSelectRegion(r
|
|
82
|
+
if (e.button === 0 && !createWithPrimary) return onSelectRegion(_objectSpread({}, r, {
|
|
83
|
+
ctrlKey: e.ctrlKey
|
|
84
|
+
}));
|
|
83
85
|
mouseEvents.onMouseDown(e);
|
|
84
86
|
}
|
|
85
87
|
} : {}, {
|
package/MainLayout/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
import { FullScreen, useFullScreenHandle } from "react-full-screen";
|
|
4
|
-
import React, { useCallback, useRef } from "react";
|
|
4
|
+
import React, { useCallback, useMemo, useRef } from "react";
|
|
5
5
|
import { makeStyles } from "@mui/styles";
|
|
6
6
|
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
7
7
|
import { styled } from "@mui/material/styles";
|
|
@@ -17,6 +17,7 @@ import RegionSelector from "../RegionSelectorSidebarBox";
|
|
|
17
17
|
import SettingsDialog from "../SettingsDialog";
|
|
18
18
|
import TagsSidebarBox from "../TagsSidebarBox";
|
|
19
19
|
import TaskDescription from "../TaskDescriptionSidebarBox";
|
|
20
|
+
import Help from "../HelpSidebarBox";
|
|
20
21
|
import MetadataEditor from "../MetadataEditorSidebarBox";
|
|
21
22
|
import GroupsEditor from "../GroupsEditorSidebarBox";
|
|
22
23
|
import Workspace from "react-material-workspace-layout/Workspace";
|
|
@@ -33,7 +34,8 @@ import { useSettings } from "../SettingsProvider";
|
|
|
33
34
|
import { withHotKeys } from "react-hotkeys";
|
|
34
35
|
import Editor from "../Editor";
|
|
35
36
|
import regionsToBlocks from '../utils/regions-to-blocks';
|
|
36
|
-
import PageSelector from "../PageSelector";
|
|
37
|
+
import PageSelector from "../PageSelector";
|
|
38
|
+
import regionsGroups from '../utils/regions-groups'; // import Fullscreen from "../Fullscreen"
|
|
37
39
|
|
|
38
40
|
var emptyArr = [];
|
|
39
41
|
var theme = createTheme();
|
|
@@ -190,6 +192,9 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
190
192
|
e.target.focus();
|
|
191
193
|
}
|
|
192
194
|
}, []);
|
|
195
|
+
var allowedGroups = useMemo(function () {
|
|
196
|
+
return regionsGroups(state.images[state.selectedImage].regions);
|
|
197
|
+
}, [state.images, state.selectedImage]);
|
|
193
198
|
var canvas = React.createElement(ImageCanvas, Object.assign({}, settings, {
|
|
194
199
|
showCrosshairs: settings.showCrosshairs && !["select", "pan", "zoom"].includes(state.selectedTool),
|
|
195
200
|
key: state.selectedImage,
|
|
@@ -235,7 +240,7 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
235
240
|
onRegionClassAdded: onRegionClassAdded,
|
|
236
241
|
allowComments: state.allowComments,
|
|
237
242
|
hideNotEditingLabel: hideNotEditingLabel,
|
|
238
|
-
allowedGroups:
|
|
243
|
+
allowedGroups: allowedGroups
|
|
239
244
|
}));
|
|
240
245
|
var onClickIconSidebarItem = useEventCallback(function (item) {
|
|
241
246
|
dispatch({
|
|
@@ -424,6 +429,9 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
424
429
|
}), state.taskDescription && React.createElement(TaskDescription, {
|
|
425
430
|
description: state.taskDescription,
|
|
426
431
|
key: "task-description"
|
|
432
|
+
}), state.help && React.createElement(Help, {
|
|
433
|
+
help: state.help,
|
|
434
|
+
key: "help"
|
|
427
435
|
}), state.regionClsList && React.createElement(ClassSelectionMenu, {
|
|
428
436
|
selectedCls: state.selectedCls,
|
|
429
437
|
regionClsList: state.regionClsList,
|
|
@@ -473,7 +481,7 @@ export var MainLayout = function MainLayout(_ref5) {
|
|
|
473
481
|
onMetadataChange: onMetadataChange,
|
|
474
482
|
key: "metadata-editor"
|
|
475
483
|
}), React.createElement(GroupsEditor, {
|
|
476
|
-
groups:
|
|
484
|
+
groups: allowedGroups,
|
|
477
485
|
onAddGroup: onAddGroup,
|
|
478
486
|
key: "groups-editor"
|
|
479
487
|
})].filter(Boolean)
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
|
|
3
|
+
function nextGroupId(groupIds) {
|
|
4
|
+
var numberIds = _toConsumableArray(groupIds.filter(function (i) {
|
|
5
|
+
return !isNaN(i);
|
|
6
|
+
}).map(function (i) {
|
|
7
|
+
return parseInt(i);
|
|
8
|
+
})).sort();
|
|
9
|
+
|
|
10
|
+
return (numberIds[numberIds.length - 1] + 1).toString();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default nextGroupId;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function regionsGroups(regions) {
|
|
2
|
+
if (!regions) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
var groups = regions.reduce(function (prev, curr) {
|
|
7
|
+
var groupId = curr.groupId;
|
|
8
|
+
|
|
9
|
+
if (prev.includes(groupId)) {
|
|
10
|
+
return prev;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
prev.push(groupId);
|
|
14
|
+
return prev;
|
|
15
|
+
}, []);
|
|
16
|
+
return groups;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default regionsGroups;
|