From 55dd0d44b7fb08788a17740949dd0d1f3932fbec Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Sat, 3 May 2025 01:14:53 +0100 Subject: [PATCH] fix(actions): Fix shortcut wrappers broken by google/blockly#8917 --- src/actions/undo_redo.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/actions/undo_redo.ts b/src/actions/undo_redo.ts index a2509767..7f537d22 100644 --- a/src/actions/undo_redo.ts +++ b/src/actions/undo_redo.ts @@ -4,7 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {ShortcutRegistry, ShortcutItems, WorkspaceSvg} from 'blockly/core'; +import { + ContextMenuRegistry, + ShortcutRegistry, + ShortcutItems, + WorkspaceSvg, +} from 'blockly/core'; /** * Class for registering a shortcut for undo/redo actions. @@ -22,9 +27,12 @@ export class UndoRedoAction { this.originalUndo = undo; const patchedUndo = { ...this.originalUndo, - preconditionFn: (workspace: WorkspaceSvg) => { + preconditionFn: ( + workspace: WorkspaceSvg, + scope: ContextMenuRegistry.Scope, + ) => { return !!( - !workspace.isDragging() && undo.preconditionFn?.(workspace) + !workspace.isDragging() && undo.preconditionFn?.(workspace, scope) ); }, allowCollision: true, @@ -39,9 +47,12 @@ export class UndoRedoAction { this.originalRedo = redo; const patchedRedo = { ...this.originalRedo, - preconditionFn: (workspace: WorkspaceSvg) => { + preconditionFn: ( + workspace: WorkspaceSvg, + scope: ContextMenuRegistry.Scope, + ) => { return !!( - !workspace.isDragging() && redo.preconditionFn?.(workspace) + !workspace.isDragging() && redo.preconditionFn?.(workspace, scope) ); }, allowCollision: true,