blockly 12.2.0-beta.0 → 12.2.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.
@@ -9,11 +9,83 @@ import type { ICopyData, ICopyable } from './interfaces/i_copyable.js';
9
9
  import { Coordinate } from './utils/coordinate.js';
10
10
  import { WorkspaceSvg } from './workspace_svg.js';
11
11
  /**
12
- * Private version of copy for stubbing in tests.
12
+ * Copy a copyable item, and record its data and the workspace it was
13
+ * copied from.
14
+ *
15
+ * This function does not perform any checks to ensure the copy
16
+ * should be allowed, e.g. to ensure the block is deletable. Such
17
+ * checks should be done before calling this function.
18
+ *
19
+ * Note that if the copyable item is not an `ISelectable` or its
20
+ * `workspace` property is not a `WorkspaceSvg`, the copy will be
21
+ * successful, but there will be no saved workspace data. This will
22
+ * impact the ability to paste the data unless you explictily pass
23
+ * a workspace into the paste method.
24
+ *
25
+ * @param toCopy item to copy.
26
+ * @param location location to save as a potential paste location.
27
+ * @returns the copied data if copy was successful, otherwise null.
28
+ */
29
+ export declare function copy<T extends ICopyData>(toCopy: ICopyable<T>, location?: Coordinate): T | null;
30
+ /**
31
+ * Gets the copy data for the last item copied. This is useful if you
32
+ * are implementing custom copy/paste behavior. If you want the default
33
+ * behavior, just use the copy and paste methods directly.
34
+ *
35
+ * @returns copy data for the last item copied, or null if none set.
36
+ */
37
+ export declare function getLastCopiedData(): ICopyable.ICopyData | null;
38
+ /**
39
+ * Sets the last copied item. You should call this method if you implement
40
+ * custom copy behavior, so that other callers are working with the correct
41
+ * data. This method is called automatically if you use the built-in copy
42
+ * method.
43
+ *
44
+ * @param copyData copy data for the last item copied.
45
+ */
46
+ export declare function setLastCopiedData(copyData: ICopyData): void;
47
+ /**
48
+ * Gets the workspace that was last copied from. This is useful if you
49
+ * are implementing custom copy/paste behavior and want to paste on the
50
+ * same workspace that was copied from. If you want the default behavior,
51
+ * just use the copy and paste methods directly.
52
+ *
53
+ * @returns workspace that was last copied from, or null if none set.
13
54
  */
14
- declare function copyInternal<T extends ICopyData>(toCopy: ICopyable<T>): T | null;
55
+ export declare function getLastCopiedWorkspace(): WorkspaceSvg | null;
15
56
  /**
16
- * Paste a pasteable element into the workspace.
57
+ * Sets the workspace that was last copied from. You should call this method
58
+ * if you implement custom copy behavior, so that other callers are working
59
+ * with the correct data. This method is called automatically if you use the
60
+ * built-in copy method.
61
+ *
62
+ * @param workspace workspace that was last copied from.
63
+ */
64
+ export declare function setLastCopiedWorkspace(workspace: WorkspaceSvg): void;
65
+ /**
66
+ * Gets the location that was last copied from. This is useful if you
67
+ * are implementing custom copy/paste behavior. If you want the
68
+ * default behavior, just use the copy and paste methods directly.
69
+ *
70
+ * @returns last saved location, or null if none set.
71
+ */
72
+ export declare function getLastCopiedLocation(): Coordinate | undefined;
73
+ /**
74
+ * Sets the location that was last copied from. You should call this method
75
+ * if you implement custom copy behavior, so that other callers are working
76
+ * with the correct data. This method is called automatically if you use the
77
+ * built-in copy method.
78
+ *
79
+ * @param location last saved location, which can be used to paste at.
80
+ */
81
+ export declare function setLastCopiedLocation(location: Coordinate): void;
82
+ /**
83
+ * Paste a pasteable element into the given workspace.
84
+ *
85
+ * This function does not perform any checks to ensure the paste
86
+ * is allowed, e.g. that the workspace is rendered or the block
87
+ * is pasteable. Such checks should be done before calling this
88
+ * function.
17
89
  *
18
90
  * @param copyData The data to paste into the workspace.
19
91
  * @param workspace The workspace to paste the data into.
@@ -22,21 +94,10 @@ declare function copyInternal<T extends ICopyData>(toCopy: ICopyable<T>): T | nu
22
94
  */
