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.
- package/blockly.min.js +933 -904
- package/blockly_compressed.js +839 -809
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +57 -58
- package/blocks_compressed.js.map +1 -1
- package/core/block.d.ts +1 -1
- package/core/block_svg.d.ts +4 -1
- package/core/bubbles/bubble.d.ts +17 -2
- package/core/bubbles/textinput_bubble.d.ts +14 -17
- package/core/clipboard.d.ts +76 -15
- package/core/comments/collapse_comment_bar_button.d.ts +52 -0
- package/core/comments/comment_bar_button.d.ts +62 -0
- package/core/comments/comment_view.d.ts +13 -25
- package/core/comments/delete_comment_bar_button.d.ts +52 -0
- package/core/comments.d.ts +3 -0
- package/core/field_input.d.ts +3 -3
- package/core/icons/comment_icon.d.ts +3 -3
- package/core/insertion_marker_previewer.d.ts +11 -0
- package/core/interfaces/i_variable_map.d.ts +1 -1
- package/core/keyboard_nav/block_comment_navigation_policy.d.ts +56 -0
- package/core/keyboard_nav/block_navigation_policy.d.ts +7 -6
- package/core/keyboard_nav/comment_bar_button_navigation_policy.d.ts +56 -0
- package/core/keyboard_nav/comment_editor_navigation_policy.d.ts +34 -0
- package/core/keyboard_nav/line_cursor.d.ts +8 -8
- package/core/keyboard_nav/workspace_comment_navigation_policy.d.ts +56 -0
- package/core/marker_manager.d.ts +2 -2
- package/core/registry.d.ts +1 -1
- package/core/utils/focusable_tree_traverser.d.ts +2 -2
- package/core/utils/rect.d.ts +9 -0
- package/core/workspace.d.ts +10 -0
- package/core/workspace_svg.d.ts +19 -4
- package/dart_compressed.js +38 -38
- package/dart_compressed.js.map +1 -1
- package/javascript_compressed.js +37 -37
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +30 -30
- package/lua_compressed.js.map +1 -1
- package/package.json +8 -7
- package/php_compressed.js +39 -39
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +32 -32
- package/python_compressed.js.map +1 -1
package/core/block.d.ts
CHANGED
|
@@ -544,7 +544,7 @@ export declare class Block {
|
|
|
544
544
|
*
|
|
545
545
|
* @yields A generator that can be used to iterate the fields on the block.
|
|
546
546
|
*/
|
|
547
|
-
getFields(): Generator<Field>;
|
|
547
|
+
getFields(): Generator<Field, undefined, void>;
|
|
548
548
|
/**
|
|
549
549
|
* Return all variables referenced by this block.
|
|
550
550
|
*
|
package/core/block_svg.d.ts
CHANGED
|
@@ -361,9 +361,12 @@ export declare class BlockSvg extends Block implements IBoundedElement, IContext
|
|
|
361
361
|
/**
|
|
362
362
|
* Encode a block for copying.
|
|
363
363
|
*
|
|
364
|
+
* @param addNextBlocks If true, copy subsequent blocks attached to this one
|
|
365
|
+
* as well.
|
|
366
|
+
*
|
|
364
367
|
* @returns Copy metadata, or null if the block is an insertion marker.
|
|
365
368
|
*/
|
|
366
|
-
toCopyData(): BlockCopyData | null;
|
|
369
|
+
toCopyData(addNextBlocks?: boolean): BlockCopyData | null;
|
|
367
370
|
/**
|
|
368
371
|
* Updates the colour of the block to match the block's state.
|
|
369
372
|
*
|
package/core/bubbles/bubble.d.ts
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { IBubble } from '../interfaces/i_bubble.js';
|
|
7
|
+
import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
|
|
7
8
|
import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
|
|
9
|
+
import type { IHasBubble } from '../interfaces/i_has_bubble.js';
|
|
8
10
|
import { ISelectable } from '../interfaces/i_selectable.js';
|
|
9
11
|
import { Coordinate } from '../utils/coordinate.js';
|
|
10
12
|
import { Rect } from '../utils/rect.js';
|
|
@@ -15,10 +17,11 @@ import { WorkspaceSvg } from '../workspace_svg.js';
|
|
|
15
17
|
* bubble, where it has a "tail" that points to the block, and a "head" that
|
|
16
18
|
* displays arbitrary svg elements.
|
|
17
19
|
*/
|
|
18
|
-
export declare abstract class Bubble implements IBubble, ISelectable {
|
|
20
|
+
export declare abstract class Bubble implements IBubble, ISelectable, IFocusableNode {
|
|
19
21
|
readonly workspace: WorkspaceSvg;
|
|
20
22
|
protected anchor: Coordinate;
|
|
21
23
|
protected ownerRect?: Rect | undefined;
|
|
24
|
+
protected owner?: (IHasBubble & IFocusableNode) | undefined;
|
|
22
25
|
/** The width of the border around the bubble. */
|
|
23
26
|
static readonly BORDER_WIDTH = 6;
|
|
24
27
|
/** Double the width of the border around the bubble. */
|
|
@@ -72,8 +75,9 @@ export declare abstract class Bubble implements IBubble, ISelectable {
|
|
|
72
75
|
* element that's represented by this bubble (as a focusable node). This
|
|
73
76
|
* element will have its ID overwritten. If not provided, the focusable
|
|
74
77
|
* element of this node will default to the bubble's SVG root.
|
|
78
|
+
* @param owner The object responsible for hosting/spawning this bubble.
|
|
75
79
|
*/
|
|
76
|
-
constructor(workspace: WorkspaceSvg, anchor: Coordinate, ownerRect?: Rect | undefined, overriddenFocusableElement?: SVGElement | HTMLElement);
|
|
80
|
+
constructor(workspace: WorkspaceSvg, anchor: Coordinate, ownerRect?: Rect | undefined, overriddenFocusableElement?: SVGElement | HTMLElement, owner?: (IHasBubble & IFocusableNode) | undefined);
|
|
77
81
|
/** Dispose of this bubble. */
|
|
78
82
|
dispose(): void;
|
|
79
83
|
/**
|
|
@@ -107,6 +111,13 @@ export declare abstract class Bubble implements IBubble, ISelectable {
|
|
|
107
111
|
* is focused.
|
|
108
112
|
*/
|
|
109
113
|
private onMouseDown;
|
|
114
|
+
/**
|
|
115
|
+
* Handles key events when this bubble is focused. By default, closes the
|
|
116
|
+
* bubble on Escape.
|
|
117
|
+
*
|
|
118
|
+
* @param e The keyboard event to handle.
|
|
119
|
+
*/
|
|
120
|
+
protected onKeyDown(e: KeyboardEvent): void;
|
|
110
121
|
/** Positions the bubble relative to its anchor. Does not render its tail. */
|
|
111
122
|
protected positionRelativeToAnchor(): void;
|
|
112
123
|
/**
|
|
@@ -209,5 +220,9 @@ export declare abstract class Bubble implements IBubble, ISelectable {
|
|
|
209
220
|
onNodeBlur(): void;
|
|
210
221
|
/** See IFocusableNode.canBeFocused. */
|
|
211
222
|
canBeFocused(): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Returns the object that owns/hosts this bubble, if any.
|
|
225
|
+
*/
|
|
226
|
+
getOwner(): (IHasBubble & IFocusableNode) | undefined;
|
|
212
227
|
}
|
|
213
228
|
//# sourceMappingURL=bubble.d.ts.map
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* Copyright 2023 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { CommentEditor } from '../comments/comment_editor.js';
|
|
7
|
+
import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
|
|
8
|
+
import type { IHasBubble } from '../interfaces/i_has_bubble.js';
|
|
6
9
|
import { Coordinate } from '../utils/coordinate.js';
|
|
7
10
|
import { Rect } from '../utils/rect.js';
|
|
8
11
|
import { Size } from '../utils/size.js';
|
|
@@ -16,10 +19,7 @@ export declare class TextInputBubble extends Bubble {
|
|
|
16
19
|
readonly workspace: WorkspaceSvg;
|
|
17
20
|
protected anchor: Coordinate;
|
|
18
21
|
protected ownerRect?: Rect | undefined;
|
|
19
|
-
|
|
20
|
-
private inputRoot;
|
|
21
|
-
/** The text input area element. */
|
|
22
|
-
private textArea;
|
|
22
|
+
protected owner?: (IHasBubble & IFocusableNode) | undefined;
|
|
23
23
|
/** The group containing the lines indicating the bubble is resizable. */
|
|
24
24
|
private resizeGroup;
|
|
25
25
|
/**
|
|
@@ -32,27 +32,26 @@ export declare class TextInputBubble extends Bubble {
|
|
|
32
32
|
* resize group.
|
|
33
33
|
*/
|
|
34
34
|
private resizePointerMoveListener;
|
|
35
|
-
/** Functions listening for changes to the text of this bubble. */
|
|
36
|
-
private textChangeListeners;
|
|
37
35
|
/** Functions listening for changes to the size of this bubble. */
|
|
38
36
|
private sizeChangeListeners;
|
|
39
37
|
/** Functions listening for changes to the location of this bubble. */
|
|
40
38
|
private locationChangeListeners;
|
|
41
|
-
/** The text of this bubble. */
|
|
42
|
-
private text;
|
|
43
39
|
/** The default size of this bubble, including borders. */
|
|
44
40
|
private readonly DEFAULT_SIZE;
|
|
45
41
|
/** The minimum size of this bubble, including borders. */
|
|
46
42
|
private readonly MIN_SIZE;
|
|
47
43
|
private editable;
|
|
44
|
+
/** View responsible for supporting text editing. */
|
|
45
|
+
private editor;
|
|
48
46
|
/**
|
|
49
47
|
* @param workspace The workspace this bubble belongs to.
|
|
50
48
|
* @param anchor The anchor location of the thing this bubble is attached to.
|
|
51
49
|
* The tail of the bubble will point to this location.
|
|
52
50
|
* @param ownerRect An optional rect we don't want the bubble to overlap with
|
|
53
51
|
* when automatically positioning.
|
|
52
|
+
* @param owner The object that owns/hosts this bubble.
|
|
54
53
|
*/
|
|
55
|
-
constructor(workspace: WorkspaceSvg, anchor: Coordinate, ownerRect?: Rect | undefined);
|
|
54
|
+
constructor(workspace: WorkspaceSvg, anchor: Coordinate, ownerRect?: Rect | undefined, owner?: (IHasBubble & IFocusableNode) | undefined);
|
|
56
55
|
/** @returns the text of this bubble. */
|
|
57
56
|
getText(): string;
|
|
58
57
|
/** Sets the text of this bubble. Calls change listeners. */
|
|
@@ -67,12 +66,6 @@ export declare class TextInputBubble extends Bubble {
|
|
|
67
66
|
addSizeChangeListener(listener: () => void): void;
|
|
68
67
|
/** Adds a change listener to be notified when this bubble's location changes. */
|
|
69
68
|
addLocationChangeListener(listener: () => void): void;
|
|
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. */
|
|
73
|
-
private createEditor;
|
|
74
|
-
/** Binds events to the text area element. */
|
|
75
|
-
private bindTextAreaEvents;
|
|
76
69
|
/** Creates the resize handler elements and binds events to them. */
|
|
77
70
|
private createResizeHandle;
|
|
78
71
|
/**
|
|
@@ -95,11 +88,15 @@ export declare class TextInputBubble extends Bubble {
|
|
|
95
88
|
private onResizePointerUp;
|
|
96
89
|
/** Handles pointer move events on the resize target. */
|
|
97
90
|
private onResizePointerMove;
|
|
98
|
-
/** Handles a text change event for the text area. Calls event listeners. */
|
|
99
|
-
private onTextChange;
|
|
100
91
|
/** Handles a size change event for the text area. Calls event listeners. */
|
|
101
92
|
private onSizeChange;
|
|
102
93
|
/** Handles a location change event for the text area. Calls event listeners. */
|
|
103
94
|
private onLocationChange;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the text editor component of this bubble.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
getEditor(): CommentEditor;
|
|
104
101
|
}
|
|
105
102
|
//# sourceMappingURL=textinput_bubble.d.ts.map
|
package/core/clipboard.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
|
55
|
+
export declare function getLastCopiedWorkspace(): WorkspaceSvg | null;
|
|
15
56
|
/**
|
|
16
|
-
*
|
|
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,52 @@
|
|
|
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
|
+
import type { CommentView } from './comment_view.js';
|
|
9
|
+
/**
|
|
10
|
+
* Magic string appended to the comment ID to create a unique ID for this button.
|
|
11
|
+
*/
|
|
12
|
+
export declare const COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER = "_collapse_bar_button";
|
|
13
|
+
/**
|
|
14
|
+
* Button that toggles the collapsed state of a comment.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CollapseCommentBarButton extends CommentBarButton {
|
|
17
|
+
protected readonly id: string;
|
|
18
|
+
protected readonly workspace: WorkspaceSvg;
|
|
19
|
+
protected readonly container: SVGGElement;
|
|
20
|
+
protected readonly commentView: CommentView;
|
|
21
|
+
/**
|
|
22
|
+
* Opaque ID used to unbind event handlers during disposal.
|
|
23
|
+
*/
|
|
24
|
+
private readonly bindId;
|
|
25
|
+
/**
|
|
26
|
+
* SVG image displayed on this button.
|
|
27
|
+
*/
|
|
28
|
+
protected readonly icon: SVGImageElement;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new CollapseCommentBarButton instance.
|
|
31
|
+
*
|
|
32
|
+
* @param id The ID of this button's parent comment.
|
|
33
|
+
* @param workspace The workspace this button's parent comment is displayed on.
|
|
34
|
+
* @param container An SVG group that this button should be a child of.
|
|
35
|
+
*/
|
|
36
|
+
constructor(id: string, workspace: WorkspaceSvg, container: SVGGElement, commentView: CommentView);
|
|
37
|
+
/**
|
|
38
|
+
* Disposes of this button.
|
|
39
|
+
*/
|
|
40
|
+
dispose(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Adjusts the positioning of this button within its container.
|
|
43
|
+
*/
|
|
44
|
+
reposition(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Toggles the collapsed state of the parent comment.
|
|
47
|
+
*
|
|
48
|
+
* @param e The event that triggered this action.
|
|
49
|
+
*/
|
|
50
|
+
performAction(e?: Event): void;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=collapse_comment_bar_button.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { CommentView } from './comment_view.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
|
+
protected readonly commentView: CommentView;
|
|
18
|
+
/**
|
|
19
|
+
* SVG image displayed on this button.
|
|
20
|
+
*/
|
|
21
|
+
protected abstract readonly icon: SVGImageElement;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new CommentBarButton instance.
|
|
24
|
+
*
|
|
25
|
+
* @param id The ID of this button's parent comment.
|
|
26
|
+
* @param workspace The workspace this button's parent comment is on.
|
|
27
|
+
* @param container An SVG group that this button should be a child of.
|
|
28
|
+
*/
|
|
29
|
+
constructor(id: string, workspace: WorkspaceSvg, container: SVGGElement, commentView: CommentView);
|
|
30
|
+
/**
|
|
31
|
+
* Returns whether or not this button is currently visible.
|
|
32
|
+
*/
|
|
33
|
+
isVisible(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the parent comment view of this comment bar button.
|
|
36
|
+
*/
|
|
37
|
+
getCommentView(): CommentView;
|
|
38
|
+
/** Adjusts the position of this button within its parent container. */
|
|
39
|
+
abstract reposition(): void;
|
|
40
|
+
/** Perform the action this button should take when it is acted on. */
|
|
41
|
+
abstract performAction(e?: Event): void;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the dimensions of this button in workspace coordinates.
|
|
44
|
+
*
|
|
45
|
+
* @param includeMargin True to include the margin when calculating the size.
|
|
46
|
+
* @returns The size of this button.
|
|
47
|
+
*/
|
|
48
|
+
getSize(includeMargin?: boolean): Rect;
|
|
49
|
+
/** Returns the margin in workspace coordinates surrounding this button. */
|
|
50
|
+
getMargin(): number;
|
|
51
|
+
/** Returns a DOM element representing this button that can receive focus. */
|
|
52
|
+
getFocusableElement(): SVGImageElement;
|
|
53
|
+
/** Returns the workspace this button is a child of. */
|
|
54
|
+
getFocusableTree(): WorkspaceSvg;
|
|
55
|
+
/** Called when this button's focusable DOM element gains focus. */
|
|
56
|
+
onNodeFocus(): void;
|
|
57
|
+
/** Called when this button's focusable DOM element loses focus. */
|
|
58
|
+
onNodeBlur(): void;
|
|
59
|
+
/** Returns whether this button can be focused. True if it is visible. */
|
|
60
|
+
canBeFocused(): boolean;
|
|
61
|
+
}
|
|
62
|
+
//# 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
|
-
|
|
14
|
+
readonly commentId: string;
|
|
14
15
|
/** The root group element of the comment view. */
|
|
15
16
|
private svgRoot;
|
|
16
17
|
/**
|
|
17
|
-
* The
|
|
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
|
|
25
|
-
private
|
|
26
|
-
/** The foldout
|
|
27
|
-
private
|
|
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
|
|
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
|
-
|
|
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,52 @@
|
|
|
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
|
+
import type { CommentView } from './comment_view.js';
|
|
9
|
+
/**
|
|
10
|
+
* Magic string appended to the comment ID to create a unique ID for this button.
|
|
11
|
+
*/
|
|
12
|
+
export declare const COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER = "_delete_bar_button";
|
|
13
|
+
/**
|
|
14
|
+
* Button that deletes a comment.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DeleteCommentBarButton extends CommentBarButton {
|
|
17
|
+
protected readonly id: string;
|
|
18
|
+
protected readonly workspace: WorkspaceSvg;
|
|
19
|
+
protected readonly container: SVGGElement;
|
|
20
|
+
protected readonly commentView: CommentView;
|
|
21
|
+
/**
|
|
22
|
+
* Opaque ID used to unbind event handlers during disposal.
|
|
23
|
+
*/
|
|
24
|
+
private readonly bindId;
|
|
25
|
+
/**
|
|
26
|
+
* SVG image displayed on this button.
|
|
27
|
+
*/
|
|
28
|
+
protected readonly icon: SVGImageElement;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new DeleteCommentBarButton instance.
|
|
31
|
+
*
|
|
32
|
+
* @param id The ID of this button's parent comment.
|
|
33
|
+
* @param workspace The workspace this button's parent comment is shown on.
|
|
34
|
+
* @param container An SVG group that this button should be a child of.
|
|
35
|
+
*/
|
|
36
|
+
constructor(id: string, workspace: WorkspaceSvg, container: SVGGElement, commentView: CommentView);
|
|
37
|
+
/**
|
|
38
|
+
* Disposes of this button.
|
|
39
|
+
*/
|
|
40
|
+
dispose(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Adjusts the positioning of this button within its container.
|
|
43
|
+
*/
|
|
44
|
+
reposition(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Deletes parent comment.
|
|
47
|
+
*
|
|
48
|
+
* @param e The event that triggered this action.
|
|
49
|
+
*/
|
|
50
|
+
performAction(e?: Event): void;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=delete_comment_bar_button.d.ts.map
|
package/core/comments.d.ts
CHANGED
|
@@ -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
|
package/core/field_input.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
52
|
-
private
|
|
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
|
|
207
|
+
* @param _e InputEvent.
|
|
208
208
|
*/
|
|
209
209
|
private onHtmlInputChange;
|
|
210
210
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import type { Block } from '../block.js';
|
|
7
|
-
import
|
|
7
|
+
import { TextInputBubble } from '../bubbles/textinput_bubble.js';
|
|
8
8
|
import type { IHasBubble } from '../interfaces/i_has_bubble.js';
|
|
9
9
|
import type { ISerializable } from '../interfaces/i_serializable.js';
|
|
10
10
|
import { Coordinate } from '../utils.js';
|
|
@@ -34,7 +34,7 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
|
|
|
34
34
|
/**
|
|
35
35
|
* The visibility of the bubble for this comment.
|
|
36
36
|
*
|
|
37
|
-
* This is used to track what the
|
|
37
|
+
* This is used to track what the visible state /should/ be, not necessarily
|
|
38
38
|
* what it currently /is/. E.g. sometimes this will be true, but the block
|
|
39
39
|
* hasn't been rendered yet, so the bubble will not currently be visible.
|
|
40
40
|
*/
|
|
@@ -94,7 +94,7 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
|
|
|
94
94
|
bubbleIsVisible(): boolean;
|
|
95
95
|
setBubbleVisible(visible: boolean): Promise<void>;
|
|
96
96
|
/** See IHasBubble.getBubble. */
|
|
97
|
-
getBubble():
|
|
97
|
+
getBubble(): TextInputBubble | null;
|
|
98
98
|
/**
|
|
99
99
|
* Shows the editable text bubble for this comment, and adds change listeners
|
|
100
100
|
* to update the state of this icon in response to changes in the bubble.
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { BlockSvg } from './block_svg.js';
|
|
7
7
|
import { IConnectionPreviewer } from './interfaces/i_connection_previewer.js';
|
|
8
8
|
import { RenderedConnection } from './rendered_connection.js';
|
|
9
|
+
import * as blocks from './serialization/blocks.js';
|
|
9
10
|
export declare class InsertionMarkerPreviewer implements IConnectionPreviewer {
|
|
10
11
|
private readonly workspace;
|
|
11
12
|
private fadedBlock;
|
|
@@ -36,6 +37,16 @@ export declare class InsertionMarkerPreviewer implements IConnectionPreviewer {
|
|
|
36
37
|
previewConnection(draggedConn: RenderedConnection, staticConn: RenderedConnection): void;
|
|
37
38
|
private shouldUseMarkerPreview;
|
|
38
39
|
private previewMarker;
|
|
40
|
+
/**
|
|
41
|
+
* Transforms the given block into a JSON representation used to construct an
|
|
42
|
+
* insertion marker.
|
|
43
|
+
*
|
|
44
|
+
* @param block The block to serialize and use as an insertion marker.
|
|
45
|
+
* @returns A JSON-formatted string corresponding to a serialized
|
|
46
|
+
* representation of the given block suitable for use as an insertion
|
|
47
|
+
* marker.
|
|
48
|
+
*/
|
|
49
|
+
protected serializeBlockToInsertionMarker(block: BlockSvg): blocks.State;
|
|
39
50
|
private createInsertionMarker;
|
|
40
51
|
/**
|
|
41
52
|
* Gets the connection on the marker block that matches the original
|
|
@@ -34,7 +34,7 @@ export interface IVariableMap<T extends IVariableModel<IVariableState>> {
|
|
|
34
34
|
* Creates a new variable with the given name. If ID is not specified, the
|
|
35
35
|
* variable map should create one. Returns the new variable.
|
|
36
36
|
*/
|
|
37
|
-
createVariable(name: string,
|
|
37
|
+
createVariable(name: string, type?: string, id?: string | null): T;
|
|
38
38
|
addVariable(variable: T): void;
|
|
39
39
|
/**
|
|
40
40
|
* Changes the name of the given variable to the name provided and returns the
|