1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

Merge branch 'master' of github.com:laurent22/joplin

This commit is contained in:
Laurent Cozic
2017-12-01 19:44:41 +00:00

View File

@@ -229,21 +229,22 @@ class Application extends BaseApplication {
label: _('Edit'), label: _('Edit'),
submenu: [{ submenu: [{
label: _('Copy'), label: _('Copy'),
screens: ['Main'], screens: ['Main', 'OneDriveLogin'],
role: 'copy', role: 'copy',
accelerator: 'CommandOrControl+C', accelerator: 'CommandOrControl+C',
}, { }, {
label: _('Cut'), label: _('Cut'),
screens: ['Main'], screens: ['Main', 'OneDriveLogin'],
role: 'cut', role: 'cut',
accelerator: 'CommandOrControl+X', accelerator: 'CommandOrControl+X',
}, { }, {
label: _('Paste'), label: _('Paste'),
screens: ['Main'], screens: ['Main', 'OneDriveLogin'],
role: 'paste', role: 'paste',
accelerator: 'CommandOrControl+V', accelerator: 'CommandOrControl+V',
}, { }, {
type: 'separator', type: 'separator',
screens: ['Main'],
}, { }, {
label: _('Search in all the notes'), label: _('Search in all the notes'),
screens: ['Main'], screens: ['Main'],
@@ -290,12 +291,21 @@ class Application extends BaseApplication {
}, },
]; ];
function isEmptyMenu(template) {
for (let i = 0; i < template.length; i++) {
const t = template[i];
if (t.type !== 'separator') return false;
}
return true;
}
function removeUnwantedItems(template, screen) { function removeUnwantedItems(template, screen) {
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.submenu) t.submenu = removeUnwantedItems(t.submenu, screen); if (t.submenu) t.submenu = removeUnwantedItems(t.submenu, screen);
if (('submenu' in t) && isEmptyMenu(t.submenu)) continue;
output.push(t); output.push(t);
} }
return output; return output;