blockly 12.2.0-beta.0 → 12.3.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.
Files changed (42) hide show
  1. package/blockly.min.js +933 -904
  2. package/blockly_compressed.js +839 -809
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +57 -58
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +1 -1
  7. package/core/block_svg.d.ts +4 -1
  8. package/core/bubbles/bubble.d.ts +17 -2
  9. package/core/bubbles/textinput_bubble.d.ts +14 -17
  10. package/core/clipboard.d.ts +76 -15
  11. package/core/comments/collapse_comment_bar_button.d.ts +52 -0
  12. package/core/comments/comment_bar_button.d.ts +62 -0
  13. package/core/comments/comment_view.d.ts +13 -25
  14. package/core/comments/delete_comment_bar_button.d.ts +52 -0
  15. package/core/comments.d.ts +3 -0
  16. package/core/field_input.d.ts +3 -3
  17. package/core/icons/comment_icon.d.ts +3 -3
  18. package/core/insertion_marker_previewer.d.ts +11 -0
  19. package/core/interfaces/i_variable_map.d.ts +1 -1
  20. package/core/keyboard_nav/block_comment_navigation_policy.d.ts +56 -0
  21. package/core/keyboard_nav/block_navigation_policy.d.ts +7 -6
  22. package/core/keyboard_nav/comment_bar_button_navigation_policy.d.ts +56 -0
  23. package/core/keyboard_nav/comment_editor_navigation_policy.d.ts +34 -0
  24. package/core/keyboard_nav/line_cursor.d.ts +8 -8
  25. package/core/keyboard_nav/workspace_comment_navigation_policy.d.ts +56 -0
  26. package/core/marker_manager.d.ts +2 -2
  27. package/core/registry.d.ts +1 -1
  28. package/core/utils/focusable_tree_traverser.d.ts +2 -2
  29. package/core/utils/rect.d.ts +9 -0
  30. package/core/workspace.d.ts +10 -0
  31. package/core/workspace_svg.d.ts +19 -4
  32. package/dart_compressed.js +38 -38
  33. package/dart_compressed.js.map +1 -1
  34. package/javascript_compressed.js +37 -37
  35. package/javascript_compressed.js.map +1 -1
  36. package/lua_compressed.js +30 -30
  37. package/lua_compressed.js.map +1 -1
  38. package/package.json +8 -7
  39. package/php_compressed.js +39 -39
  40. package/php_compressed.js.map +1 -1
  41. package/python_compressed.js +32 -32
  42. package/python_compressed.js.map +1 -1
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { TextInputBubble } from '../bubbles/textinput_bubble.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 TextInputBubble.
11
+ */
12
+ export declare class BlockCommentNavigationPolicy implements INavigationPolicy<TextInputBubble> {
13
+ /**
14
+ * Returns the first child of the given block comment.
15
+ *
16
+ * @param current The block comment to return the first child of.
17
+ * @returns The text editor of the given block comment bubble.
18
+ */
19
+ getFirstChild(current: TextInputBubble): IFocusableNode | null;
20
+ /**
21
+ * Returns the parent of the given block comment.
22
+ *
23
+ * @param current The block comment to return the parent of.
24
+ * @returns The parent block of the given block comment.
25
+ */
26
+ getParent(current: TextInputBubble): IFocusableNode | null;
27
+ /**
28
+ * Returns the next peer node of the given block comment.
29
+ *
30
+ * @param _current The block comment to find the following element of.
31
+ * @returns Null.
32
+ */
33
+ getNextSibling(_current: TextInputBubble): IFocusableNode | null;
34
+ /**
35
+ * Returns the previous peer node of the given block comment.
36
+ *
37
+ * @param _current The block comment to find the preceding element of.
38
+ * @returns Null.
39
+ */
40
+ getPreviousSibling(_current: TextInputBubble): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given block comment can be navigated to.
43
+ *
44
+ * @param current The instance to check for navigability.
45
+ * @returns True if the given block comment can be focused.
46
+ */
47
+ isNavigable(current: TextInputBubble): 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 TextInputBubble.
53
+ */
54
+ isApplicable(current: any): current is TextInputBubble;
55
+ }
56
+ //# sourceMappingURL=block_comment_navigation_policy.d.ts.map
@@ -8,6 +8,7 @@ import type { Field } from '../field.js';
8
8
  import type { Icon } from '../icons/icon.js';
9
9
  import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
10
10
  import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
11
+ import type { ISelectable } from '../interfaces/i_selectable.js';
11
12
  import { RenderedConnection } from '../rendered_connection.js';
