Skip to content

Commit 56851eb

Browse files
authored
Merge pull request #2666 from yougotwill/menu_items_overhaul
Menu items overhaul
2 parents b224c72 + 102d13b commit 56851eb

File tree

2 files changed

+34
-42
lines changed

2 files changed

+34
-42
lines changed

browser/main/NoteList/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class NoteList extends React.Component {
7171
this.jumpNoteByHash = this.jumpNoteByHashHandler.bind(this)
7272
this.handleNoteListKeyUp = this.handleNoteListKeyUp.bind(this)
7373
this.getNoteKeyFromTargetIndex = this.getNoteKeyFromTargetIndex.bind(this)
74+
this.cloneNote = this.cloneNote.bind(this)
7475
this.deleteNote = this.deleteNote.bind(this)
7576
this.focusNote = this.focusNote.bind(this)
7677
this.pinToTop = this.pinToTop.bind(this)
@@ -96,6 +97,7 @@ class NoteList extends React.Component {
9697
this.refreshTimer = setInterval(() => this.forceUpdate(), 60 * 1000)
9798
ee.on('list:next', this.selectNextNoteHandler)
9899
ee.on('list:prior', this.selectPriorNoteHandler)
100+
ee.on('list:clone', this.cloneNote)
99101
ee.on('list:focus', this.focusHandler)
100102
ee.on('list:isMarkdownNote', this.alertIfSnippetHandler)
101103
ee.on('import:file', this.importFromFileHandler)
@@ -118,6 +120,7 @@ class NoteList extends React.Component {
118120

119121
ee.off('list:next', this.selectNextNoteHandler)
120122
ee.off('list:prior', this.selectPriorNoteHandler)
123+
ee.off('list:clone', this.cloneNote)
121124
ee.off('list:focus', this.focusHandler)
122125
ee.off('list:isMarkdownNote', this.alertIfSnippetHandler)
123126
ee.off('import:file', this.importFromFileHandler)
@@ -277,12 +280,6 @@ class NoteList extends React.Component {
277280
ee.emit('top:new-note')
278281
}
279282

280-
// D key
281-
if (e.keyCode === 68) {
282-
e.preventDefault()
283-
this.deleteNote()
284-
}
285-
286283
// E key
287284
if (e.keyCode === 69) {
288285
e.preventDefault()

lib/main-menu.js

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,39 @@ const file = {
8585
},
8686
{
8787
label: 'Focus Note',
88-
accelerator: 'Control+E',
88+
accelerator: macOS ? 'Command+E' : 'Control+E',
8989
click () {
9090
mainWindow.webContents.send('detail:focus')
9191
}
9292
},
93+
{
94+
label: 'Delete Note',
95+
accelerator: macOS ? 'Command+Shift+Backspace' : 'Control+Shift+Backspace',
96+
click () {
97+
mainWindow.webContents.send('detail:delete')
98+
}
99+
},
100+
{
101+
label: 'Clone Note',
102+
accelerator: macOS ? 'Command+D' : 'Control+D',
103+
click () {
104+
mainWindow.webContents.send('list:clone')
105+
}
106+
},
93107
{
94108
type: 'separator'
95109
},
110+
{
111+
label: 'Import from',
112+
submenu: [
113+
{
114+
label: 'Plain Text, MarkDown (.txt, .md)',
115+
click () {
116+
mainWindow.webContents.send('import:file')
117+
}
118+
}
119+
]
120+
},
96121
{
97122
label: 'Export as',
98123
submenu: [
@@ -123,33 +148,16 @@ const file = {
123148
type: 'separator'
124149
},
125150
{
126-
label: 'Import from',
127-
submenu: [
128-
{
129-
label: 'Plain Text, MarkDown (.txt, .md)',
130-
click () {
131-
mainWindow.webContents.send('import:file')
132-
}
133-
}
134-
]
135-
},
136-
{
137-
type: 'separator'
138-
},
139-
{
140-
label: 'Format Table',
151+
label: 'Generate/Update Markdown TOC',
152+
accelerator: 'Shift+Ctrl+T',
141153
click () {
142-
mainWindow.webContents.send('code:format-table')
154+
mainWindow.webContents.send('code:generate-toc')
143155
}
144156
},
145157
{
146-
type: 'separator'
147-
},
148-
{
149-
label: 'Generate/Update Markdown TOC',
150-
accelerator: 'Shift+Ctrl+T',
158+
label: 'Format Table',
151159
click () {
152-
mainWindow.webContents.send('code:generate-toc')
160+
mainWindow.webContents.send('code:format-table')
153161
}
154162
},
155163
{
@@ -162,16 +170,6 @@ const file = {
162170
mainWindow.webContents.send('list:isMarkdownNote', 'print')
163171
mainWindow.webContents.send('print')
164172
}
165-
},
166-
{
167-
type: 'separator'
168-
},
169-
{
170-
label: 'Delete Note',
171-
accelerator: macOS ? 'Control+Backspace' : 'Control+Delete',
172-
click () {
173-
mainWindow.webContents.send('detail:delete')
174-
}
175173
}
176174
]
177175
}
@@ -296,9 +294,6 @@ const view = {
296294
mainWindow.setFullScreen(!mainWindow.isFullScreen())
297295
}
298296
},
299-
{
300-
type: 'separator'
301-
},
302297
{
303298
label: 'Toggle Side Bar',
304299
accelerator: 'CommandOrControl+B',

0 commit comments

Comments
 (0)