blockly 12.0.0-beta.5 → 12.0.0-beta.7

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 (72) hide show
  1. package/blockly.min.js +396 -403
  2. package/blockly.mjs +1 -1
  3. package/blockly_compressed.js +395 -402
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +1 -1
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +1 -16
  8. package/core/block_svg.d.ts +3 -31
  9. package/core/blockly.d.ts +4 -8
  10. package/core/bubbles/bubble.d.ts +22 -3
  11. package/core/bubbles/textinput_bubble.d.ts +3 -5
  12. package/core/comments/rendered_workspace_comment.d.ts +11 -0
  13. package/core/common.d.ts +19 -7
  14. package/core/connection.d.ts +1 -2
  15. package/core/contextmenu_registry.d.ts +1 -1
  16. package/core/dropdowndiv.d.ts +3 -1
  17. package/core/events/events.d.ts +0 -2
  18. package/core/events/predicates.d.ts +0 -3
  19. package/core/events/utils.d.ts +1 -5
  20. package/core/field.d.ts +20 -20
  21. package/core/field_checkbox.d.ts +0 -9
  22. package/core/field_dropdown.d.ts +7 -10
  23. package/core/field_image.d.ts +0 -11
  24. package/core/field_input.d.ts +16 -1
  25. package/core/field_label.d.ts +0 -9
  26. package/core/field_number.d.ts +0 -9
  27. package/core/field_textinput.d.ts +0 -9
  28. package/core/field_variable.d.ts +0 -2
  29. package/core/flyout_base.d.ts +3 -1
  30. package/core/flyout_button.d.ts +3 -24
  31. package/core/flyout_item.d.ts +3 -3
  32. package/core/flyout_navigator.d.ts +11 -0
  33. package/core/flyout_separator.d.ts +13 -11
  34. package/core/focus_manager.d.ts +9 -5
  35. package/core/icons/comment_icon.d.ts +3 -0
  36. package/core/icons/icon.d.ts +13 -0
  37. package/core/icons/mutator_icon.d.ts +3 -0
  38. package/core/icons/warning_icon.d.ts +3 -0
  39. package/core/interfaces/i_bubble.d.ts +2 -1
  40. package/core/interfaces/i_focusable_node.d.ts +39 -5
  41. package/core/interfaces/i_has_bubble.d.ts +13 -0
  42. package/core/interfaces/i_icon.d.ts +2 -1
  43. package/core/interfaces/i_navigation_policy.d.ts +26 -5
  44. package/core/interfaces/i_selectable.d.ts +7 -1
  45. package/core/keyboard_nav/block_navigation_policy.d.ts +17 -14
  46. package/core/keyboard_nav/connection_navigation_policy.d.ts +20 -6
  47. package/core/keyboard_nav/field_navigation_policy.d.ts +20 -6
  48. package/core/keyboard_nav/flyout_button_navigation_policy.d.ts +20 -6
  49. package/core/keyboard_nav/flyout_navigation_policy.d.ts +19 -5
  50. package/core/keyboard_nav/flyout_separator_navigation_policy.d.ts +20 -6
  51. package/core/keyboard_nav/line_cursor.d.ts +14 -104
  52. package/core/keyboard_nav/marker.d.ts +7 -10
  53. package/core/keyboard_nav/workspace_navigation_policy.d.ts +20 -6
  54. package/core/layer_manager.d.ts +3 -2
  55. package/core/navigator.d.ts +12 -12
  56. package/core/rendered_connection.d.ts +3 -14
  57. package/core/toolbox/toolbox.d.ts +2 -0
  58. package/core/toolbox/toolbox_item.d.ts +2 -0
  59. package/core/utils/object.d.ts +3 -0
  60. package/core/variable_map.d.ts +7 -2
  61. package/core/widgetdiv.d.ts +6 -1
  62. package/core/workspace.d.ts +1 -2
  63. package/core/workspace_dragger.d.ts +5 -0
  64. package/core/workspace_svg.d.ts +10 -15
  65. package/index.mjs +1 -1
  66. package/package.json +1 -1
  67. package/core/events/events_marker_move.d.ts +0 -69
  68. package/core/interfaces/i_ast_node_location.d.ts +0 -11
  69. package/core/interfaces/i_ast_node_location_svg.d.ts +0 -12
  70. package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -19
  71. package/core/interfaces/i_navigable.d.ts +0 -30
  72. package/core/keyboard_nav/ast_node.d.ts +0 -185
