Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,41 +91,43 @@ export const editor: JupyterFrontEndPlugin<IVoilaGridStackTracker> = {
const isEnabled = () => {
const widget = tracker.currentWidget;

if (!widget) {
return false;
if (widget?.isVisible && widget === app.shell.currentWidget) {
return true;
}
return true;
return false;
};

commands.addCommand(CommandIDs.redo, {
label: 'Redo',
execute: () => {
const widget = tracker.currentWidget;
if (!widget) {
return;
}
widget.redo();
},
isEnabled,
});

commands.addCommand(CommandIDs.undo, {
label: 'Undo',
execute: () => {
const widget = tracker.currentWidget;
if (!widget) {
return;
}
widget.undo();
},
isEnabled,
});

// Add undo/redo hooks to the edit menu.
mainMenu.editMenu.undoers.undo.add({
id: CommandIDs.undo,
isEnabled,
});
// Add undo/redo hooks to the edit menu.
mainMenu.editMenu.undoers.redo.add({
id: CommandIDs.redo,
isEnabled,
});

app.docRegistry.addWidgetFactory(factory);
Expand Down