23
95
  export declare function paste<T extends ICopyData>(copyData: T, workspace: WorkspaceSvg, coordinate?: Coordinate): ICopyable<T> | null;
24
96
  /**
25
- * Pastes the last copied ICopyable into the workspace.
97
+ * Pastes the last copied ICopyable into the last copied-from workspace.
26
98
  *
27
99
  * @returns the pasted thing if the paste was successful, null otherwise.
28
100
  */
29
101
  export declare function paste(): ICopyable<ICopyData> | null;
30
- /**
31
- * Private version of duplicate for stubbing in tests.
32
- */
33
- declare function duplicateInternal<U extends ICopyData, T extends ICopyable<U> & IHasWorkspace>(toDuplicate: T): T | null;
34
- interface IHasWorkspace {
35
- workspace: WorkspaceSvg;
36
- }
37
- export declare const TEST_ONLY: {
38
- duplicateInternal: typeof duplicateInternal;
39
- copyInternal: typeof copyInternal;
40
- };
41
102
  export { BlockCopyData, BlockPaster, registry };
42
103
  //# sourceMappingURL=clipboard.d.ts.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { WorkspaceSvg } from '../workspace_svg.js';
7
+ import { CommentBarButton } from './comment_bar_button.js';
8
+ /**
9
+ * Magic string appended to the comment ID to create a unique ID for this button.
10
+ */
11
+ export declare const COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER = "_collapse_bar_button";
12
+ /**
13
+ * Button that toggles the collapsed state of a comment.
14
+ */
15
+ export declare class CollapseCommentBarButton extends CommentBarButton {
16
+ protected readonly id: string;
17
+ protected readonly workspace: WorkspaceSvg;
18
+ protected readonly container: SVGGElement;
19
+ /**
20
+ * Opaque ID used to unbind event handlers during disposal.
21
+ */
22
+ private readonly bindId;
23
+ /**
24
+ * SVG image displayed on this button.
25
+ */
26
+ protected readonly icon: SVGImageElement;
27
+ /**
28
+ * Creates a new CollapseCommentBarButton instance.
29
+ *
30
+ * @param id The ID of this button's parent comment.
31
+ * @param workspace The workspace this button's parent comment is displayed on.
32
+ * @param container An SVG group that this button should be a child of.
33
+ */
34
+ constructor(id: string, workspace: WorkspaceSvg, container: SVGGElement);
35
+ /**
36
+ * Disposes of this button.
37
+ */
38
+ dispose(): void;
39
+ /**
40
+ * Adjusts the positioning of this button within its container.
41
+ */
42
+ reposition(): void;
43
+ /**
44
+ * Toggles the collapsed state of the parent comment.
45
+ *
46
+ * @param e The event that triggered this action.
47
+ */
48
+ performAction(e?: Event): void;
49
+ }
50
+ //# sourceMappingURL=collapse_comment_bar_button.d.ts.map
@@ -0,0 +1,61 @@
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 { Rect } from '../utils/rect.js';
8
+ import type { WorkspaceSvg } from '../workspace_svg.js';
9
+ import type { RenderedWorkspaceComment } from './rendered_workspace_comment.js';
10
+ /**
11
+ * Button displayed on a comment's top bar.
12
+ */
13
+ export declare abstract class CommentBarButton implements IFocusableNode {
14
+ protected readonly id: string;
15
+ protected readonly workspace: WorkspaceSvg;
16
+ protected readonly container: SVGGElement;
17
+ /**
18
+ * SVG image displayed on this button.
19
+ */
20
+ protected abstract readonly icon: SVGImageElement;
21
+ /**
22
+ * Creates a new CommentBarButton instance.
23
+ *
24
+ * @param id The ID of this button's parent comment.
25
+ * @param workspace The workspace this button's parent comment is on.
26
+ * @param container An SVG group that this button should be a child of.
27
+ */
28
+ constructor(id: string, workspace: WorkspaceSvg, container: SVGGElement);
29
+ /**
30
+ * Returns whether or not this button is currently visible.
31
+ */
32
+ isVisible(): boolean;
33
+ /**
34
+ * Returns the parent comment of this comment bar button.
35
+ */
36
+ getParentComment(): RenderedWorkspaceComment;
37
+ /** Adjusts the position of this button within its parent container. */
38
+ abstract reposition(): void;
39
+ /** Perform the action this button should take when it is acted on. */
40
+ abstract performAction(e?: Event): void;
41
+ /**
42
+ * Returns the dimensions of this button in workspace coordinates.
43
+ *
44
+ * @param includeMargin True to include the margin when calculating the size.
45
+ * @returns The size of this button.
46
+ */
47
+ getSize(includeMargin?: boolean): Rect;
48
+ /** Returns the margin in workspace coordinates surrounding this button. */
49
+ getMargin(): number;
50
+ /** Returns a DOM element representing this button that can receive focus. */
51
+ getFocusableElement(): SVGImageElement;
52
+ /** Returns the workspace this button is a child of. */
53
+ getFocusableTree(): WorkspaceSvg;
54
+ /** Called when this button's focusable DOM element gains focus. */
55
+ onNodeFocus(): void;
56
+ /** Called when this button's focusable DOM element loses focus. */
57
+ onNodeBlur(): void;
58
+ /** Returns whether this button can be focused. True if it is visible. */
59
+ canBeFocused(): boolean;
60
+ }
61
+ //# sourceMappingURL=comment_bar_button.d.ts.map
@@ -8,23 +8,24 @@ import { IRenderedElement } from '../interfaces/i_rendered_element.js';
8
8
  import { Coordinate } from '../utils/coordinate.js';
