@searpent/react-image-annotate 2.0.36 → 2.0.38

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.
@@ -420,7 +420,7 @@ var examplePhotos = [{
420
420
  "Y2": 0.8037425
421
421
  },
422
422
  "text": "[{\"label\":\"title\",\"text\":\"Fotbal. Remíza s Ukrajinou\"}]",
423
- "groupId": "0",
423
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
424
424
  "id": "346807503780052992"
425
425
  }, {
426
426
  "label": "text",
@@ -432,7 +432,7 @@ var examplePhotos = [{
432
432
  "Y2": 0.95930564
433
433
  },
434
434
  "text": "[{\"label\":\"text\",\"text\":\"\"}]",
435
- "groupId": "0",
435
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
436
436
  "id": "346807503780052993"
437
437
  }, {
438
438
  "label": "author",
@@ -444,7 +444,7 @@ var examplePhotos = [{
444
444
  "Y2": 0.95930564
445
445
  },
446
446
  "text": "[{\"label\":\"author\",\"text\":\"ČTK\"}]",
447
- "groupId": "0",
447
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
448
448
  "id": "346807503780052994"
449
449
  }, {
450
450
  "label": "title",
@@ -784,7 +784,7 @@ var examplePhotos = [{
784
784
  "Y2": 1
785
785
  },
786
786
  "text": "[{\"key\":\"articleType\",\"value\":\"news\"}, {\"key\":\"section\",\"value\":\"editorial\"}]",
787
- "groupId": "0",
787
+ "groupId": "42ba09e0-b2f5-439d-bdae-201e7c37787b",
788
788
  "id": "aba453dd-f870-4510-ae40-a19eb52eb7d6"
789
789
  }, {
790
790
  "label": "metadata",
@@ -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) {
@@ -50,6 +50,16 @@ function defaultClsColor(cls) {
50
50
  }
51
51
  }
52
52
 
53
+ function stringToNumber(str) {
54
+ var sum = 0;
55
+
56
+ for (var index = 0; index < str.length; index++) {
57
+ sum += str.charCodeAt(index);
58
+ }
59
+
60
+ return sum;
61
+ }
62
+
53
63
  var useColors = function useColors() {
54
64
  var _useSettings = useSettings(),
55
65
  clsColors = _useSettings.clsColors,
@@ -68,7 +78,11 @@ var useColors = function useColors() {
68
78
  };
69
79
 
70
80
  var groupColor = function groupColor(idx) {
71
- return groupColors[idx % groupColors.length] || DEFAULT_GROUP_COLOR;
81
+ if (isNaN(idx)) {
82
+ return groupColors[stringToNumber(idx) % groupColors.length] || DEFAULT_GROUP_COLOR;
83
+ } else {
84
+ return groupColors[idx % groupColors.length] || DEFAULT_GROUP_COLOR;
85
+ }
72
86
  };
73
87
 
74
88
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searpent/react-image-annotate",
3
- "version": "2.0.36",
3
+ "version": "2.0.38",
4
4
  "dependencies": {
5
5
  "@editorjs/editorjs": "^2.25.0",
6
6
  "@editorjs/paragraph": "^2.8.0",