mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Electron: Added several keyboard shortcuts
This commit is contained in:
parent
7244e12b78
commit
4218b65969
@ -63,7 +63,7 @@ class ElectronAppWrapper {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
// Uncomment this to view errors if the application does not start
|
// Uncomment this to view errors if the application does not start
|
||||||
if (this.env_ === 'dev') this.win_.webContents.openDevTools();
|
// if (this.env_ === 'dev') this.win_.webContents.openDevTools();
|
||||||
|
|
||||||
this.win_.on('close', (event) => {
|
this.win_.on('close', (event) => {
|
||||||
// If it's on macOS, the app is completely closed only if the user chooses to close the app (willQuitApp_ will be true)
|
// If it's on macOS, the app is completely closed only if the user chooses to close the app (willQuitApp_ will be true)
|
||||||
|
@ -200,6 +200,7 @@ class Application extends BaseApplication {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: _('New notebook'),
|
label: _('New notebook'),
|
||||||
|
accelerator: 'CommandOrControl+B',
|
||||||
screens: ['Main'],
|
screens: ['Main'],
|
||||||
click: () => {
|
click: () => {
|
||||||
this.dispatch({
|
this.dispatch({
|
||||||
@ -228,6 +229,14 @@ class Application extends BaseApplication {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
type: 'separator',
|
||||||
|
platforms: ['darwin'],
|
||||||
|
}, {
|
||||||
|
label: _('Hide %s', 'Joplin'),
|
||||||
|
platforms: ['darwin'],
|
||||||
|
accelerator: 'CommandOrControl+H',
|
||||||
|
click: () => { bridge().window().hide() }
|
||||||
}, {
|
}, {
|
||||||
type: 'separator',
|
type: 'separator',
|
||||||
}, {
|
}, {
|
||||||
@ -266,6 +275,19 @@ class Application extends BaseApplication {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
}, {
|
||||||
|
label: _('View'),
|
||||||
|
submenu: [{
|
||||||
|
label: _('Toggle editor layout'),
|
||||||
|
screens: ['Main'],
|
||||||
|
accelerator: 'CommandOrControl+L',
|
||||||
|
click: () => {
|
||||||
|
this.dispatch({
|
||||||
|
type: 'WINDOW_COMMAND',
|
||||||
|
name: 'toggleVisiblePanes',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}],
|
||||||
}, {
|
}, {
|
||||||
label: _('Tools'),
|
label: _('Tools'),
|
||||||
submenu: [{
|
submenu: [{
|
||||||
@ -289,6 +311,7 @@ class Application extends BaseApplication {
|
|||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
label: _('General Options'),
|
label: _('General Options'),
|
||||||
|
accelerator: 'CommandOrControl+,',
|
||||||
click: () => {
|
click: () => {
|
||||||
this.dispatch({
|
this.dispatch({
|
||||||
type: 'NAV_GO',
|
type: 'NAV_GO',
|
||||||
@ -334,10 +357,13 @@ class Application extends BaseApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeUnwantedItems(template, screen) {
|
function removeUnwantedItems(template, screen) {
|
||||||
|
const platform = shim.platformName();
|
||||||
|
|
||||||
let output = [];
|
let output = [];
|
||||||
for (let i = 0; i < template.length; i++) {
|
for (let i = 0; i < template.length; i++) {
|
||||||
const t = Object.assign({}, template[i]);
|
const t = Object.assign({}, template[i]);
|
||||||
if (t.screens && t.screens.indexOf(screen) < 0) continue;
|
if (t.screens && t.screens.indexOf(screen) < 0) continue;
|
||||||
|
if (t.platforms && t.platforms.indexOf(platform) < 0) continue;
|
||||||
if (t.submenu) t.submenu = removeUnwantedItems(t.submenu, screen);
|
if (t.submenu) t.submenu = removeUnwantedItems(t.submenu, screen);
|
||||||
if (('submenu' in t) && isEmptyMenu(t.submenu)) continue;
|
if (('submenu' in t) && isEmptyMenu(t.submenu)) continue;
|
||||||
output.push(t);
|
output.push(t);
|
||||||
|
@ -50,14 +50,47 @@ autoUpdater.on('error', (error) => {
|
|||||||
onCheckEnded();
|
onCheckEnded();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function findDownloadFilename_(info) {
|
||||||
|
// { version: '1.0.64',
|
||||||
|
// files:
|
||||||
|
// [ { url: 'Joplin-1.0.64-mac.zip',
|
||||||
|
// sha512: 'OlemXqhq/fSifx7EutvMzfoCI/1kGNl10i8nkvACEDfVXwP8hankDBXEC0+GxSArsZuxOh3U1+C+4j72SfIUew==' },
|
||||||
|
// { url: 'Joplin-1.0.64.dmg',
|
||||||
|
// sha512: 'jAewQQoJ3nCaOj8hWDgf0sc3LBbAWQtiKqfTflK8Hc3Dh7fAy9jRHfFAZKFUZ9ll95Bun0DVsLq8wLSUrdsMXw==',
|
||||||
|
// size: 77104485 } ],
|
||||||
|
// path: 'Joplin-1.0.64-mac.zip',
|
||||||
|
// sha512: 'OlemXqhq/fSifx7EutvMzfoCI/1kGNl10i8nkvACEDfVXwP8hankDBXEC0+GxSArsZuxOh3U1+C+4j72SfIUew==',
|
||||||
|
// releaseDate: '2018-02-16T00:13:01.634Z',
|
||||||
|
// releaseName: 'v1.0.64',
|
||||||
|
// releaseNotes: '<p>Still more fixes and im...' }
|
||||||
|
|
||||||
|
if (!info) return null;
|
||||||
|
|
||||||
|
if (!info.files) {
|
||||||
|
// info.path seems to contain a default, though not a good one,
|
||||||
|
// so the loop below if preferable to find the right file.
|
||||||
|
return info.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < info.files.length; i++) {
|
||||||
|
const f = info.files[i].url; // Annoyingly this is called "url" but it's obviously not a url, so hopefully it won't change later on and become one.
|
||||||
|
if (f.indexOf('.exe') >= 0) return f;
|
||||||
|
if (f.indexOf('.dmg') >= 0) return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return info.path;
|
||||||
|
}
|
||||||
|
|
||||||
autoUpdater.on('update-available', (info) => {
|
autoUpdater.on('update-available', (info) => {
|
||||||
if (!info.version || !info.path) {
|
const filename = findDownloadFilename_(info);
|
||||||
|
|
||||||
|
if (!info.version || !filename) {
|
||||||
if (checkInBackground_) return onCheckEnded();
|
if (checkInBackground_) return onCheckEnded();
|
||||||
showErrorMessageBox(('Could not get version info: ' + JSON.stringify(info)));
|
showErrorMessageBox(('Could not get version info: ' + JSON.stringify(info)));
|
||||||
return onCheckEnded();
|
return onCheckEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadUrl = 'https://github.com/laurent22/joplin/releases/download/v' + info.version + '/' + info.path;
|
const downloadUrl = 'https://github.com/laurent22/joplin/releases/download/v' + info.version + '/' + filename;
|
||||||
|
|
||||||
let releaseNotes = info.releaseNotes + '';
|
let releaseNotes = info.releaseNotes + '';
|
||||||
if (releaseNotes) releaseNotes = '\n\n' + _('Release notes:\n\n%s', htmlToText_(releaseNotes));
|
if (releaseNotes) releaseNotes = '\n\n' + _('Release notes:\n\n%s', htmlToText_(releaseNotes));
|
||||||
|
@ -163,6 +163,8 @@ class MainScreenComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if (command.name === 'toggleVisiblePanes') {
|
||||||
|
this.toggleVisiblePanes();
|
||||||
} else if (command.name === 'editAlarm') {
|
} else if (command.name === 'editAlarm') {
|
||||||
const note = await Note.load(command.noteId);
|
const note = await Note.load(command.noteId);
|
||||||
|
|
||||||
@ -309,9 +311,7 @@ class MainScreenComponent extends React.Component {
|
|||||||
title: _('Layout'),
|
title: _('Layout'),
|
||||||
iconName: 'fa-columns',
|
iconName: 'fa-columns',
|
||||||
enabled: !!notes.length,
|
enabled: !!notes.length,
|
||||||
onClick: () => {
|
onClick: () => { this.doCommand({ name: 'toggleVisiblePanes' }) },
|
||||||
this.toggleVisiblePanes();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.promptOnClose_) {
|
if (!this.promptOnClose_) {
|
||||||
|
@ -22,6 +22,14 @@ shim.isMac = () => {
|
|||||||
return process && process.platform === 'darwin';
|
return process && process.platform === 'darwin';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shim.platformName = function() {
|
||||||
|
if (shim.isReactNative()) return 'mobile';
|
||||||
|
if (shim.isMac()) return 'darwin';
|
||||||
|
if (shim.isWindows()) return 'win32';
|
||||||
|
if (shim.isLinux()) return 'linux';
|
||||||
|
throw new Error('Cannot determine platform');
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/cheton/is-electron
|
// https://github.com/cheton/is-electron
|
||||||
shim.isElectron = () => {
|
shim.isElectron = () => {
|
||||||
// Renderer process
|
// Renderer process
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"ElectronClient/app/css/font-awesome.min.css",
|
"ElectronClient/app/css/font-awesome.min.css",
|
||||||
"docs/*.html",
|
"docs/*.html",
|
||||||
"docs/*.svg",
|
"docs/*.svg",
|
||||||
|
"ReactNativeClient/lib/mime-utils.js",
|
||||||
],
|
],
|
||||||
"folder_exclude_patterns":
|
"folder_exclude_patterns":
|
||||||
[
|
[
|
||||||
@ -52,7 +53,8 @@
|
|||||||
"tests/logs",
|
"tests/logs",
|
||||||
"ReactNativeClient/ios/build",
|
"ReactNativeClient/ios/build",
|
||||||
"ElectronClient/app/dist",
|
"ElectronClient/app/dist",
|
||||||
"_releases"
|
"_releases",
|
||||||
|
"ReactNativeClient/lib/csstojs",
|
||||||
],
|
],
|
||||||
"path": "."
|
"path": "."
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user