Skip to content

Commit 09296e4

Browse files
authored
fix: Merge pull request #103 from Hummer12007/del-shortcut
Added a shortcut to delete selected regions
2 parents 8d24d9a + 0dfdbf0 commit 09296e4

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/Annotator/reducers/general-reducer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,13 @@ export default (state: MainLayoutState, action: Action) => {
745745
(activeImage.regions || []).filter((r) => r.id !== action.region.id)
746746
)
747747
}
748+
case "DELETE_SELECTED_REGION": {
749+
return setIn(
750+
state,
751+
[...pathToActiveImage, "regions"],
752+
(activeImage.regions || []).filter((r) => !r.highlighted)
753+
)
754+
}
748755
case "HEADER_BUTTON_CLICKED": {
749756
const buttonName = action.buttonName.toLowerCase()
750757
switch (buttonName) {

src/MainLayout/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export type Action =
148148
| {| type: "OPEN_REGION_EDITOR", region: Region |}
149149
| {| type: "CLOSE_REGION_EDITOR", region: Region |}
150150
| {| type: "DELETE_REGION", region: Region |}
151+
| {| type: "DELETE_SELECTED_REGION" |}
151152
| {| type: "HEADER_BUTTON_CLICKED", buttonName: string |}
152153
| {| type: "SELECT_TOOL", selectedTool: ToolEnum |}
153154
| {| type: "CANCEL" |}

src/ShortcutsManager/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export const defaultHotkeys = [
5353
id: "exit_sample",
5454
description: "Exit sample without saving",
5555
},
56+
{
57+
id: "delete_region",
58+
description: "Delete selected region",
59+
binding: "Delete",
60+
},
5661
]
5762
export const defaultKeyMap = {}
5863
for (const { id, binding } of defaultHotkeys) defaultKeyMap[id] = binding
@@ -120,6 +125,11 @@ export const useDispatchHotkeyHandlers = ({ dispatch }) => {
120125
buttonName: "Save",
121126
})
122127
},
128+
delete_region: () => {
129+
dispatch({
130+
type: "DELETE_SELECTED_REGION",
131+
})
132+
},
123133
// TODO
124134
// exit_sample: () => {
125135
// dispatch({

0 commit comments

Comments
 (0)