blockly 12.0.0 → 12.0.1-beta.1

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.
@@ -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;
@@ -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.
@@ -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.
@@ -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
@@ -29,7 +29,7 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
29
29
  * Returns the next peer node of the given block.
30
30
  *
31
31
  * @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
32
+ * @returns The first node of the next input/stack if the given block is a terminal
33
33
  * block, or its next connection.
34
34
  */
35
35
  getNextSibling(current: BlockSvg): IFocusableNode | null;
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly",
3
- "version": "12.0.0",
3
+ "version": "12.0.1-beta.1",
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",