Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit b0efd98

Browse files
committed
added discard changes shortcut
1 parent 93d1b20 commit b0efd98

File tree

7 files changed

+35
-3
lines changed

7 files changed

+35
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Every notable changes in each version will be listed in this file.
88

99
- **Interface**: New tags input with tag auto complete
1010
- **Core**: Save snippet with keyboard shortcut `ctrl + s` ([84f1e45](https://github.com/ZeroX-DG/SnippetStore/commit/84f1e45))
11+
- **Core**: Discard changes snippet with keyboard shortcut `esc`
1112

1213
## Improvements:
1314

browser/core/functions/keyboard.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ const actions = [
3434
action: () => {
3535
eventEmitter.emit('snippets:saveAll')
3636
}
37+
},
38+
{
39+
name: 'CancelEditSnippets',
40+
action: () => {
41+
eventEmitter.emit('snippets:unSave')
42+
}
3743
}
3844
]
3945

browser/lib/config-manager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const DEFAULT_CONFIG = {
3636
openSetting: OSX ? 'Cmd + ,' : 'Ctrl + ,',
3737
toggleSidebar: OSX ? 'Cmd + B' : 'Ctrl + B',
3838
closeAllModals: 'Esc',
39-
SaveAllSnippets: OSX ? 'Cmd + S' : 'Ctrl + S'
39+
SaveAllSnippets: OSX ? 'Cmd + S' : 'Ctrl + S',
40+
CancelEditSnippets: 'Esc'
4041
}
4142
}
4243

browser/render/layouts/list-and-detail/snippet-detail-multi-file/index.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ export default class SnippetDetailMultiFile extends React.Component {
2828

2929
componentDidMount () {
3030
eventEmitter.on('snippets:saveAll', () => {
31-
this.handleSaveChangesClick()
31+
if (this.state.isEditing) {
32+
this.handleSaveChangesClick()
33+
}
34+
})
35+
eventEmitter.on('snippets:unSave', () => {
36+
if (this.state.isEditing) {
37+
this.handleDiscardChangesClick()
38+
}
3239
})
3340
}
3441

browser/render/layouts/list-and-detail/snippet-detail/index.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ export default class SnippetDetail extends React.Component {
2626

2727
componentDidMount () {
2828
eventEmitter.on('snippets:saveAll', () => {
29-
this.handleSaveChangesClick()
29+
if (this.state.isEditing) {
30+
this.handleSaveChangesClick()
31+
}
32+
})
33+
eventEmitter.on('snippets:unSave', () => {
34+
if (this.state.isEditing) {
35+
this.handleDiscardChangesClick()
36+
}
3037
})
3138
}
3239

browser/render/layouts/original/snippet-item-multi-files/index.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export default class SnippetItemMultiFiles extends React.Component {
3232
this.handleSaveChangesClick()
3333
}
3434
})
35+
eventEmitter.on('snippets:unSave', () => {
36+
if (this.state.isEditing) {
37+
this.handleDiscardChangesClick()
38+
}
39+
})
3540
}
3641

3742
renderHeader () {

browser/render/layouts/original/snippet-item/index.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export default class SnippetItem extends React.Component {
3030
this.handleSaveChangesClick()
3131
}
3232
})
33+
eventEmitter.on('snippets:unSave', () => {
34+
if (this.state.isEditing) {
35+
this.handleDiscardChangesClick()
36+
}
37+
})
3338
}
3439

3540
handleSnippetLangChange () {

0 commit comments

Comments
 (0)