9
9
  import { Size } from '../utils/size.js';
10
10
  import { WorkspaceSvg } from '../workspace_svg.js';
11
+ import { CommentBarButton } from './comment_bar_button.js';
11
12
  export declare class CommentView implements IRenderedElement {
12
13
  readonly workspace: WorkspaceSvg;
13
- private commentId?;
14
+ private commentId;
14
15
  /** The root group element of the comment view. */
15
16
  private svgRoot;
16
17
  /**
17
- * The svg rect element that we use to create a hightlight around the comment.
18
+ * The SVG rect element that we use to create a highlight around the comment.
18
19
  */
19
20
  private highlightRect;
20
21
  /** The group containing all of the top bar elements. */
21
22
  private topBarGroup;
22
23
  /** The rect background for the top bar. */
23
24
  private topBarBackground;
24
- /** The delete icon that goes in the top bar. */
25
- private deleteIcon;
26
- /** The foldout icon that goes in the top bar. */
27
- private foldoutIcon;
25
+ /** The delete button that goes in the top bar. */
26
+ private deleteButton;
27
+ /** The foldout button that goes in the top bar. */
28
+ private foldoutButton;
28
29
  /** The text element that goes in the top bar. */
29
30
  private textPreview;
30
31
  /** The actual text node in the text preview. */
@@ -65,7 +66,7 @@ export declare class CommentView implements IRenderedElement {
65
66
  private preResizeSize?;
66
67
  /** The default size of newly created comments. */
67
68
  static defaultCommentSize: Size;
68
- constructor(workspace: WorkspaceSvg, commentId?: string | undefined);
69
+ constructor(workspace: WorkspaceSvg, commentId: string);
69
70
  /**
70
71
  * Creates the rect we use for highlighting the comment when it's selected.
71
72
  */
@@ -112,22 +113,10 @@ export declare class CommentView implements IRenderedElement {
112
113
  * The minimum height is based on the height of the top bar.
113
114
  */
114
115
  private calcMinSize;
115
- /** Calculates the margin that should exist around the delete icon. */
116
- private calcDeleteMargin;
117
- /** Calculates the margin that should exist around the foldout icon. */
118
- private calcFoldoutMargin;
119
116
  /** Updates the size of the highlight rect to reflect the new size. */
120
117
  private updateHighlightRect;
121
118
  /** Updates the size of the top bar to reflect the new size. */
122
119
  private updateTopBarSize;
123
- /**
124
- * Updates the position of the delete icon elements to reflect the new size.
125
- */
126
- private updateDeleteIconPosition;
127
- /**
128
- * Updates the position of the foldout icon elements to reflect the new size.
129
- */
130
- private updateFoldoutIconPosition;
131
120
  /**
132
121
  * Updates the size and position of the text preview elements to reflect the new size.
133
122
  */
@@ -170,11 +159,6 @@ export declare class CommentView implements IRenderedElement {
170
159
  addOnCollapseListener(listener: (newCollapse: boolean) => void): void;
171
160
  /** Removes the given listener from the list of on collapse listeners. */
172
161
  removeOnCollapseListener(listener: () => void): void;
173
- /**
174
- * Toggles the collapsedness of the block when we receive a pointer down
175
- * event on the foldout icon.
176
- */
177
- private onFoldoutDown;
178
162
  /** Returns true if the comment is currently editable. */
179
163
  isEditable(): boolean;
180
164
  /** Sets the editability of the comment. */
@@ -202,7 +186,7 @@ export declare class CommentView implements IRenderedElement {
202
186
  /** Truncates the text to fit within the top view. */
203
187
  private truncateText;
204
188
  /** Brings the workspace comment to the front of its layer. */
205
- private bringToFront;
189
+ bringToFront(): void;
206
190
  /**
207
191
  * Handles disposing of the comment when we get a pointer down event on the
208
192
  * delete icon.
@@ -221,5 +205,9 @@ export declare class CommentView implements IRenderedElement {
221
205
  addDisposeListener(listener: () => void): void;
222
206
  /** Removes the given listener from the list of disposal listeners. */
223
207
  removeDisposeListener(listener: () => void): void;
208
+ /**
209
+ * @internal
210
+ */
211
+ getCommentBarButtons(): CommentBarButton[];
224
212
  }
225
213
  //# sourceMappingURL=comment_view.d.ts.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { WorkspaceSvg } from '../workspace_svg.js';
7
+ import { CommentBarButton } from './comment_bar_button.js';
8
+ /**
9
+ * Magic string appended to the comment ID to create a unique ID for this button.
10
+ */
11
+ export declare const COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER = "_delete_bar_button";
12
+ /**
13
+ * Button that deletes a comment.
14
+ */
15
+ export declare class DeleteCommentBarButton extends CommentBarButton {
16
+ protected readonly id: string;
17
+ protected readonly workspace: WorkspaceSvg;
18
+ protected readonly container: SVGGElement;
19
+ /**
20
+ * Opaque ID used to unbind event handlers during disposal.
21
+ */
22
+ private readonly bindId;
23
+ /**
24
+ * SVG image displayed on this button.
25
+ */
26
+ protected readonly icon: SVGImageElement;
27
+ /**
28
+ * Creates a new DeleteCommentBarButton instance.
29
+ *
30
+ * @param id The ID of this button's parent comment.
31
+ * @param workspace The workspace this button's parent comment is shown on.
32
+ * @param container An SVG group that this button should be a child of.
33
+ */
34
+ constructor(id: string, workspace: WorkspaceSvg, container: SVGGElement);
35
+ /**
36
+ * Disposes of this button.
37
+ */
38
+ dispose(): void;
39
+ /**
40
+ * Adjusts the positioning of this button within its container.
41
+ */
42
+ reposition(): void;
43
+ /**
44
+ * Deletes parent comment.
45
+ *
46
+ * @param e The event that triggered this action.
47
+ */
48
+ performAction(e?: Event): void;
49
+ }
50
+ //# sourceMappingURL=delete_comment_bar_button.d.ts.map
@@ -3,8 +3,11 @@
3
3
  * Copyright 2024 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ export { CollapseCommentBarButton } from './comments/collapse_comment_bar_button.js';
7
+ export { CommentBarButton } from './comments/comment_bar_button.js';
6
8
  export { CommentEditor } from './comments/comment_editor.js';
7
9
  export { CommentView } from './comments/comment_view.js';
10
+ export { DeleteCommentBarButton } from './comments/delete_comment_bar_button.js';
8
11
  export { RenderedWorkspaceComment } from './comments/rendered_workspace_comment.js';
9
12
  export { WorkspaceComment } from './comments/workspace_comment.js';
10
13
  //# sourceMappingURL=comments.d.ts.map
@@ -48,8 +48,8 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
48
48
  protected valueWhenEditorWasOpened_: string | T | null;
49
49
  /** Key down event data. */
50
50
  private onKeyDownWrapper;
51
- /** Key input event data. */
52
- private onKeyInputWrapper;
51
+ /** Input element input event data. */
52
+ private onInputWrapper;
53
53
  /**
54
54
  * Whether the field should consider the whole parent block to be its click
55
55
  * target.
@@ -204,7 +204,7 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
204
204
  /**
205
205
  * Handle a change to the editor.
206
206
  *
207
- * @param _e Keyboard event.
207
+ * @param _e InputEvent.
208
208
  */
209
209
  private onHtmlInputChange;
210
210
  /**
@@ -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
@@ -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
  *
@@ -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
  *