blockly 12.0.0 → 12.1.0-beta.0

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/core/blockly.d.ts CHANGED
@@ -106,6 +106,7 @@ import { IVariableMap } from './interfaces/i_variable_map.js';
106
106
  import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
107
107
  import { LineCursor } from './keyboard_nav/line_cursor.js';
108
108
  import { Marker } from './keyboard_nav/marker.js';
109
+ import { KeyboardNavigationController, keyboardNavigationController } from './keyboard_navigation_controller.js';
109
110
  import type { LayerManager } from './layer_manager.js';
110
111
  import * as layers from './layers.js';
111
112
  import { MarkerManager } from './marker_manager.js';
@@ -281,5 +282,5 @@ export * from './navigator.js';
281
282
  export * from './toast.js';
282
283
  export { Block, BlockSvg, BlocklyOptions, Blocks, CollapsibleToolboxCategory, ComponentManager, Connection, ConnectionChecker, ConnectionDB, ConnectionType, ContextMenu, ContextMenuItems, ContextMenuRegistry, Css, DeleteArea, DragTarget, Events, Extensions, LineCursor, Procedures, ShortcutItems, Themes, Tooltip, Touch, Variables, VariablesDynamic, WidgetDiv, Xml, blockAnimations, blockRendering, browserEvents, bubbles, bumpObjects, clipboard, comments, common, constants, dialog, dragging, fieldRegistry, geras, Procedures as procedures, registry, thrasos, uiPosition, utils, zelos, };
283
284
  export declare const DropDownDiv: typeof dropDownDiv;
