mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 05:58:41 -09:00
Fix contextMenu
This commit is contained in:
parent
62e29effbf
commit
ec6ecdd258
1 changed files with 10 additions and 3 deletions
|
|
@ -1,8 +1,15 @@
|
||||||
const editMenu = require('../menus/menus/edit');
|
const editMenu = require('../menus/menus/edit');
|
||||||
const shellMenu = require('../menus/menus/shell');
|
const shellMenu = require('../menus/menus/shell');
|
||||||
const {getKeymaps: commands} = require('../config');
|
const {execCommand} = require('../commands');
|
||||||
|
const {getDecoratedKeymaps} = require('../plugins');
|
||||||
const separator = {type: 'separator'};
|
const separator = {type: 'separator'};
|
||||||
|
|
||||||
|
const allCommandKeys = getDecoratedKeymaps();
|
||||||
|
const commandKeys = Object.keys(allCommandKeys).reduce((result, command) => {
|
||||||
|
result[command] = allCommandKeys[command][0];
|
||||||
|
return result;
|
||||||
|
}, {});
|
||||||
|
|
||||||
// only display cut/copy when there's a cursor selection
|
// only display cut/copy when there's a cursor selection
|
||||||
const filterCutCopy = (selection, menuItem) => {
|
const filterCutCopy = (selection, menuItem) => {
|
||||||
if (/^cut$|^copy$/.test(menuItem.role) && !selection) {
|
if (/^cut$|^copy$/.test(menuItem.role) && !selection) {
|
||||||
|
|
@ -12,7 +19,7 @@ const filterCutCopy = (selection, menuItem) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = (createWindow, selection) => {
|
module.exports = (createWindow, selection) => {
|
||||||
const _shell = shellMenu(commands, createWindow).submenu;
|
const _shell = shellMenu(commandKeys, execCommand).submenu;
|
||||||
const _edit = editMenu(commands).submenu.filter(filterCutCopy.bind(null, selection));
|
const _edit = editMenu(commandKeys, execCommand).submenu.filter(filterCutCopy.bind(null, selection));
|
||||||
return _edit.concat(separator, _shell);
|
return _edit.concat(separator, _shell);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue