From df302de74c2d7de150e2e7a7c49fc9f44f72b114 Mon Sep 17 00:00:00 2001 From: Universe-sudojam <173473046+Universe-sudojam@users.noreply.github.com> Date: Thu, 4 Sep 2025 21:56:50 +0000 Subject: [PATCH] Fixed undo/redo hooks to edit menu --- src/editor/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/editor/index.ts b/src/editor/index.ts index 3e24a64..c69cc2b 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -91,13 +91,14 @@ export const editor: JupyterFrontEndPlugin = { 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) { @@ -105,10 +106,10 @@ export const editor: JupyterFrontEndPlugin = { } widget.redo(); }, - isEnabled, }); commands.addCommand(CommandIDs.undo, { + label: 'Undo', execute: () => { const widget = tracker.currentWidget; if (!widget) { @@ -116,16 +117,17 @@ export const editor: JupyterFrontEndPlugin = { } 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);