mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 19:52:44 +01:00
999e855254
closes #1217
31 lines
791 B
JavaScript
31 lines
791 B
JavaScript
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);
|
|
}
|
|
});
|
|
};
|