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
@@ -16,7 +16,6 @@ import type { WorkspaceSvg } from './workspace_svg.js';
16
16
  export declare class BlockFlyoutInflater implements IFlyoutInflater {
17
17
  protected permanentlyDisabledBlocks: Set<BlockSvg>;
18
18
  protected listeners: Map<string, browserEvents.Data[]>;
19
- protected flyoutWorkspace?: WorkspaceSvg;
20
19
  protected flyout?: IFlyout;
21
20
  private capacityWrapper;
22
21
  /**
@@ -27,10 +26,10 @@ export declare class BlockFlyoutInflater implements IFlyoutInflater {
27
26
  * Inflates a flyout block from the given state and adds it to the flyout.
28
27
  *
29
28
  * @param state A JSON representation of a flyout block.
30
- * @param flyoutWorkspace The workspace to create the block on.
29
+ * @param flyout The flyout to create the block on.
31
30
  * @returns A newly created block.
32
31
  */
33
- load(state: object, flyoutWorkspace: WorkspaceSvg): FlyoutItem;
32
+ load(state: object, flyout: IFlyout): FlyoutItem;
34
33
  /**
35
34
  * Creates a block on the given workspace.
36
35
  *
@@ -60,11 +59,11 @@ export declare class BlockFlyoutInflater implements IFlyoutInflater {
60
59
  */
61
60
  protected removeListeners(blockId: string): void;
62
61
  /**
63
- * Updates this inflater's flyout workspace.
62
+ * Updates this inflater's flyout.
64
63
  *
65
- * @param workspace The workspace of the flyout that owns this inflater.
64
+ * @param flyout The flyout that owns this inflater.
66
65
  */
67
- protected setFlyoutWorkspace(workspace: WorkspaceSvg): void;
66
+ protected setFlyout(flyout: IFlyout): void;
68
67
  /**
69
68
  * Updates the enabled state of the given block based on the capacity of the
70
69
  * workspace.
@@ -15,7 +15,6 @@ import { BlockCopyData } from './clipboard/block_paster.js';
15
15
  import type { Connection } from './connection.js';
16
16
  import { ConnectionType } from './connection_type.js';
17
17
  import { ContextMenuOption, LegacyContextMenuOption } from './contextmenu_registry.js';
18
- import type { Field } from './field.js';
19
18
  import { IconType } from './icons/icon_types.js';
20
19
  import { MutatorIcon } from './icons/mutator_icon.js';
21
20
  import type { Input } from './inputs/input.js';
@@ -232,13 +231,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
232
231
  * for that state.
233
232
  */
234
233
  private updateCollapsed;
235
- /**
236
- * Open the next (or previous) FieldTextInput.
237
- *
238
- * @param start Current field.
239
- * @param forward If true go forward, otherwise backward.
240
- */
241
- tab(start: Field, forward: boolean): void;
242
234
  /**
243
235
  * Handle a pointerdown on an SVG block.
244
236
  *
package/core/blockly.d.ts CHANGED
@@ -55,6 +55,7 @@ import { FlyoutItem } from './flyout_item.js';
55
55
  import { FlyoutMetricsManager } from './flyout_metrics_manager.js';
56
56
  import { FlyoutSeparator } from './flyout_separator.js';
57
57
  import { VerticalFlyout } from './flyout_vertical.js';
58
+ import { FocusManager, ReturnEphemeralFocus, getFocusManager } from './focus_manager.js';
58
59
  import { CodeGenerator } from './generator.js';
59
60
  import { Gesture } from './gesture.js';
60
61
  import { Grid } from './grid.js';
@@ -84,6 +85,8 @@ import { IDragTarget } from './interfaces/i_drag_target.js';
84
85
  import { IDragStrategy, IDraggable, isDraggable } from './interfaces/i_draggable.js';
85
86
  import { IDragger } from './interfaces/i_dragger.js';
86
87
  import { IFlyout } from './interfaces/i_flyout.js';
88
+ import { IFocusableNode } from './interfaces/i_focusable_node.js';
89
+ import { IFocusableTree } from './interfaces/i_focusable_tree.js';
87
90
  import { IHasBubble, hasBubble } from './interfaces/i_has_bubble.js';
88
91
  import { IIcon, isIcon } from './interfaces/i_icon.js';
89
92
  import { IKeyboardAccessible } from './interfaces/i_keyboard_accessible.js';
@@ -104,10 +107,8 @@ import { IVariableBackedParameterModel, isVariableBackedParameterModel } from '.
104
107
  import { IVariableMap } from './interfaces/i_variable_map.js';
105
108
  import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
106
109
  import { ASTNode } from './keyboard_nav/ast_node.js';
107
- import { BasicCursor } from './keyboard_nav/basic_cursor.js';
108
- import { Cursor } from './keyboard_nav/cursor.js';
110
+ import { CursorOptions, LineCursor } from './keyboard_nav/line_cursor.js';
109
111
  import { Marker } from './keyboard_nav/marker.js';
110
- import { TabNavigateCursor } from './keyboard_nav/tab_navigate_cursor.js';
111
112
  import type { LayerManager } from './layer_manager.js';
112
113
  import * as layers from './layers.js';
113
114
  import { MarkerManager } from './marker_manager.js';
@@ -270,7 +271,7 @@ export declare const VARIABLE_DYNAMIC_CATEGORY_NAME: string;
270
271
  * procedure blocks.
271
272
  */
272
273
  export declare const PROCEDURE_CATEGORY_NAME: string;
273
- export { ASTNode, BasicCursor, Block, BlockSvg, BlocklyOptions, Blocks, CollapsibleToolboxCategory, ComponentManager, Connection, ConnectionChecker, ConnectionDB, ConnectionType, ContextMenu, ContextMenuItems, ContextMenuRegistry, Css, Cursor, DeleteArea, DragTarget, Events, Extensions, 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, };
274
+ export { ASTNode, Block, BlockSvg, BlocklyOptions, Blocks, CollapsibleToolboxCategory, ComponentManager, Connection, ConnectionChecker, ConnectionDB, ConnectionType, ContextMenu, ContextMenuItems, ContextMenuRegistry, Css, CursorOptions, 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, };
274
275
  export declare const DropDownDiv: typeof dropDownDiv;
275
- 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, CodeGenerator as Generator, Gesture, Grid, HorizontalFlyout, IASTNodeLocation, IASTNodeLocationSvg, IASTNodeLocationWithBlock, IAutoHideable, IBoundedElement, IBubble, ICollapsibleToolboxItem, IComponent, IConnectionChecker, IConnectionPreviewer, IContextMenu, ICopyData, ICopyable, IDeletable, IDeleteArea, IDragStrategy, IDragTarget, IDraggable, IDragger, IFlyout, IFlyoutInflater, 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, Scrollbar, ScrollbarPair, SeparatorFlyoutInflater, ShortcutRegistry, TabNavigateCursor, Theme, ThemeManager, Toolbox, ToolboxCategory, ToolboxItem, ToolboxSeparator, Trashcan, UnattachedFieldError, VariableMap, VariableModel, VerticalFlyout, Workspace, WorkspaceAudio, WorkspaceDragger, WorkspaceSvg, ZoomControls, config, hasBubble, icons, inject, inputs, isCopyable, isDeletable, isDraggable, isIcon, isObservable, isPaster, isRenderedElement, isSelectable, isSerializable, isVariableBackedParameterModel, layers, renderManagement, serialization, setLocale, };
276
+ 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, CodeGenerator as Generator, Gesture, Grid, HorizontalFlyout, IASTNodeLocation, IASTNodeLocationSvg, IASTNodeLocationWithBlock, 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, };
276
277
  //# sourceMappingURL=blockly.d.ts.map
