blockly 12.0.0-beta.1 → 12.0.0-beta.3

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.
Files changed (54) hide show
  1. package/blockly.min.js +297 -276
  2. package/blockly.mjs +3 -3
  3. package/blockly_compressed.js +282 -261
  4. package/blockly_compressed.js.map +1 -1
  5. package/core/block_flyout_inflater.d.ts +5 -6
  6. package/core/block_svg.d.ts +0 -8
  7. package/core/blockly.d.ts +6 -5
  8. package/core/bubbles/text_bubble.d.ts +5 -5
  9. package/core/button_flyout_inflater.d.ts +3 -3
  10. package/core/comments/comment_view.d.ts +3 -3
  11. package/core/contextmenu_registry.d.ts +51 -11
  12. package/core/dragging/block_drag_strategy.d.ts +14 -2
  13. package/core/dragging/bubble_drag_strategy.d.ts +0 -2
  14. package/core/dragging/comment_drag_strategy.d.ts +0 -2
  15. package/core/field.d.ts +3 -9
  16. package/core/field_dropdown.d.ts +7 -9
  17. package/core/field_input.d.ts +1 -7
  18. package/core/field_variable.d.ts +3 -3
  19. package/core/focus_manager.d.ts +163 -0
  20. package/core/interfaces/i_flyout_inflater.d.ts +3 -3
  21. package/core/interfaces/i_focusable_node.d.ts +37 -0
  22. package/core/interfaces/i_focusable_tree.d.ts +58 -0
  23. package/core/keyboard_nav/ast_node.d.ts +6 -6
  24. package/core/keyboard_nav/line_cursor.d.ts +313 -0
  25. package/core/keyboard_nav/marker.d.ts +4 -8
  26. package/core/label_flyout_inflater.d.ts +3 -3
  27. package/core/marker_manager.d.ts +3 -3
  28. package/core/menu.d.ts +29 -23
  29. package/core/menu_separator.d.ts +25 -0
  30. package/core/menuitem.d.ts +7 -0
  31. package/core/registry.d.ts +2 -2
  32. package/core/renderers/common/marker_svg.d.ts +2 -2
  33. package/core/renderers/zelos/path_object.d.ts +2 -1
  34. package/core/separator_flyout_inflater.d.ts +3 -3
  35. package/core/utils/aria.d.ts +2 -1
  36. package/core/utils/focusable_tree_traverser.d.ts +53 -0
  37. package/core/utils/toolbox.d.ts +0 -2
  38. package/core/workspace.d.ts +13 -1
  39. package/core/workspace_svg.d.ts +16 -2
  40. package/dart_compressed.js +1 -1
  41. package/dart_compressed.js.map +1 -1
  42. package/index.mjs +3 -3
  43. package/javascript_compressed.js +15 -15
  44. package/javascript_compressed.js.map +1 -1
  45. package/lua_compressed.js +1 -1
  46. package/lua_compressed.js.map +1 -1
  47. package/package.json +2 -2
  48. package/php_compressed.js +1 -1
  49. package/php_compressed.js.map +1 -1
  50. package/python_compressed.js +3 -3
  51. package/python_compressed.js.map +1 -1
  52. package/core/keyboard_nav/basic_cursor.d.ts +0 -96
  53. package/core/keyboard_nav/cursor.d.ts +0 -44
  54. package/core/keyboard_nav/tab_navigate_cursor.d.ts +0 -20
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFocusableTree } from './i_focusable_tree.js';
7
+ /** Represents anything that can have input focus. */
8
+ export interface IFocusableNode {
9
+ /**
10
+ * Returns the DOM element that can be explicitly requested to receive focus.
11
+ *
12
+ * IMPORTANT: Please note that this element is expected to have a visual
13
+ * presence on the page as it will both be explicitly focused and have its
14
+ * style changed depending on its current focus state (i.e. blurred, actively
15
+ * focused, and passively focused). The element will have one of two styles
16
+ * attached (where no style indicates blurred/not focused):
17
+ * - blocklyActiveFocus
18
+ * - blocklyPassiveFocus
19
+ *
20
+ * The returned element must also have a valid ID specified, and unique to the
21
+ * element relative to its nearest IFocusableTree parent. It must also have a
22
+ * negative tabindex (since the focus manager itself will manage its tab index
23
+ * and a tab index must be present in order for the element to be focusable in
24
+ * the DOM).
25
+ *
26
+ * It's expected the return element will not change for the lifetime of the
27
+ * node.
28
+ */
29
+ getFocusableElement(): HTMLElement | SVGElement;
30
+ /**
31
+ * Returns the closest parent tree of this node (in cases where a tree has
32
+ * distinct trees underneath it), which represents the tree to which this node
33
+ * belongs.
34
+ */
35
+ getFocusableTree(): IFocusableTree;
36
+ }
37
+ //# sourceMappingURL=i_focusable_node.d.ts.map
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFocusableNode } from './i_focusable_node.js';
7
+ /**
8
+ * Represents a tree of focusable elements with its own active/passive focus
9
+ * context.
10
+ *
11
+ * Note that focus is handled by FocusManager, and tree implementations can have
12
+ * at most one IFocusableNode focused at one time. If the tree itself has focus,
13
+ * then the tree's focused node is considered 'active' ('passive' if another
14
+ * tree has focus).
15
+ *
16
+ * Focus is shared between one or more trees, where each tree can have exactly
17
+ * one active or passive node (and only one active node can exist on the whole
18
+ * page at any given time). The idea of passive focus is to provide context to
19
+ * users on where their focus will be restored upon navigating back to a
20
+ * previously focused tree.
21
+ *
22
+ * Note that if the tree's current focused node (passive or active) is needed,
23
+ * FocusableTreeTraverser.findFocusedNode can be used.
24
+ *
25
+ * Note that if specific nodes are needed to be retrieved for this tree, either
26
+ * use lookUpFocusableNode or FocusableTreeTraverser.findFocusableNodeFor.
27
+ */
28
+ export interface IFocusableTree {
29
+ /**
30
+ * Returns the top-level focusable node of the tree.
31
+ *
32
+ * It's expected that the returned node will be focused in cases where
33
+ * FocusManager wants to focus a tree in a situation where it does not
34
+ * currently have a focused node.
35
+ */
36
+ getRootFocusableNode(): IFocusableNode;
37
+ /**
38
+ * Returns all directly nested trees under this tree.
39
+ *
40
+ * Note that the returned list of trees doesn't need to be stable, however all
41
+ * returned trees *do* need to be registered with FocusManager. Additionally,
42
+ * this must return actual nested trees as omitting a nested tree will affect
43
+ * how focus changes map to a specific node and its tree, potentially leading
44
+ * to user confusion.
45
+ */
46
+ getNestedTrees(): Array<IFocusableTree>;
47
+ /**
48
+ * Returns the IFocusableNode corresponding to the specified element ID, or
49
+ * null if there's no exact node within this tree with that ID or if the ID
50
+ * corresponds to the root of the tree.
51
+ *
52
+ * This will never match against nested trees.
53
+ *
54
+ * @param id The ID of the node's focusable HTMLElement or SVGElement.
55
+ */
56
+ lookUpFocusableNode(id: string): IFocusableNode | null;
57
+ }
58
+ //# sourceMappingURL=i_focusable_tree.d.ts.map
@@ -72,7 +72,7 @@ export declare class ASTNode {
72
72
  * @returns The workspace coordinate or null if the location is not a
73
73
  * workspace.
74
74
  */
75
- getWsCoordinate(): Coordinate;
75
+ getWsCoordinate(): Coordinate | null;
76
76
  /**
77
77
  * Whether the node points to a connection.
78
78
  *
@@ -213,7 +213,7 @@ export declare class ASTNode {
213
213
  * @param field The location of the AST node.
214
214
  * @returns An AST node pointing to a field.
215
215
  */
216
- static createFieldNode(field: Field): ASTNode | null;
216
+ static createFieldNode(field: Field): ASTNode;
217
217
  /**
218
218
  * Creates an AST node pointing to a connection. If the connection has a
219
219
  * parent input then create an AST node of type input that will hold the
@@ -237,7 +237,7 @@ export declare class ASTNode {
237
237
  * @param block The block used to create an AST node.
238
238
  * @returns An AST node pointing to a block.
239
239
  */
240
- static createBlockNode(block: Block): ASTNode | null;
240
+ static createBlockNode(block: Block): ASTNode;
241
241
  /**
242
242
  * Create an AST node of type stack. A stack, represented by its top block, is
243
243
  * the set of all blocks connected to a top block, including the top
@@ -248,7 +248,7 @@ export declare class ASTNode {
248
248
  * @returns An AST node of type stack that points to the top block on the
249
249
  * stack.
250
250
  */
251
- static createStackNode(topBlock: Block): ASTNode | null;
251
+ static createStackNode(topBlock: Block): ASTNode;
252
252
  /**
253
253
  * Create an AST node of type button. A button in this case refers
254
254
  * specifically to a button in a flyout.
@@ -258,7 +258,7 @@ export declare class ASTNode {
258
258
  * @returns An AST node of type stack that points to the top block on the
259
259
  * stack.
260
260
  */
261
- static createButtonNode(button: FlyoutButton): ASTNode | null;
261
+ static createButtonNode(button: FlyoutButton): ASTNode;
262
262
  /**
263
263
  * Creates an AST node pointing to a workspace.
264
264
  *
@@ -267,7 +267,7 @@ export declare class ASTNode {
267
267
  * @returns An AST node pointing to a workspace and a position on the
268
268
  * workspace.
269
269
  */
270
- static createWorkspaceNode(workspace: Workspace | null, wsCoordinate: Coordinate | null): ASTNode | null;
270
+ static createWorkspaceNode(workspace: Workspace, wsCoordinate: Coordinate): ASTNode;
271
271
  /**
272
272
  * Creates an AST node for the top position on a block.
273
273
  * This is either an output connection, previous connection, or block.
@@ -0,0 +1,313 @@
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
+ getNextNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
145
+ /**
146
+ * Reverses the pre order traversal in order to find the previous node. This
147
+ * will allow a user to easily navigate the entire Blockly AST without having
148
+ * to go in and out levels on the tree.
149
+ *
150
+ * @param node The current position in the AST.
151
+ * @param isValid A function true/false depending on whether the given node
152
+ * should be traversed.
153
+ * @returns The previous node in the traversal or null if no previous node
154
+ * exists.
155
+ */
156
+ getPreviousNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
157
+ /**
158
+ * From the given node find either the next valid sibling or the parent's
159
+ * next sibling.
160
+ *
161
+ * @param node The current position in the AST.
162
+ * @returns The next sibling node, the parent's next sibling, or null.
163
+ */
164
+ private findSiblingOrParentSibling;
165
+ /**
166
+ * Get the right most child of a node.
167
+ *
168
+ * @param node The node to find the right most child of.
169
+ * @returns The right most child of the given node, or the node if no child
170
+ * exists.
171
+ */
172
+ private getRightMostChild;
173
+ /**
174
+ * Prepare for the deletion of a block by making a list of nodes we
175
+ * could move the cursor to afterwards and save it to
176
+ * this.potentialNodes.
177
+ *
178
+ * After the deletion has occurred, call postDelete to move it to
179
+ * the first valid node on that list.
180
+ *
181
+ * The locations to try (in order of preference) are:
182
+ *
183
+ * - The current location.
184
+ * - The connection to which the deleted block is attached.
185
+ * - The block connected to the next connection of the deleted block.
186
+ * - The parent block of the deleted block.
187
+ * - A location on the workspace beneath the deleted block.
188
+ *
189
+ * N.B.: When block is deleted, all of the blocks conneccted to that
190
+ * block's inputs are also deleted, but not blocks connected to its
191
+ * next connection.
192
+ *
193
+ * @param deletedBlock The block that is being deleted.
194
+ */
195
+ preDelete(deletedBlock: Block): void;
196
+ /**
197
+ * Move the cursor to the first valid location in
198
+ * this.potentialNodes, following a block deletion.
199
+ */
200
+ postDelete(): void;
201
+ /**
202
+ * Get the current location of the cursor.
203
+ *
204
+ * Overrides normal Marker getCurNode to update the current node from the
205
+ * selected block. This typically happens via the selection listener but that
206
+ * is not called immediately when `Gesture` calls
207
+ * `Blockly.common.setSelected`. In particular the listener runs after showing
208
+ * the context menu.
209
+ *
210
+ * @returns The current field, connection, or block the cursor is on.
211
+ */
212
+ getCurNode(): ASTNode | null;
213
+ /**
214
+ * Sets the object in charge of drawing the marker.
215
+ *
216
+ * We want to customize drawing, so rather than directly setting the given
217
+ * object, we instead set a wrapper proxy object that passes through all
218
+ * method calls and property accesses except for draw(), which it delegates
219
+ * to the drawMarker() method in this class.
220
+ *
221
+ * @param drawer The object ~in charge of drawing the marker.
222
+ */
223
+ setDrawer(drawer: MarkerSvg): void;
224
+ /**
225
+ * Set the location of the cursor and draw it.
226
+ *
227
+ * Overrides normal Marker setCurNode logic to call
228
+ * this.drawMarker() instead of this.drawer.draw() directly.
229
+ *
230
+ * @param newNode The new location of the cursor.
231
+ * @param updateSelection If true (the default) we'll update the selection
232
+ * too.
233
+ */
234
+ setCurNode(newNode: ASTNode | null, updateSelection?: boolean): void;
235
+ /**
236
+ * Draw this cursor's marker.
237
+ *
238
+ * This is a wrapper around this.drawer.draw (usually implemented by
239
+ * MarkerSvg.prototype.draw) that will, if newNode is a BLOCK node,
240
+ * instead call `setSelected` to select it (if it's a regular block)
241
+ * or `addSelect` (if it's a shadow block, since shadow blocks can't
242
+ * be selected) instead of using the normal drawer logic.
243
+ *
244
+ * TODO(#142): The selection and fake-selection code was originally
245
+ * a hack added for testing on October 28 2024, because the default
246
+ * drawer (MarkerSvg) behaviour in Zelos was to draw a box around
247
+ * the block and all attached child blocks, which was confusing when
248
+ * navigating stacks.
249
+ *
250
+ * Since then we have decided that we probably _do_ in most cases
251
+ * want navigating to a block to select the block, but more
252
+ * particularly that we want navigation to move _focus_. Replace
253
+ * this selection hack with non-hacky changing of focus once that's
254
+ * possible.
255
+ *
256
+ * @param oldNode The previous node.
257
+ * @param curNode The current node.
258
+ * @param realDrawer The object ~in charge of drawing the marker.
259
+ */
260
+ private drawMarker;
261
+ /**
262
+ * Check whether the node represents a value input connection.
263
+ *
264
+ * @param node The node to check
265
+ * @returns True if the node represents a value input connection.
266
+ */
267
+ private isValueInputConnection;
268
+ /**
269
+ * Hide the cursor rendering at the given input node.
270
+ *
271
+ * @param node The input node to hide.
272
+ */
273
+ private hideAtInput;
274
+ /**
275
+ * Show the cursor rendering at the given input node.
276
+ *
277
+ * @param node The input node to show.
278
+ */
279
+ private showAtInput;
280
+ /**
281
+ * Event listener that syncs the cursor location to the selected block on
282
+ * SELECTED events.
283
+ *
284
+ * This does not run early enough in all cases so `getCurNode()` also updates
285
+ * the node from the selection.
286
+ *
287
+ * @param event The `Selected` event.
288
+ */
289
+ private changeListener;
290
+ /**
291
+ * Updates the current node to match the selection.
292
+ *
293
+ * Clears the current node if it's on a block but the selection is null.
294
+ * Sets the node to a block if selected for our workspace.
295
+ * For shadow blocks selections the parent is used by default (unless we're
296
+ * already on the shadow block via keyboard) as that's where the visual
297
+ * selection is.
298
+ */
299
+ private updateCurNodeFromSelection;
300
+ /**
301
+ * Updates the selection from the node.
302
+ *
303
+ * Clears the selection for non-block nodes.
304
+ * Clears the selection for shadow blocks as the selection is drawn on
305
+ * the parent but the cursor will be drawn on the shadow block itself.
306
+ * We need to take care not to later clear the current node due to that null
307
+ * selection, so we track the latest selection we're in sync with.
308
+ *
309
+ * @param newNode The new node.
310
+ */
311
+ private updateSelectionFromNode;
312
+ }
313
+ //# sourceMappingURL=line_cursor.d.ts.map
@@ -27,8 +27,6 @@ export declare class Marker {
27
27
  private drawer;
28
28
  /** The type of the marker. */
29
29
  type: string;
30
- /** Constructs a new Marker instance. */
31
- constructor();
32
30
  /**
33
31
  * Sets the object in charge of drawing the marker.
34
32
  *
@@ -40,21 +38,19 @@ export declare class Marker {
40
38
  *
41
39
  * @returns The object in charge of drawing the marker.
42
40
  */
43
- getDrawer(): MarkerSvg;
41
+ getDrawer(): MarkerSvg | null;
44
42
  /**
45
43
  * Gets the current location of the marker.
46
44
  *
47
45
  * @returns The current field, connection, or block the marker is on.
48
46
  */
49
- getCurNode(): ASTNode;
47
+ getCurNode(): ASTNode | null;
50
48
  /**
51
49
  * Set the location of the marker and call the update method.
52
- * Setting isStack to true will only work if the newLocation is the top most
53
- * output or previous connection on a stack.
54
50
  *
55
- * @param newNode The new location of the marker.
51
+ * @param newNode The new location of the marker, or null to remove it.
56
52
  */
57
- setCurNode(newNode: ASTNode): void;
53
+ setCurNode(newNode: ASTNode | null): void;
58
54
  /**
59
55
  * Redraw the current marker.
60
56
  *
@@ -4,8 +4,8 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { FlyoutItem } from './flyout_item.js';
7
+ import type { IFlyout } from './interfaces/i_flyout.js';
7
8
  import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
8
- import type { WorkspaceSvg } from './workspace_svg.js';
9
9
  /**
10
10
  * Class responsible for creating labels for flyouts.
11
11
  */
@@ -14,10 +14,10 @@ export declare class LabelFlyoutInflater implements IFlyoutInflater {
14
14
  * Inflates a flyout label from the given state and adds it to the flyout.
15
15
  *
16
16
  * @param state A JSON representation of a flyout label.
17
- * @param flyoutWorkspace The workspace to create the label on.
17
+ * @param flyout The flyout to create the label on.
18
18
  * @returns A FlyoutButton configured as a label.
19
19
  */
20
- load(state: object, flyoutWorkspace: WorkspaceSvg): FlyoutItem;
20
+ load(state: object, flyout: IFlyout): FlyoutItem;
21
21
  /**
22
22
  * Returns the amount of space that should follow this label.
23
23
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @class
10
10
  */
11
- import type { Cursor } from './keyboard_nav/cursor.js';
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(): Cursor | null;
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: Cursor): void;
67
+ setCursor(cursor: LineCursor): void;
68
68
  /**
69
69
  * Add the cursor SVG to this workspace SVG group.
70
70
  *
package/core/menu.d.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { MenuItem } from './menuitem.js';
6
+ import type { MenuSeparator } from './menu_separator.js';
7
+ import { MenuItem } from './menuitem.js';
7
8
  import * as aria from './utils/aria.js';
8
9
  import { Coordinate } from './utils/coordinate.js';
9
10
  import type { Size } from './utils/size.js';
@@ -12,14 +13,12 @@ import type { Size } from './utils/size.js';
12
13
  */
13
14
  export declare class Menu {
14
15
  /**
15
- * Array of menu items.
16
- * (Nulls are never in the array, but typing the array as nullable prevents
17
- * the compiler from objecting to .indexOf(null))
16
+ * Array of menu items and separators.
18
17
  */
19
18
  private readonly menuItems;
20
19
  /**
21
- * Coordinates of the mousedown event that caused this menu to open. Used to
22
- * prevent the consequent mouseup event due to a simple click from
20
+ * Coordinates of the pointerdown event that caused this menu to open. Used to
21
+ * prevent the consequent pointerup event due to a simple click from
23
22
  * activating a menu item immediately.
24
23
  */
25
24
  openingCoords: Coordinate | null;
@@ -28,14 +27,14 @@ export declare class Menu {
28
27
  * A value of null means no menu item is highlighted.
29
28
  */
30
29
  private highlightedItem;
31
- /** Mouse over event data. */
32
- private mouseOverHandler;
30
+ /** Pointer over event data. */
31
+ private pointerMoveHandler;
33
32
  /** Click event data. */
34
33
  private clickHandler;
35
- /** Mouse enter event data. */
36
- private mouseEnterHandler;
37
- /** Mouse leave event data. */
38
- private mouseLeaveHandler;
34
+ /** Pointer enter event data. */
35
+ private pointerEnterHandler;
36
+ /** Pointer leave event data. */
37
+ private pointerLeaveHandler;
39
38
  /** Key down event data. */
40
39
  private onKeyDownHandler;
41
40
  /** The menu's root DOM element. */
@@ -47,10 +46,10 @@ export declare class Menu {
47
46
  /**
48
47
  * Add a new menu item to the bottom of this menu.
49
48
  *
50
- * @param menuItem Menu item to append.
49
+ * @param menuItem Menu item or separator to append.
51
50
  * @internal
52
51
  */
53
- addChild(menuItem: MenuItem): void;
52
+ addChild(menuItem: MenuItem | MenuSeparator): void;
54
53
  /**
55
54
  * Creates the menu DOM.
56
55
  *
@@ -124,11 +123,12 @@ export declare class Menu {
124
123
  */
125
124
  private highlightHelper;
126
125
  /**
127
- * Handles mouseover events. Highlight menuitems as the user hovers over them.
126
+ * Handles pointermove events. Highlight menu items as the user hovers over
127
+ * them.
128
128
  *
129
- * @param e Mouse event to handle.
129
+ * @param e Pointer event to handle.
130
130
  */
131
- private handleMouseOver;
131
+ private handlePointerMove;
132
132
  /**
133
133
  * Handles click events. Pass the event onto the child menuitem to handle.
134
134
  *
@@ -136,17 +136,17 @@ export declare class Menu {
136
136
  */
137
137
  private handleClick;
138
138
  /**
139
- * Handles mouse enter events. Focus the element.
139
+ * Handles pointer enter events. Focus the element.
140
140
  *
141
- * @param _e Mouse event to handle.
141
+ * @param _e Pointer event to handle.
142
142
  */
143
- private handleMouseEnter;
143
+ private handlePointerEnter;
144
144
  /**
145
- * Handles mouse leave events. Blur and clear highlight.
145
+ * Handles pointer leave events by clearing the active highlight.
146
146
  *
147
- * @param _e Mouse event to handle.
147
+ * @param _e Pointer event to handle.
148
148
  */
149
- private handleMouseLeave;
149
+ private handlePointerLeave;
150
150
  /**
151
151
  * Attempts to handle a keyboard event.
152
152
  *
@@ -160,5 +160,11 @@ export declare class Menu {
160
160
  * @internal
161
161
  */
162
162
  getSize(): Size;
163
+ /**
164
+ * Returns the action menu items (omitting separators) in this menu.
165
+ *
166
+ * @returns The MenuItem objects displayed in this menu.
167
+ */
168
+ private getMenuItems;
163
169
  }
164
170
  //# sourceMappingURL=menu.d.ts.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Representation of a section separator in a menu.
8
+ */
9
+ export declare class MenuSeparator {
10
+ /**
11
+ * DOM element representing this separator in a menu.
12
+ */
13
+ private element;
14
+ /**
15
+ * Creates the DOM representation of this separator.
16
+ *
17
+ * @returns An <hr> element.
18
+ */
19
+ createDom(): HTMLHRElement;
20
+ /**
21
+ * Disposes of this separator.
22
+ */
23
+ dispose(): void;
24
+ }
25
+ //# sourceMappingURL=menu_separator.d.ts.map