Skip to content

Commit 0a22812

Browse files
committed
[WIP] Support Blockly v12
Signed-off-by: Hollow Man <[email protected]>
1 parent b67345a commit 0a22812

File tree

7 files changed

+363
-443
lines changed

7 files changed

+363
-443
lines changed

package-lock.json

Lines changed: 331 additions & 427 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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@
4242
"dragselect": "^2.7.4"
4343
},
4444
"devDependencies": {
45-
"@blockly/dev-scripts": "^4.0.7",
46-
"@blockly/dev-tools": "^8.0.12",
47-
"@blockly/keyboard-navigation": "^0.6.12",
48-
"@blockly/workspace-backpack": "^6.0.12",
49-
"blockly": "^11.2.0"
45+
"@blockly/dev-scripts": "^4.0.9",
46+
"@blockly/dev-tools": "^9.0.1",
47+
"@blockly/workspace-backpack": "^7.0.1",
48+
"blockly": "^12.1.0"
5049
},
5150
"peerDependencies": {
5251
"blockly": ">=11"

src/multiselect_contextmenu.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const registerDuplicate = function() {
210210
});
211211
dragSelection.clear();
212212
multiDraggable.clearAll_();
213-
Blockly.common.setSelected(null);
213+
Blockly.common.setSelected(workspace);
214214
} else {
215215
apply(scope.block);
216216
}
@@ -821,7 +821,7 @@ const registerSelectAll = function() {
821821
} else {
822822
Blockly.getSelected().unselect();
823823
}
824-
Blockly.common.setSelected(null);
824+
Blockly.common.setSelected(scope.workspace);
825825
multiDraggable.clearAll_();
826826
dragSelectionWeakMap.get(scope.workspace).clear();
827827
}
@@ -1103,7 +1103,7 @@ const registerCommentDuplicate = function() {
11031103
});
11041104
dragSelection.clear();
11051105
multiDraggable.clearAll_();
1106-
Blockly.common.setSelected(null);
1106+
Blockly.common.setSelected(workspace);
11071107
} else {
11081108
apply(scope.comment);
11091109
}

src/multiselect_controls.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export class MultiselectControls {
387387
}
388388
this.multiDraggable.clearAll_();
389389
this.dragSelection.clear();
390-
Blockly.common.setSelected(null);
390+
Blockly.common.setSelected(this.workspace_);
391391
} else if (Blockly.getSelected() &&
392392
!(Blockly.getSelected() instanceof MultiselectDraggable)) {
393393
// Blockly.getSelected() is not a multiselectDraggable
@@ -415,7 +415,7 @@ export class MultiselectControls {
415415
MultiselectDraggable)) {
416416
if (Blockly.getSelected() instanceof Blockly.BlockSvg &&
417417
!Blockly.getSelected().isShadow()) {
418-
Blockly.common.setSelected(null);
418+
Blockly.common.setSelected(this.workspace_);
419419
}
420420
// TODO: Look into this after gesture has been updated at Blockly
421421
// Currently, the setSelected is called twice even with selection of

src/multiselect_draggable.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ export class MultiselectDraggable {
3232
this.dragSelection = dragSelectionWeakMap.get(workspace);
3333
}
3434

35+
canBeFocused() {
36+
return true;
37+
}
38+
39+
getFocusableTree() {
40+
return this.workspace;
41+
}
42+
43+
getFocusableElement() {
44+
for (const id of this.dragSelection) {
45+
const block = this.workspace.getBlockById(id);
46+
if (block) {
47+
return block.getSvgRoot();
48+
}
49+
}
50+
}
51+
3552
/**
3653
* Clears everything in the subDraggables
3754
* map of the MultiselectDraggable object.

src/multiselect_shortcut.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ const registerSelectAll = function() {
471471
} else {
472472
Blockly.getSelected().unselect();
473473
}
474-
Blockly.common.setSelected(null);
474+
Blockly.common.setSelected(workspace);
475475
multiDraggable.clearAll_();
476476
dragSelectionWeakMap.get(workspace).clear();
477477
}

test/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import * as Blockly from 'blockly';
1212
import {toolboxCategories, createPlayground} from '@blockly/dev-tools';
1313
import {Multiselect} from '../src/index';
1414
import {Backpack} from '@blockly/workspace-backpack';
15-
import {NavigationController} from '@blockly/keyboard-navigation';
15+
// import {NavigationController} from '@blockly/keyboard-navigation';
1616

17-
const navigationController = new NavigationController();
17+
// const navigationController = new NavigationController();
1818
/**
1919
* Create a workspace.
2020
* @param {HTMLElement} blocklyDiv The blockly container div.
@@ -28,7 +28,7 @@ function createWorkspace(blocklyDiv, options) {
2828
const backpack = new Backpack(workspace);
2929
backpack.init();
3030

31-
navigationController.addWorkspace(workspace);
31+
// navigationController.addWorkspace(workspace);
3232

3333
// Initialize multiselect plugin.
3434
const multiselectPlugin = new Multiselect(workspace);
@@ -38,8 +38,8 @@ function createWorkspace(blocklyDiv, options) {
3838
}
3939

4040
Blockly.ContextMenuItems.registerCommentOptions();
41-
// Initialize keyboard nav plugin.
42-
navigationController.init();
41+
// // Initialize keyboard nav plugin.
42+
// navigationController.init();
4343

4444
document.addEventListener('DOMContentLoaded', function() {
4545
const defaultOptions = {

0 commit comments

Comments
 (0)