@@ -26,12 +26,12 @@ export declare class TextBubble extends Bubble {
26
26
  * broken up by newlines.
27
27
  */
28
28
  private stringToSvg;
29
- /** Creates the paragraph container for this bubble's view's spans. */
29
+ /** Creates the paragraph container for this bubble's view's text fragments. */
30
30
  private createParagraph;
31
- /** Creates the spans visualizing the text of this bubble. */
32
- private createSpans;
33
- /** Right aligns the given spans. */
34
- private rightAlignSpans;
31
+ /** Creates the text fragments visualizing the text of this bubble. */
32
+ private createTextFragments;
33
+ /** Right aligns the given text fragments. */
34
+ private rightAlignTextFragments;
35
35
  /** Updates the size of this bubble to account for the size of the text. */
36
36
  private updateBubbleSize;
37
37
  }
@@ -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 buttons for flyouts.
11
11
  */
@@ -14,10 +14,10 @@ export declare class ButtonFlyoutInflater implements IFlyoutInflater {
14
14
  * Inflates a flyout button from the given state and adds it to the flyout.
15
15
  *
16
16
  * @param state A JSON representation of a flyout button.
17
- * @param flyoutWorkspace The workspace to create the button on.
17
+ * @param flyout The flyout to create the button on.
18
18
  * @returns A newly created FlyoutButton.
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 button.
23
23
  *
@@ -8,7 +8,7 @@ import { Coordinate } from '../utils/coordinate.js';
8
8
  import { Size } from '../utils/size.js';
9
9
  import { WorkspaceSvg } from '../workspace_svg.js';
10
10
  export declare class CommentView implements IRenderedElement {
11
- private readonly workspace;
11
+ readonly workspace: WorkspaceSvg;
12
12
  /** The root group element of the comment view. */
13
13
  private svgRoot;
14
14
  /**
@@ -62,9 +62,9 @@ export declare class CommentView implements IRenderedElement {
62
62
  */
63
63
  private resizePointerMoveListener;
64
64
  /** Whether this comment view is currently being disposed or not. */
65
- private disposing;
65
+ protected disposing: boolean;
66
66
  /** Whether this comment view has been disposed or not. */
67
- private disposed;
67
+ protected disposed: boolean;
68
68
  /** Size of this comment when the resize drag was initiated. */
69
69
  private preResizeSize?;
70
70
  /** The default size of newly created comments. */
@@ -62,7 +62,7 @@ export declare namespace ContextMenuRegistry {
62
62
  * rendered in multiple scopes, e.g. on both a block and a workspace, it
63
63
  * should be registered for each scope.
64
64
  */
65
- enum ScopeType {
65
+ export enum ScopeType {
66
66
  BLOCK = "block",
67
67
  WORKSPACE = "workspace",
68
68
  COMMENT = "comment"
@@ -71,15 +71,23 @@ export declare namespace ContextMenuRegistry {
71
71
  * The actual workspace/block where the menu is being rendered. This is passed
72
72
  * to callback and displayText functions that depend on this information.
73
73
  */
74
- interface Scope {
74
+ export interface Scope {
75
75
  block?: BlockSvg;
76
76
  workspace?: WorkspaceSvg;
77
77
  comment?: RenderedWorkspaceComment;
78
78
  }
79
79
  /**
80
- * A menu item as entered in the registry.
80
+ * Fields common to all context menu registry items.
81
+ */
82
+ interface CoreRegistryItem {
83
+ scopeType: ScopeType;
84
+ weight: number;
85
+ id: string;
86
+ }
87
+ /**
88
+ * A representation of a normal, clickable menu item in the registry.
81
89
  */
82
- interface RegistryItem {
90
+ interface ActionRegistryItem extends CoreRegistryItem {
83
91
  /**
84
92
  * @param scope Object that provides a reference to the thing that had its
85
93
  * context menu opened.
@@ -87,16 +95,34 @@ export declare namespace ContextMenuRegistry {
87
95
  * the event that triggered the click on the option.
88
96
  */
89
97
  callback: (scope: Scope, e: PointerEvent) => void;
90
- scopeType: ScopeType;
91
98
  displayText: ((p1: Scope) => string | HTMLElement) | string | HTMLElement;
92
99
  preconditionFn: (p1: Scope) => string;
100
+ separator?: never;
101
+ }
102
+ /**
103
+ * A representation of a menu separator item in the registry.
104
+ */
105
+ interface SeparatorRegistryItem extends CoreRegistryItem {
106
+ separator: true;
107
+ callback?: never;
108
+ displayText?: never;
109
+ preconditionFn?: never;
110
+ }
111
+ /**
112
+ * A menu item as entered in the registry.
113
+ */
114
+ export type RegistryItem = ActionRegistryItem | SeparatorRegistryItem;
115
+ /**
116
+ * Fields common to all context menu items as used by contextmenu.ts.
117
+ */
118
+ export interface CoreContextMenuOption {
119
+ scope: Scope;
93
120
  weight: number;
94
- id: string;
95
121
  }
96
122
  /**
97
- * A menu item as presented to contextmenu.js.
123
+ * A representation of a normal, clickable menu item in contextmenu.ts.
98
124
  */
99
- interface ContextMenuOption {
125
+ export interface ActionContextMenuOption extends CoreContextMenuOption {
100
126
  text: string | HTMLElement;
101
127
  enabled: boolean;
102
128
  /**
@@ -106,18 +132,32 @@ export declare namespace ContextMenuRegistry {
106
132
  * the event that triggered the click on the option.
107
133
  */
108
134
  callback: (scope: Scope, e: PointerEvent) => void;
109
- scope: Scope;
110
- weight: number;
135
+ separator?: never;
136
+ }
137
+ /**
138
+ * A representation of a menu separator item in contextmenu.ts.
139
+ */
140
+ export interface SeparatorContextMenuOption extends CoreContextMenuOption {
141
+ separator: true;
142
+ text?: never;
143
+ enabled?: never;
144
+ callback?: never;
111
145
  }
146
+ /**
147
+ * A menu item as presented to contextmenu.ts.
148
+ */
149
+ export type ContextMenuOption = ActionContextMenuOption | SeparatorContextMenuOption;
112
150
  /**
113
151
  * A subset of ContextMenuOption corresponding to what was publicly
114
152
  * documented. ContextMenuOption should be preferred for new code.
115
153
  */
116
- interface LegacyContextMenuOption {
154
+ export interface LegacyContextMenuOption {
117
155
  text: string;
118
156
  enabled: boolean;
119
157
  callback: (p1: Scope) => void;
158
+ separator?: never;
120
159
  }
160
+ export {};
121
161
  }
122
162
  export type ScopeType = ContextMenuRegistry.ScopeType;
123
163
  export declare const ScopeType: typeof ContextMenuRegistry.ScopeType;
@@ -25,8 +25,8 @@ export declare class BlockDragStrategy implements IDragStrategy {
25
25
  * block, to add to the drag location. In workspace units.
26
26
  */
27
27
  private dragOffset;
28
- /** Was there already an event group in progress when the drag started? */
29
- private inGroup;
28
+ /** Used to persist an event group when snapping is done async. */
29
+ private originalEventGroup;
30
30
  constructor(block: BlockSvg);
31
31
  /** Returns true if the block is currently movable. False otherwise. */
32
32
  isMovable(): boolean;
@@ -35,6 +35,14 @@ export declare class BlockDragStrategy implements IDragStrategy {
35
35
  * from any parent blocks.
36
36
  */
37
37
  startDrag(e?: PointerEvent): void;
38
+ /**
39
+ * Get whether the drag should act on a single block or a block stack.
40
+ *
41
+ * @param e The instigating pointer event, if any.
42
+ * @returns True if just the initial block should be dragged out, false
43
+ * if all following blocks should also be dragged.
44
+ */
45
+ protected shouldHealStack(e: PointerEvent | undefined): boolean;
38
46
  /** Starts a drag on a shadow, recording the drag offset. */
39
47
  private startDraggingShadow;
40
48
  /**
@@ -84,6 +92,10 @@ export declare class BlockDragStrategy implements IDragStrategy {
84
92
  * compatible type (input, output, etc) and connection check.
85
93
  */
86
94
  private getConnectionCandidate;
95
+ /**
96
+ * Get the radius to use when searching for a nearby valid connection.
97
+ */
98
+ protected getSearchRadius(): number;
87
99
  /**
88
100
  * Returns all of the connections we might connect to blocks on the workspace.
89
101
  *
@@ -10,8 +10,6 @@ export declare class BubbleDragStrategy implements IDragStrategy {
10
10
  private bubble;
11
11
  private workspace;
12
12
  private startLoc;
13
- /** Was there already an event group in progress when the drag started? */
14
- private inGroup;
15
13
  constructor(bubble: IBubble, workspace: WorkspaceSvg);
16
14
  isMovable(): boolean;
17
15
  startDrag(): void;
@@ -10,8 +10,6 @@ export declare class CommentDragStrategy implements IDragStrategy {
10
10
  private comment;
11
11
  private startLoc;
12
12
  private workspace;
13
- /** Was there already an event group in progress when the drag started? */
14
- private inGroup;
15
13
  constructor(comment: RenderedWorkspaceComment);
16
14
  isMovable(): boolean;
17
15
  startDrag(): void;
package/core/field.d.ts CHANGED
@@ -54,8 +54,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
54
54
  * `FieldImage.prototype.DEFAULT_VALUE = null;`
55
55
  */
56
56
  DEFAULT_VALUE: T | null;
57
- /** Non-breaking space. */
58
- static readonly NBSP = "\u00A0";
59
57
  /**
60
58
  * A value used to signal when a field's constructor should *not* set the
61
59
  * field's value or run configure_, and should allow a subclass to do that
@@ -205,8 +203,10 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
205
203
  * intend because the behavior was kind of hacked in. If you are thinking
206
204
  * about overriding this function, post on the forum with your intended
207
205
  * behavior to see if there's another approach.
206
+ *
207
+ * @internal
208
208
  */
209
- protected isFullBlockField(): boolean;
209
+ isFullBlockField(): boolean;
210
210
  /**
211
211
  * Create a field border rect element. Not to be overridden by subclasses.
212
212
  * Instead modify the result of the function inside initView, or create a
@@ -662,12 +662,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
662
662
  * @returns True if we should flip in RTL.
663
663
  */
664
664
  getFlipRtl(): boolean;
665
- /**
666
- * Returns whether or not the field is tab navigable.
667
- *
668
- * @returns True if the field is tab navigable.
669
- */
670
- isTabNavigable(): boolean;
671
665
  /**
672
666
  * Handles the given keyboard shortcut.
673
667
  *
@@ -10,13 +10,10 @@ import { MenuItem } from './menuitem.js';
10
10
  * Class for an editable dropdown field.
11
11
  */
12
12
  export declare class FieldDropdown extends Field<string> {
13
- /** Horizontal distance that a checkmark overhangs the dropdown. */
14
- static CHECKMARK_OVERHANG: number;
15
13
  /**
16
- * Maximum height of the dropdown menu, as a percentage of the viewport
17
- * height.
14
+ * Magic constant used to represent a separator in a list of dropdown items.
18
15
  */
19
- static MAX_MENU_HEIGHT_VH: number;
16
+ static readonly SEPARATOR = "separator";
20
17
  static ARROW_CHAR: string;
21
18
  /** A reference to the currently selected menu item. */
22
19
  private selectedMenuItem;
@@ -239,11 +236,12 @@ export interface ImageProperties {
239
236
  height: number;
240
237
  }
241
238
  /**
242
- * An individual option in the dropdown menu. The first element is the human-
243
- * readable value (text or image), and the second element is the language-
244
- * neutral value.
239
+ * An individual option in the dropdown menu. Can be either the string literal
240
+ * `separator` for a menu separator item, or an array for normal action menu
241
+ * items. In the latter case, the first element is the human-readable value
242
+ * (text or image), and the second element is the language-neutral value.
245
243
  */
246
- export type MenuOption = [string | ImageProperties, string];
244
+ export type MenuOption = [string | ImageProperties, string] | 'separator';
247
245
  /**
248
246
  * A function that generates an array of menu options for FieldDropdown
249
247
  * or its descendants.
@@ -79,7 +79,7 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
79
79
  constructor(value?: string | typeof Field.SKIP_SETUP, validator?: FieldInputValidator<T> | null, config?: FieldInputConfig);
80
80
  protected configure_(config: FieldInputConfig): void;
81
81
  initView(): void;
82
- protected isFullBlockField(): boolean;
82
+ isFullBlockField(): boolean;
83
83
  /**
84
84
  * Called by setValue if the text input is not valid. If the field is
85
85
  * currently being edited it reverts value of the field to the previous
@@ -214,12 +214,6 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
214
214
  * div.
215
215
  */
216
216
  repositionForWindowResize(): boolean;
217
- /**
218
- * Returns whether or not the field is tab navigable.
219
- *
220
- * @returns True if the field is tab navigable.
221
- */
222
- isTabNavigable(): boolean;
223
217
  /**
224
218
  * Use the `getText_` developer hook to override the field's text
225
219
  * representation. When we're currently editing, return the current HTML value
@@ -47,7 +47,8 @@ export declare class FieldVariable extends FieldDropdown {
47
47
  * field's value. Takes in a variable ID & returns a validated variable
48
48
  * ID, or null to abort the change.
49
49
  * @param variableTypes A list of the types of variables to include in the
50
- * dropdown. Will only be used if config is not provided.
50
+ * dropdown. Pass `null` to include all types that exist on the
51
+ * workspace. Will only be used if config is not provided.
51
52
  * @param defaultType The type of variable to create if this field's value
52
53
  * is not explicitly set. Defaults to ''. Will only be used if config
53
54
  * is not provided.
@@ -56,7 +57,7 @@ export declare class FieldVariable extends FieldDropdown {
56
57
  * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/variable#creation}
57
58
  * for a list of properties this parameter supports.
58
59
  */
59
- constructor(varName: string | null | typeof Field.SKIP_SETUP, validator?: FieldVariableValidator, variableTypes?: string[], defaultType?: string, config?: FieldVariableConfig);
60
+ constructor(varName: string | null | typeof Field.SKIP_SETUP, validator?: FieldVariableValidator, variableTypes?: string[] | null, defaultType?: string, config?: FieldVariableConfig);
60
61
  /**
61
62
  * Configure the field based on the given map of options.
62
63
  *
@@ -173,7 +174,6 @@ export declare class FieldVariable extends FieldDropdown {
173
174
  * Return a list of variable types to include in the dropdown.
174
175
  *
175
176
  * @returns Array of variable types.
176
- * @throws {Error} if variableTypes is an empty array.
177
177
  */
178
178
  private getVariableTypes;
179
179
  /**
@@ -0,0 +1,163 @@
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
+ * Type declaration for returning focus to FocusManager upon completing an
10
+ * ephemeral UI flow (such as a dialog).
11
+ *
12
+ * See FocusManager.takeEphemeralFocus for more details.
13
+ */
14
+ export type ReturnEphemeralFocus = () => void;
15
+ /**
16
+ * A per-page singleton that manages Blockly focus across one or more
17
+ * IFocusableTrees, and bidirectionally synchronizes this focus with the DOM.
18
+ *
19
+ * Callers that wish to explicitly change input focus for select Blockly
20
+ * components on the page should use the focus functions in this manager.
21
+ *
22
+ * The manager is responsible for handling focus events from the DOM (which may
23
+ * may arise from users clicking on page elements) and ensuring that
24
+ * corresponding IFocusableNodes are clearly marked as actively/passively
25
+ * highlighted in the same way that this would be represented with calls to
26
+ * focusNode().
27
+ */
28
+ export declare class FocusManager {
29
+ /**
30
+ * The CSS class assigned to IFocusableNode elements that presently have
31
+ * active DOM and Blockly focus.
32
+ *
33
+ * This should never be used directly. Instead, rely on FocusManager to ensure
34
+ * nodes have active focus (either automatically through DOM focus or manually
35
+ * through the various focus* methods provided by this class).
36
+ *
37
+ * It's recommended to not query using this class name, either. Instead, use
38
+ * FocusableTreeTraverser or IFocusableTree's methods to find a specific node.
39
+ */
40
+ static readonly ACTIVE_FOCUS_NODE_CSS_CLASS_NAME = "blocklyActiveFocus";
41
+ /**
42
+ * The CSS class assigned to IFocusableNode elements that presently have
43
+ * passive focus (that is, they were the most recent node in their relative
44
+ * tree to have active focus--see ACTIVE_FOCUS_NODE_CSS_CLASS_NAME--and will
45
+ * receive active focus again if their surrounding tree is requested to become
46
+ * focused, i.e. using focusTree below).
47
+ *
48
+ * See ACTIVE_FOCUS_NODE_CSS_CLASS_NAME for caveats and limitations around
49
+ * using this constant directly (generally it never should need to be used).
50
+ */
51
+ static readonly PASSIVE_FOCUS_NODE_CSS_CLASS_NAME = "blocklyPassiveFocus";
52
+ focusedNode: IFocusableNode | null;
53
+ registeredTrees: Array<IFocusableTree>;
54
+ private currentlyHoldsEphemeralFocus;
55
+ constructor(addGlobalEventListener: (type: string, listener: EventListener) => void);
56
+ /**
57
+ * Registers a new IFocusableTree for automatic focus management.
58
+ *
59
+ * If the tree currently has an element with DOM focus, it will not affect the
60
+ * internal state in this manager until the focus changes to a new,
61
+ * now-monitored element/node.
62
+ *
63
+ * This function throws if the provided tree is already currently registered
64
+ * in this manager. Use isRegistered to check in cases when it can't be
65
+ * certain whether the tree has been registered.
66
+ */
67
+ registerTree(tree: IFocusableTree): void;
68
+ /**
69
+ * Returns whether the specified tree has already been registered in this
70
+ * manager using registerTree and hasn't yet been unregistered using
71
+ * unregisterTree.
72
+ */
73
+ isRegistered(tree: IFocusableTree): boolean;
74
+ /**
75
+ * Unregisters a IFocusableTree from automatic focus management.
76
+ *
77
+ * If the tree had a previous focused node, it will have its highlight
78
+ * removed. This function does NOT change DOM focus.
79
+ *
80
+ * This function throws if the provided tree is not currently registered in
81
+ * this manager.
82
+ */
83
+ unregisterTree(tree: IFocusableTree): void;
84
+ /**
85
+ * Returns the current IFocusableTree that has focus, or null if none
86
+ * currently do.
87
+ *
88
+ * Note also that if ephemeral focus is currently captured (e.g. using
89
+ * takeEphemeralFocus) then the returned tree here may not currently have DOM
90
+ * focus.
91
+ */
92
+ getFocusedTree(): IFocusableTree | null;
93
+ /**
94
+ * Returns the current IFocusableNode with focus (which is always tied to a
95
+ * focused IFocusableTree), or null if there isn't one.
96
+ *
97
+ * Note that this function will maintain parity with
98
+ * IFocusableTree.getFocusedNode(). That is, if a tree itself has focus but
99
+ * none of its non-root children do, this will return null but
100
+ * getFocusedTree() will not.
101
+ *
102
+ * Note also that if ephemeral focus is currently captured (e.g. using
103
+ * takeEphemeralFocus) then the returned node here may not currently have DOM
104
+ * focus.
105
+ */
106
+ getFocusedNode(): IFocusableNode | null;
107
+ /**
108
+ * Focuses the specific IFocusableTree. This either means restoring active
109
+ * focus to the tree's passively focused node, or focusing the tree's root
110
+ * node.
111
+ *
112
+ * Note that if the specified tree already has a focused node then this will
113
+ * not change any existing focus (unless that node has passive focus, then it
114
+ * will be restored to active focus).
115
+ *
116
+ * See getFocusedNode for details on how other nodes are affected.
117
+ *
118
+ * @param focusableTree The tree that should receive active
119
+ * focus.
120
+ */
121
+ focusTree(focusableTree: IFocusableTree): void;
122
+ /**
123
+ * Focuses DOM input on the selected node, and marks it as actively focused.
124
+ *
125
+ * Any previously focused node will be updated to be passively highlighted (if
126
+ * it's in a different focusable tree) or blurred (if it's in the same one).
127
+ *
128
+ * @param focusableNode The node that should receive active
129
+ * focus.
130
+ */
131
+ focusNode(focusableNode: IFocusableNode): void;
132
+ /**
133
+ * Ephemerally captures focus for a selected element until the returned lambda
134
+ * is called. This is expected to be especially useful for ephemeral UI flows
135
+ * like dialogs.
136
+ *
137
+ * IMPORTANT: the returned lambda *must* be called, otherwise automatic focus
138
+ * will no longer work anywhere on the page. It is highly recommended to tie
139
+ * the lambda call to the closure of the corresponding UI so that if input is
140
+ * manually changed to an element outside of the ephemeral UI, the UI should
141
+ * close and automatic input restored. Note that this lambda must be called
142
+ * exactly once and that subsequent calls will throw an error.
143
+ *
144
+ * Note that the manager will continue to track DOM input signals even when
145
+ * ephemeral focus is active, but it won't actually change node state until
146
+ * the returned lambda is called. Additionally, only 1 ephemeral focus context
147
+ * can be active at any given time (attempting to activate more than one
148
+ * simultaneously will result in an error being thrown).
149
+ */
150
+ takeEphemeralFocus(focusableElement: HTMLElement | SVGElement): ReturnEphemeralFocus;
151
+ private defocusCurrentFocusedNode;
152
+ private setNodeToActive;
153
+ private setNodeToPassive;
154
+ private removeHighlight;
155
+ }
156
+ /**
157
+ * Returns the page-global FocusManager.
158
+ *
159
+ * The returned instance is guaranteed to not change across function calls, but
160
+ * may change across page loads.
161
+ */
162
+ export declare function getFocusManager(): FocusManager;
163
+ //# sourceMappingURL=focus_manager.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type { FlyoutItem } from '../flyout_item.js';
2
- import type { WorkspaceSvg } from '../workspace_svg.js';
2
+ import type { IFlyout } from './i_flyout.js';
3
3
  export interface IFlyoutInflater {
4
4
  /**
5
5
  * Loads the object represented by the given state onto the workspace.
@@ -8,14 +8,14 @@ export interface IFlyoutInflater {
8
8
  * allow for code reuse.
9
9
  *
10
10
  * @param state A JSON representation of an element to inflate on the flyout.
11
- * @param flyoutWorkspace The flyout's workspace, where the inflated element
11
+ * @param flyout The flyout on whose workspace the inflated element
12
12
  * should be created. If the inflated element is an `IRenderedElement` it
13
13
  * itself or the inflater should append it to the workspace; the flyout
14
14
  * will not do so itself. The flyout is responsible for positioning the
15
15
  * element, however.
16
16
  * @returns The newly inflated flyout element.
17
17
  */
18
- load(state: object, flyoutWorkspace: WorkspaceSvg): FlyoutItem;
18
+ load(state: object, flyout: IFlyout): FlyoutItem;
19
19
  /**
20
20
  * Returns the amount of spacing that should follow the element corresponding
21
21
  * to the given JSON representation.