package/core/block.d.ts CHANGED
@@ -18,7 +18,6 @@ import type { Field } from './field.js';
18
18
  import { IconType } from './icons/icon_types.js';
19
19
  import type { MutatorIcon } from './icons/mutator_icon.js';
20
20
  import { Input } from './inputs/input.js';
21
- import type { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
22
21
  import { type IIcon } from './interfaces/i_icon.js';
23
22
  import type { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
24
23
  import * as Tooltip from './tooltip.js';
@@ -29,7 +28,7 @@ import type { Workspace } from './workspace.js';
29
28
  * Class for one block.
30
29
  * Not normally called directly, workspace.newBlock() is preferred.
31
30
  */
32
- export declare class Block implements IASTNodeLocation {
31
+ export declare class Block {
33
32
  /**
34
33
  * An optional callback method to use whenever the block's parent workspace
35
34
  * changes. This is usually only called from the constructor, the block type
@@ -647,20 +646,6 @@ export declare class Block implements IASTNodeLocation {
647
646
  * @returns True if enabled.
648
647
  */
649
648
  isEnabled(): boolean;
650
- /** @deprecated v11 - Get or sets whether the block is manually disabled. */
651
- private get disabled();
652
- private set disabled(value);
653
- /**
654
- * @deprecated v11 - Set whether the block is manually enabled or disabled.
655
- * The user can toggle whether a block is disabled from a context menu
656
- * option. A block may still be disabled for other reasons even if the user
657
- * attempts to manually enable it, such as when the block is in an invalid
658
- * location. This method is deprecated and setDisabledReason should be used
659
- * instead.
660
- *
661
- * @param enabled True if enabled.
662
- */
663
- setEnabled(enabled: boolean): void;
664
649
  /**
665
650
  * Add or remove a reason why the block might be disabled. If a block has
666
651
  * any reasons to be disabled, then the block itself will be considered
@@ -17,7 +17,6 @@ import { ContextMenuOption, LegacyContextMenuOption } from './contextmenu_regist
17
17
  import { IconType } from './icons/icon_types.js';
18
18
  import { MutatorIcon } from './icons/mutator_icon.js';
19
19
  import type { Input } from './inputs/input.js';
20
- import type { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
21
20
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
22
21
  import { IContextMenu } from './interfaces/i_contextmenu.js';
23
22
  import type { ICopyable } from './interfaces/i_copyable.js';
@@ -26,7 +25,6 @@ import type { IDragStrategy, IDraggable } from './interfaces/i_draggable.js';
26
25
  import type { IFocusableNode } from './interfaces/i_focusable_node.js';
27
26
  import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
28
27
  import { IIcon } from './interfaces/i_icon.js';
29
- import type { INavigable } from './interfaces/i_navigable.js';
30
28
  import { RenderedConnection } from './rendered_connection.js';
31
29
  import type { IPathObject } from './renderers/common/i_path_object.js';
32
30
  import type { BlockStyle } from './theme.js';
@@ -39,7 +37,7 @@ import type { WorkspaceSvg } from './workspace_svg.js';
39
37
  * Class for a block's SVG representation.
40
38
  * Not normally called directly, workspace.newBlock() is preferred.
41
39
  */
42
- export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBoundedElement, IContextMenu, ICopyable<BlockCopyData>, IDraggable, IDeletable, IFocusableNode, INavigable<BlockSvg> {
40
+ export declare class BlockSvg extends Block implements IBoundedElement, IContextMenu, ICopyable<BlockCopyData>, IDraggable, IDeletable, IFocusableNode {
43
41
  /**
44
42
  * Constant for identifying rows that are to be rendered inline.
45
43
  * Don't collide with Blockly.inputTypes.
@@ -400,19 +398,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
400
398
  */
401
399
  private createIconPointerDownListener;
402
400
  removeIcon(type: IconType<IIcon>): boolean;
403
- /**
404
- * Set whether the block is manually enabled or disabled.
405
- *
406
- * The user can toggle whether a block is disabled from a context menu
407
- * option. A block may still be disabled for other reasons even if the user
408
- * attempts to manually enable it, such as when the block is in an invalid
409
- * location. This method is deprecated and setDisabledReason should be used
410
- * instead.
411
- *
412
- * @deprecated v11: use setDisabledReason.
413
- * @param enabled True if enabled.
414
- */
415
- setEnabled(enabled: boolean): void;
416
401
  /**
417
402
  * Add or remove a reason why the block might be disabled. If a block has
418
403
  * any reasons to be disabled, then the block itself will be considered
@@ -737,20 +722,7 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
737
722
  onNodeFocus(): void;
738
723
  /** See IFocusableNode.onNodeBlur. */
739
724
  onNodeBlur(): void;
740
- /**
741
- * Returns whether or not this block can be navigated to via the keyboard.
742
- *
743
- * @returns True if this block is keyboard navigable, otherwise false.
744
- */
745
- isNavigable(): boolean;
746
- /**
747
- * Returns this block's class.
748
- *
749
- * Used by keyboard navigation to look up the rules for navigating from this
750
- * block.
751
- *
752
- * @returns This block's class.
753
- */
754
- getClass(): typeof BlockSvg;
725
+ /** See IFocusableNode.canBeFocused. */
726
+ canBeFocused(): boolean;
755
727
  }
756
728
  //# sourceMappingURL=block_svg.d.ts.map
package/core/blockly.d.ts CHANGED
@@ -68,9 +68,6 @@ import { SeparatorFlyoutInflater } from './separator_flyout_inflater.js';
68
68
  import { FocusableTreeTraverser } from './utils/focusable_tree_traverser.js';
69
69
  import { Input } from './inputs/input.js';
70
70
  import { InsertionMarkerPreviewer } from './insertion_marker_previewer.js';
71
- import { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
72
- import { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
73
- import { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
74
71
  import { IAutoHideable } from './interfaces/i_autohideable.js';
75
72
  import { IBoundedElement } from './interfaces/i_bounded_element.js';
76
73
  import { IBubble } from './interfaces/i_bubble.js';
@@ -107,8 +104,7 @@ import { IToolboxItem } from './interfaces/i_toolbox_item.js';
107
104
  import { IVariableBackedParameterModel, isVariableBackedParameterModel } from './interfaces/i_variable_backed_parameter_model.js';
108
105
  import { IVariableMap } from './interfaces/i_variable_map.js';
109
106
  import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
110
- import { ASTNode } from './keyboard_nav/ast_node.js';
111
- import { CursorOptions, LineCursor } from './keyboard_nav/line_cursor.js';
107
+ import { LineCursor } from './keyboard_nav/line_cursor.js';
112
108
  import { Marker } from './keyboard_nav/marker.js';
113
109
  import type { LayerManager } from './layer_manager.js';
114
110
  import * as layers from './layers.js';
@@ -272,7 +268,7 @@ export declare const VARIABLE_DYNAMIC_CATEGORY_NAME: string;
272
268
  * procedure blocks.
273
269
  */
274
270
  export declare const PROCEDURE_CATEGORY_NAME: string;
275
- export * from './interfaces/i_navigable.js';
271
+ export * from './flyout_navigator.js';
276
272
  export * from './interfaces/i_navigation_policy.js';
277
273
  export * from './keyboard_nav/block_navigation_policy.js';
278
274
  export * from './keyboard_nav/connection_navigation_policy.js';
@@ -283,7 +279,7 @@ export * from './keyboard_nav/flyout_separator_navigation_policy.js';
283
279
  export * from './keyboard_nav/workspace_navigation_policy.js';
284
280
  export * from './navigator.js';
285
281
  export * from './toast.js';
286
- 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, };
282
+ 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, };
287
283
  export declare const DropDownDiv: typeof dropDownDiv;
288
- 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, 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, };
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, };
289
285
  //# sourceMappingURL=blockly.d.ts.map
@@ -3,8 +3,9 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { ISelectable } from '../blockly.js';
7
6
  import { IBubble } from '../interfaces/i_bubble.js';
7
+ import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
8
+ import { ISelectable } from '../interfaces/i_selectable.js';
8
9
  import { Coordinate } from '../utils/coordinate.js';
9
10
  import { Rect } from '../utils/rect.js';
10
11
  import { Size } from '../utils/size.js';
@@ -60,14 +61,19 @@ export declare abstract class Bubble implements IBubble, ISelectable {
60
61
  /** The position of the left of the bubble realtive to its anchor. */
61
62
  private relativeLeft;
62
63
  private dragStrategy;
64
+ private focusableElement;
63
65
  /**
64
66
  * @param workspace The workspace this bubble belongs to.
65
67
  * @param anchor The anchor location of the thing this bubble is attached to.
66
68
  * The tail of the bubble will point to this location.
67
69
  * @param ownerRect An optional rect we don't want the bubble to overlap with
68
70
  * when automatically positioning.
71
+ * @param overriddenFocusableElement An optional replacement to the focusable
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.
69
75
  */
70
- constructor(workspace: WorkspaceSvg, anchor: Coordinate, ownerRect?: Rect | undefined);
76
+ constructor(workspace: WorkspaceSvg, anchor: Coordinate, ownerRect?: Rect | undefined, overriddenFocusableElement?: SVGElement | HTMLElement);
71
77
  /** Dispose of this bubble. */
72
78
  dispose(): void;
73
79
  /**
@@ -96,7 +102,10 @@ export declare abstract class Bubble implements IBubble, ISelectable {
96
102
  protected getColour(): string;
97
103
  /** Sets the colour of the background and tail of this bubble. */
98
104
  setColour(colour: string): void;
99
- /** Brings the bubble to the front and passes the pointer event off to the gesture system. */
105
+ /**
106
+ * Passes the pointer event off to the gesture system and ensures the bubble
107
+ * is focused.
108
+ */
100
109
  private onMouseDown;
101
110
  /** Positions the bubble relative to its anchor. Does not render its tail. */
102
111
  protected positionRelativeToAnchor(): void;
@@ -190,5 +199,15 @@ export declare abstract class Bubble implements IBubble, ISelectable {
190
199
  revertDrag(): void;
191
200
  select(): void;
192
201
  unselect(): void;
202
+ /** See IFocusableNode.getFocusableElement. */
203
+ getFocusableElement(): HTMLElement | SVGElement;
204
+ /** See IFocusableNode.getFocusableTree. */
205
+ getFocusableTree(): IFocusableTree;
206
+ /** See IFocusableNode.onNodeFocus. */
207
+ onNodeFocus(): void;
208
+ /** See IFocusableNode.onNodeBlur. */
209
+ onNodeBlur(): void;
210
+ /** See IFocusableNode.canBeFocused. */
211
+ canBeFocused(): boolean;
193
212
  }
194
213
  //# sourceMappingURL=bubble.d.ts.map
@@ -67,7 +67,9 @@ export declare class TextInputBubble extends Bubble {
67
67
  addSizeChangeListener(listener: () => void): void;
68
68
  /** Adds a change listener to be notified when this bubble's location changes. */
69
69
  addLocationChangeListener(listener: () => void): void;
70
- /** Creates the editor UI for this bubble. */
70
+ /** Creates and returns the editable text area for this bubble's editor. */
71
+ private static createTextArea;
72
+ /** Creates and returns the UI container element for this bubble's editor. */
71
73
  private createEditor;
72
74
  /** Binds events to the text area element. */
73
75
  private bindTextAreaEvents;
@@ -93,10 +95,6 @@ export declare class TextInputBubble extends Bubble {
93
95
  private onResizePointerUp;
94
96
  /** Handles pointer move events on the resize target. */
95
97
  private onResizePointerMove;
96
- /**
97
- * Handles starting an edit of the text area. Brings the bubble to the front.
98
- */
99
- private onStartEdit;
100
98
  /** Handles a text change event for the text area. Calls event listeners. */
101
99
  private onTextChange;
102
100
  /** Handles a size change event for the text area. Calls event listeners. */
@@ -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 type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
12
13
  import { IRenderedElement } from '../interfaces/i_rendered_element.js';
13
14
  import { ISelectable } from '../interfaces/i_selectable.js';
14
15
  import { Coordinate } from '../utils/coordinate.js';
@@ -98,5 +99,15 @@ export declare class RenderedWorkspaceComment extends WorkspaceComment implement
98
99
  showContextMenu(e: Event): void;
99
100
  /** Snap this comment to the nearest grid point. */
100
101
  snapToGrid(): void;
102
+ /** See IFocusableNode.getFocusableElement. */
103
+ getFocusableElement(): HTMLElement | SVGElement;
104
+ /** See IFocusableNode.getFocusableTree. */
105
+ getFocusableTree(): IFocusableTree;
106
+ /** See IFocusableNode.onNodeFocus. */
107
+ onNodeFocus(): void;
108
+ /** See IFocusableNode.onNodeBlur. */
109
+ onNodeBlur(): void;
110
+ /** See IFocusableNode.canBeFocused. */
111
+ canBeFocused(): boolean;
101
112
  }
102
113
  //# sourceMappingURL=rendered_workspace_comment.d.ts.map
package/core/common.d.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { Block } from './block.js';
7
- import { ISelectable } from './blockly.js';
8
7
  import { BlockDefinition } from './blocks.js';
9
8
  import type { Connection } from './connection.js';
9
+ import { ISelectable } from './interfaces/i_selectable.js';
10
10
  import type { Workspace } from './workspace.js';
11
11
  import type { WorkspaceSvg } from './workspace_svg.js';
12
12
  /**
@@ -49,18 +49,30 @@ export declare function getMainWorkspace(): Workspace;
49
49
  */
50
50
  export declare function setMainWorkspace(workspace: Workspace): void;
51
51
  /**
52
- * Returns the currently selected copyable object.
52
+ * Returns the current selection.
53
53
  */
54
54
  export declare function getSelected(): ISelectable | null;
55
55
  /**
56
- * Sets the currently selected block. This function does not visually mark the
57
- * block as selected or fire the required events. If you wish to
58
- * programmatically select a block, use `BlockSvg#select`.
56
+ * Sets the current selection.
59
57
  *
60
- * @param newSelection The newly selected block.
58
+ * To clear the current selection, select another ISelectable or focus a
59
+ * non-selectable (like the workspace root node).
60
+ *
61
+ * @param newSelection The new selection to make.
62
+ * @internal
63
+ */
64
+ export declare function setSelected(newSelection: ISelectable): void;
65
+ /**
66
+ * Fires a selection change event based on the new selection.
67
+ *
68
+ * This is only expected to be called by ISelectable implementations and should
69
+ * always be called before updating the current selection state. It does not
70
+ * change focus or selection state.
71
+ *
72
+ * @param newSelection The new selection.
61
73
  * @internal
62
74
  */
63
- export declare function setSelected(newSelection: ISelectable | null): void;
75
+ export declare function fireSelectedEvent(newSelection: ISelectable | null): void;
64
76
  /**
65
77
  * Get the container element in which to render the WidgetDiv, DropDownDiv and
66
78
  * Tooltip.
@@ -10,13 +10,12 @@
10
10
  */
11
11
  import type { Block } from './block.js';
12
12
  import type { Input } from './inputs/input.js';
13
- import type { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
14
13
  import type { IConnectionChecker } from './interfaces/i_connection_checker.js';
15
14
  import * as blocks from './serialization/blocks.js';
16
15
  /**
17
16
  * Class for a connection between blocks.
18
17
  */
19
- export declare class Connection implements IASTNodeLocationWithBlock {
18
+ export declare class Connection {
20
19
  type: number;
21
20
  /** Constants for checking whether two connections are compatible. */
22
21
  static CAN_CONNECT: number;
@@ -77,7 +77,7 @@ export declare namespace ContextMenuRegistry {
77
77
  block?: BlockSvg;
78
78
  workspace?: WorkspaceSvg;
79
79
  comment?: RenderedWorkspaceComment;
80
- focusedNode?: IFocusableNode | any;
80
+ focusedNode?: IFocusableNode;
81
81
  }
82
82
  /**
83
83
  * Fields common to all context menu registry items.
@@ -126,10 +126,12 @@ export declare function showPositionedByField<T>(field: Field<T>, opt_onHide?: (
126
126
  * @param secondaryX Secondary/alternative origin point x, in absolute px.
127
127
  * @param secondaryY Secondary/alternative origin point y, in absolute px.
128
128
  * @param opt_onHide Optional callback for when the drop-down is hidden.
129
+ * @param manageEphemeralFocus Whether ephemeral focus should be managed
130
+ * according to the widget div's lifetime.
129
131
  * @returns True if the menu rendered at the primary origin point.
130
132
  * @internal
131
133
  */
132
- export declare function show<T>(newOwner: Field<T>, rtl: boolean, primaryX: number, primaryY: number, secondaryX: number, secondaryY: number, opt_onHide?: () => void): boolean;
134
+ export declare function show<T>(newOwner: Field<T>, rtl: boolean, primaryX: number, primaryY: number, secondaryX: number, secondaryY: number, manageEphemeralFocus: boolean, opt_onHide?: () => void): boolean;
133
135
  /**
134
136
  * Get the x positions for the left side of the DropDownDiv and the arrow,
135
137
  * accounting for the bounds of the workspace.
@@ -22,7 +22,6 @@ export { CommentDelete } from './events_comment_delete.js';
22
22
  export { CommentDrag, CommentDragJson } from './events_comment_drag.js';
23
23
  export { CommentMove, CommentMoveJson } from './events_comment_move.js';
24
24
  export { CommentResize, CommentResizeJson } from './events_comment_resize.js';
25
- export { MarkerMove, MarkerMoveJson } from './events_marker_move.js';
26
25
  export { Selected, SelectedJson } from './events_selected.js';
27
26
  export { ThemeChange, ThemeChangeJson } from './events_theme_change.js';
28
27
  export { ToolboxItemSelect, ToolboxItemSelectJson, } from './events_toolbox_item_select.js';
@@ -57,7 +56,6 @@ export declare const CREATE = EventType.BLOCK_CREATE;
57
56
  /** @deprecated Use BLOCK_DELETE instead */
58
57
  export declare const DELETE = EventType.BLOCK_DELETE;
59
58
  export declare const FINISHED_LOADING = EventType.FINISHED_LOADING;
60
- export declare const MARKER_MOVE = EventType.MARKER_MOVE;
61
59
  /** @deprecated Use BLOCK_MOVE instead */
62
60
  export declare const MOVE = EventType.BLOCK_MOVE;
63
61
  export declare const SELECTED = EventType.SELECTED;
@@ -27,7 +27,6 @@ import type { CommentDelete } from './events_comment_delete.js';
27
27
  import type { CommentDrag } from './events_comment_drag.js';
28
28
  import type { CommentMove } from './events_comment_move.js';
29
29
  import type { CommentResize } from './events_comment_resize.js';
30
- import type { MarkerMove } from './events_marker_move.js';
31
30
  import type { Selected } from './events_selected.js';
32
31
  import type { ThemeChange } from './events_theme_change.js';
33
32
  import type { ToolboxItemSelect } from './events_toolbox_item_select.js';
@@ -59,8 +58,6 @@ export declare function isBlockDrag(event: Abstract): event is BlockDrag;
59
58
  export declare function isSelected(event: Abstract): event is Selected;
60
59
  /** @returns true iff event.type is EventType.CLICK */
61
60
  export declare function isClick(event: Abstract): event is Click;
62
- /** @returns true iff event.type is EventType.MARKER_MOVE */
63
- export declare function isMarkerMove(event: Abstract): event is MarkerMove;
64
61
  /** @returns true iff event.type is EventType.BUBBLE_OPEN */
65
62
  export declare function isBubbleOpen(event: Abstract): event is BubbleOpen;
66
63
  /** @returns true iff event.type is EventType.TRASHCAN_OPEN */
@@ -129,13 +129,9 @@ declare function enqueueEvent(event: Abstract): void;
129
129
  * cause them to be reordered.
130
130
  *
131
131
  * @param queue Array of events.
132
- * @param forward True if forward (redo), false if backward (undo).
133
- * This parameter is deprecated: true is now the default and
134
- * calling filter with it set to false will in future not be
135
- * supported.
136
132
  * @returns Array of filtered events.
137
133
  */
138
- export declare function filter(queue: Abstract[], forward?: boolean): Abstract[];
134
+ export declare function filter(queue: Abstract[]): Abstract[];
139
135
  /**
140
136
  * Modify pending undo events so that when they are fired they don't land
141
137
  * in the undo stack. Called by Workspace.clearUndo.
package/core/field.d.ts CHANGED
@@ -13,12 +13,9 @@
13
13
  import './events/events_block_change.js';
14
14
  import type { Block } from './block.js';
15
15
  import type { Input } from './inputs/input.js';
16
- import type { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
17
- import type { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
18
16
  import type { IFocusableNode } from './interfaces/i_focusable_node.js';
19
17
  import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
20
18
  import type { IKeyboardAccessible } from './interfaces/i_keyboard_accessible.js';
21
- import type { INavigable } from './interfaces/i_navigable.js';
22
19
  import type { IRegistrable } from './interfaces/i_registrable.js';
23
20
  import { ISerializable } from './interfaces/i_serializable.js';
24
21
  import type { ConstantProvider } from './renderers/common/constants.js';
@@ -48,7 +45,7 @@ export type FieldValidator<T = any> = (newValue: T) => T | null | undefined;
48
45
  *
49
46
  * @typeParam T - The value stored on the field.
50
47
  */
51
- export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IASTNodeLocationWithBlock, IKeyboardAccessible, IRegistrable, ISerializable, IFocusableNode, INavigable<Field<T>> {
48
+ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRegistrable, ISerializable, IFocusableNode {
52
49
  /**
53
50
  * To overwrite the default value which is set in **Field**, directly update
54
51
  * the prototype.
@@ -57,6 +54,8 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
57
54
  * `FieldImage.prototype.DEFAULT_VALUE = null;`
58
55
  */
59
56
  DEFAULT_VALUE: T | null;
57
+ /** Non-breaking space. */
58
+ static readonly NBSP = "\u00A0";
60
59
  /**
61
60
  * A value used to signal when a field's constructor should *not* set the
62
61
  * field's value or run configure_, and should allow a subclass to do that
@@ -76,7 +75,21 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
76
75
  * field is not yet initialized. Is *not* guaranteed to be accurate.
77
76
  */
78
77
  private tooltip;
79
- protected size_: Size;
78
+ /** This field's dimensions. */
79
+ private size;
80
+ /**
81
+ * Gets the size of this field. Because getSize() and updateSize() have side
82
+ * effects, this acts as a shim for subclasses which wish to adjust field
83
+ * bounds when setting/getting the size without triggering unwanted rendering
84
+ * or other side effects. Note that subclasses must override *both* get and
85
+ * set if either is overridden; the implementation may just call directly
86
+ * through to super, but it must exist per the JS spec.
87
+ */
88
+ protected get size_(): Size;
89
+ /**
90
+ * Sets the size of this field.
91
+ */
92
+ protected set size_(newValue: Size);
80
93
  /** The rendered field's SVG group element. */
81
94
  protected fieldGroup_: SVGGElement | null;
82
95
  /** The rendered field's SVG border element. */
@@ -672,6 +685,8 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
672
685
  onNodeFocus(): void;
673
686
  /** See IFocusableNode.onNodeBlur. */
674
687
  onNodeBlur(): void;
688
+ /** See IFocusableNode.canBeFocused. */
689
+ canBeFocused(): boolean;
675
690
  /**
676
691
  * Subclasses should reimplement this method to construct their Field
677
692
  * subclass from a JSON arg object.
@@ -683,21 +698,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
683
698
  * to configure a specific field.
684
699
  */
685
700
  static fromJson(_options: FieldConfig): Field;
686
- /**
687
- * Returns whether or not this field is accessible by keyboard navigation.
688
- *
689
- * @returns True if this field is keyboard accessible, otherwise false.
690
- */
691
- isNavigable(): boolean;
692
- /**
693
- * Returns this field's class.
694
- *
695
- * Used by keyboard navigation to look up the rules for navigating from this
696
- * field. Must be implemented by subclasses.
697
- *
698
- * @returns This field's class.
699
- */
700
- abstract getClass(): new (...args: any) => Field<T>;
701
701
  }
702
702
  /**
703
703
  * Extra configuration options for the base field.
@@ -123,15 +123,6 @@ export declare class FieldCheckbox extends Field<CheckboxBool> {
123
123
  * @internal
124
124
  */
125
125
  static fromJson(options: FieldCheckboxFromJsonConfig): FieldCheckbox;
126
- /**
127
- * Returns this field's class.
128
- *
129
- * Used by keyboard navigation to look up the rules for navigating from this
130
- * field.
131
- *
132
- * @returns This field's class.
133
- */
134
- getClass(): typeof FieldCheckbox;
135
126
  }
136
127
  /**
137
128
  * Config options for the checkbox field.
@@ -191,7 +191,13 @@ export declare class FieldDropdown extends Field<string> {
191
191
  /**
192
192
  * Use the `getText_` developer hook to override the field's text
193
193
  * representation. Get the selected option text. If the selected option is
194
- * an image we return the image alt text.
194
+ * an image we return the image alt text. If the selected option is
195
+ * an HTMLElement, return the title, ariaLabel, or innerText of the
196
+ * element.
197
+ *
198
+ * If you use HTMLElement options in Node.js and call this function,
199
+ * ensure that you are supplying an implementation of HTMLElement,
200
+ * such as through jsdom-global.
195
201
  *
196
202
  * @returns Selected option text.
197
203
  */
@@ -232,15 +238,6 @@ export declare class FieldDropdown extends Field<string> {
232
238
  * @throws {TypeError} If proposed options are incorrectly structured.
233
239
  */
234
240
  protected validateOptions(options: MenuOption[]): void;
235
- /**
236
- * Returns this field's class.
237
- *
238
- * Used by keyboard navigation to look up the rules for navigating from this
239
- * field.
240
- *
241
- * @returns This field's class.
242
- */
243
- getClass(): typeof FieldDropdown;
244
241
  }
245
242
  /**
246
243
  * Definition of a human-readable image dropdown option.
@@ -9,7 +9,6 @@
9
9
  * @class
10
10
  */
11
11
  import { Field, FieldConfig } from './field.js';
12
- import { Size } from './utils/size.js';
13
12
  /**
14
13
  * Class for an image on a block.
15
14
  */
@@ -19,7 +18,6 @@ export declare class FieldImage extends Field<string> {
19
18
  * of the field.
20
19
  */
21
20
  private static readonly Y_PADDING;
22
- protected size_: Size;
23
21
  protected readonly imageHeight: number;
24
22
  /** The function to be called when this field is clicked. */
25
23
  private clickHandler;
@@ -125,15 +123,6 @@ export declare class FieldImage extends Field<string> {
125
123
  * @internal
126
124
  */
127
125
  static fromJson(options: FieldImageFromJsonConfig): FieldImage;
128
- /**
129
- * Returns this field's class.
130
- *
131
- * Used by keyboard navigation to look up the rules for navigating from this
132
- * field.
133
- *
134
- * @returns This field's class.
135
- */
136
- getClass(): typeof FieldImage;
137
126
  }
138
127
  /**
139
128
  * Config options for the image field.
@@ -62,6 +62,15 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
62
62
  * are not. Editable fields should also be serializable.
63
63
  */
64
64
  SERIALIZABLE: boolean;
65
+ /**
66
+ * Sets the size of this field. Although this appears to be a no-op, it must
67
+ * exist since the getter is overridden below.
68
+ */
69
+ protected set size_(newValue: Size);
70
+ /**
71
+ * Returns the size of this field, with a minimum width of 14.
72
+ */
73
+ protected get size_(): Size;
65
74
  /**
66
75
  * @param value The initial value of the field. Should cast to a string.
67
76
  * Defaults to an empty string if null or undefined. Also accepts
@@ -141,8 +150,12 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
141
150
  * undefined if triggered programmatically.
142
151
  * @param quietInput True if editor should be created without focus.
143
152
  * Defaults to false.
153
+ * @param manageEphemeralFocus Whether ephemeral focus should be managed as
154
+ * part of the editor's inline editor (when the inline editor is shown).
155
+ * Callers must manage ephemeral focus themselves if this is false.
156
+ * Defaults to true.
144
157
  */
145
- protected showEditor_(_e?: Event, quietInput?: boolean): void;
158
+ protected showEditor_(_e?: Event, quietInput?: boolean, manageEphemeralFocus?: boolean): void;
146
159
  /**
147
160
  * Create and show a text input editor that is a prompt (usually a popup).
148
161
  * Mobile browsers may have issues with in-line textareas (focus and
@@ -153,6 +166,8 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
153
166
  * Create and show a text input editor that sits directly over the text input.
154
167
  *
155
168
  * @param quietInput True if editor should be created without focus.
169
+ * @param manageEphemeralFocus Whether ephemeral focus should be managed as
170
+ * part of the field's inline editor (widget div).
156
171
  */
157
172
  private showInlineEditor;
158
173
  /**
@@ -64,15 +64,6 @@ export declare class FieldLabel extends Field<string> {
64
64
  * @internal
65
65
  */
66
66
  static fromJson(options: FieldLabelFromJsonConfig): FieldLabel;
67
- /**
68
- * Returns this field's class.
69
- *
70
- * Used by keyboard navigation to look up the rules for navigating from this
71
- * field.
72
- *
73
- * @returns This field's class.
74
- */
75
- getClass(): typeof FieldLabel;
76
67
  }
77
68
  /**
78
69
  * Config options for the label field.
@@ -160,15 +160,6 @@ export declare class FieldNumber extends FieldInput<number> {
160
160
  * @internal
161
161
  */
162
162
  static fromJson(options: FieldNumberFromJsonConfig): FieldNumber;
163
- /**
164
- * Returns this field's class.
165
- *
166
- * Used by keyboard navigation to look up the rules for navigating from this
167
- * field.
168
- *
169
- * @returns This field's class.
170
- */
171
- getClass(): typeof FieldNumber;
172
163
  }
173
164
  /**
174
165
  * Config options for the number field.