@searpent/react-image-annotate 2.1.1 → 2.3.0-cand
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/exampleImages_bugdemo_15_1.js +80 -0
- package/Annotator/examplePhotos_repr.js +7052 -0
- package/Annotator/index.story_bugdemo_15_1.js +882 -0
- package/Annotator/index.story_repr.js +1075 -0
- package/Editor/index.js +6 -32
- package/Editor/index_bugdemo_15_1.js +147 -0
- package/Editor/readOnly.js +25 -373
- package/MainLayout/index_bugdemo_15_1.js +588 -0
- package/MetadataEditorSidebarBox/index_14_01_25.js +231 -0
- package/MetadataEditorSidebarBox/index_repr.js +271 -0
- package/package.json +7 -4
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import { FullScreen, useFullScreenHandle } from "react-full-screen";
|
|
4
|
+
import React, { useCallback, useMemo, useRef } from "react";
|
|
5
|
+
import { makeStyles } from "@mui/styles";
|
|
6
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
7
|
+
import { styled } from "@mui/material/styles";
|
|
8
|
+
import ClassSelectionMenu from "../ClassSelectionMenu";
|
|
9
|
+
import DebugBox from "../DebugSidebarBox";
|
|
10
|
+
import HistorySidebarBox from "../HistorySidebarBox";
|
|
11
|
+
import ImageCanvas from "../ImageCanvas";
|
|
12
|
+
import ImageSelector from "../ImageSelectorSidebarBox";
|
|
13
|
+
import GroupSelector from "../GroupSelectorSidebarBox";
|
|
14
|
+
import KeyframeTimeline from "../KeyframeTimeline";
|
|
15
|
+
import KeyframesSelector from "../KeyframesSelectorSidebarBox";
|
|
16
|
+
import RegionSelector from "../RegionSelectorSidebarBox";
|
|
17
|
+
import SettingsDialog from "../SettingsDialog";
|
|
18
|
+
import TagsSidebarBox from "../TagsSidebarBox";
|
|
19
|
+
import TaskDescription from "../TaskDescriptionSidebarBox";
|
|
20
|
+
import Help from "../HelpSidebarBox";
|
|
21
|
+
import MetadataEditor from "../MetadataEditorSidebarBox";
|
|
22
|
+
import GroupsEditor from "../GroupsEditorSidebarBox";
|
|
23
|
+
import Workspace from "react-material-workspace-layout/Workspace";
|
|
24
|
+
import classnames from "classnames";
|
|
25
|
+
import getActiveImage from "../Annotator/reducers/get-active-image";
|
|
26
|
+
import getHotkeyHelpText from "../utils/get-hotkey-help-text";
|
|
27
|
+
import iconDictionary from "./icon-dictionary";
|
|
28
|
+
import styles from "./styles";
|
|
29
|
+
import { useDispatchHotkeyHandlers } from "../ShortcutsManager";
|
|
30
|
+
import useEventCallback from "use-event-callback";
|
|
31
|
+
import useImpliedVideoRegions from "./use-implied-video-regions";
|
|
32
|
+
import useKey from "use-key-hook";
|
|
33
|
+
import { useSettings } from "../SettingsProvider";
|
|
34
|
+
import { withHotKeys } from "react-hotkeys";
|
|
35
|
+
import Editor from "../Editor";
|
|
36
|
+
import regionsToBlocks from '../utils/regions-to-blocks';
|
|
37
|
+
import PageSelector from "../PageSelector";
|
|
38
|
+
import regionsGroups from '../utils/regions-groups';
|
|
39
|
+
import RightSidebarItemsWrapper from './RightSidebarItemsWrapper';
|
|
40
|
+
import Locker from '../Locker';
|
|
41
|
+
import { reacalcActionsEnum } from "../utils/saveable-actions-enum";
|
|
42
|
+
import intersection from "lodash/intersection";
|
|
43
|
+
import useColors from '../hooks/use-colors'; // import Fullscreen from "../Fullscreen"
|
|
44
|
+
|
|
45
|
+
var emptyArr = [];
|
|
46
|
+
var theme = createTheme();
|
|
47
|
+
var useStyles = makeStyles(function (theme) {
|
|
48
|
+
return styles;
|
|
49
|
+
});
|
|
50
|
+
var HotkeyDiv = withHotKeys(function (_ref) {
|
|
51
|
+
var hotKeys = _ref.hotKeys,
|
|
52
|
+
children = _ref.children,
|
|
53
|
+
divRef = _ref.divRef,
|
|
54
|
+
props = _objectWithoutProperties(_ref, ["hotKeys", "children", "divRef"]);
|
|
55
|
+
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({}, _objectSpread({}, hotKeys, props), {
|
|
57
|
+
ref: divRef
|
|
58
|
+
}), children);
|
|
59
|
+
});
|
|
60
|
+
var FullScreenContainer = styled("div")(function (_ref2) {
|
|
61
|
+
var theme = _ref2.theme;
|
|
62
|
+
return {
|
|
63
|
+
width: "100%",
|
|
64
|
+
height: "100%",
|
|
65
|
+
"& .fullscreen": {
|
|
66
|
+
width: "100%",
|
|
67
|
+
height: "100%"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
var WorkspaceWrapper = styled("div")(function (_ref3) {
|
|
72
|
+
var theme = _ref3.theme;
|
|
73
|
+
return {
|
|
74
|
+
height: "100vh",
|
|
75
|
+
width: "auto",
|
|
76
|
+
backgroundColor: "red",
|
|
77
|
+
flex: 1
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
var EditorWrapper = styled("div")(function (_ref4) {
|
|
81
|
+
var theme = _ref4.theme;
|
|
82
|
+
return {
|
|
83
|
+
padding: "1rem",
|
|
84
|
+
paddingLeft: "2rem",
|
|
85
|
+
height: "100vh",
|
|
86
|
+
width: "30vw",
|
|
87
|
+
overflowY: "scroll"
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
export var MainLayout = function MainLayout(_ref5) {
|
|
91
|
+
var _state$images$state$s, _state$images$state$s2, _state$images$state$s3, _state$images$state$s4;
|
|
92
|
+
|
|
93
|
+
var state = _ref5.state,
|
|
94
|
+
dispatch = _ref5.dispatch,
|
|
95
|
+
_ref5$alwaysShowNextB = _ref5.alwaysShowNextButton,
|
|
96
|
+
alwaysShowNextButton = _ref5$alwaysShowNextB === void 0 ? false : _ref5$alwaysShowNextB,
|
|
97
|
+
_ref5$alwaysShowPrevB = _ref5.alwaysShowPrevButton,
|
|
98
|
+
alwaysShowPrevButton = _ref5$alwaysShowPrevB === void 0 ? false : _ref5$alwaysShowPrevB,
|
|
99
|
+
RegionEditLabel = _ref5.RegionEditLabel,
|
|
100
|
+
onRegionClassAdded = _ref5.onRegionClassAdded,
|
|
101
|
+
hideHeader = _ref5.hideHeader,
|
|
102
|
+
hideHeaderText = _ref5.hideHeaderText,
|
|
103
|
+
_ref5$hideNext = _ref5.hideNext,
|
|
104
|
+
hideNext = _ref5$hideNext === void 0 ? false : _ref5$hideNext,
|
|
105
|
+
_ref5$hidePrev = _ref5.hidePrev,
|
|
106
|
+
hidePrev = _ref5$hidePrev === void 0 ? false : _ref5$hidePrev,
|
|
107
|
+
_ref5$hideClone = _ref5.hideClone,
|
|
108
|
+
hideClone = _ref5$hideClone === void 0 ? false : _ref5$hideClone,
|
|
109
|
+
_ref5$hideSettings = _ref5.hideSettings,
|
|
110
|
+
hideSettings = _ref5$hideSettings === void 0 ? false : _ref5$hideSettings,
|
|
111
|
+
_ref5$hideFullScreen = _ref5.hideFullScreen,
|
|
112
|
+
hideFullScreen = _ref5$hideFullScreen === void 0 ? false : _ref5$hideFullScreen,
|
|
113
|
+
_ref5$hideSave = _ref5.hideSave,
|
|
114
|
+
hideSave = _ref5$hideSave === void 0 ? false : _ref5$hideSave,
|
|
115
|
+
_ref5$groups = _ref5.groups,
|
|
116
|
+
groups = _ref5$groups === void 0 ? [] : _ref5$groups,
|
|
117
|
+
_ref5$onGroupSelect = _ref5.onGroupSelect,
|
|
118
|
+
onGroupSelect = _ref5$onGroupSelect === void 0 ? function () {} : _ref5$onGroupSelect,
|
|
119
|
+
_ref5$hideHistory = _ref5.hideHistory,
|
|
120
|
+
hideHistory = _ref5$hideHistory === void 0 ? false : _ref5$hideHistory,
|
|
121
|
+
_ref5$hideNotEditingL = _ref5.hideNotEditingLabel,
|
|
122
|
+
hideNotEditingLabel = _ref5$hideNotEditingL === void 0 ? false : _ref5$hideNotEditingL,
|
|
123
|
+
_ref5$showEditor = _ref5.showEditor,
|
|
124
|
+
showEditor = _ref5$showEditor === void 0 ? false : _ref5$showEditor,
|
|
125
|
+
_ref5$showPageSelecto = _ref5.showPageSelector,
|
|
126
|
+
showPageSelector = _ref5$showPageSelecto === void 0 ? false : _ref5$showPageSelecto,
|
|
127
|
+
_ref5$recalcActive = _ref5.recalcActive,
|
|
128
|
+
recalcActive = _ref5$recalcActive === void 0 ? false : _ref5$recalcActive,
|
|
129
|
+
_ref5$saveActive = _ref5.saveActive,
|
|
130
|
+
saveActive = _ref5$saveActive === void 0 ? false : _ref5$saveActive,
|
|
131
|
+
onMetadataChange = _ref5.onMetadataChange,
|
|
132
|
+
onAddGroup = _ref5.onAddGroup,
|
|
133
|
+
onRecalcClick = _ref5.onRecalcClick;
|
|
134
|
+
var classes = useStyles();
|
|
135
|
+
var settings = useSettings();
|
|
136
|
+
var fullScreenHandle = useFullScreenHandle();
|
|
137
|
+
|
|
138
|
+
var _useColors = useColors(),
|
|
139
|
+
clsColor = _useColors.clsColor;
|
|
140
|
+
|
|
141
|
+
var memoizedActionFns = useRef({});
|
|
142
|
+
|
|
143
|
+
var action = function action(type) {
|
|
144
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
145
|
+
params[_key - 1] = arguments[_key];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var fnKey = "".concat(type, "(").concat(params.join(","), ")");
|
|
149
|
+
if (memoizedActionFns.current[fnKey]) return memoizedActionFns.current[fnKey];
|
|
150
|
+
|
|
151
|
+
var fn = function fn() {
|
|
152
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
153
|
+
args[_key2] = arguments[_key2];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return params.length > 0 ? dispatch(_objectSpread({
|
|
157
|
+
type: type
|
|
158
|
+
}, params.reduce(function (acc, p, i) {
|
|
159
|
+
return acc[p] = args[i], acc;
|
|
160
|
+
}, {}))) : dispatch(_objectSpread({
|
|
161
|
+
type: type
|
|
162
|
+
}, args[0]));
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
memoizedActionFns.current[fnKey] = fn;
|
|
166
|
+
return fn;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
var _getActiveImage = getActiveImage(state),
|
|
170
|
+
currentImageIndex = _getActiveImage.currentImageIndex,
|
|
171
|
+
activeImage = _getActiveImage.activeImage;
|
|
172
|
+
|
|
173
|
+
var nextImage;
|
|
174
|
+
|
|
175
|
+
if (currentImageIndex !== null) {
|
|
176
|
+
nextImage = state.images[currentImageIndex + 1];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
useKey(function () {
|
|
180
|
+
return dispatch({
|
|
181
|
+
type: "CANCEL"
|
|
182
|
+
});
|
|
183
|
+
}, {
|
|
184
|
+
detectKeys: [27]
|
|
185
|
+
});
|
|
186
|
+
var isAVideoFrame = activeImage && activeImage.frameTime !== undefined;
|
|
187
|
+
var innerContainerRef = useRef();
|
|
188
|
+
var hotkeyHandlers = useDispatchHotkeyHandlers({
|
|
189
|
+
dispatch: dispatch
|
|
190
|
+
});
|
|
191
|
+
var impliedVideoRegions = useImpliedVideoRegions(state);
|
|
192
|
+
var refocusOnMouseEvent = useCallback(function (e) {
|
|
193
|
+
if (!innerContainerRef.current) return;
|
|
194
|
+
if (innerContainerRef.current.contains(document.activeElement)) return;
|
|
195
|
+
|
|
196
|
+
if (innerContainerRef.current.contains(e.target)) {
|
|
197
|
+
innerContainerRef.current.focus();
|
|
198
|
+
e.target.focus();
|
|
199
|
+
}
|
|
200
|
+
}, []);
|
|
201
|
+
var allowedGroups = useMemo(function () {
|
|
202
|
+
return regionsGroups(state.images[state.selectedImage].regions);
|
|
203
|
+
}, [state.images, state.selectedImage]);
|
|
204
|
+
var canvas = /*#__PURE__*/React.createElement(ImageCanvas, Object.assign({}, settings, {
|
|
205
|
+
showCrosshairs: settings.showCrosshairs && !["select", "pan", "zoom"].includes(state.selectedTool),
|
|
206
|
+
key: state.selectedImage,
|
|
207
|
+
showMask: state.showMask,
|
|
208
|
+
fullImageSegmentationMode: state.fullImageSegmentationMode,
|
|
209
|
+
autoSegmentationOptions: state.autoSegmentationOptions,
|
|
210
|
+
showTags: state.showTags,
|
|
211
|
+
allowedArea: state.allowedArea,
|
|
212
|
+
modifyingAllowedArea: state.selectedTool === "modify-allowed-area",
|
|
213
|
+
regionClsList: state.regionClsList,
|
|
214
|
+
regionTagList: state.regionTagList,
|
|
215
|
+
regions: state.annotationType === "image" ? activeImage.regions || [] : impliedVideoRegions,
|
|
216
|
+
realSize: activeImage ? activeImage.realSize : undefined,
|
|
217
|
+
videoPlaying: state.videoPlaying,
|
|
218
|
+
imageSrc: state.annotationType === "image" ? activeImage.src : null,
|
|
219
|
+
videoSrc: state.annotationType === "video" ? state.videoSrc : null,
|
|
220
|
+
pointDistancePrecision: state.pointDistancePrecision,
|
|
221
|
+
createWithPrimary: state.selectedTool.includes("create"),
|
|
222
|
+
dragWithPrimary: state.selectedTool === "pan",
|
|
223
|
+
zoomWithPrimary: state.selectedTool === "zoom",
|
|
224
|
+
showPointDistances: state.showPointDistances,
|
|
225
|
+
videoTime: state.annotationType === "image" ? state.selectedImageFrameTime : state.currentVideoTime,
|
|
226
|
+
keypointDefinitions: state.keypointDefinitions,
|
|
227
|
+
onMouseMove: action("MOUSE_MOVE"),
|
|
228
|
+
onMouseDown: action("MOUSE_DOWN"),
|
|
229
|
+
onMouseUp: action("MOUSE_UP"),
|
|
230
|
+
onChangeRegion: action("CHANGE_REGION", "region"),
|
|
231
|
+
onBeginRegionEdit: action("OPEN_REGION_EDITOR", "region"),
|
|
232
|
+
onCloseRegionEdit: action("CLOSE_REGION_EDITOR", "region"),
|
|
233
|
+
onDeleteRegion: action("DELETE_REGION", "region"),
|
|
234
|
+
onDeleteGroup: action("DELETE_GROUP", "groupId"),
|
|
235
|
+
onBeginBoxTransform: action("BEGIN_BOX_TRANSFORM", "box", "directions"),
|
|
236
|
+
onResetZoom: function onResetZoom() {
|
|
237
|
+
return dispatch({
|
|
238
|
+
type: "ZOOM_RESET"
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
onBeginMovePolygonPoint: action("BEGIN_MOVE_POLYGON_POINT", "polygon", "pointIndex"),
|
|
242
|
+
onBeginMoveKeypoint: action("BEGIN_MOVE_KEYPOINT", "region", "keypointId"),
|
|
243
|
+
onAddPolygonPoint: action("ADD_POLYGON_POINT", "polygon", "point", "pointIndex"),
|
|
244
|
+
onSelectRegion: action("SELECT_REGION", "region"),
|
|
245
|
+
onBeginMovePoint: action("BEGIN_MOVE_POINT", "point"),
|
|
246
|
+
onImageLoaded: action("IMAGE_LOADED", "image"),
|
|
247
|
+
RegionEditLabel: RegionEditLabel,
|
|
248
|
+
onImageOrVideoLoaded: action("IMAGE_OR_VIDEO_LOADED", "metadata"),
|
|
249
|
+
onChangeVideoTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
250
|
+
onChangeVideoPlaying: action("CHANGE_VIDEO_PLAYING", "isPlaying"),
|
|
251
|
+
onRegionClassAdded: onRegionClassAdded,
|
|
252
|
+
allowComments: state.allowComments,
|
|
253
|
+
hideNotEditingLabel: hideNotEditingLabel,
|
|
254
|
+
allowedGroups: allowedGroups
|
|
255
|
+
}));
|
|
256
|
+
var onClickIconSidebarItem = useEventCallback(function (item) {
|
|
257
|
+
dispatch({
|
|
258
|
+
type: "SELECT_TOOL",
|
|
259
|
+
selectedTool: item.name
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
var onClickHeaderItem = useEventCallback(function (item) {
|
|
263
|
+
if (item.name === "Fullscreen") {
|
|
264
|
+
fullScreenHandle.enter();
|
|
265
|
+
} else if (item.name === "Window") {
|
|
266
|
+
fullScreenHandle.exit();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
dispatch({
|
|
270
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
271
|
+
buttonName: item.name
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
var debugModeOn = Boolean(window.localStorage.$ANNOTATE_DEBUG_MODE && state);
|
|
275
|
+
var nextImageHasRegions = !nextImage || nextImage.regions && nextImage.regions.length > 0; // Editor.js blocks
|
|
276
|
+
|
|
277
|
+
var selectedGroupId = ((_state$images$state$s = state.images[state.selectedImage]) === null || _state$images$state$s === void 0 ? void 0 : _state$images$state$s.selectedGroupId) || null; // BUG SIMULATION: Only activate with ?bug=true parameter (not just localhost)
|
|
278
|
+
// This allows Storybook to test both the fix and the bug simulation
|
|
279
|
+
|
|
280
|
+
var isBugMode = typeof window !== 'undefined' && (window.location.search.includes('bug=true') || window.location.search.includes('bug=on'));
|
|
281
|
+
var originalSelectedGroupId = selectedGroupId; // Preserve original for filtering
|
|
282
|
+
|
|
283
|
+
var selectedGroupIdForBug = isBugMode ? null : selectedGroupId; // Use null in bug mode to simulate the bug
|
|
284
|
+
// Only process blocks if there's a valid selected image with regions
|
|
285
|
+
|
|
286
|
+
var selectedImage = state.selectedImage != null && state.images[state.selectedImage] ? state.images[state.selectedImage] : null;
|
|
287
|
+
var extractionEngineRegions = (selectedImage === null || selectedImage === void 0 ? void 0 : selectedImage.regions) ? (selectedImage.regions || []).filter(function (r) {
|
|
288
|
+
return r.cls !== 'metadata';
|
|
289
|
+
}) : [];
|
|
290
|
+
var editorBlocks = extractionEngineRegions.length > 0 ? regionsToBlocks(extractionEngineRegions, clsColor) : []; // DEBUG: Always log the filtering process
|
|
291
|
+
|
|
292
|
+
console.log('[MainLayout DEBUG] ===========================================');
|
|
293
|
+
console.log('[MainLayout DEBUG] selectedImage:', state.selectedImage);
|
|
294
|
+
console.log('[MainLayout DEBUG] originalSelectedGroupId:', originalSelectedGroupId, '(type:', typeof originalSelectedGroupId, ')');
|
|
295
|
+
console.log('[MainLayout DEBUG] selectedGroupIdForBug:', selectedGroupIdForBug, '(type:', typeof selectedGroupIdForBug, ')');
|
|
296
|
+
console.log('[MainLayout DEBUG] extractionEngineRegions count:', extractionEngineRegions.length);
|
|
297
|
+
console.log('[MainLayout DEBUG] extractionEngineRegions groupIds:', extractionEngineRegions.map(function (r) {
|
|
298
|
+
return r.groupId;
|
|
299
|
+
}));
|
|
300
|
+
console.log('[MainLayout DEBUG] editorBlocks count:', editorBlocks.length);
|
|
301
|
+
|
|
302
|
+
if (editorBlocks.length > 0) {
|
|
303
|
+
console.log('[MainLayout DEBUG] editorBlocks groupIds:', editorBlocks.map(function (b) {
|
|
304
|
+
var _b$data;
|
|
305
|
+
|
|
306
|
+
return b === null || b === void 0 ? void 0 : (_b$data = b.data) === null || _b$data === void 0 ? void 0 : _b$data.groupId;
|
|
307
|
+
}));
|
|
308
|
+
console.log('[MainLayout DEBUG] editorBlocks sample:', editorBlocks[0]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
var filteredBlocks = editorBlocks.filter(function (i) {
|
|
312
|
+
var _i$data;
|
|
313
|
+
|
|
314
|
+
return (i === null || i === void 0 ? void 0 : (_i$data = i.data) === null || _i$data === void 0 ? void 0 : _i$data.groupId) === originalSelectedGroupId;
|
|
315
|
+
});
|
|
316
|
+
console.log('[MainLayout DEBUG] filtered blocks count:', filteredBlocks.length);
|
|
317
|
+
console.log('[MainLayout DEBUG] BUG CHECK: selectedGroupIdForBug is', selectedGroupIdForBug === null ? 'NULL' : selectedGroupIdForBug, 'but blocks have groupIds:', editorBlocks.map(function (b) {
|
|
318
|
+
var _b$data2;
|
|
319
|
+
|
|
320
|
+
return b === null || b === void 0 ? void 0 : (_b$data2 = b.data) === null || _b$data2 === void 0 ? void 0 : _b$data2.groupId;
|
|
321
|
+
}).filter(function (v, i, a) {
|
|
322
|
+
return a.indexOf(v) === i;
|
|
323
|
+
}));
|
|
324
|
+
|
|
325
|
+
if (selectedGroupIdForBug === null && editorBlocks.length > 0 && editorBlocks.some(function (b) {
|
|
326
|
+
var _b$data3;
|
|
327
|
+
|
|
328
|
+
return (b === null || b === void 0 ? void 0 : (_b$data3 = b.data) === null || _b$data3 === void 0 ? void 0 : _b$data3.groupId) != null;
|
|
329
|
+
})) {
|
|
330
|
+
console.warn('[MainLayout DEBUG] ⚠️ BUG SCENARIO: selectedGroupIdForBug is null but blocks have groupId! Filtered blocks will be empty.');
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
console.log('[MainLayout DEBUG] ==========================================='); // FIX: Show all blocks when selectedGroupId is null
|
|
334
|
+
// This fixes the bug where text disappears in edit mode when selectedGroupId is null but blocks have groupId
|
|
335
|
+
// BUG SIMULATION: In bug mode, pass unfiltered blocks to Editor so read-only mode works
|
|
336
|
+
// Editor component will handle buggy filtering for edit mode only
|
|
337
|
+
// Use originalSelectedGroupId for normal filtering, but pass all blocks in bug mode
|
|
338
|
+
|
|
339
|
+
var blocks = isBugMode ? editorBlocks // Pass unfiltered blocks in bug mode (Editor will filter using originalSelectedGroupId)
|
|
340
|
+
: originalSelectedGroupId === null ? editorBlocks : editorBlocks.filter(function (i) {
|
|
341
|
+
var _i$data2;
|
|
342
|
+
|
|
343
|
+
return (i === null || i === void 0 ? void 0 : (_i$data2 = i.data) === null || _i$data2 === void 0 ? void 0 : _i$data2.groupId) === originalSelectedGroupId;
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
var handleEditorChange = function handleEditorChange(_ref6) {
|
|
347
|
+
var imageIndex = _ref6.imageIndex,
|
|
348
|
+
data = _ref6.data;
|
|
349
|
+
var newRegions = data.blocks.map(function (i) {
|
|
350
|
+
return {
|
|
351
|
+
id: i.id,
|
|
352
|
+
cls: i.data.labelName,
|
|
353
|
+
text: i.data.text
|
|
354
|
+
};
|
|
355
|
+
});
|
|
356
|
+
dispatch({
|
|
357
|
+
type: "UPDATE_REGIONS",
|
|
358
|
+
regions: newRegions,
|
|
359
|
+
imageIndex: imageIndex
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
var pages = state.images.map(function (i, idx) {
|
|
364
|
+
var _i$metadata, _i$metadata$find;
|
|
365
|
+
|
|
366
|
+
return {
|
|
367
|
+
id: "".concat(i.id),
|
|
368
|
+
src: i.thumbnail,
|
|
369
|
+
isActive: idx === state.selectedImage,
|
|
370
|
+
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) {
|
|
371
|
+
return md.key === "pageNumber";
|
|
372
|
+
})) === null || _i$metadata$find === void 0 ? void 0 : _i$metadata$find.value) || null,
|
|
373
|
+
metadata: i.metadata || [],
|
|
374
|
+
lockedUntil: i.lockedUntil,
|
|
375
|
+
syncError: i.syncError || null,
|
|
376
|
+
isRecalcReady: intersection(reacalcActionsEnum, state.images[idx].saveableActions).length > 0
|
|
377
|
+
};
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
var handlePageClick = function handlePageClick(pageIndex) {
|
|
381
|
+
dispatch({
|
|
382
|
+
type: "SELECT_IMAGE",
|
|
383
|
+
imageIndex: pageIndex
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
var isSelectedImageLocked = ((_state$images$state$s2 = state.images[state.selectedImage]) === null || _state$images$state$s2 === void 0 ? void 0 : _state$images$state$s2.lockedUntil) ? true : false;
|
|
388
|
+
var selectedFrame = ((_state$images$state$s3 = state.images[state.selectedImage]) === null || _state$images$state$s3 === void 0 ? void 0 : (_state$images$state$s4 = _state$images$state$s3.regions.find(function (i) {
|
|
389
|
+
return i.highlighted === true;
|
|
390
|
+
})) === null || _state$images$state$s4 === void 0 ? void 0 : _state$images$state$s4.id) || '';
|
|
391
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
392
|
+
theme: theme
|
|
393
|
+
}, /*#__PURE__*/React.createElement(FullScreenContainer, null, /*#__PURE__*/React.createElement(FullScreen, {
|
|
394
|
+
handle: fullScreenHandle,
|
|
395
|
+
onChange: function onChange(open) {
|
|
396
|
+
if (!open) {
|
|
397
|
+
fullScreenHandle.exit();
|
|
398
|
+
action("HEADER_BUTTON_CLICKED", "buttonName")("Window");
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}, /*#__PURE__*/React.createElement(HotkeyDiv, {
|
|
402
|
+
tabIndex: -1,
|
|
403
|
+
divRef: innerContainerRef,
|
|
404
|
+
onMouseDown: refocusOnMouseEvent,
|
|
405
|
+
onMouseOver: refocusOnMouseEvent,
|
|
406
|
+
allowChanges: true,
|
|
407
|
+
handlers: hotkeyHandlers,
|
|
408
|
+
className: classnames(classes.container, state.fullScreen && "Fullscreen")
|
|
409
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
410
|
+
style: {
|
|
411
|
+
display: 'flex',
|
|
412
|
+
flexDirection: 'row'
|
|
413
|
+
}
|
|
414
|
+
}, showPageSelector && /*#__PURE__*/React.createElement(PageSelector, {
|
|
415
|
+
pages: pages,
|
|
416
|
+
onPageClick: handlePageClick,
|
|
417
|
+
onMetadataChange: onMetadataChange,
|
|
418
|
+
metadataConfigs: state.metadataConfigs || [],
|
|
419
|
+
onRecalcClick: onRecalcClick
|
|
420
|
+
}), /*#__PURE__*/React.createElement(WorkspaceWrapper, null, /*#__PURE__*/React.createElement(Workspace, {
|
|
421
|
+
style: {
|
|
422
|
+
width: "auto"
|
|
423
|
+
},
|
|
424
|
+
allowFullscreen: true,
|
|
425
|
+
iconDictionary: iconDictionary,
|
|
426
|
+
hideHeader: hideHeader,
|
|
427
|
+
hideHeaderText: hideHeaderText,
|
|
428
|
+
headerLeftSide: [state.annotationType === "video" ? /*#__PURE__*/React.createElement(KeyframeTimeline, {
|
|
429
|
+
currentTime: state.currentVideoTime,
|
|
430
|
+
duration: state.videoDuration,
|
|
431
|
+
onChangeCurrentTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
432
|
+
keyframes: state.keyframes
|
|
433
|
+
}) : activeImage ? /*#__PURE__*/React.createElement("div", {
|
|
434
|
+
className: classes.headerTitle
|
|
435
|
+
}, activeImage.name) : null].filter(Boolean),
|
|
436
|
+
headerItems: [!hidePrev && {
|
|
437
|
+
name: "Prev"
|
|
438
|
+
}, !hideNext && {
|
|
439
|
+
name: "Next"
|
|
440
|
+
}, state.annotationType !== "video" ? null : !state.videoPlaying ? {
|
|
441
|
+
name: "Play"
|
|
442
|
+
} : {
|
|
443
|
+
name: "Pause"
|
|
444
|
+
}, !hideClone && !nextImageHasRegions && activeImage.regions && {
|
|
445
|
+
name: "Clone"
|
|
446
|
+
}, !hideSettings && {
|
|
447
|
+
name: "Settings"
|
|
448
|
+
}, !hideFullScreen && (state.fullScreen ? {
|
|
449
|
+
name: "Window"
|
|
450
|
+
} : {
|
|
451
|
+
name: "Fullscreen"
|
|
452
|
+
}), !hideSave && {
|
|
453
|
+
name: "Save"
|
|
454
|
+
}].filter(Boolean),
|
|
455
|
+
onClickHeaderItem: onClickHeaderItem,
|
|
456
|
+
onClickIconSidebarItem: onClickIconSidebarItem,
|
|
457
|
+
selectedTools: [state.selectedTool, state.showTags && "show-tags", state.showMask && "show-mask"].filter(Boolean),
|
|
458
|
+
iconSidebarItems: !state.enabledTools ? [] : [{
|
|
459
|
+
name: "select",
|
|
460
|
+
helperText: "Select" + getHotkeyHelpText("select_tool"),
|
|
461
|
+
alwaysShowing: false
|
|
462
|
+
}, {
|
|
463
|
+
name: "pan",
|
|
464
|
+
helperText: "Drag/Pan (right or middle click)" + getHotkeyHelpText("pan_tool"),
|
|
465
|
+
alwaysShowing: false
|
|
466
|
+
}, {
|
|
467
|
+
name: "zoom",
|
|
468
|
+
helperText: "Zoom In/Out (scroll)" + getHotkeyHelpText("zoom_tool"),
|
|
469
|
+
alwaysShowing: false
|
|
470
|
+
}, {
|
|
471
|
+
name: "show-tags",
|
|
472
|
+
helperText: "Show / Hide Tags",
|
|
473
|
+
alwaysShowing: false
|
|
474
|
+
}, {
|
|
475
|
+
name: "create-point",
|
|
476
|
+
helperText: "Add Point" + getHotkeyHelpText("create_point")
|
|
477
|
+
}, {
|
|
478
|
+
name: "create-box",
|
|
479
|
+
helperText: "Add Bounding Box" + getHotkeyHelpText("create_bounding_box")
|
|
480
|
+
}, {
|
|
481
|
+
name: "create-polygon",
|
|
482
|
+
helperText: "Add Polygon" + getHotkeyHelpText("create_polygon")
|
|
483
|
+
}, {
|
|
484
|
+
name: "create-line",
|
|
485
|
+
helperText: "Add Line"
|
|
486
|
+
}, {
|
|
487
|
+
name: "create-expanding-line",
|
|
488
|
+
helperText: "Add Expanding Line"
|
|
489
|
+
}, {
|
|
490
|
+
name: "create-keypoints",
|
|
491
|
+
helperText: "Add Keypoints (Pose)"
|
|
492
|
+
}, state.fullImageSegmentationMode && {
|
|
493
|
+
name: "show-mask",
|
|
494
|
+
alwaysShowing: false,
|
|
495
|
+
helperText: "Show / Hide Mask"
|
|
496
|
+
}, {
|
|
497
|
+
name: "modify-allowed-area",
|
|
498
|
+
helperText: "Modify Allowed Area"
|
|
499
|
+
}].filter(Boolean).filter(function (a) {
|
|
500
|
+
return a.alwaysShowing || state.enabledTools.includes(a.name);
|
|
501
|
+
}),
|
|
502
|
+
rightSidebarItems: [/*#__PURE__*/React.createElement(RightSidebarItemsWrapper, null, [isSelectedImageLocked && /*#__PURE__*/React.createElement(Locker, null), debugModeOn && /*#__PURE__*/React.createElement(DebugBox, {
|
|
503
|
+
state: debugModeOn,
|
|
504
|
+
lastAction: state.lastAction,
|
|
505
|
+
key: "debug-box"
|
|
506
|
+
}), state.taskDescription && /*#__PURE__*/React.createElement(TaskDescription, {
|
|
507
|
+
description: state.taskDescription,
|
|
508
|
+
key: "task-description"
|
|
509
|
+
}), state.help && /*#__PURE__*/React.createElement(Help, {
|
|
510
|
+
help: state.help,
|
|
511
|
+
key: "help"
|
|
512
|
+
}), state.regionClsList && /*#__PURE__*/React.createElement(ClassSelectionMenu, {
|
|
513
|
+
selectedCls: state.selectedCls,
|
|
514
|
+
regionClsList: state.regionClsList,
|
|
515
|
+
onSelectCls: action("SELECT_CLASSIFICATION", "cls"),
|
|
516
|
+
key: "class-selection-menu"
|
|
517
|
+
}), state.labelImages && /*#__PURE__*/React.createElement(TagsSidebarBox, {
|
|
518
|
+
currentImage: activeImage,
|
|
519
|
+
imageClsList: state.imageClsList,
|
|
520
|
+
imageTagList: state.imageTagList,
|
|
521
|
+
onChangeImage: action("CHANGE_IMAGE", "delta"),
|
|
522
|
+
expandedByDefault: true,
|
|
523
|
+
key: "tags-sidebar-box"
|
|
524
|
+
}),,
|
|
525
|
+
/*#__PURE__*/
|
|
526
|
+
// (state.images?.length || 0) > 1 && (
|
|
527
|
+
// <ImageSelector
|
|
528
|
+
// onSelect={action("SELECT_REGION", "region")}
|
|
529
|
+
// images={state.images}
|
|
530
|
+
// />
|
|
531
|
+
// ),
|
|
532
|
+
// groups && (
|
|
533
|
+
// <GroupSelector
|
|
534
|
+
// title="Articles"
|
|
535
|
+
// groups={groups}
|
|
536
|
+
// selectedGroupId={selectedGroupId}
|
|
537
|
+
// onSelect={onGroupSelect}
|
|
538
|
+
// />
|
|
539
|
+
// )
|
|
540
|
+
React.createElement(RegionSelector, {
|
|
541
|
+
regions: activeImage ? activeImage.regions : emptyArr,
|
|
542
|
+
onSelectRegion: action("SELECT_REGION", "region"),
|
|
543
|
+
onDeleteRegion: action("DELETE_REGION", "region"),
|
|
544
|
+
onChangeRegion: action("CHANGE_REGION", "region"),
|
|
545
|
+
key: "region-selector"
|
|
546
|
+
}), state.keyframes && /*#__PURE__*/React.createElement(KeyframesSelector, {
|
|
547
|
+
onChangeVideoTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
548
|
+
onDeleteKeyframe: action("DELETE_KEYFRAME", "time"),
|
|
549
|
+
onChangeCurrentTime: action("CHANGE_VIDEO_TIME", "newTime"),
|
|
550
|
+
currentTime: state.currentVideoTime,
|
|
551
|
+
duration: state.videoDuration,
|
|
552
|
+
keyframes: state.keyframes,
|
|
553
|
+
key: "key-frame-selector"
|
|
554
|
+
}), !hideHistory && /*#__PURE__*/React.createElement(HistorySidebarBox, {
|
|
555
|
+
history: state.history,
|
|
556
|
+
onRestoreHistory: action("RESTORE_HISTORY"),
|
|
557
|
+
key: "history-sidebar"
|
|
558
|
+
}), /*#__PURE__*/React.createElement(MetadataEditor, {
|
|
559
|
+
state: state,
|
|
560
|
+
onMetadataChange: onMetadataChange,
|
|
561
|
+
key: "metadata-editor"
|
|
562
|
+
}), /*#__PURE__*/React.createElement(GroupsEditor, {
|
|
563
|
+
groups: allowedGroups,
|
|
564
|
+
onAddGroup: onAddGroup,
|
|
565
|
+
key: "groups-editor"
|
|
566
|
+
})].filter(Boolean))]
|
|
567
|
+
}, isSelectedImageLocked && /*#__PURE__*/React.createElement(Locker, null), canvas)), showEditor && !isSelectedImageLocked && /*#__PURE__*/React.createElement(EditorWrapper, {
|
|
568
|
+
id: "editor-wrapper"
|
|
569
|
+
}, /*#__PURE__*/React.createElement(Editor, {
|
|
570
|
+
id: "editor",
|
|
571
|
+
blocks: blocks,
|
|
572
|
+
imageIndex: state.selectedImage,
|
|
573
|
+
key: "".concat(state.selectedImage, "#").concat(originalSelectedGroupId),
|
|
574
|
+
selectedFrame: selectedFrame,
|
|
575
|
+
onChange: handleEditorChange,
|
|
576
|
+
selectedGroupId: selectedGroupIdForBug,
|
|
577
|
+
originalSelectedGroupId: originalSelectedGroupId
|
|
578
|
+
}))), /*#__PURE__*/React.createElement(SettingsDialog, {
|
|
579
|
+
open: state.settingsOpen,
|
|
580
|
+
onClose: function onClose() {
|
|
581
|
+
return dispatch({
|
|
582
|
+
type: "HEADER_BUTTON_CLICKED",
|
|
583
|
+
buttonName: "Settings"
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
})))));
|
|
587
|
+
};
|
|
588
|
+
export default MainLayout;
|