12
13
  /**
13
14
  * Set of rules controlling keyboard navigation from a block.
@@ -60,17 +61,17 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
60
61
  isApplicable(current: any): current is BlockSvg;
61
62
  }
62
63
  /**
63
- * Returns the next/previous stack relative to the given block's stack.
64
+ * Returns the next/previous stack relative to the given element's stack.
64
65
  *
65
- * @param current The block whose stack will be navigated relative to.
66
+ * @param current The element whose stack will be navigated relative to.
66
67
  * @param delta The difference in index to navigate; positive values navigate
67
68
  * to the nth next stack, while negative values navigate to the nth previous
68
69
  * 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.
70
+ * @returns The first element in the stack offset by `delta` relative to the
71
+ * current element's stack, or the last element in the stack offset by
72
+ * `delta` relative to the current element's stack when navigating backwards.
72
73
  */
73
- export declare function navigateStacks(current: BlockSvg, delta: number): BlockSvg | null;
74
+ export declare function navigateStacks(current: ISelectable, delta: number): IFocusableNode | null;
74
75
  /**
75
76
  * Returns the next navigable item relative to the provided block child.
76
77
  *
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { CommentBarButton } from '../comments/comment_bar_button.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 a CommentBarButton.
11
+ */
12
+ export declare class CommentBarButtonNavigationPolicy implements INavigationPolicy<CommentBarButton> {
13
+ /**
14
+ * Returns the first child of the given CommentBarButton.
15
+ *
16
+ * @param _current The CommentBarButton to return the first child of.
17
+ * @returns Null.
18
+ */
19
+ getFirstChild(_current: CommentBarButton): IFocusableNode | null;
20
+ /**
21
+ * Returns the parent of the given CommentBarButton.
22
+ *
23
+ * @param current The CommentBarButton to return the parent of.
24
+ * @returns The parent comment of the given CommentBarButton.
25
+ */
26
+ getParent(current: CommentBarButton): IFocusableNode | null;
27
+ /**
28
+ * Returns the next peer node of the given CommentBarButton.
29
+ *
30
+ * @param current The CommentBarButton to find the following element of.
31
+ * @returns The next CommentBarButton, if any.
32
+ */
33
+ getNextSibling(current: CommentBarButton): IFocusableNode | null;
34
+ /**
35
+ * Returns the previous peer node of the given CommentBarButton.
36
+ *
37
+ * @param current The CommentBarButton to find the preceding element of.
38
+ * @returns The CommentBarButton's previous CommentBarButton, if any.
39
+ */
40
+ getPreviousSibling(current: CommentBarButton): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given CommentBarButton can be navigated to.
43
+ *
44
+ * @param current The instance to check for navigability.
45
+ * @returns True if the given CommentBarButton can be focused.
46
+ */
47
+ isNavigable(current: CommentBarButton): 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 CommentBarButton.
53
+ */
54
+ isApplicable(current: any): current is CommentBarButton;
55
+ }
56
+ //# sourceMappingURL=comment_bar_button_navigation_policy.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { CommentEditor } from '../comments/comment_editor.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 a comment editor.
11
+ * This is a no-op placeholder (other than isNavigable/isApplicable) since
12
+ * comment editors handle their own navigation when editing ends.
13
+ */
14
+ export declare class CommentEditorNavigationPolicy implements INavigationPolicy<CommentEditor> {
15
+ getFirstChild(_current: CommentEditor): IFocusableNode | null;
16
+ getParent(_current: CommentEditor): IFocusableNode | null;
17
+ getNextSibling(_current: CommentEditor): IFocusableNode | null;
18
+ getPreviousSibling(_current: CommentEditor): IFocusableNode | null;
19
+ /**
20
+ * Returns whether or not the given comment editor can be navigated to.
21
+ *
22
+ * @param current The instance to check for navigability.
23
+ * @returns False.
24
+ */
25
+ isNavigable(current: CommentEditor): boolean;
26
+ /**
27
+ * Returns whether the given object can be navigated from by this policy.
28
+ *
29
+ * @param current The object to check if this policy applies to.
30
+ * @returns True if the object is a CommentEditor.
31
+ */
32
+ isApplicable(current: any): current is CommentEditor;
33
+ }
34
+ //# sourceMappingURL=comment_editor_navigation_policy.d.ts.map
@@ -28,11 +28,11 @@ export declare class LineCursor extends Marker {
28
28
  */
29
29
  constructor(workspace: WorkspaceSvg);
30
30
  /**
31
- * Moves the cursor to the next previous connection, next connection or block
32
- * in the pre order traversal. Finds the next node in the pre order traversal.
31
+ * Moves the cursor to the next block or workspace comment in the pre-order
32
+ * traversal.
33
33
  *
34
- * @returns The next node, or null if the current node is
35
- * not set or there is no next value.
34
+ * @returns The next node, or null if the current node is not set or there is
35
+ * no next value.
36
36
  */
37
37
  next(): IFocusableNode | null;
38
38
  /**
@@ -44,11 +44,11 @@ export declare class LineCursor extends Marker {
44
44
  */
45
45
  in(): IFocusableNode | null;
46
46
  /**
47
- * Moves the cursor to the previous next connection or previous connection in
48
- * the pre order traversal.
47
+ * Moves the cursor to the previous block or workspace comment in the
48
+ * pre-order traversal.
49
49
  *
50
- * @returns The previous node, or null if the current node
51
- * is not set or there is no previous value.
50
+ * @returns The previous node, or null if the current node is not set or there
51
+ * is no previous value.
52
52
  */
53
53
  prev(): IFocusableNode | null;
54
54
  /**
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { RenderedWorkspaceComment } from '../comments/rendered_workspace_comment.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 RenderedWorkspaceComment.
11
+ */
12
+ export declare class WorkspaceCommentNavigationPolicy implements INavigationPolicy<RenderedWorkspaceComment> {
13
+ /**
14
+ * Returns the first child of the given workspace comment.
15
+ *
16
+ * @param current The workspace comment to return the first child of.
17
+ * @returns The first child button of the given comment.
18
+ */
19
+ getFirstChild(current: RenderedWorkspaceComment): IFocusableNode | null;
20
+ /**
21
+ * Returns the parent of the given workspace comment.
22
+ *
23
+ * @param current The workspace comment to return the parent of.
24
+ * @returns The parent workspace of the given comment.
25
+ */
26
+ getParent(current: RenderedWorkspaceComment): IFocusableNode | null;
27
+ /**
28
+ * Returns the next peer node of the given workspace comment.
29
+ *
30
+ * @param current The workspace comment to find the following element of.
31
+ * @returns The next workspace comment or block stack, if any.
32
+ */
33
+ getNextSibling(current: RenderedWorkspaceComment): IFocusableNode | null;
34
+ /**
35
+ * Returns the previous peer node of the given workspace comment.
36
+ *
37
+ * @param current The workspace comment to find the preceding element of.
38
+ * @returns The previous workspace comment or block stack, if any.
39
+ */
40
+ getPreviousSibling(current: RenderedWorkspaceComment): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given workspace comment can be navigated to.
43
+ *
44
+ * @param current The instance to check for navigability.
45
+ * @returns True if the given workspace comment can be focused.
46
+ */
47
+ isNavigable(current: RenderedWorkspaceComment): 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 RenderedWorkspaceComment.
53
+ */
54
+ isApplicable(current: any): current is RenderedWorkspaceComment;
55
+ }
56
+ //# sourceMappingURL=workspace_comment_navigation_policy.d.ts.map
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @class
10
10
  */
11
- import type { LineCursor } from './keyboard_nav/line_cursor.js';
11
+ import { LineCursor } from './keyboard_nav/line_cursor.js';
12
12
  import type { Marker } from './keyboard_nav/marker.js';
13
13
  import type { WorkspaceSvg } from './workspace_svg.js';
14
14
  /**
@@ -45,7 +45,7 @@ export declare class MarkerManager {
45
45
  *
46
46
  * @returns The cursor for this workspace.
47
47
  */
48
- getCursor(): LineCursor | null;
48
+ getCursor(): LineCursor;
49
49
  /**
50
50
  * Get a single marker that corresponds to the given ID.
51
51
  *
@@ -73,7 +73,7 @@ export declare class Type<_T> {
73
73
  static ICON: Type<IIcon>;
74
74
  /** @internal */
75
75
  static PASTER: Type<IPaster<ICopyable.ICopyData, ICopyable<ICopyable.ICopyData>>>;
76
- static VARIABLE_MODEL: Type<IVariableModelStatic<IVariableState>>;
76
+ static VARIABLE_MODEL: Type<IVariableModelStatic<IVariableState> & IVariableModel<IVariableState>>;
77
77
  static VARIABLE_MAP: Type<IVariableMap<IVariableModel<IVariableState>>>;
78
78
  }
