@searpent/react-image-annotate 2.0.78 → 2.0.80

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.
@@ -677,8 +677,10 @@ export default (function (state, action) {
677
677
  return r.highlighted === true;
678
678
  })) === null || _state4$images$state$3 === void 0 ? void 0 : _state4$images$state$3.groupId;
679
679
  var groupSelected = true;
680
+ var isNewRegion = false;
680
681
 
681
682
  if (groupId === undefined) {
683
+ isNewRegion = true;
682
684
  groupId = nextGroupId();
683
685
  groupSelected = false;
684
686
  }
@@ -698,6 +700,40 @@ export default (function (state, action) {
698
700
  groupHighlighted: true,
699
701
  groupId: groupId
700
702
  };
703
+
704
+ if (isNewRegion) {
705
+ var _state5;
706
+
707
+ var selectedImageIdx = state.selectedImage;
708
+ var metadataTextValue = (_state5 = state) === null || _state5 === void 0 ? void 0 : _state5.metadataConfigs.filter(function (metadataConfig) {
709
+ return metadataConfig.level === "photo_metadata-engine";
710
+ }).map(function (metadataConfig) {
711
+ return {
712
+ key: metadataConfig.key,
713
+ value: "",
714
+ metadataId: getRandomId()
715
+ };
716
+ });
717
+ var newRegionMetadata = {
718
+ cls: "metadata",
719
+ editingLabels: false,
720
+ groupHighlighted: false,
721
+ groupId: groupId,
722
+ x: 0,
723
+ y: 0,
724
+ w: 1,
725
+ h: 1,
726
+ highlighted: false,
727
+ id: getRandomId(),
728
+ text: JSON.stringify(metadataTextValue),
729
+ type: "box",
730
+ undefined: false,
731
+ visible: false
732
+ };
733
+ state = addSaveableAction(state, "ADD_METADATA");
734
+ state = setIn(state, ["images", selectedImageIdx, "regions"], [].concat(_toConsumableArray(state.images[selectedImageIdx].regions), [newRegionMetadata]));
735
+ }
736
+
701
737
  state = setIn(state, ["mode"], {
702
738
  mode: "RESIZE_BOX",
703
739
  editLabelEditorAfter: !groupSelected,
@@ -837,12 +873,12 @@ export default (function (state, action) {
837
873
  var _x2 = action.x,
838
874
  _y2 = action.y;
839
875
 
840
- var _state5 = state,
841
- _state5$mouseDownAt = _state5.mouseDownAt,
842
- _mouseDownAt2 = _state5$mouseDownAt === void 0 ? {
876
+ var _state6 = state,
877
+ _state6$mouseDownAt = _state6.mouseDownAt,
878
+ _mouseDownAt2 = _state6$mouseDownAt === void 0 ? {
843
879
  x: _x2,
844
880
  y: _y2
845
- } : _state5$mouseDownAt;
881
+ } : _state6$mouseDownAt;
846
882
 
847
883
  if (!state.mode) return state;
848
884
  state = setIn(state, ["mouseDownAt"], null);
@@ -1089,8 +1125,8 @@ export default (function (state, action) {
1089
1125
 
1090
1126
  case "CANCEL":
1091
1127
  {
1092
- var _state6 = state,
1093
- mode = _state6.mode;
1128
+ var _state7 = state,
1129
+ mode = _state7.mode;
1094
1130
 
1095
1131
  if (mode) {
1096
1132
  switch (mode.mode) {
@@ -298,6 +298,11 @@ function () {
298
298
  */
299
299
 
300
300
  tag.dataset.placeholder = this.api.i18n.t(this._settings.placeholder || '');
301
+ /**
302
+ * Add spellcheck
303
+ */
304
+
305
+ tag.spellcheck = 'true';
301
306
  return tag;
302
307
  }
303
308
  /**
package/Editor/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
- import React, { useState } from 'react';
4
+ import React, { useEffect, useState } from 'react';
5
5
  import { createReactEditorJS } from 'react-editor-js';
6
6
  import blocksToArticle from '../utils/blocks-to-article';
7
7
  import { EDITOR_JS_TOOLS } from './tools';
@@ -60,6 +60,22 @@ function Editor(_ref) {
60
60
  });
61
61
  };
62
62
 
63
+ useEffect(function () {
64
+ if (!editMode) {
65
+ return;
66
+ }
67
+
68
+ setTimeout(function () {
69
+ var editableElements = document.querySelectorAll(".ce-header");
70
+ editableElements.forEach(function (element) {
71
+ element.focus();
72
+ setTimeout(function () {
73
+ element.blur();
74
+ }, 100);
75
+ });
76
+ }, 1000);
77
+ }, [editMode]);
78
+
63
79
  if (blocks.length < 1) {
64
80
  return React.createElement("div", {
65
81
  className: "instructions"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searpent/react-image-annotate",
3
- "version": "2.0.78",
3
+ "version": "2.0.80",
4
4
  "dependencies": {
5
5
  "@editorjs/editorjs": "^2.25.0",
6
6
  "@editorjs/paragraph": "^2.8.0",
@@ -5,7 +5,9 @@ function regionsGroups(regions) {
5
5
  return [];
6
6
  }
7
7
 
8
- var groups = regions.reduce(function (acc, curr) {
8
+ var groups = regions.filter(function (region) {
9
+ return region.cls !== 'metadata';
10
+ }).reduce(function (acc, curr) {
9
11
  var _curr$text;
10
12
 
11
13
  var groupId = curr.groupId;
@@ -1,3 +1,3 @@
1
1
  var reacalcActionsEnum = ["MOUSE_UP_RESIZE_BOX", "DELETE_REGION", "DELETE_GROUP", "MOUSE_UP_MOVE_REGION", "SELECT_CLASSIFICATION", "CHANGE_REGION"];
2
- var saveableActionsEnum = [reacalcActionsEnum, "UPDATE_REGIONS", "UPDATE_METADATA", "UPDATE_ALBUM_METADATA"];
2
+ var saveableActionsEnum = [reacalcActionsEnum, "UPDATE_REGIONS", "UPDATE_METADATA", "UPDATE_ALBUM_METADATA", "ADD_METADATA"];
3
3
  export { saveableActionsEnum, reacalcActionsEnum };