Skip to content

Commit 50e43de

Browse files
committed
Merge branch 'main' into introduce-initial-screen-reader-support
2 parents 7462da7 + 7ee7ba5 commit 50e43de

24 files changed

+508
-220
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Assign requested reviewers
2+
3+
# This workflow adds requested reviewers as assignees. If you remove a
4+
# requested reviewer, it will not remove them as an assignee.
5+
#
6+
# See https://github.com/google/blockly/issues/5643 for more
7+
# information on why this was added.
8+
#
9+
# N.B.: Runs with a read-write repo token. Do not check out the
10+
# submitted branch!
11+
on:
12+
pull_request_target:
13+
types: [review_requested]
14+
15+
jobs:
16+
requested-reviewer:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
pull-requests: write
20+
steps:
21+
- name: Assign requested reviewer
22+
uses: actions/github-script@v7
23+
with:
24+
script: |
25+
try {
26+
if (context.payload.pull_request === undefined) {
27+
throw new Error("Can't get pull_request payload. " +
28+
'Check a request reviewer event was triggered.');
29+
}
30+
const reviewers = context.payload.pull_request.requested_reviewers;
31+
// Assignees takes in a list of logins rather than the
32+
// reviewer object.
33+
const reviewerNames = reviewers.map(reviewer => reviewer.login);
34+
const {number:issue_number} = context.payload.pull_request;
35+
github.rest.issues.addAssignees({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
issue_number: issue_number,
39+
assignees: reviewerNames
40+
});
41+
} catch (error) {
42+
core.setFailed(error.message);
43+
}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ const workspace = Blockly.inject('blocklyDiv', {
8181
const keyboardNav = new KeyboardNavigation(workspace);
8282
```
8383

84+
## Add shortcuts to page
85+
86+
In order to see the keyboard help popup when the user presses /, you need to add an empty div element to the hosting page that has the Blockly div element with the id "shortcuts". The plugin will take care of layout and formatting.
87+
88+
```html
89+
...
90+
<div id="shortcuts"></div>
91+
...
92+
<div id="blockly"></div>
93+
...
94+
```
95+
8496
### Usage with cross-tab-copy-paste plugin
8597

8698
This plugin adds context menu items for copying & pasting. It also adds feedback to copying & pasting as toasts that are shown to the user upon successful copy or cut. It is compatible with the `@blockly/plugin-cross-tab-copy-paste` by following these steps:

package-lock.json

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

src/actions/action_menu.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ export class ActionMenu {
8686
// TODO(#362): Pass this through the precondition and callback instead of making it up.
8787
const menuOpenEvent = new KeyboardEvent('keydown');
8888

89-
const cursor = workspace.getCursor();
90-
if (!cursor) throw new Error('workspace has no cursor');
91-
const node = cursor.getCurNode();
89+
const node = workspace.getCursor().getCurNode();
9290
if (!node) return false;
9391
// TODO(google/blockly#8847): Add typeguard for IContextMenu in core when this moves over
9492
if (

src/actions/arrow_navigation.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ export class ArrowNavigation {
3838
workspace: WorkspaceSvg,
3939
shortcut: ShortcutRegistry.KeyboardShortcut,
4040
): boolean {
41-
const cursor = workspace.getCursor();
42-
if (!cursor || !cursor.getCurNode()) {
43-
return false;
44-
}
45-
const curNode = cursor.getCurNode();
41+
const curNode = workspace.getCursor().getCurNode();
4642
if (curNode instanceof Field) {
4743
return curNode.onShortcut(shortcut);
4844
}
@@ -70,7 +66,7 @@ export class ArrowNavigation {
7066
if (
7167
!this.navigation.defaultWorkspaceCursorPositionIfNeeded(workspace)
7268
) {
73-
workspace.getCursor()?.in();
69+
workspace.getCursor().in();
7470
}
7571
isHandled = true;
7672
}
@@ -103,7 +99,7 @@ export class ArrowNavigation {
10399
if (
104100
!this.navigation.defaultWorkspaceCursorPositionIfNeeded(workspace)
105101
) {
106-
workspace.getCursor()?.out();
102+
workspace.getCursor().out();
107103
}
108104
isHandled = true;
109105
}
@@ -169,7 +165,7 @@ export class ArrowNavigation {
169165
workspace,
170166
)
171167
) {
172-
workspace.getCursor()?.next();
168+
workspace.getCursor().next();
173169
}
174170
isHandled = true;
175171
}
@@ -182,7 +178,7 @@ export class ArrowNavigation {
182178
workspace.targetWorkspace,
183179
)
184180
) {
185-
workspace.getCursor()?.next();
181+
workspace.getCursor().next();
186182
}
187183
isHandled = true;
188184
}
@@ -232,7 +228,7 @@ export class ArrowNavigation {
232228
'last',
233229
)
234230
) {
235-
workspace.getCursor()?.prev();
231+
workspace.getCursor().prev();
236232
}
237233
isHandled = true;
238234
}
@@ -246,7 +242,7 @@ export class ArrowNavigation {
246242
'last',
247243
)
248244
) {
249-
workspace.getCursor()?.prev();
245+
workspace.getCursor().prev();
250246
}
251247
isHandled = true;
252248
}

src/actions/disconnect.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export class DisconnectAction {
7878
*/
7979
disconnectBlocks(workspace: WorkspaceSvg) {
8080
const cursor = workspace.getCursor();
81-
if (!cursor) return;
8281
const curNode = cursor.getCurNode();
8382
if (!(curNode instanceof BlockSvg)) return;
8483

src/actions/edit.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {
8-
ContextMenuRegistry,
9-
LineCursor,
10-
Msg,
11-
keyboardNavigationController,
12-
} from 'blockly';
7+
import {ContextMenuRegistry, Msg, keyboardNavigationController} from 'blockly';
138
import {Navigation} from 'src/navigation';
149
import {getMenuItem} from '../shortcut_formatting';
1510
import * as Constants from '../constants';
@@ -67,7 +62,7 @@ export class EditAction {
6762
if (!workspace || !this.navigation.canCurrentlyNavigate(workspace)) {
6863
return 'disabled';
6964
}
70-
const cursor = workspace.getCursor() as LineCursor | null;
65+
const cursor = workspace.getCursor();
7166
if (!cursor) return 'disabled';
7267
return cursor.atEndOfLine() ? 'hidden' : 'enabled';
7368
},

src/actions/enter.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
renderManagement,
1919
comments,
2020
getFocusManager,
21+
hasBubble,
2122
} from 'blockly/core';
2223

2324
import type {Block} from 'blockly/core';
@@ -116,8 +117,7 @@ export class EnterAction {
116117
private shouldHandleEnterForWS(workspace: WorkspaceSvg): boolean {
117118
if (!this.navigation.canCurrentlyNavigate(workspace)) return false;
118119

119-
const cursor = workspace.getCursor();
120-
const curNode = cursor?.getCurNode();
120+
const curNode = workspace.getCursor().getCurNode();
121121
if (!curNode) return false;
122122
if (curNode instanceof Field) return curNode.isClickable();
123123
if (
@@ -143,7 +143,7 @@ export class EnterAction {
143143
*/
144144
private handleEnterForWS(workspace: WorkspaceSvg): boolean {
145145
const cursor = workspace.getCursor();
146-
const curNode = cursor?.getCurNode();
146+
const curNode = cursor.getCurNode();
147147
if (!curNode) return false;
148148
if (curNode instanceof Field) {
149149
curNode.showEditor();
@@ -164,13 +164,11 @@ export class EnterAction {
164164
// opening a bubble of some sort. We then need to wait for the bubble to
165165
// appear before attempting to navigate into it.
166166
curNode.onClick();
167-
// This currently only works for MutatorIcons.
168-
// See icon_navigation_policy.
169-
if (curNode instanceof icons.MutatorIcon) {
170-
renderManagement.finishQueuedRenders().then(() => {
171-
cursor?.in();
172-
});
173-
}
167+
renderManagement.finishQueuedRenders().then(() => {
168+
if (hasBubble(curNode) && curNode.bubbleIsVisible()) {
169+
cursor.in();
170+
}
171+
});
174172
return true;
175173
} else if (curNode instanceof comments.CommentBarButton) {
176174
curNode.performAction();

src/actions/move.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class MoveActions {
260260
const node = getFocusManager().getFocusedNode();
261261
if (node instanceof comments.RenderedWorkspaceComment) return node;
262262

263-
let block = workspace?.getCursor()?.getSourceBlock();
263+
let block = workspace.getCursor().getSourceBlock();
264264
if (!block) return undefined;
265265
while (block.isShadow()) {
266266
block = block.getParent();

src/actions/mover.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class Mover {
161161
// In case a block is detached, ensure that it still retains focus
162162
// (otherwise dragging will break). This is also the point a new block's
163163
// initial insert position is scrolled into view.
164-
workspace.getCursor()?.setCurNode(draggable);
164+
workspace.getCursor().setCurNode(draggable);
165165
draggable.getFocusableElement().addEventListener('blur', blurListener);
166166

167167
// Register a keyboard shortcut under the key combos of all existing
@@ -258,7 +258,7 @@ export class Mover {
258258
);
259259

260260
if (dragStrategy.moveType === MoveType.Insert && target) {
261-
workspace.getCursor()?.setCurNode(target);
261+
workspace.getCursor().setCurNode(target);
262262
}
263263

264264
this.postDragEndCleanup(workspace, info);

0 commit comments

Comments
 (0)