@searpent/react-image-annotate 2.3.2-cand → 2.3.3-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.
@@ -1018,6 +1018,17 @@ export default (function (state, action) {
1018
1018
  }));
1019
1019
  }
1020
1020
 
1021
+ case "DELETE_ALL_REGIONS":
1022
+ {
1023
+ // Delete all non-metadata regions (frames) and article-level metadata,
1024
+ // but keep page-level/global metadata (metadata without groupId).
1025
+ state = saveToHistory(state, "Delete all regions");
1026
+ state = addSaveableAction(state, "DELETE_REGION");
1027
+ return setIn(state, [].concat(_toConsumableArray(pathToActiveImage), ["regions"]), (activeImage.regions || []).filter(function (r) {
1028
+ return r.cls === "metadata" && (r.groupId === null || r.groupId === undefined);
1029
+ }));
1030
+ }
1031
+
1021
1032
  case "DELETE_GROUP":
1022
1033
  {
1023
1034
  var _groupId = action.groupId;
@@ -16,6 +16,8 @@ export default (function (state, action) {
16
16
  if (typeof duration === "number") {
17
17
  return setIn(state, ["videoDuration"], duration * 1000);
18
18
  }
19
+
20
+ break;
19
21
  }
20
22
 
21
23
  case "HEADER_BUTTON_CLICKED":
@@ -26,7 +28,12 @@ export default (function (state, action) {
26
28
 
27
29
  case "pause":
28
30
  return setIn(state, ["videoPlaying"], false);
31
+
32
+ default:
33
+ break;
29
34
  }
35
+
36
+ break;
30
37
  }
31
38
 
32
39
  case "CHANGE_VIDEO_TIME":
@@ -44,6 +51,11 @@ export default (function (state, action) {
44
51
  return setIn(state, ["keyframes"], without(state.keyframes, action.time));
45
52
  }
46
53
 
54
+ case "DELETE_ALL_KEYFRAMES":
55
+ {
56
+ return setIn(state, ["keyframes"], {});
57
+ }
58
+
47
59
  default:
48
60
  break;
49
61
  } // Before the user modifies regions, copy the interpolated regions over to a
@@ -49,7 +49,8 @@ var KeyframesSelectorSidebarBox = function KeyframesSelectorSidebarBox(_ref2) {
49
49
  var currentVideoTime = _ref2.currentVideoTime,
50
50
  keyframes = _ref2.keyframes,
51
51
  onChangeVideoTime = _ref2.onChangeVideoTime,
52
- onDeleteKeyframe = _ref2.onDeleteKeyframe;
52
+ onDeleteKeyframe = _ref2.onDeleteKeyframe,
53
+ onDeleteAllKeyframes = _ref2.onDeleteAllKeyframes;
53
54
  var keyframeTimes = Object.keys(keyframes).map(function (t) {
54
55
  return parseInt(t);
55
56
  });
@@ -64,7 +65,32 @@ var KeyframesSelectorSidebarBox = function KeyframesSelectorSidebarBox(_ref2) {
64
65
  }
65
66
  }),
66
67
  expandedByDefault: true
67
- }, keyframeTimes.map(function (t) {
68
+ }, keyframeTimes.length > 0 && React.createElement("div", {
69
+ style: {
70
+ padding: 8,
71
+ paddingBottom: 0
72
+ }
73
+ }, React.createElement("button", {
74
+ type: "button",
75
+ onClick: function onClick(e) {
76
+ e.stopPropagation();
77
+
78
+ if (window.confirm("Are you really sure you want to delete all frames? This will remove all keyframes for this video.")) {
79
+ if (onDeleteAllKeyframes) {
80
+ onDeleteAllKeyframes();
81
+ }
82
+ }
83
+ },
84
+ style: {
85
+ fontSize: 12,
86
+ color: colors.red[700],
87
+ background: "none",
88
+ border: "none",
89
+ cursor: "pointer",
90
+ padding: 0,
91
+ textDecoration: "underline"
92
+ }
93
+ }, "Delete all frames")), keyframeTimes.map(function (t) {
68
94
  var _keyframes$t;
69
95
 
70
96
  return React.createElement(KeyframeRow, {
@@ -481,11 +481,13 @@ export var MainLayout = function MainLayout(_ref5) {
481
481
  regions: activeImage ? activeImage.regions : emptyArr,
482
482
  onSelectRegion: action("SELECT_REGION", "region"),
483
483
  onDeleteRegion: action("DELETE_REGION", "region"),
484
+ onDeleteAllRegions: action("DELETE_ALL_REGIONS"),
484
485
  onChangeRegion: action("CHANGE_REGION", "region"),
485
486
  key: "region-selector"
486
487
  }), state.keyframes && React.createElement(KeyframesSelector, {
487
488
  onChangeVideoTime: action("CHANGE_VIDEO_TIME", "newTime"),
488
489
  onDeleteKeyframe: action("DELETE_KEYFRAME", "time"),
490
+ onDeleteAllKeyframes: action("DELETE_ALL_KEYFRAMES"),
489
491
  onChangeCurrentTime: action("CHANGE_VIDEO_TIME", "newTime"),
490
492
  currentTime: state.currentVideoTime,
491
493
  duration: state.videoDuration,
@@ -216,6 +216,7 @@ export var RegionSelectorSidebarBox = function RegionSelectorSidebarBox(_ref5) {
216
216
  var _ref5$regions = _ref5.regions,
217
217
  regions = _ref5$regions === void 0 ? emptyArr : _ref5$regions,
218
218
  onDeleteRegion = _ref5.onDeleteRegion,
219
+ onDeleteAllRegions = _ref5.onDeleteAllRegions,
219
220
  onChangeRegion = _ref5.onChangeRegion,
220
221
  onSelectRegion = _ref5.onSelectRegion;
221
222
  var classes = useStyles();
@@ -232,7 +233,31 @@ export var RegionSelectorSidebarBox = function RegionSelectorSidebarBox(_ref5) {
232
233
  expandedByDefault: true
233
234
  }, React.createElement("div", {
234
235
  className: classes.container
235
- }, React.createElement(MemoRowHeader, null), React.createElement(HeaderSep, null), regions.map(function (r, i) {
236
+ }, regions.length > 0 && onDeleteAllRegions && React.createElement("div", {
237
+ style: {
238
+ display: "flex",
239
+ justifyContent: "flex-end",
240
+ marginBottom: 4
241
+ }
242
+ }, React.createElement("button", {
243
+ type: "button",
244
+ onClick: function onClick(e) {
245
+ e.stopPropagation();
246
+
247
+ if (window.confirm("Are you really sure you want to delete all frames on this page? This will remove all non-metadata regions.")) {
248
+ onDeleteAllRegions();
249
+ }
250
+ },
251
+ style: {
252
+ fontSize: 12,
253
+ color: "#d32f2f",
254
+ background: "none",
255
+ border: "none",
256
+ cursor: "pointer",
257
+ padding: 0,
258
+ textDecoration: "underline"
259
+ }
260
+ }, "Delete all frames")), React.createElement(MemoRowHeader, null), React.createElement(HeaderSep, null), regions.map(function (r, i) {
236
261
  return React.createElement(MemoRow, Object.assign({
237
262
  key: r.id
238
263
  }, r, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searpent/react-image-annotate",
3
- "version": "2.3.2-cand",
3
+ "version": "2.3.3-cand",
4
4
  "dependencies": {
5
5
  "@editorjs/editorjs": "^2.25.0",
6
6
  "@editorjs/paragraph": "^2.8.0",