context menu

This commit is contained in:
Jan Prochazka
2021-03-20 08:16:32 +01:00
parent dcb4c5071a
commit efc07280a6
8 changed files with 106 additions and 20 deletions

View File

@@ -142,6 +142,24 @@ registerCommand({
group: 'saveAs',
});
registerCommand({
id: 'group.undo',
category: null,
isGroupCommand: true,
name: 'Undo',
keyText: 'Ctrl+Z',
group: 'undo',
});
registerCommand({
id: 'group.redo',
category: null,
isGroupCommand: true,
name: 'Redo',
keyText: 'Ctrl+Y',
group: 'redo',
});
if (electron) {
registerCommand({
id: 'file.open',
@@ -175,6 +193,7 @@ export function registerFileCommands({
execute = false,
toggleComment = false,
findReplace = false,
undoRedo = false,
}) {
registerCommand({
id: idPrefix + '.save',
@@ -248,4 +267,22 @@ export function registerFileCommands({
onClick: () => getCurrentEditor().replace(),
});
}
if (undoRedo) {
registerCommand({
id: idPrefix + '.undo',
category,
name: 'Undo',
group: 'undo',
testEnabled: () => getCurrentEditor()?.canUndo(),
onClick: () => getCurrentEditor().undo(),
});
registerCommand({
id: idPrefix + '.redo',
category,
group: 'redo',
name: 'Replace',
testEnabled: () => getCurrentEditor()?.canRedo(),
onClick: () => getCurrentEditor().redo(),
});
}
}