284
- export { BlockFlyoutInflater, ButtonFlyoutInflater, CodeGenerator, Field, FieldCheckbox, FieldCheckboxConfig, FieldCheckboxFromJsonConfig, FieldCheckboxValidator, FieldConfig, FieldDropdown, FieldDropdownConfig, FieldDropdownFromJsonConfig, FieldDropdownValidator, FieldImage, FieldImageConfig, FieldImageFromJsonConfig, FieldLabel, FieldLabelConfig, FieldLabelFromJsonConfig, FieldLabelSerializable, FieldNumber, FieldNumberConfig, FieldNumberFromJsonConfig, FieldNumberValidator, FieldTextInput, FieldTextInputConfig, FieldTextInputFromJsonConfig, FieldTextInputValidator, FieldValidator, FieldVariable, FieldVariableConfig, FieldVariableFromJsonConfig, FieldVariableValidator, Flyout, FlyoutButton, FlyoutItem, FlyoutMetricsManager, FlyoutSeparator, FocusManager, FocusableTreeTraverser, CodeGenerator as Generator, Gesture, Grid, HorizontalFlyout, IAutoHideable, IBoundedElement, IBubble, ICollapsibleToolboxItem, IComponent, IConnectionChecker, IConnectionPreviewer, IContextMenu, ICopyData, ICopyable, IDeletable, IDeleteArea, IDragStrategy, IDragTarget, IDraggable, IDragger, IFlyout, IFlyoutInflater, IFocusableNode, IFocusableTree, IHasBubble, IIcon, IKeyboardAccessible, IMetricsManager, IMovable, IObservable, IPaster, IPositionable, IRegistrable, IRenderedElement, ISelectable, ISelectableToolboxItem, ISerializable, IStyleable, IToolbox, IToolboxItem, IVariableBackedParameterModel, IVariableMap, IVariableModel, IVariableState, ImageProperties, Input, InsertionMarkerPreviewer, LabelFlyoutInflater, LayerManager, Marker, MarkerManager, Menu, MenuGenerator, MenuGeneratorFunction, MenuItem, MenuOption, MetricsManager, Msg, Names, Options, RenderedConnection, ReturnEphemeralFocus, Scrollbar, ScrollbarPair, SeparatorFlyoutInflater, ShortcutRegistry, Theme, ThemeManager, Toolbox, ToolboxCategory, ToolboxItem, ToolboxSeparator, Trashcan, UnattachedFieldError, VariableMap, VariableModel, VerticalFlyout, Workspace, WorkspaceAudio, WorkspaceDragger, WorkspaceSvg, ZoomControls, config, getFocusManager, hasBubble, icons, inject, inputs, isCopyable, isDeletable, isDraggable, isIcon, isObservable, isPaster, isRenderedElement, isSelectable, isSerializable, isVariableBackedParameterModel, layers, renderManagement, serialization, setLocale, };
285
+ export { BlockFlyoutInflater, ButtonFlyoutInflater, CodeGenerator, Field, FieldCheckbox, FieldCheckboxConfig, FieldCheckboxFromJsonConfig, FieldCheckboxValidator, FieldConfig, FieldDropdown, FieldDropdownConfig, FieldDropdownFromJsonConfig, FieldDropdownValidator, FieldImage, FieldImageConfig, FieldImageFromJsonConfig, FieldLabel, FieldLabelConfig, FieldLabelFromJsonConfig, FieldLabelSerializable, FieldNumber, FieldNumberConfig, FieldNumberFromJsonConfig, FieldNumberValidator, FieldTextInput, FieldTextInputConfig, FieldTextInputFromJsonConfig, FieldTextInputValidator, FieldValidator, FieldVariable, FieldVariableConfig, FieldVariableFromJsonConfig, FieldVariableValidator, Flyout, FlyoutButton, FlyoutItem, FlyoutMetricsManager, FlyoutSeparator, FocusManager, FocusableTreeTraverser, CodeGenerator as Generator, Gesture, Grid, HorizontalFlyout, IAutoHideable, IBoundedElement, IBubble, ICollapsibleToolboxItem, IComponent, IConnectionChecker, IConnectionPreviewer, IContextMenu, ICopyData, ICopyable, IDeletable, IDeleteArea, IDragStrategy, IDragTarget, IDraggable, IDragger, IFlyout, IFlyoutInflater, IFocusableNode, IFocusableTree, IHasBubble, IIcon, IKeyboardAccessible, IMetricsManager, IMovable, IObservable, IPaster, IPositionable, IRegistrable, IRenderedElement, ISelectable, ISelectableToolboxItem, ISerializable, IStyleable, IToolbox, IToolboxItem, IVariableBackedParameterModel, IVariableMap, IVariableModel, IVariableState, ImageProperties, Input, InsertionMarkerPreviewer, KeyboardNavigationController, LabelFlyoutInflater, LayerManager, Marker, MarkerManager, Menu, MenuGenerator, MenuGeneratorFunction, MenuItem, MenuOption, MetricsManager, Msg, Names, Options, RenderedConnection, ReturnEphemeralFocus, Scrollbar, ScrollbarPair, SeparatorFlyoutInflater, ShortcutRegistry, Theme, ThemeManager, Toolbox, ToolboxCategory, ToolboxItem, ToolboxSeparator, Trashcan, UnattachedFieldError, VariableMap, VariableModel, VerticalFlyout, Workspace, WorkspaceAudio, WorkspaceDragger, WorkspaceSvg, ZoomControls, config, getFocusManager, hasBubble, icons, inject, inputs, isCopyable, isDeletable, isDraggable, isIcon, isObservable, isPaster, isRenderedElement, isSelectable, isSerializable, isVariableBackedParameterModel, keyboardNavigationController, layers, renderManagement, serialization, setLocale, };
285
286
  //# sourceMappingURL=blockly.d.ts.map
