blockly 12.0.0-beta.2 → 12.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.min.js +177 -152
- package/blockly.mjs +3 -3
- package/blockly_compressed.js +177 -152
- package/blockly_compressed.js.map +1 -1
- package/core/block_svg.d.ts +18 -12
- package/core/blockly.d.ts +4 -5
- package/core/comments/rendered_workspace_comment.d.ts +1 -1
- package/core/contextmenu.d.ts +6 -2
- package/core/contextmenu_registry.d.ts +11 -8
- package/core/dragging/block_drag_strategy.d.ts +12 -0
- package/core/field.d.ts +3 -7
- package/core/field_input.d.ts +1 -7
- package/core/field_variable.d.ts +3 -3
- package/core/focus_manager.d.ts +163 -0
- package/core/interfaces/i_focusable_node.d.ts +4 -1
- package/core/interfaces/i_focusable_tree.d.ts +23 -13
- package/core/keyboard_nav/ast_node.d.ts +6 -6
- package/core/keyboard_nav/line_cursor.d.ts +348 -0
- package/core/marker_manager.d.ts +3 -3
- package/core/menuitem.d.ts +5 -2
- package/core/registry.d.ts +2 -2
- package/core/renderers/zelos/path_object.d.ts +2 -1
- package/core/utils/focusable_tree_traverser.d.ts +53 -0
- package/core/workspace.d.ts +0 -1
- package/core/workspace_svg.d.ts +18 -4
- package/index.mjs +3 -3
- package/package.json +1 -1
- package/core/keyboard_nav/basic_cursor.d.ts +0 -96
- package/core/keyboard_nav/cursor.d.ts +0 -44
- package/core/keyboard_nav/tab_navigate_cursor.d.ts +0 -20
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @fileoverview The class representing a line cursor.
|
|
8
|
+
* A line cursor tries to traverse the blocks and connections on a block as if
|
|
9
|
+
* they were lines of code in a text editor. Previous and next traverse previous
|
|
10
|
+
* connections, next connections and blocks, while in and out traverse input
|
|
11
|
+
* connections and fields.
|
|
12
|
+
* @author aschmiedt@google.com (Abby Schmiedt)
|
|
13
|
+
*/
|
|
14
|
+
import type { Block } from '../block.js';
|
|
15
|
+
import type { MarkerSvg } from '../renderers/common/marker_svg.js';
|
|
16
|
+
import type { WorkspaceSvg } from '../workspace_svg.js';
|
|
17
|
+
import { ASTNode } from './ast_node.js';
|
|
18
|
+
import { Marker } from './marker.js';
|
|
19
|
+
/** Options object for LineCursor instances. */
|
|
20
|
+
export interface CursorOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Can the cursor visit all stack connections (next/previous), or
|
|
23
|
+
* (if false) only unconnected next connections?
|
|
24
|
+
*/
|
|
25
|
+
stackConnections: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Class for a line cursor.
|
|
29
|
+
*/
|
|
30
|
+
export declare class LineCursor extends Marker {
|
|
31
|
+
private readonly workspace;
|
|
32
|
+
type: string;
|
|
33
|
+
/** Options for this line cursor. */
|
|
34
|
+
private readonly options;
|
|
35
|
+
/** Locations to try moving the cursor to after a deletion. */
|
|
36
|
+
private potentialNodes;
|
|
37
|
+
/** Whether the renderer is zelos-style. */
|
|
38
|
+
private isZelos;
|
|
39
|
+
/**
|
|
40
|
+
* @param workspace The workspace this cursor belongs to.
|
|
41
|
+
* @param options Cursor options.
|
|
42
|
+
*/
|
|
43
|
+
constructor(workspace: WorkspaceSvg, options?: Partial<CursorOptions>);
|
|
44
|
+
/**
|
|
45
|
+
* Clean up this cursor.
|
|
46
|
+
*/
|
|
47
|
+
dispose(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Moves the cursor to the next previous connection, next connection or block
|
|
50
|
+
* in the pre order traversal. Finds the next node in the pre order traversal.
|
|
51
|
+
*
|
|
52
|
+
* @returns The next node, or null if the current node is
|
|
53
|
+
* not set or there is no next value.
|
|
54
|
+
*/
|
|
55
|
+
next(): ASTNode | null;
|
|
56
|
+
/**
|
|
57
|
+
* Moves the cursor to the next input connection or field
|
|
58
|
+
* in the pre order traversal.
|
|
59
|
+
*
|
|
60
|
+
* @returns The next node, or null if the current node is
|
|
61
|
+
* not set or there is no next value.
|
|
62
|
+
*/
|
|
63
|
+
in(): ASTNode | null;
|
|
64
|
+
/**
|
|
65
|
+
* Moves the cursor to the previous next connection or previous connection in
|
|
66
|
+
* the pre order traversal.
|
|
67
|
+
*
|
|
68
|
+
* @returns The previous node, or null if the current node
|
|
69
|
+
* is not set or there is no previous value.
|
|
70
|
+
*/
|
|
71
|
+
prev(): ASTNode | null;
|
|
72
|
+
/**
|
|
73
|
+
* Moves the cursor to the previous input connection or field in the pre order
|
|
74
|
+
* traversal.
|
|
75
|
+
*
|
|
76
|
+
* @returns The previous node, or null if the current node
|
|
77
|
+
* is not set or there is no previous value.
|
|
78
|
+
*/
|
|
79
|
+
out(): ASTNode | null;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true iff the node to which we would navigate if in() were
|
|
82
|
+
* called, which will be a validInLineNode, is also a validLineNode
|
|
83
|
+
* - in effect, if the LineCursor is at the end of the 'current
|
|
84
|
+
* line' of the program.
|
|
85
|
+
*/
|
|
86
|
+
atEndOfLine(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Returns true iff the given node represents the "beginning of a
|
|
89
|
+
* new line of code" (and thus can be visited by pressing the
|
|
90
|
+
* up/down arrow keys). Specifically, if the node is for:
|
|
91
|
+
*
|
|
92
|
+
* - Any block that is not a value block.
|
|
93
|
+
* - A top-level value block (one that is unconnected).
|
|
94
|
+
* - An unconnected next statement input.
|
|
95
|
+
* - An unconnected 'next' connection - the "blank line at the end".
|
|
96
|
+
* This is to facilitate connecting additional blocks to a
|
|
97
|
+
* stack/substack.
|
|
98
|
+
*
|
|
99
|
+
* If options.stackConnections is true (the default) then allow the
|
|
100
|
+
* cursor to visit all (useful) stack connection by additionally
|
|
101
|
+
* returning true for:
|
|
102
|
+
*
|
|
103
|
+
* - Any next statement input
|
|
104
|
+
* - Any 'next' connection.
|
|
105
|
+
* - An unconnected previous statement input.
|
|
106
|
+
*
|
|
107
|
+
* @param node The AST node to check.
|
|
108
|
+
* @returns True if the node should be visited, false otherwise.
|
|
109
|
+
*/
|
|
110
|
+
protected validLineNode(node: ASTNode | null): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Returns true iff the given node can be visited by the cursor when
|
|
113
|
+
* using the left/right arrow keys. Specifically, if the node is
|
|
114
|
+
* any node for which valideLineNode would return true, plus:
|
|
115
|
+
*
|
|
116
|
+
* - Any block.
|
|
117
|
+
* - Any field that is not a full block field.
|
|
118
|
+
* - Any unconnected next or input connection. This is to
|
|
119
|
+
* facilitate connecting additional blocks.
|
|
120
|
+
*
|
|
121
|
+
* @param node The AST node to check whether it is valid.
|
|
122
|
+
* @returns True if the node should be visited, false otherwise.
|
|
123
|
+
*/
|
|
124
|
+
protected validInLineNode(node: ASTNode | null): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Returns true iff the given node can be visited by the cursor.
|
|
127
|
+
* Specifically, if the node is any for which validInLineNode would
|
|
128
|
+
* return true, or if it is a workspace node.
|
|
129
|
+
*
|
|
130
|
+
* @param node The AST node to check whether it is valid.
|
|
131
|
+
* @returns True if the node should be visited, false otherwise.
|
|
132
|
+
*/
|
|
133
|
+
protected validNode(node: ASTNode | null): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Uses pre order traversal to navigate the Blockly AST. This will allow
|
|
136
|
+
* a user to easily navigate the entire Blockly AST without having to go in
|
|
137
|
+
* and out levels on the tree.
|
|
138
|
+
*
|
|
139
|
+
* @param node The current position in the AST.
|
|
140
|
+
* @param isValid A function true/false depending on whether the given node
|
|
141
|
+
* should be traversed.
|
|
142
|
+
* @returns The next node in the traversal.
|
|
143
|
+
*/
|
|
144
|
+
private getNextNodeImpl;
|
|
145
|
+
/**
|
|
146
|
+
* Get the next node in the AST, optionally allowing for loopback.
|
|
147
|
+
*
|
|
148
|
+
* @param node The current position in the AST.
|
|
149
|
+
* @param isValid A function true/false depending on whether the given node
|
|
150
|
+
* should be traversed.
|
|
151
|
+
* @param loop Whether to loop around to the beginning of the workspace if
|
|
152
|
+
* novalid node was found.
|
|
153
|
+
* @returns The next node in the traversal.
|
|
154
|
+
*/
|
|
155
|
+
getNextNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean, loop: boolean): ASTNode | null;
|
|
156
|
+
/**
|
|
157
|
+
* Reverses the pre order traversal in order to find the previous node. This
|
|
158
|
+
* will allow a user to easily navigate the entire Blockly AST without having
|
|
159
|
+
* to go in and out levels on the tree.
|
|
160
|
+
*
|
|
161
|
+
* @param node The current position in the AST.
|
|
162
|
+
* @param isValid A function true/false depending on whether the given node
|
|
163
|
+
* should be traversed.
|
|
164
|
+
* @returns The previous node in the traversal or null if no previous node
|
|
165
|
+
* exists.
|
|
166
|
+
*/
|
|
167
|
+
private getPreviousNodeImpl;
|
|
168
|
+
/**
|
|
169
|
+
* Get the previous node in the AST, optionally allowing for loopback.
|
|
170
|
+
*
|
|
171
|
+
* @param node The current position in the AST.
|
|
172
|
+
* @param isValid A function true/false depending on whether the given node
|
|
173
|
+
* should be traversed.
|
|
174
|
+
* @param loop Whether to loop around to the end of the workspace if no
|
|
175
|
+
* valid node was found.
|
|
176
|
+
* @returns The previous node in the traversal or null if no previous node
|
|
177
|
+
* exists.
|
|
178
|
+
*/
|
|
179
|
+
getPreviousNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean, loop: boolean): ASTNode | null;
|
|
180
|
+
/**
|
|
181
|
+
* From the given node find either the next valid sibling or the parent's
|
|
182
|
+
* next sibling.
|
|
183
|
+
*
|
|
184
|
+
* @param node The current position in the AST.
|
|
185
|
+
* @returns The next sibling node, the parent's next sibling, or null.
|
|
186
|
+
*/
|
|
187
|
+
private findSiblingOrParentSibling;
|
|
188
|
+
/**
|
|
189
|
+
* Get the right most child of a node.
|
|
190
|
+
*
|
|
191
|
+
* @param node The node to find the right most child of.
|
|
192
|
+
* @returns The right most child of the given node, or the node if no child
|
|
193
|
+
* exists.
|
|
194
|
+
*/
|
|
195
|
+
private getRightMostChild;
|
|
196
|
+
/**
|
|
197
|
+
* Prepare for the deletion of a block by making a list of nodes we
|
|
198
|
+
* could move the cursor to afterwards and save it to
|
|
199
|
+
* this.potentialNodes.
|
|
200
|
+
*
|
|
201
|
+
* After the deletion has occurred, call postDelete to move it to
|
|
202
|
+
* the first valid node on that list.
|
|
203
|
+
*
|
|
204
|
+
* The locations to try (in order of preference) are:
|
|
205
|
+
*
|
|
206
|
+
* - The current location.
|
|
207
|
+
* - The connection to which the deleted block is attached.
|
|
208
|
+
* - The block connected to the next connection of the deleted block.
|
|
209
|
+
* - The parent block of the deleted block.
|
|
210
|
+
* - A location on the workspace beneath the deleted block.
|
|
211
|
+
*
|
|
212
|
+
* N.B.: When block is deleted, all of the blocks conneccted to that
|
|
213
|
+
* block's inputs are also deleted, but not blocks connected to its
|
|
214
|
+
* next connection.
|
|
215
|
+
*
|
|
216
|
+
* @param deletedBlock The block that is being deleted.
|
|
217
|
+
*/
|
|
218
|
+
preDelete(deletedBlock: Block): void;
|
|
219
|
+
/**
|
|
220
|
+
* Move the cursor to the first valid location in
|
|
221
|
+
* this.potentialNodes, following a block deletion.
|
|
222
|
+
*/
|
|
223
|
+
postDelete(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Get the current location of the cursor.
|
|
226
|
+
*
|
|
227
|
+
* Overrides normal Marker getCurNode to update the current node from the
|
|
228
|
+
* selected block. This typically happens via the selection listener but that
|
|
229
|
+
* is not called immediately when `Gesture` calls
|
|
230
|
+
* `Blockly.common.setSelected`. In particular the listener runs after showing
|
|
231
|
+
* the context menu.
|
|
232
|
+
*
|
|
233
|
+
* @returns The current field, connection, or block the cursor is on.
|
|
234
|
+
*/
|
|
235
|
+
getCurNode(): ASTNode | null;
|
|
236
|
+
/**
|
|
237
|
+
* Sets the object in charge of drawing the marker.
|
|
238
|
+
*
|
|
239
|
+
* We want to customize drawing, so rather than directly setting the given
|
|
240
|
+
* object, we instead set a wrapper proxy object that passes through all
|
|
241
|
+
* method calls and property accesses except for draw(), which it delegates
|
|
242
|
+
* to the drawMarker() method in this class.
|
|
243
|
+
*
|
|
244
|
+
* @param drawer The object ~in charge of drawing the marker.
|
|
245
|
+
*/
|
|
246
|
+
setDrawer(drawer: MarkerSvg): void;
|
|
247
|
+
/**
|
|
248
|
+
* Set the location of the cursor and draw it.
|
|
249
|
+
*
|
|
250
|
+
* Overrides normal Marker setCurNode logic to call
|
|
251
|
+
* this.drawMarker() instead of this.drawer.draw() directly.
|
|
252
|
+
*
|
|
253
|
+
* @param newNode The new location of the cursor.
|
|
254
|
+
* @param updateSelection If true (the default) we'll update the selection
|
|
255
|
+
* too.
|
|
256
|
+
*/
|
|
257
|
+
setCurNode(newNode: ASTNode | null, updateSelection?: boolean): void;
|
|
258
|
+
/**
|
|
259
|
+
* Draw this cursor's marker.
|
|
260
|
+
*
|
|
261
|
+
* This is a wrapper around this.drawer.draw (usually implemented by
|
|
262
|
+
* MarkerSvg.prototype.draw) that will, if newNode is a BLOCK node,
|
|
263
|
+
* instead call `setSelected` to select it (if it's a regular block)
|
|
264
|
+
* or `addSelect` (if it's a shadow block, since shadow blocks can't
|
|
265
|
+
* be selected) instead of using the normal drawer logic.
|
|
266
|
+
*
|
|
267
|
+
* TODO(#142): The selection and fake-selection code was originally
|
|
268
|
+
* a hack added for testing on October 28 2024, because the default
|
|
269
|
+
* drawer (MarkerSvg) behaviour in Zelos was to draw a box around
|
|
270
|
+
* the block and all attached child blocks, which was confusing when
|
|
271
|
+
* navigating stacks.
|
|
272
|
+
*
|
|
273
|
+
* Since then we have decided that we probably _do_ in most cases
|
|
274
|
+
* want navigating to a block to select the block, but more
|
|
275
|
+
* particularly that we want navigation to move _focus_. Replace
|
|
276
|
+
* this selection hack with non-hacky changing of focus once that's
|
|
277
|
+
* possible.
|
|
278
|
+
*
|
|
279
|
+
* @param oldNode The previous node.
|
|
280
|
+
* @param curNode The current node.
|
|
281
|
+
* @param realDrawer The object ~in charge of drawing the marker.
|
|
282
|
+
*/
|
|
283
|
+
private drawMarker;
|
|
284
|
+
/**
|
|
285
|
+
* Check whether the node represents a value input connection.
|
|
286
|
+
*
|
|
287
|
+
* @param node The node to check
|
|
288
|
+
* @returns True if the node represents a value input connection.
|
|
289
|
+
*/
|
|
290
|
+
private isValueInputConnection;
|
|
291
|
+
/**
|
|
292
|
+
* Hide the cursor rendering at the given input node.
|
|
293
|
+
*
|
|
294
|
+
* @param node The input node to hide.
|
|
295
|
+
*/
|
|
296
|
+
private hideAtInput;
|
|
297
|
+
/**
|
|
298
|
+
* Show the cursor rendering at the given input node.
|
|
299
|
+
*
|
|
300
|
+
* @param node The input node to show.
|
|
301
|
+
*/
|
|
302
|
+
private showAtInput;
|
|
303
|
+
/**
|
|
304
|
+
* Event listener that syncs the cursor location to the selected block on
|
|
305
|
+
* SELECTED events.
|
|
306
|
+
*
|
|
307
|
+
* This does not run early enough in all cases so `getCurNode()` also updates
|
|
308
|
+
* the node from the selection.
|
|
309
|
+
*
|
|
310
|
+
* @param event The `Selected` event.
|
|
311
|
+
*/
|
|
312
|
+
private changeListener;
|
|
313
|
+
/**
|
|
314
|
+
* Updates the current node to match the selection.
|
|
315
|
+
*
|
|
316
|
+
* Clears the current node if it's on a block but the selection is null.
|
|
317
|
+
* Sets the node to a block if selected for our workspace.
|
|
318
|
+
* For shadow blocks selections the parent is used by default (unless we're
|
|
319
|
+
* already on the shadow block via keyboard) as that's where the visual
|
|
320
|
+
* selection is.
|
|
321
|
+
*/
|
|
322
|
+
private updateCurNodeFromSelection;
|
|
323
|
+
/**
|
|
324
|
+
* Updates the selection from the node.
|
|
325
|
+
*
|
|
326
|
+
* Clears the selection for non-block nodes.
|
|
327
|
+
* Clears the selection for shadow blocks as the selection is drawn on
|
|
328
|
+
* the parent but the cursor will be drawn on the shadow block itself.
|
|
329
|
+
* We need to take care not to later clear the current node due to that null
|
|
330
|
+
* selection, so we track the latest selection we're in sync with.
|
|
331
|
+
*
|
|
332
|
+
* @param newNode The new node.
|
|
333
|
+
*/
|
|
334
|
+
private updateSelectionFromNode;
|
|
335
|
+
/**
|
|
336
|
+
* Get the first navigable node on the workspace, or null if none exist.
|
|
337
|
+
*
|
|
338
|
+
* @returns The first navigable node on the workspace, or null.
|
|
339
|
+
*/
|
|
340
|
+
getFirstNode(): ASTNode | null;
|
|
341
|
+
/**
|
|
342
|
+
* Get the last navigable node on the workspace, or null if none exist.
|
|
343
|
+
*
|
|
344
|
+
* @returns The last navigable node on the workspace, or null.
|
|
345
|
+
*/
|
|
346
|
+
getLastNode(): ASTNode | null;
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=line_cursor.d.ts.map
|
package/core/marker_manager.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @class
|
|
10
10
|
*/
|
|
11
|
-
import type {
|
|
11
|
+
import type { LineCursor } from './keyboard_nav/line_cursor.js';
|
|
12
12
|
import type { Marker } from './keyboard_nav/marker.js';
|
|
13
13
|
import type { WorkspaceSvg } from './workspace_svg.js';
|
|
14
14
|
/**
|
|
@@ -49,7 +49,7 @@ export declare class MarkerManager {
|
|
|
49
49
|
*
|
|
50
50
|
* @returns The cursor for this workspace.
|
|
51
51
|
*/
|
|
52
|
-
getCursor():
|
|
52
|
+
getCursor(): LineCursor | null;
|
|
53
53
|
/**
|
|
54
54
|
* Get a single marker that corresponds to the given ID.
|
|
55
55
|
*
|
|
@@ -64,7 +64,7 @@ export declare class MarkerManager {
|
|
|
64
64
|
*
|
|
65
65
|
* @param cursor The cursor used to move around this workspace.
|
|
66
66
|
*/
|
|
67
|
-
setCursor(cursor:
|
|
67
|
+
setCursor(cursor: LineCursor): void;
|
|
68
68
|
/**
|
|
69
69
|
* Add the cursor SVG to this workspace SVG group.
|
|
70
70
|
*
|
package/core/menuitem.d.ts
CHANGED
|
@@ -120,9 +120,12 @@ export declare class MenuItem {
|
|
|
120
120
|
* Performs the appropriate action when the menu item is activated
|
|
121
121
|
* by the user.
|
|
122
122
|
*
|
|
123
|
+
* @param menuSelectEvent the event that triggered the selection
|
|
124
|
+
* of the menu item.
|
|
125
|
+
*
|
|
123
126
|
* @internal
|
|
124
127
|
*/
|
|
125
|
-
performAction(): void;
|
|
128
|
+
performAction(menuSelectEvent: Event): void;
|
|
126
129
|
/**
|
|
127
130
|
* Set the handler that's called when the menu item is activated by the user.
|
|
128
131
|
* `obj` will be used as the 'this' object in the function when called.
|
|
@@ -131,6 +134,6 @@ export declare class MenuItem {
|
|
|
131
134
|
* @param obj Used as the 'this' object in fn when called.
|
|
132
135
|
* @internal
|
|
133
136
|
*/
|
|
134
|
-
onAction(fn: (p1: MenuItem) => void, obj: object): void;
|
|
137
|
+
onAction(fn: (p1: MenuItem, menuSelectEvent: Event) => void, obj: object): void;
|
|
135
138
|
}
|
|
136
139
|
//# sourceMappingURL=menuitem.d.ts.map
|
package/core/registry.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type { ISerializer } from './interfaces/i_serializer.js';
|
|
|
19
19
|
import type { IToolbox } from './interfaces/i_toolbox.js';
|
|
20
20
|
import type { IVariableMap } from './interfaces/i_variable_map.js';
|
|
21
21
|
import type { IVariableModel, IVariableModelStatic, IVariableState } from './interfaces/i_variable_model.js';
|
|
22
|
-
import type {
|
|
22
|
+
import type { LineCursor } from './keyboard_nav/line_cursor.js';
|
|
23
23
|
import type { Options } from './options.js';
|
|
24
24
|
import type { Renderer } from './renderers/common/renderer.js';
|
|
25
25
|
import type { Theme } from './theme.js';
|
|
@@ -50,7 +50,7 @@ export declare class Type<_T> {
|
|
|
50
50
|
toString(): string;
|
|
51
51
|
static CONNECTION_CHECKER: Type<IConnectionChecker>;
|
|
52
52
|
static CONNECTION_PREVIEWER: Type<IConnectionPreviewer>;
|
|
53
|
-
static CURSOR: Type<
|
|
53
|
+
static CURSOR: Type<LineCursor>;
|
|
54
54
|
static EVENT: Type<Abstract>;
|
|
55
55
|
static FIELD: Type<Field<any>>;
|
|
56
56
|
static INPUT: Type<Input>;
|
|
@@ -61,10 +61,11 @@ export declare class PathObject extends BasePathObject {
|
|
|
61
61
|
/**
|
|
62
62
|
* Create's an outline path for the specified input.
|
|
63
63
|
*
|
|
64
|
+
* @internal
|
|
64
65
|
* @param name The input name.
|
|
65
66
|
* @returns The SVG outline path.
|
|
66
67
|
*/
|
|
67
|
-
|
|
68
|
+
getOutlinePath(name: string): SVGElement;
|
|
68
69
|
/**
|
|
69
70
|
* Remove an outline path that is associated with the specified input.
|
|
70
71
|
*
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
|
|
7
|
+
import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
|
|
8
|
+
/**
|
|
9
|
+
* A helper utility for IFocusableTree implementations to aid with common
|
|
10
|
+
* tree traversals.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FocusableTreeTraverser {
|
|
13
|
+
private static readonly ACTIVE_CLASS_NAME;
|
|
14
|
+
private static readonly PASSIVE_CSS_CLASS_NAME;
|
|
15
|
+
private static readonly ACTIVE_FOCUS_NODE_CSS_SELECTOR;
|
|
16
|
+
private static readonly PASSIVE_FOCUS_NODE_CSS_SELECTOR;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the current IFocusableNode that is styled (and thus represented) as
|
|
19
|
+
* having either passive or active focus, only considering HTML and SVG
|
|
20
|
+
* elements.
|
|
21
|
+
*
|
|
22
|
+
* This can match against the tree's root.
|
|
23
|
+
*
|
|
24
|
+
* Note that this will never return a node from a nested sub-tree as that tree
|
|
25
|
+
* should specifically be used to retrieve its focused node.
|
|
26
|
+
*
|
|
27
|
+
* @param tree The IFocusableTree in which to search for a focused node.
|
|
28
|
+
* @returns The IFocusableNode currently with focus, or null if none.
|
|
29
|
+
*/
|
|
30
|
+
static findFocusedNode(tree: IFocusableTree): IFocusableNode | null;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the IFocusableNode corresponding to the specified HTML or SVG
|
|
33
|
+
* element iff it's the root element or a descendent of the root element of
|
|
34
|
+
* the specified IFocusableTree.
|
|
35
|
+
*
|
|
36
|
+
* If the element exists within the specified tree's DOM structure but does
|
|
37
|
+
* not directly correspond to a node, the nearest parent node (or the tree's
|
|
38
|
+
* root) will be returned to represent the provided element.
|
|
39
|
+
*
|
|
40
|
+
* If the tree contains another nested IFocusableTree, the nested tree may be
|
|
41
|
+
* traversed but its nodes will never be returned here per the contract of
|
|
42
|
+
* IFocusableTree.lookUpFocusableNode.
|
|
43
|
+
*
|
|
44
|
+
* The provided element must have a non-null ID that conforms to the contract
|
|
45
|
+
* mentioned in IFocusableNode.
|
|
46
|
+
*
|
|
47
|
+
* @param element The HTML or SVG element being sought.
|
|
48
|
+
* @param tree The tree under which the provided element may be a descendant.
|
|
49
|
+
* @returns The matching IFocusableNode, or null if there is no match.
|
|
50
|
+
*/
|
|
51
|
+
static findFocusableNodeFor(element: HTMLElement | SVGElement, tree: IFocusableTree): IFocusableNode | null;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=focusable_tree_traverser.d.ts.map
|
package/core/workspace.d.ts
CHANGED
|
@@ -411,7 +411,6 @@ export declare class Workspace implements IASTNodeLocation {
|
|
|
411
411
|
* These exist in the flyout but not in the workspace.
|
|
412
412
|
*
|
|
413
413
|
* @returns The potential variable map.
|
|
414
|
-
* @internal
|
|
415
414
|
*/
|
|
416
415
|
getPotentialVariableMap(): IVariableMap<IVariableModel<IVariableState>> | null;
|
|
417
416
|
/**
|
package/core/workspace_svg.d.ts
CHANGED
|
@@ -22,12 +22,13 @@ import { Gesture } from './gesture.js';
|
|
|
22
22
|
import { Grid } from './grid.js';
|
|
23
23
|
import type { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
|
|
24
24
|
import type { IBoundedElement } from './interfaces/i_bounded_element.js';
|
|
25
|
+
import { IContextMenu } from './interfaces/i_contextmenu.js';
|
|
25
26
|
import type { IDragTarget } from './interfaces/i_drag_target.js';
|
|
26
27
|
import type { IFlyout } from './interfaces/i_flyout.js';
|
|
27
28
|
import type { IMetricsManager } from './interfaces/i_metrics_manager.js';
|
|
28
29
|
import type { IToolbox } from './interfaces/i_toolbox.js';
|
|
29
30
|
import type { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
|
|
30
|
-
import type {
|
|
31
|
+
import type { LineCursor } from './keyboard_nav/line_cursor.js';
|
|
31
32
|
import type { Marker } from './keyboard_nav/marker.js';
|
|
32
33
|
import { LayerManager } from './layer_manager.js';
|
|
33
34
|
import { MarkerManager } from './marker_manager.js';
|
|
@@ -50,7 +51,7 @@ import { ZoomControls } from './zoom_controls.js';
|
|
|
50
51
|
* Class for a workspace. This is an onscreen area with optional trashcan,
|
|
51
52
|
* scrollbars, bubbles, and dragging.
|
|
52
53
|
*/
|
|
53
|
-
export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
|
|
54
|
+
export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg, IContextMenu {
|
|
54
55
|
/**
|
|
55
56
|
* A wrapper function called when a resize event occurs.
|
|
56
57
|
* You can pass the result to `eventHandling.unbind`.
|
|
@@ -304,7 +305,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
|
|
|
304
305
|
*
|
|
305
306
|
* @returns The cursor for the workspace.
|
|
306
307
|
*/
|
|
307
|
-
getCursor():
|
|
308
|
+
getCursor(): LineCursor | null;
|
|
308
309
|
/**
|
|
309
310
|
* Get the block renderer attached to this workspace.
|
|
310
311
|
*
|
|
@@ -711,7 +712,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
|
|
|
711
712
|
* @param e Mouse event.
|
|
712
713
|
* @internal
|
|
713
714
|
*/
|
|
714
|
-
showContextMenu(e:
|
|
715
|
+
showContextMenu(e: Event): void;
|
|
715
716
|
/**
|
|
716
717
|
* Modify the block tree on the existing toolbox.
|
|
717
718
|
*
|
|
@@ -1004,6 +1005,19 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
|
|
|
1004
1005
|
*/
|
|
1005
1006
|
removeClass(className: string): void;
|
|
1006
1007
|
setIsReadOnly(readOnly: boolean): void;
|
|
1008
|
+
/**
|
|
1009
|
+
* Scrolls the provided bounds into view.
|
|
1010
|
+
*
|
|
1011
|
+
* In the case of small workspaces/large bounds, this function prioritizes
|
|
1012
|
+
* getting the top left corner of the bounds into view. It also adds some
|
|
1013
|
+
* padding around the bounds to allow the element to be comfortably in view.
|
|
1014
|
+
*
|
|
1015
|
+
* @internal
|
|
1016
|
+
* @param bounds A rectangle to scroll into view, as best as possible.
|
|
1017
|
+
* @param padding Amount of spacing to put between the bounds and the edge of
|
|
1018
|
+
* the workspace's viewport.
|
|
1019
|
+
*/
|
|
1020
|
+
scrollBoundsIntoView(bounds: Rect, padding?: number): void;
|
|
1007
1021
|
}
|
|
1008
1022
|
/**
|
|
1009
1023
|
* Size the workspace when the contents change. This also updates
|
package/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Blockly from './index.js';
|
|
2
2
|
export const {
|
|
3
3
|
ASTNode,
|
|
4
|
-
BasicCursor,
|
|
5
4
|
Block,
|
|
6
5
|
BlockFlyoutInflater,
|
|
7
6
|
BlockSvg,
|
|
@@ -21,7 +20,6 @@ export const {
|
|
|
21
20
|
ContextMenuItems,
|
|
22
21
|
ContextMenuRegistry,
|
|
23
22
|
Css,
|
|
24
|
-
Cursor,
|
|
25
23
|
DELETE_VARIABLE_ID,
|
|
26
24
|
DeleteArea,
|
|
27
25
|
DragTarget,
|
|
@@ -42,6 +40,7 @@ export const {
|
|
|
42
40
|
FlyoutItem,
|
|
43
41
|
FlyoutMetricsManager,
|
|
44
42
|
FlyoutSeparator,
|
|
43
|
+
FocusManager,
|
|
45
44
|
Generator,
|
|
46
45
|
Gesture,
|
|
47
46
|
Grid,
|
|
@@ -50,6 +49,7 @@ export const {
|
|
|
50
49
|
Input,
|
|
51
50
|
InsertionMarkerPreviewer,
|
|
52
51
|
LabelFlyoutInflater,
|
|
52
|
+
LineCursor,
|
|
53
53
|
Marker,
|
|
54
54
|
MarkerManager,
|
|
55
55
|
Menu,
|
|
@@ -75,7 +75,6 @@ export const {
|
|
|
75
75
|
TOOLBOX_AT_LEFT,
|
|
76
76
|
TOOLBOX_AT_RIGHT,
|
|
77
77
|
TOOLBOX_AT_TOP,
|
|
78
|
-
TabNavigateCursor,
|
|
79
78
|
Theme,
|
|
80
79
|
ThemeManager,
|
|
81
80
|
Themes,
|
|
@@ -117,6 +116,7 @@ export const {
|
|
|
117
116
|
dragging,
|
|
118
117
|
fieldRegistry,
|
|
119
118
|
geras,
|
|
119
|
+
getFocusManager,
|
|
120
120
|
getMainWorkspace,
|
|
121
121
|
getSelected,
|
|
122
122
|
hasBubble,
|