79
79
  /**
@@ -41,8 +41,8 @@ export declare class FocusableTreeTraverser {
41
41
  * traversed but its nodes will never be returned here per the contract of
42
42
  * IFocusableTree.lookUpFocusableNode.
43
43
  *
44
- * The provided element must have a non-null ID that conforms to the contract
45
- * mentioned in IFocusableNode.
44
+ * The provided element must have a non-null, non-empty ID that conforms to
45
+ * the contract mentioned in IFocusableNode.
46
46
  *
47
47
  * @param element The HTML or SVG element being sought.
48
48
  * @param tree The tree under which the provided element may be a descendant.
@@ -26,6 +26,13 @@ export declare class Rect {
26
26
  * @param right Right.
27
27
  */
28
28
  constructor(top: number, bottom: number, left: number, right: number);
29
+ /**
30
+ * Converts a DOM or SVG Rect to a Blockly Rect.
31
+ *
32
+ * @param rect The rectangle to convert.
33
+ * @returns A representation of the same rectangle as a Blockly Rect.
34
+ */
35
+ static from(rect: DOMRect | SVGRect): Rect;
29
36
  /**
30
37
  * Creates a new copy of this rectangle.
31
38
  *
@@ -36,6 +43,8 @@ export declare class Rect {
36
43
  getHeight(): number;
37
44
  /** Returns the width of this rectangle. */