@@ -70,8 +70,8 @@ export declare abstract class Bubble implements IBubble, ISelectable {
70
70
  * when automatically positioning.
71
71
  * @param overriddenFocusableElement An optional replacement to the focusable
72
72
  * element that's represented by this bubble (as a focusable node). This
73
- * element will have its ID and tabindex overwritten. If not provided, the
74
- * focusable element of this node will default to the bubble's SVG root.
73
+ * element will have its ID overwritten. If not provided, the focusable
74
+ * element of this node will default to the bubble's SVG root.
75
75
  */
76
76
  constructor(workspace: WorkspaceSvg, anchor: Coordinate, ownerRect?: Rect | undefined, overriddenFocusableElement?: SVGElement | HTMLElement);
77
77
  /** Dispose of this bubble. */
@@ -9,6 +9,7 @@ import { IContextMenu } from '../interfaces/i_contextmenu.js';
9
9
  import { ICopyable } from '../interfaces/i_copyable.js';
10
10
  import { IDeletable } from '../interfaces/i_deletable.js';
11
11
  import { IDraggable } from '../interfaces/i_draggable.js';
12
+ import { IFocusableNode } from '../interfaces/i_focusable_node.js';
12
13
  import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
13
14
  import { IRenderedElement } from '../interfaces/i_rendered_element.js';
14
15
  import { ISelectable } from '../interfaces/i_selectable.js';
@@ -17,7 +18,7 @@ import { Rect } from '../utils/rect.js';
17
18
  import { Size } from '../utils/size.js';
18
19
  import { WorkspaceSvg } from '../workspace_svg.js';
19
20
  import { WorkspaceComment } from './workspace_comment.js';
20
- export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement, IDraggable, ISelectable, IDeletable, ICopyable<WorkspaceCommentCopyData>, IContextMenu {
21
+ export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement, IDraggable, ISelectable, IDeletable, ICopyable<WorkspaceCommentCopyData>, IContextMenu, IFocusableNode {
21
22
  /** The class encompassing the svg elements making up the workspace comment. */
22
23
  private view;
23
24
  readonly workspace: WorkspaceSvg;
package/core/common.d.ts CHANGED
@@ -148,6 +148,14 @@ export declare function createBlockDefinitionsFromJsonArray(jsonArray: any[]): {
148
148
  export declare function defineBlocks(blocks: {
149
149
  [key: string]: BlockDefinition;
150
150
  }): void;
151
+ /**
152
+ * Handle a key-down on SVG drawing surface. Does nothing if the main workspace
153
+ * is not visible.
154
+ *
155
+ * @internal
156
+ * @param e Key down event.
157
+ */
158
+ export declare function globalShortcutHandler(e: KeyboardEvent): void;
151
159
  export declare const TEST_ONLY: {
152
160
  defineBlocksWithJsonArrayInternal: typeof defineBlocksWithJsonArrayInternal;
153
161
  };
@@ -95,9 +95,14 @@ export declare function setColour(backgroundColour: string, borderColour: string
95
95
  * @param block Block to position the drop-down around.
96
96
  * @param opt_onHide Optional callback for when the drop-down is hidden.
97
97
  * @param opt_secondaryYOffset Optional Y offset for above-block positioning.
98
+ * @param manageEphemeralFocus Whether ephemeral focus should be managed
99
+ * according to the drop-down div's lifetime. Note that if a false value is
100
+ * passed in here then callers should manage ephemeral focus directly
101
+ * otherwise focus may not properly restore when the widget closes. Defaults
102
+ * to true.
98
103
  * @returns True if the menu rendered below block; false if above.
99
104
  */
100
- export declare function showPositionedByBlock<T>(field: Field<T>, block: BlockSvg, opt_onHide?: () => void, opt_secondaryYOffset?: number): boolean;
105
+ export declare function showPositionedByBlock<T>(field: Field<T>, block: BlockSvg, opt_onHide?: () => void, opt_secondaryYOffset?: number, manageEphemeralFocus?: boolean): boolean;
101
106
  /**
102
107
  * Shortcut to show and place the drop-down with positioning determined
103
108
  * by a particular field. The primary position will be below the field,
@@ -107,9 +112,14 @@ export declare function showPositionedByBlock<T>(field: Field<T>, block: BlockSv
107
112
  * @param field The field to position the dropdown against.
108
113
  * @param opt_onHide Optional callback for when the drop-down is hidden.
109
114
  * @param opt_secondaryYOffset Optional Y offset for above-block positioning.
115
+ * @param manageEphemeralFocus Whether ephemeral focus should be managed
116
+ * according to the drop-down div's lifetime. Note that if a false value is
117
+ * passed in here then callers should manage ephemeral focus directly
118
+ * otherwise focus may not properly restore when the widget closes. Defaults
119
+ * to true.
110
120
  * @returns True if the menu rendered below block; false if above.
111
121
  */
112
- export declare function showPositionedByField<T>(field: Field<T>, opt_onHide?: () => void, opt_secondaryYOffset?: number): boolean;
122
+ export declare function showPositionedByField<T>(field: Field<T>, opt_onHide?: () => void, opt_secondaryYOffset?: number, manageEphemeralFocus?: boolean): boolean;
113
123
  /**
114
124
  * Show and place the drop-down.
115
125
  * The drop-down is placed with an absolute "origin point" (x, y) - i.e.,
@@ -92,6 +92,12 @@ export declare class FieldImage extends Field<string> {
92
92
  * @param alt New alt text.
93
93
  */
94
94
  setAlt(alt: string | null): void;
95
+ /**
96
+ * Check whether this field should be clickable.
97
+ *
98
+ * @returns Whether this field is clickable.
99
+ */
100
+ isClickable(): boolean;
95
101
  /**
96
102
  * If field click is called, and click handler defined,
97
103
  * call the handler.
@@ -401,9 +401,17 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
401
401
  * is registered for that type.
402
402
  */
403
403
  protected getInflaterForType(type: string): IFlyoutInflater | null;
404
- /** See IFocusableNode.getFocusableElement. */
404
+ /**
405
+ * See IFocusableNode.getFocusableElement.
406
+ *
407
+ * @deprecated v12: Use the Flyout's workspace for focus operations, instead.
408
+ */
405
409
  getFocusableElement(): HTMLElement | SVGElement;
406
- /** See IFocusableNode.getFocusableTree. */
410
+ /**
411
+ * See IFocusableNode.getFocusableTree.
412
+ *
413
+ * @deprecated v12: Use the Flyout's workspace for focus operations, instead.
414
+ */
407
415
  getFocusableTree(): IFocusableTree;
408
416
  /** See IFocusableNode.onNodeFocus. */
409
417
  onNodeFocus(): void;
@@ -411,17 +419,37 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
411
419
  onNodeBlur(): void;
412
420
  /** See IFocusableNode.canBeFocused. */
413
421
  canBeFocused(): boolean;
414
- /** See IFocusableTree.getRootFocusableNode. */
422
+ /**
423
+ * See IFocusableNode.getRootFocusableNode.
424
+ *
425
+ * @deprecated v12: Use the Flyout's workspace for focus operations, instead.
426
+ */
415
427
  getRootFocusableNode(): IFocusableNode;
416
- /** See IFocusableTree.getRestoredFocusableNode. */
428
+ /**
429
+ * See IFocusableNode.getRestoredFocusableNode.
430
+ *
431
+ * @deprecated v12: Use the Flyout's workspace for focus operations, instead.
432
+ */
417
433
  getRestoredFocusableNode(_previousNode: IFocusableNode | null): IFocusableNode | null;
418
- /** See IFocusableTree.getNestedTrees. */
434
+ /**
435
+ * See IFocusableNode.getNestedTrees.
436
+ *
437
+ * @deprecated v12: Use the Flyout's workspace for focus operations, instead.
438
+ */
419
439
  getNestedTrees(): Array<IFocusableTree>;
420
- /** See IFocusableTree.lookUpFocusableNode. */
440
+ /**
441
+ * See IFocusableNode.lookUpFocusableNode.
442
+ *
443
+ * @deprecated v12: Use the Flyout's workspace for focus operations, instead.
444
+ */
421
445
  lookUpFocusableNode(_id: string): IFocusableNode | null;
422
446
  /** See IFocusableTree.onTreeFocus. */
423
447
  onTreeFocus(_node: IFocusableNode, _previousTree: IFocusableTree | null): void;
424
- /** See IFocusableTree.onTreeBlur. */
425
- onTreeBlur(nextTree: IFocusableTree | null): void;
448
+ /**
449
+ * See IFocusableNode.onTreeBlur.
450
+ *
451
+ * @deprecated v12: Use the Flyout's workspace for focus operations, instead.
452
+ */
453
+ onTreeBlur(_nextTree: IFocusableTree | null): void;
426
454
  }
427
455
  //# sourceMappingURL=flyout_base.d.ts.map
@@ -55,6 +55,7 @@ export declare class FocusManager {
55
55
  private currentlyHoldsEphemeralFocus;
56
56
  private lockFocusStateChanges;
57
57
  private recentlyLostAllFocus;
58
+ private isUpdatingFocusedNode;
58
59
  constructor(addGlobalEventListener: (type: string, listener: EventListener) => void);
59
60
  /**
60
61
  * Registers a new IFocusableTree for automatic focus management.
@@ -66,14 +67,30 @@ export declare class FocusManager {
66
67
  * This function throws if the provided tree is already currently registered
67
68
  * in this manager. Use isRegistered to check in cases when it can't be
68
69
  * certain whether the tree has been registered.
70
+ *
71
+ * The tree's registration can be customized to configure automatic tab stops.
72
+ * This specifically provides capability for the user to be able to tab
73
+ * navigate to the root of the tree but only when the tree doesn't hold active
74
+ * focus. If this functionality is disabled then the tree's root will
75
+ * automatically be made focusable (but not tabbable) when it is first focused
76
+ * in the same way as any other focusable node.
77
+ *
78
+ * @param tree The IFocusableTree to register.
79
+ * @param rootShouldBeAutoTabbable Whether the root of this tree should be
80
+ * added as a top-level page tab stop when it doesn't hold active focus.
69
81
  */
70
- registerTree(tree: IFocusableTree): void;
82
+ registerTree(tree: IFocusableTree, rootShouldBeAutoTabbable?: boolean): void;
71
83
  /**
72
84
  * Returns whether the specified tree has already been registered in this
73
85
  * manager using registerTree and hasn't yet been unregistered using
74
86
  * unregisterTree.
75
87
  */
76
88
  isRegistered(tree: IFocusableTree): boolean;
89
+ /**
90
+ * Returns the TreeRegistration for the specified tree, or null if the tree is
91
+ * not currently registered.
92
+ */
93
+ private lookUpRegistration;
77
94
  /**
78
95
  * Unregisters a IFocusableTree from automatic focus management.
79
96
  *
@@ -82,6 +99,9 @@ export declare class FocusManager {
82
99
  *
83
100
  * This function throws if the provided tree is not currently registered in
84
101
  * this manager.
102
+ *
103
+ * This function will reset the tree's root element tabindex if the tree was
104
+ * registered with automatic tab management.
85
105
  */
86
106
  unregisterTree(tree: IFocusableTree): void;
87
107
  /**
@@ -132,6 +152,9 @@ export declare class FocusManager {
132
152
  * canBeFocused() method returns false), it will be ignored and any existing
133
153
  * focus state will remain unchanged.
134
154
  *
155
+ * Note that this may update the specified node's element's tabindex to ensure
156
+ * that it can be properly read out by screenreaders while focused.
157
+ *
135
158
  * @param focusableNode The node that should receive active focus.
136
159
  */
137
160
  focusNode(focusableNode: IFocusableNode): void;
@@ -72,5 +72,11 @@ export declare abstract class Icon implements IIcon {
72
72
  onNodeBlur(): void;
73
73
  /** See IFocusableNode.canBeFocused. */
74
74
  canBeFocused(): boolean;
75
+ /**
76
+ * Returns the block that this icon is attached to.
77
+ *
78
+ * @returns The block this icon is attached to.
79
+ */
80
+ getSourceBlock(): Block;
75
81
  }
76
82
  //# sourceMappingURL=icon.d.ts.map
@@ -17,13 +17,11 @@ export interface IFocusableNode {
17
17
  * - blocklyActiveFocus
18
18
  * - blocklyPassiveFocus
19
19
  *
20
- * The returned element must also have a valid ID specified, and unique across
21
- * the entire page. Failing to have a properly unique ID could result in
22
- * trying to focus one node (such as via a mouse click) leading to another
23
- * node with the same ID actually becoming focused by FocusManager. The
24
- * returned element must also have a negative tabindex (since the focus
25
- * manager itself will manage its tab index and a tab index must be present in
26
- * order for the element to be focusable in the DOM).
20
+ * The returned element must also have a valid ID specified, and this ID
21
+ * should be unique across the entire page. Failing to have a properly unique
22
+ * ID could result in trying to focus one node (such as via a mouse click)
23
+ * leading to another node with the same ID actually becoming focused by
24
+ * FocusManager.
27
25
  *
28
26
  * The returned element must be visible if the node is ever focused via
29
27
  * FocusManager.focusNode() or FocusManager.focusTree(). It's allowed for an
@@ -32,7 +30,11 @@ export interface IFocusableNode {
32
30
  *
33
31
  * It's expected the actual returned element will not change for the lifetime
34
32
  * of the node (that is, its properties can change but a new element should
35
- * never be returned).
33
+ * never be returned). Also, the returned element will have its tabindex
34
+ * overwritten throughout the lifecycle of this node and FocusManager.
35
+ *
36
+ * If a node requires the ability to be focused directly without first being
37
+ * focused via FocusManager then it must set its own tab index.
36
38
  *
37
39
  * @returns The HTMLElement or SVGElement which can both receive focus and be
38
40
  * visually represented as actively or passively focused for this node.
@@ -4,8 +4,11 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { BlockSvg } from '../block_svg.js';
7
+ import type { Field } from '../field.js';
8
+ import type { Icon } from '../icons/icon.js';
7
9
  import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
10
  import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
11
+ import { RenderedConnection } from '../rendered_connection.js';
9
12
  /**
10
13
  * Set of rules controlling keyboard navigation from a block.
11
14
  */
@@ -29,7 +32,7 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
29
32
  * Returns the next peer node of the given block.
30
33
  *
31
34
  * @param current The block to find the following element of.
32
- * @returns The first block of the next stack if the given block is a terminal
35
+ * @returns The first node of the next input/stack if the given block is a terminal
33
36
  * block, or its next connection.
34
37
  */
35
38
  getNextSibling(current: BlockSvg): IFocusableNode | null;
@@ -56,4 +59,25 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
56
59
  */
57
60
  isApplicable(current: any): current is BlockSvg;
58
61
  }
62
+ /**
63
+ * Returns the next/previous stack relative to the given block's stack.
64
+ *
65
+ * @param current The block whose stack will be navigated relative to.
66
+ * @param delta The difference in index to navigate; positive values navigate
67
+ * to the nth next stack, while negative values navigate to the nth previous
68
+ * stack.
69
+ * @returns The first block in the stack offset by `delta` relative to the
70
+ * current block's stack, or the last block in the stack offset by `delta`
71
+ * relative to the current block's stack when navigating backwards.
72
+ */
73
+ export declare function navigateStacks(current: BlockSvg, delta: number): BlockSvg | null;
74
+ /**
75
+ * Returns the next navigable item relative to the provided block child.
76
+ *
77
+ * @param current The navigable block child item to navigate relative to.
78
+ * @param delta The difference in index to navigate; positive values navigate
79
+ * forward by n, while negative values navigate backwards by n.
80
+ * @returns The navigable block child offset by `delta` relative to `current`.
81
+ */
82
+ export declare function navigateBlock(current: Icon | Field | RenderedConnection | BlockSvg, delta: number): IFocusableNode | null;
59
83
  //# sourceMappingURL=block_navigation_policy.d.ts.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Icon } from '../icons/icon.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from an icon.
11
+ */
12
+ export declare class IconNavigationPolicy implements INavigationPolicy<Icon> {
13
+ /**
14
+ * Returns the first child of the given icon.
15
+ *
16
+ * @param _current The icon to return the first child of.
17
+ * @returns Null.
18
+ */
19
+ getFirstChild(_current: Icon): IFocusableNode | null;
20
+ /**
21
+ * Returns the parent of the given icon.
22
+ *
23
+ * @param current The icon to return the parent of.
24
+ * @returns The source block of the given icon.
25
+ */
26
+ getParent(current: Icon): IFocusableNode | null;
27
+ /**
28
+ * Returns the next peer node of the given icon.
29
+ *
30
+ * @param current The icon to find the following element of.
31
+ * @returns The next icon, field or input following this icon, if any.
32
+ */
33
+ getNextSibling(current: Icon): IFocusableNode | null;
34
+ /**
35
+ * Returns the previous peer node of the given icon.
36
+ *
37
+ * @param current The icon to find the preceding element of.
38
+ * @returns The icon's previous icon, if any.
39
+ */
40
+ getPreviousSibling(current: Icon): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given icon can be navigated to.
43
+ *
44
+ * @param current The instance to check for navigability.
45
+ * @returns True if the given icon can be focused.
46
+ */
47
+ isNavigable(current: Icon): boolean;
48
+ /**
49
+ * Returns whether the given object can be navigated from by this policy.
50
+ *
51
+ * @param current The object to check if this policy applies to.
52
+ * @returns True if the object is an Icon.
53
+ */
54
+ isApplicable(current: any): current is Icon;
55
+ }
56
+ //# sourceMappingURL=icon_navigation_policy.d.ts.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * The KeyboardNavigationController handles coordinating Blockly-wide
8
+ * keyboard navigation behavior, such as enabling/disabling full
9
+ * cursor visualization.
10
+ */
11
+ export declare class KeyboardNavigationController {
12
+ /** Whether the user is actively using keyboard navigation. */
13
+ private isActive;
14
+ /** Css class name added to body if keyboard nav is active. */
15
+ private activeClassName;
16
+ /**
17
+ * Sets whether a user is actively using keyboard navigation.
18
+ *
19
+ * If they are, apply a css class to the entire page so that
20
+ * focused items can apply additional styling for keyboard users.
21
+ *
22
+ * Note that since enabling keyboard navigation presents significant UX changes
23
+ * (such as cursor visualization and move mode), callers should take care to
24
+ * only set active keyboard navigation when they have a high confidence in that
25
+ * being the correct state. In general, in any given mouse or key input situation
26
+ * callers can choose one of three paths:
27
+ * 1. Do nothing. This should be the choice for neutral actions that don't
28
+ * predominantly imply keyboard or mouse usage (such as clicking to select a block).
29
+ * 2. Disable keyboard navigation. This is the best choice when a user is definitely
30
+ * predominantly using the mouse (such as using a right click to open the context menu).
31
+ * 3. Enable keyboard navigation. This is the best choice when there's high confidence
32
+ * a user actually intends to use it (such as attempting to use the arrow keys to move
33
+ * around).
34
+ *
35
+ * @param isUsing
36
+ */
37
+ setIsActive(isUsing?: boolean): void;
38
+ /**
39
+ * @returns true if the user is actively using keyboard navigation
40
+ * (e.g., has recently taken some action that is only relevant to keyboard users)
41
+ */
42
+ getIsActive(): boolean;
43
+ /** Adds or removes the css class that indicates keyboard navigation is active. */
44
+ private updateActiveVisualization;
45
+ }
46
+ /** Singleton instance of the keyboard navigation controller. */
47
+ export declare const keyboardNavigationController: KeyboardNavigationController;
48
+ //# sourceMappingURL=keyboard_navigation_controller.d.ts.map
@@ -6,7 +6,7 @@
6
6
  import * as browserEvents from '../browser_events.js';
7
7
  import { DeleteArea } from '../delete_area.js';
8
8
  import '../events/events_toolbox_item_select.js';
9
- import type { IAutoHideable } from '../interfaces/i_autohideable.js';
9
+ import { type IAutoHideable } from '../interfaces/i_autohideable.js';
10
10
  import type { IDraggable } from '../interfaces/i_draggable.js';
11
11
  import type { IFlyout } from '../interfaces/i_flyout.js';
12
12
  import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
@@ -412,6 +412,6 @@ export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeybo
412
412
  /** See IFocusableTree.onTreeFocus. */
413
413
  onTreeFocus(node: IFocusableNode, _previousTree: IFocusableTree | null): void;
414
414
  /** See IFocusableTree.onTreeBlur. */
415
- onTreeBlur(_nextTree: IFocusableTree | null): void;
415
+ onTreeBlur(nextTree: IFocusableTree | null): void;
416
416
  }
417
417
  //# sourceMappingURL=toolbox.d.ts.map
package/index.mjs CHANGED
@@ -55,6 +55,7 @@ export const {
55
55
  INPUT_VALUE,
56
56
  Input,
57
57
  InsertionMarkerPreviewer,
58
+ KeyboardNavigationController,
58
59
  LabelFlyoutInflater,
59
60
  LineCursor,
60
61
  Marker,
@@ -144,7 +145,10 @@ export const {
144
145
  isSelectable,
145
146
  isSerializable,
146
147
  isVariableBackedParameterModel,
148
+ keyboardNavigationController,
147
149
  layers,
150
+ navigateBlock,
151
+ navigateStacks,
148
152
  procedures,
149
153
  registry,
150
154
  renderManagement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly",
3
- "version": "12.0.0",
3
+ "version": "12.1.0-beta.0",
4
4
  "description": "Blockly is a library for building visual programming editors.",
5
5
  "keywords": [
6
6
  "blockly"
@@ -68,7 +68,7 @@
68
68
  "license": "Apache-2.0",
69
69
  "devDependencies": {
70
70
  "@blockly/block-test": "^6.0.4",
71
- "@blockly/dev-tools": "^8.0.6",
71
+ "@blockly/dev-tools": "^9.0.0",
72
72
  "@blockly/theme-modern": "^6.0.3",
73
73
  "@hyperjump/browser": "^1.1.4",
74
74
  "@hyperjump/json-schema": "^1.5.0",
@@ -99,7 +99,7 @@
99
99
  "http-server": "^14.0.0",
100
100
  "json5": "^2.2.0",
101
101
  "markdown-tables-to-json": "^0.1.7",
102
- "mocha": "^10.0.0",
102
+ "mocha": "^11.3.0",
103
103
  "patch-package": "^8.0.0",
104
104
  "prettier": "^3.3.3",
105
105
  "prettier-plugin-organize-imports": "^4.0.0",