@@ -28,6 +28,12 @@ export class DeleteAction {
2828 */
2929 private oldContextMenuItem : ContextMenuRegistry . RegistryItem | null = null ;
3030
31+ /**
32+ * Saved delete shortcut, which is re-registered when this action
33+ * is uninstalled.
34+ */
35+ private oldDeleteShortcut : ShortcutRegistry . KeyboardShortcut | null = null ;
36+
3137 /**
3238 * Registration name for the keyboard shortcut.
3339 */
@@ -53,19 +59,30 @@ export class DeleteAction {
5359 ContextMenuRegistry . registry . register ( this . oldContextMenuItem ) ;
5460 }
5561 ShortcutRegistry . registry . unregister ( this . deleteShortcutName ) ;
62+ if ( this . oldDeleteShortcut ) {
63+ ShortcutRegistry . registry . register ( this . oldDeleteShortcut ) ;
64+ }
5665 }
5766
5867 /**
5968 * Create and register the keyboard shortcut for this action.
6069 */
6170 private registerShortcut ( ) {
71+ this . oldDeleteShortcut = ShortcutRegistry . registry . getRegistry ( ) [ 'delete' ] ;
72+
73+ if ( ! this . oldDeleteShortcut ) return ;
74+
75+ // Unregister the original shortcut.
76+ ShortcutRegistry . registry . unregister ( this . oldDeleteShortcut . name ) ;
77+
6278 const deleteShortcut : ShortcutRegistry . KeyboardShortcut = {
6379 name : this . deleteShortcutName ,
6480 preconditionFn : this . deletePrecondition . bind ( this ) ,
6581 callback : this . deleteCallback . bind ( this ) ,
6682 keyCodes : [ KeyCodes . DELETE , KeyCodes . BACKSPACE ] ,
6783 allowCollision : true ,
6884 } ;
85+
6986 ShortcutRegistry . registry . register ( deleteShortcut ) ;
7087 }
7188
@@ -139,6 +156,7 @@ export class DeleteAction {
139156 private deletePrecondition ( workspace : WorkspaceSvg ) {
140157 const sourceBlock = workspace . getCursor ( ) ?. getCurNode ( ) ?. getSourceBlock ( ) ;
141158 return (
159+ ! workspace . isDragging ( ) &&
142160 this . navigation . canCurrentlyEdit ( workspace ) &&
143161 ! ! sourceBlock ?. isDeletable ( )
144162 ) ;
0 commit comments