38
45
  getWidth(): number;
46
+ /** Returns the top left coordinate of this rectangle. */
47
+ getOrigin(): Coordinate;
39
48
  /**
40
49
  * Tests whether this rectangle contains a x/y coordinate.
41
50
  *
@@ -13,6 +13,7 @@ import type { Block } from './block.js';
13
13
  import { WorkspaceComment } from './comments/workspace_comment.js';
14
14
  import type { ConnectionDB } from './connection_db.js';
15
15
  import type { Abstract } from './events/events_abstract.js';
16
+ import type { IBoundedElement } from './interfaces/i_bounded_element.js';
16
17
  import type { IConnectionChecker } from './interfaces/i_connection_checker.js';
17
18
  import { IProcedureMap } from './interfaces/i_procedure_map.js';
18
19
  import type { IVariableMap } from './interfaces/i_variable_map.js';
@@ -108,6 +109,15 @@ export declare class Workspace {
108
109
  * a's index.
109
110
  */
110
111
  private sortObjects;
112
+ /**
113
+ * Sorts bounded elements on the workspace by their relative position, top to
114
+ * bottom (with slight LTR or RTL bias).
115
+ *
116
+ * @param a The first element to sort.
117
+ * @param b The second elment to sort.
118
+ * @returns -1, 0 or 1 depending on the sort order.
119
+ */
120
+ protected sortByOrigin(a: IBoundedElement, b: IBoundedElement): number;
111
121
  /**
112
122
  * Adds a block to the list of top blocks.
113
123
  *
@@ -14,6 +14,7 @@ import './events/events_viewport.js';
14
14
  import type { Block } from './block.js';
15
15
  import type { BlockSvg } from './block_svg.js';
16
16
  import * as browserEvents from './browser_events.js';
17
+ import { RenderedWorkspaceComment } from './comments/rendered_workspace_comment.js';
17
18
  import { WorkspaceComment } from './comments/workspace_comment.js';
18
19
  import { ComponentManager } from './component_manager.js';
19
20
  import { ContextMenuOption } from './contextmenu_registry.js';
@@ -297,7 +298,7 @@ export declare class WorkspaceSvg extends Workspace implements IContextMenu, IFo
297
298
  *
298
299
  * @returns The cursor for the workspace.
299
300
  */
300
- getCursor(): LineCursor | null;
301
+ getCursor(): LineCursor;
301
302
  /**
302
303
  * Get the block renderer attached to this workspace.
303
304
  *
@@ -850,13 +851,27 @@ export declare class WorkspaceSvg extends Workspace implements IContextMenu, IFo
850
851
  *
851
852
  * @param comment comment to add.
852
853
  */
853
- addTopComment(comment: WorkspaceComment): void;
854
+ addTopComment(comment: RenderedWorkspaceComment): void;
854
855
  /**
855
856
  * Removes a comment from the list of top comments.
856
857
  *
857
858
  * @param comment comment to remove.
858
859
  */
859
- removeTopComment(comment: WorkspaceComment): void;
860
+ removeTopComment(comment: RenderedWorkspaceComment): void;
861
+ /**
862
+ * Returns a list of comments on this workspace.
863
+ *
864
+ * @param ordered If true, sorts the comments based on their position.
865
+ * @returns A list of workspace comments.
866
+ */
867
+ getTopComments(ordered?: boolean): RenderedWorkspaceComment[];
868
+ /**
869
+ * Returns the workspace comment with the given ID, if any.
870
+ *
871
+ * @param id The ID of the comment to retrieve.
872
+ * @returns The workspace comment with the given ID, or null.
873
+ */
874
+ getCommentById(id: string): RenderedWorkspaceComment | null;
860
875
  getRootWorkspace(): WorkspaceSvg | null;
861
876
  /**
862
877
  * Adds a bounded element to the list of top bounded elements.
@@ -875,7 +890,7 @@ export declare class WorkspaceSvg extends Workspace implements IContextMenu, IFo
875
890
  *
876
891
  * @returns The top-level bounded elements.
877
892
  */
878
- getTopBoundedElements(): IBoundedElement[];
893
+ getTopBoundedElements(ordered?: boolean): IBoundedElement[];
879
894
  /**
880
895
  * Update whether this workspace has resizes enabled.
881
896
  * If enabled, workspace will resize when appropriate.