Remove separator when none of undo and redo button are visible

This commit is contained in:
Alice Gaudon 2020-01-10 16:59:51 +01:00
parent 1e822fd5ce
commit 0d2f3a60cd

View File

@ -55,25 +55,29 @@ webContents.on('context-menu', (event, props) => {
// Text clipboard // Text clipboard
if (editFlags.canUndo || editFlags.canRedo || editFlags.canCut || editFlags.canCopy || editFlags.canPaste || editFlags.canDelete) { if (editFlags.canUndo || editFlags.canRedo || editFlags.canCut || editFlags.canCopy || editFlags.canPaste || editFlags.canDelete) {
if (menu.items.length > 0) { if (editFlags.canUndo || editFlags.canRedo) {
menu.append(new MenuItem({type: 'separator'})); if (menu.items.length > 0) {
} menu.append(new MenuItem({type: 'separator'}));
if (editFlags.canUndo) { }
menu.append(new MenuItem({
label: 'Undo', if (editFlags.canUndo) {
role: 'undo', menu.append(new MenuItem({
})); label: 'Undo',
} role: 'undo',
if (editFlags.canRedo) { }));
menu.append(new MenuItem({ }
label: 'Redo', if (editFlags.canRedo) {
role: 'redo', menu.append(new MenuItem({
})); label: 'Redo',
role: 'redo',
}));
}
} }
if (menu.items.length > 0) { if (menu.items.length > 0) {
menu.append(new MenuItem({type: 'separator'})); menu.append(new MenuItem({type: 'separator'}));
} }
menu.append(new MenuItem({ menu.append(new MenuItem({
label: 'Cut', label: 'Cut',
role: 'cut', role: 'cut',