1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

renewal key binding

This commit is contained in:
Rokt33r
2015-12-29 02:18:37 +09:00
parent b820bdec09
commit 0187217c86
17 changed files with 388 additions and 48 deletions

View File

@@ -9,7 +9,7 @@ app.on('ready', function () {
app.dock.hide()
}
var template = require('./menu-template')
var template = require('./finder-menu')
var menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)

94
lib/finder-menu.js Normal file
View File

@@ -0,0 +1,94 @@
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const OSX = process.platform === 'darwin'
const WIN = process.platform === 'win32'
var edit = {
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'Command+Z',
selector: 'undo:'
},
{
label: 'Redo',
accelerator: 'Shift+Command+Z',
selector: 'redo:'
},
{
type: 'separator'
},
{
label: 'Cut',
accelerator: 'Command+X',
selector: 'cut:'
},
{
label: 'Copy',
accelerator: 'Command+C',
selector: 'copy:'
},
{
label: 'Paste',
accelerator: 'Command+V',
selector: 'paste:'
},
{
label: 'Select All',
accelerator: 'Command+A',
selector: 'selectAll:'
}
]
}
var view = {
label: 'View',
submenu: [
{
label: 'Focus Search',
accelerator: 'Control + Alt + F',
click: function () {
console.log('focus find')
}
},
{
type: 'separator'
},
{
label: 'Toggle Markdown Preview',
accelerator: OSX ? 'Command + P' : 'Ctrl + P',
click: function () {
console.log('markdown')
}
},
{
type: 'separator'
},
{
label: 'Reload',
accelerator: (function () {
if (process.platform === 'darwin') return 'Command+R'
else return 'Ctrl+R'
})(),
click: function () {
BrowserWindow.getFocusedWindow().reload()
}
},
{
label: 'Toggle Developer Tools',
accelerator: (function () {
if (process.platform === 'darwin') return 'Alt+Command+I'
else return 'Ctrl+Shift+I'
})(),
click: function (item, focusedWindow) {
if (focusedWindow) BrowserWindow.getFocusedWindow().toggleDevTools()
}
}
]
}
module.exports = process.platform === 'darwin'
? [edit, view]
: [view]

View File

@@ -227,7 +227,7 @@ app.on('ready', function () {
if (finderProcess) finderProcess.kill()
})
var template = require('./menu-template')
var template = require('./main-menu')
if (process.platform === 'win32') {
template.unshift({
label: 'Boostnote',

View File

@@ -1,6 +1,10 @@
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const shell = electron.shell
const mainWindow = require('./main-window')
const OSX = process.platform === 'darwin'
const WIN = process.platform === 'win32'
var boost = {
label: 'Boostnote',
@@ -12,13 +16,6 @@ var boost = {
{
type: 'separator'
},
{
label: 'Services',
submenu: []
},
{
type: 'separator'
},
{
label: 'Hide Boostnote',
accelerator: 'Command+H',
@@ -44,6 +41,53 @@ var boost = {
]
}
var file = {
label: 'File',
submenu: [
{
label: 'New Post',
accelerator: OSX ? 'Command + N' : 'Control + N',
click: function () {
mainWindow.webContents.send('nav-new-post')
}
},
{
label: 'New Folder',
accelerator: OSX ? 'Command + Shift + N' : 'Control + Shift + N',
click: function () {
mainWindow.webContents.send('nav-new-folder')
}
},
{
type: 'separator'
},
{
label: 'Save Post',
accelerator: OSX ? 'Command + S' : 'Control + S',
click: function () {
mainWindow.webContents.send('detail-save')
}
},
{
label: 'Save All Posts',
accelerator: OSX ? 'Command + Shift + S' : 'Control + Shift + S',
click: function () {
mainWindow.webContents.send('top-save-all')
}
},
{
type: 'separator'
},
{
label: 'Delete Post',
accelerator: OSX ? 'Control + Backspace' : 'Control + Delete',
click: function () {
mainWindow.webContents.send('detail-delete')
}
}
]
}
var edit = {
label: 'Edit',
submenu: [
@@ -86,6 +130,26 @@ var edit = {
var view = {
label: 'View',
submenu: [
{
label: 'Focus Search',
accelerator: 'Control + Alt + F',
click: function () {
mainWindow.webContents.send('top-focus-search')
}
},
{
type: 'separator'
},
{
label: 'Toggle Markdown Preview',
accelerator: OSX ? 'Command + P' : 'Ctrl + P',
click: function () {
mainWindow.webContents.send('detail-toggle-preview')
}
},
{
type: 'separator'
},
{
label: 'Reload',
accelerator: (function () {
@@ -156,5 +220,5 @@ var help = {
}
module.exports = process.platform === 'darwin'
? [boost, edit, view, window, help]
: [view, help]
? [boost, file, edit, view, window, help]
: [file, view, help]

View File

@@ -21,6 +21,16 @@ mainWindow.webContents.on('new-window', function (e) {
e.preventDefault()
})
mainWindow.webContents.sendInputEvent({
type: 'keyDown',
keyCode: '\u0008'
})
mainWindow.webContents.sendInputEvent({
type: 'keyUp',
keyCode: '\u0008'
})
app.on('activate', function () {
if (mainWindow == null) return null
mainWindow.show()