Skip to content

Commit 3696e2b

Browse files
authored
fix: improve reliability of disposing and reinitializing plugin (#687)
* fix: improve reliability of disposing and reinitializing plugin * chore: format * chore: improve test names
1 parent 42aa296 commit 3696e2b

File tree

10 files changed

+275
-184
lines changed

10 files changed

+275
-184
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"predeploy": "blockly-scripts predeploy",
1515
"prepublishOnly": "npm login --registry https://wombat-dressing-room.appspot.com",
1616
"start": "blockly-scripts start",
17-
"test": "npm run wdio:clean && npm run wdio:build && npm run wdio:run",
17+
"test": "npm run test:mocha && npm run test:wdio",
18+
"test:mocha": "blockly-scripts test",
19+
"test:wdio": "npm run wdio:clean && npm run wdio:run",
1820
"wdio:build": "npm run wdio:build:app && npm run wdio:build:tests",
1921
"wdio:build:app": "cd test/webdriverio && webpack",
2022
"wdio:build:tests": "tsc -p ./test/webdriverio/test/tsconfig.json",
@@ -65,6 +67,7 @@
6567
"eslint-plugin-jsdoc": "^46.8.2",
6668
"globals": "^15.4.0",
6769
"html-webpack-plugin": "^5.6.0",
70+
"jsdom-global": "^3.0.2",
6871
"mocha": "^11.1.0",
6972
"p5": "^1.10.0",
7073
"prettier": "^3.3.1",

src/actions/clipboard.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ export class Clipboard {
6060

6161
/**
6262
* Uninstall this action as both a keyboard shortcut and a context menu item.
63-
* N. B. This does *not* currently reinstall the original keyboard shortcuts.
64-
* You should manually reinstall the previously registered shortcuts (either
65-
* from core or from another plugin you may be using).
63+
* Reinstall the original cut/copy/paste shortcuts.
6664
*/
6765
uninstall() {
6866
ContextMenuRegistry.registry.unregister('blockCutFromContextMenu');
@@ -72,6 +70,18 @@ export class Clipboard {
7270
ShortcutRegistry.registry.unregister(Constants.SHORTCUT_NAMES.CUT);
7371
ShortcutRegistry.registry.unregister(Constants.SHORTCUT_NAMES.COPY);
7472
ShortcutRegistry.registry.unregister(Constants.SHORTCUT_NAMES.PASTE);
73+
74+
if (this.oldCutShortcut) {
75+
ShortcutRegistry.registry.register(this.oldCutShortcut);
76+
}
77+
78+
if (this.oldCopyShortcut) {
79+
ShortcutRegistry.registry.register(this.oldCopyShortcut);
80+
}
81+
82+
if (this.oldPasteShortcut) {
83+
ShortcutRegistry.registry.register(this.oldPasteShortcut);
84+
}
7585
}
7686

7787
/**

src/actions/edit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import {ContextMenuRegistry, Msg, keyboardNavigationController} from 'blockly';
8-
import {Navigation} from 'src/navigation';
8+
import {Navigation} from '../navigation';
99
import {getMenuItem} from '../shortcut_formatting';
1010
import * as Constants from '../constants';
1111

src/actions/enter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class EnterAction {
105105
}
106106
},
107107
keyCodes: [KeyCodes.ENTER, KeyCodes.SPACE],
108+
allowCollision: true,
108109
});
109110
}
110111

@@ -116,6 +117,7 @@ export class EnterAction {
116117
*/
117118
private shouldHandleEnterForWS(workspace: WorkspaceSvg): boolean {
118119
if (!this.navigation.canCurrentlyNavigate(workspace)) return false;
120+
if (workspace.isDragging()) return false;
119121

120122
const curNode = workspace.getCursor().getCurNode();
121123
if (!curNode) return false;

0 commit comments

Comments
 (0)