@searpent/react-image-annotate 2.0.35 → 2.0.37

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.
@@ -207,20 +207,23 @@ export var Annotator = function Annotator(_ref) {
207
207
  type: "ADD_GROUP",
208
208
  group: group
209
209
  });
210
- }; // FIXME: solve this problem
211
- // // trigger this on every BBox manipulation (there is currently no way to detect adding of new box!)
212
- // useEffect(() => {
213
- // if (!state.lastAction || !["BEGIN_BOX_TRANSFORM", "CHANGE_REGION", "DELETE_REGION", "UPDATE_METADATA", "SELECT_CLASSIFICATION"].includes(state.lastAction.type)) { return }
214
- // if (onImagesChange) {
215
- // onImagesChange(state.images)
216
- // }
217
- // dispatchToReducer({
218
- // type: "IMAGES_UPDATED",
219
- // updatedAt: new Date()
220
- // })
221
- // }, [onImagesChange, state.images, state.lastAction])
210
+ }; // trigger this on every BBox manipulation (there is currently no way to detect adding of new box!)
222
211
 
223
212
 
213
+ useEffect(function () {
214
+ if (!state.lastAction || !["BEGIN_BOX_TRANSFORM", "CHANGE_REGION", "DELETE_REGION", "UPDATE_METADATA", "SELECT_CLASSIFICATION"].includes(state.lastAction.type)) {
215
+ return;
216
+ }
217
+
218
+ if (onImagesChange) {
219
+ onImagesChange(state.images);
220
+ }
221
+
222
+ dispatchToReducer({
223
+ type: "IMAGES_UPDATED",
224
+ updatedAt: new Date()
225
+ });
226
+ }, [onImagesChange, state.images, state.lastAction]);
224
227
  useEffect(function () {
225
228
  if (selectedImage === undefined) return;
226
229
  dispatchToReducer({
@@ -1172,7 +1172,7 @@ export default (function (state, action) {
1172
1172
 
1173
1173
  if (metadataIndex < 0) {
1174
1174
  console.error("can't find metadata by key \"".concat(name, "\""));
1175
- return;
1175
+ return state;
1176
1176
  }
1177
1177
 
1178
1178
  return setIn(state, ["albumMetadata", metadataIndex], {
@@ -1183,7 +1183,7 @@ export default (function (state, action) {
1183
1183
  var _state$images$_imageI3, _state$images$_imageI4;
1184
1184
 
1185
1185
  // update metadata of article
1186
- if (!isNaN(_groupId2)) {
1186
+ if (_groupId2) {
1187
1187
  var _state$images$_imageI, _state$images$_imageI2;
1188
1188
 
1189
1189
  var articleMetadataRegionIdx = (_state$images$_imageI = state.images[_imageIndex]) === null || _state$images$_imageI === void 0 ? void 0 : _state$images$_imageI.regions.findIndex(function (r) {
@@ -1192,7 +1192,7 @@ export default (function (state, action) {
1192
1192
 
1193
1193
  if (articleMetadataRegionIdx < 0) {
1194
1194
  console.error("can't find article metadata for goupId \"".concat(_groupId2, "\""));
1195
- return;
1195
+ return state;
1196
1196
  }
1197
1197
 
1198
1198
  var articleRegionToUpdate = (_state$images$_imageI2 = state.images[_imageIndex]) === null || _state$images$_imageI2 === void 0 ? void 0 : _state$images$_imageI2.regions[articleMetadataRegionIdx];
@@ -1203,7 +1203,7 @@ export default (function (state, action) {
1203
1203
 
1204
1204
  if (toBeUpdatedMetadataIdx < 0) {
1205
1205
  console.error("can't find metadata field in article metadata for key \"".concat(name, "\""));
1206
- return;
1206
+ return state;
1207
1207
  }
1208
1208
 
1209
1209
  articleMetadata[toBeUpdatedMetadataIdx].value = value;
@@ -1219,7 +1219,7 @@ export default (function (state, action) {
1219
1219
 
1220
1220
  if (_metadataIndex < 0) {
1221
1221
  console.error("can't find photo metadata by key \"".concat(name, "\""));
1222
- return;
1222
+ return state;
1223
1223
  }
1224
1224
 
1225
1225
  return setIn(state, ["images", _imageIndex, "metadata", _metadataIndex], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searpent/react-image-annotate",
3
- "version": "2.0.35",
3
+ "version": "2.0.37",
4
4
  "dependencies": {
5
5
  "@editorjs/editorjs": "^2.25.0",
6
6
  "@editorjs/paragraph": "^2.8.0",