mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 10:22:31 +01:00
32 lines
854 B
JavaScript
32 lines
854 B
JavaScript
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
const { Menu } = require('electron');
|
|
|
|
// https://github.com/electron/electron/issues/4068#issuecomment-274159726
|
|
module.exports = (window) => {
|
|
const selectionMenu = Menu.buildFromTemplate([
|
|
{ role: 'copy' },
|
|
{ type: 'separator' },
|
|
{ role: 'selectAll' },
|
|
]);
|
|
|
|
const inputMenu = Menu.buildFromTemplate([
|
|
{ role: 'undo' },
|
|
{ role: 'redo' },
|
|
{ type: 'separator' },
|
|
{ role: 'cut' },
|
|
{ role: 'copy' },
|
|
{ role: 'paste' },
|
|
{ type: 'separator' },
|
|
{ role: 'selectAll' },
|
|
]);
|
|
|
|
window.webContents.on('context-menu', (_e, props) => {
|
|
const { selectionText, isEditable } = props;
|
|
if (isEditable) {
|
|
inputMenu.popup(window);
|
|
} else if (selectionText && selectionText.trim() !== '') {
|
|
selectionMenu.popup(window);
|
|
}
|
|
});
|
|
};
|