blockly 11.0.0-beta.6 → 11.0.0-beta.8

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 (64) hide show
  1. package/blockly.min.js +361 -346
  2. package/blockly_compressed.js +350 -335
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +1 -1
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +2 -3
  7. package/core/block_svg.d.ts +23 -10
  8. package/core/blockly.d.ts +16 -15
  9. package/core/bubbles/bubble.d.ts +17 -2
  10. package/core/bubbles/mini_workspace_bubble.d.ts +1 -1
  11. package/core/bubbles/text_bubble.d.ts +1 -1
  12. package/core/bubbles/textinput_bubble.d.ts +1 -1
  13. package/core/comments/comment_view.d.ts +15 -1
  14. package/core/comments/rendered_workspace_comment.d.ts +43 -3
  15. package/core/comments/workspace_comment.d.ts +9 -3
  16. package/core/connection.d.ts +1 -1
  17. package/core/delete_area.d.ts +1 -2
  18. package/core/dragging/block_drag_strategy.d.ts +105 -0
  19. package/core/dragging/bubble_drag_strategy.d.ts +20 -0
  20. package/core/dragging/comment_drag_strategy.d.ts +20 -0
  21. package/core/dragging/dragger.d.ts +48 -0
  22. package/core/dragging.d.ts +11 -0
  23. package/core/events/events.d.ts +3 -0
  24. package/core/events/events_comment_base.d.ts +6 -1
  25. package/core/events/events_comment_change.d.ts +1 -1
  26. package/core/events/events_comment_collapse.d.ts +39 -0
  27. package/core/events/events_comment_create.d.ts +5 -1
  28. package/core/events/events_comment_delete.d.ts +5 -1
  29. package/core/events/events_comment_move.d.ts +17 -1
  30. package/core/events/utils.d.ts +2 -0
  31. package/core/flyout_base.d.ts +17 -1
  32. package/core/flyout_button.d.ts +26 -1
  33. package/core/gesture.d.ts +27 -53
  34. package/core/icons/comment_icon.d.ts +5 -0
  35. package/core/interfaces/i_comment_icon.d.ts +5 -1
  36. package/core/interfaces/i_deletable.d.ts +6 -0
  37. package/core/interfaces/i_delete_area.d.ts +1 -2
  38. package/core/interfaces/i_draggable.d.ts +47 -3
  39. package/core/interfaces/i_dragger.d.ts +32 -0
  40. package/core/interfaces/i_selectable.d.ts +5 -3
  41. package/core/internal_constants.d.ts +0 -7
  42. package/core/keyboard_nav/ast_node.d.ts +21 -2
  43. package/core/registry.d.ts +6 -2
  44. package/core/renderers/common/marker_svg.d.ts +7 -0
  45. package/core/toolbox/toolbox.d.ts +1 -2
  46. package/core/workspace_comment_svg.d.ts +1 -2
  47. package/core/workspace_svg.d.ts +0 -2
  48. package/core/xml.d.ts +5 -0
  49. package/dart_compressed.js +8 -8
  50. package/dart_compressed.js.map +1 -1
  51. package/javascript_compressed.js +10 -10
  52. package/javascript_compressed.js.map +1 -1
  53. package/lua_compressed.js +6 -7
  54. package/lua_compressed.js.map +1 -1
  55. package/media/delete-icon.svg +1 -0
  56. package/package.json +2 -2
  57. package/php_compressed.js +7 -7
  58. package/php_compressed.js.map +1 -1
  59. package/python_compressed.js +3 -3
  60. package/python_compressed.js.map +1 -1
  61. package/core/block_dragger.d.ts +0 -212
  62. package/core/bubble_dragger.d.ts +0 -77
  63. package/core/interfaces/i_block_dragger.d.ts +0 -47
  64. /package/media/{arrow-dropdown.svg → foldout-icon.svg} +0 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { IDragTarget } from '../interfaces/i_drag_target.js';
7
+ import { IDeletable } from '../interfaces/i_deletable.js';
8
+ import { IDragger } from '../interfaces/i_dragger.js';
9
+ import { IDraggable } from '../interfaces/i_draggable.js';
10
+ import { Coordinate } from '../utils/coordinate.js';
11
+ import { WorkspaceSvg } from '../workspace_svg.js';
12
+ export declare class Dragger implements IDragger {
13
+ protected draggable: IDraggable;
14
+ protected workspace: WorkspaceSvg;
15
+ protected startLoc: Coordinate;
16
+ protected dragTarget: IDragTarget | null;
17
+ constructor(draggable: IDraggable, workspace: WorkspaceSvg);
18
+ /** Handles any drag startup. */
19
+ onDragStart(e: PointerEvent): void;
20
+ /**
21
+ * Handles calculating where the element should actually be moved to.
22
+ *
23
+ * @param totalDelta The total amount in pixel coordinates the mouse has moved
24
+ * since the start of the drag.
25
+ */
26
+ onDrag(e: PointerEvent, totalDelta: Coordinate): void;
27
+ /** Updates the drag target under the pointer (if there is one). */
28
+ protected updateDragTarget(e: PointerEvent): void;
29
+ /**
30
+ * Calculates the correct workspace coordinate for the movable and tells
31
+ * the draggable to go to that location.
32
+ */
33
+ private moveDraggable;
34
+ /**
35
+ * Returns true if we would delete the draggable if it was dropped
36
+ * at the current location.
37
+ */
38
+ protected wouldDeleteDraggable(e: PointerEvent, draggable: IDraggable & IDeletable): boolean;
39
+ /** Handles any drag cleanup. */
40
+ onDragEnd(e: PointerEvent): void;
41
+ /**
42
+ * Returns true if we should return the draggable to its original location
43
+ * at the end of the drag.
44
+ */
45
+ protected shouldReturnToStart(e: PointerEvent, draggable: IDraggable): boolean;
46
+ protected pixelsToWorkspaceUnits(pixelCoord: Coordinate): Coordinate;
47
+ }
48
+ //# sourceMappingURL=dragger.d.ts.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Dragger } from './dragging/dragger.js';
7
+ import { BlockDragStrategy } from './dragging/block_drag_strategy.js';
8
+ import { BubbleDragStrategy } from './dragging/bubble_drag_strategy.js';
9
+ import { CommentDragStrategy } from './dragging/comment_drag_strategy.js';
10
+ export { Dragger, BlockDragStrategy, BubbleDragStrategy, CommentDragStrategy };
11
+ //# sourceMappingURL=dragging.d.ts.map
@@ -18,6 +18,7 @@ import { CommentChange, CommentChangeJson } from './events_comment_change.js';
18
18
  import { CommentCreate, CommentCreateJson } from './events_comment_create.js';
19
19
  import { CommentDelete } from './events_comment_delete.js';
20
20
  import { CommentMove, CommentMoveJson } from './events_comment_move.js';
21
+ import { CommentCollapse, CommentCollapseJson } from './events_comment_collapse.js';
21
22
  import { MarkerMove, MarkerMoveJson } from './events_marker_move.js';
22
23
  import { Selected, SelectedJson } from './events_selected.js';
23
24
  import { ThemeChange, ThemeChangeJson } from './events_theme_change.js';
@@ -62,6 +63,8 @@ export { CommentCreateJson };
62
63
  export { CommentDelete };
63
64
  export { CommentMove };
64
65
  export { CommentMoveJson };
66
+ export { CommentCollapse };
67
+ export { CommentCollapseJson };
65
68
  export { FinishedLoading };
66
69
  export { MarkerMove };
67
70
  export { MarkerMoveJson };
@@ -3,7 +3,12 @@
3
3
  * Copyright 2018 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { WorkspaceComment } from '../workspace_comment.js';
6
+ /**
7
+ * Base class for comment events.
8
+ *
9
+ * @class
10
+ */
11
+ import type { WorkspaceComment } from '../comments/workspace_comment.js';
7
12
  import { Abstract as AbstractEvent, AbstractEventJson } from './events_abstract.js';
8
13
  import type { CommentCreate } from './events_comment_create.js';
9
14
  import type { CommentDelete } from './events_comment_delete.js';
@@ -3,7 +3,7 @@
3
3
  * Copyright 2018 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { WorkspaceComment } from '../workspace_comment.js';
6
+ import type { WorkspaceComment } from '../comments/workspace_comment.js';
7
7
  import { CommentBase, CommentBaseJson } from './events_comment_base.js';
8
8
  import type { Workspace } from '../workspace.js';
9
9
  /**
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { WorkspaceComment } from '../comments/workspace_comment.js';
7
+ import { CommentBase, CommentBaseJson } from './events_comment_base.js';
8
+ import type { Workspace } from '../workspace.js';
9
+ export declare class CommentCollapse extends CommentBase {
10
+ newCollapsed?: boolean | undefined;
11
+ type: string;
12
+ constructor(comment?: WorkspaceComment, newCollapsed?: boolean | undefined);
13
+ /**
14
+ * Encode the event as JSON.
15
+ *
16
+ * @returns JSON representation.
17
+ */
18
+ toJson(): CommentCollapseJson;
19
+ /**
20
+ * Deserializes the JSON event.
21
+ *
22
+ * @param event The event to append new properties to. Should be a subclass
23
+ * of CommentCollapse, but we can't specify that due to the fact that
24
+ * parameters to static methods in subclasses must be supertypes of
25
+ * parameters to static methods in superclasses.
26
+ * @internal
27
+ */
28
+ static fromJson(json: CommentCollapseJson, workspace: Workspace, event?: any): CommentCollapse;
29
+ /**
30
+ * Run a collapse event.
31
+ *
32
+ * @param forward True if run forward, false if run backward (undo).
33
+ */
34
+ run(forward: boolean): void;
35
+ }
36
+ export interface CommentCollapseJson extends CommentBaseJson {
37
+ newCollapsed: boolean;
38
+ }
39
+ //# sourceMappingURL=events_comment_collapse.d.ts.map
@@ -3,7 +3,8 @@
3
3
  * Copyright 2018 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { WorkspaceComment } from '../workspace_comment.js';
6
+ import type { WorkspaceComment } from '../comments/workspace_comment.js';
7
+ import * as comments from '../serialization/workspace_comments.js';
7
8
  import { CommentBase, CommentBaseJson } from './events_comment_base.js';
8
9
  import type { Workspace } from '../workspace.js';
9
10
  /**
@@ -13,6 +14,8 @@ export declare class CommentCreate extends CommentBase {
13
14
  type: string;
14
15
  /** The XML representation of the created workspace comment. */
15
16
  xml?: Element | DocumentFragment;
17
+ /** The JSON representation of the created workspace comment. */
18
+ json?: comments.State;
16
19
  /**
17
20
  * @param opt_comment The created comment.
18
21
  * Undefined for a blank event.
@@ -43,5 +46,6 @@ export declare class CommentCreate extends CommentBase {
43
46
  }
44
47
  export interface CommentCreateJson extends CommentBaseJson {
45
48
  xml: string;
49
+ json: object;
46
50
  }
47
51
  //# sourceMappingURL=events_comment_create.d.ts.map
@@ -3,7 +3,8 @@
3
3
  * Copyright 2018 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { WorkspaceComment } from '../workspace_comment.js';
6
+ import type { WorkspaceComment } from '../comments/workspace_comment.js';
7
+ import * as comments from '../serialization/workspace_comments.js';
7
8
  import { CommentBase, CommentBaseJson } from './events_comment_base.js';
8
9
  import type { Workspace } from '../workspace.js';
9
10
  /**
@@ -13,6 +14,8 @@ export declare class CommentDelete extends CommentBase {
13
14
  type: string;
14
15
  /** The XML representation of the deleted workspace comment. */
15
16
  xml?: Element;
17
+ /** The JSON representation of the created workspace comment. */
18
+ json?: comments.State;
16
19
  /**
17
20
  * @param opt_comment The deleted comment.
18
21
  * Undefined for a blank event.
@@ -43,5 +46,6 @@ export declare class CommentDelete extends CommentBase {
43
46
  }
44
47
  export interface CommentDeleteJson extends CommentBaseJson {
45
48
  xml: string;
49
+ json: object;
46
50
  }
47
51
  //# sourceMappingURL=events_comment_delete.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { Coordinate } from '../utils/coordinate.js';
7
- import type { WorkspaceComment } from '../workspace_comment.js';
7
+ import type { WorkspaceComment } from '../comments/workspace_comment.js';
8
8
  import { CommentBase, CommentBaseJson } from './events_comment_base.js';
9
9
  import type { Workspace } from '../workspace.js';
10
10
  /**
@@ -18,6 +18,16 @@ export declare class CommentMove extends CommentBase {
18
18
  oldCoordinate_?: Coordinate;
19
19
  /** The location of the comment after the move, in workspace coordinates. */
20
20
  newCoordinate_?: Coordinate;
21
+ /**
22
+ * An explanation of what this move is for. Known values include:
23
+ * 'drag' -- A drag operation completed.
24
+ * 'snap' -- Comment got shifted to line up with the grid.
25
+ * 'inbounds' -- Block got pushed back into a non-scrolling workspace.
26
+ * 'create' -- Block created via deserialization.
27
+ * 'cleanup' -- Workspace aligned top-level blocks.
28
+ * Event merging may create multiple reasons: ['drag', 'inbounds', 'snap'].
29
+ */
30
+ reason?: string[];
21
31
  /**
22
32
  * @param opt_comment The comment that is being moved. Undefined for a blank
23
33
  * event.
@@ -28,6 +38,12 @@ export declare class CommentMove extends CommentBase {
28
38
  * called once.
29
39
  */
30
40
  recordNew(): void;
41
+ /**
42
+ * Sets the reason for a move event.
43
+ *
44
+ * @param reason Why is this move happening? 'drag', 'bump', 'snap', ...
45
+ */
46
+ setReason(reason: string[]): void;
31
47
  /**
32
48
  * Override the location before the move. Use this if you don't create the
33
49
  * event until the end of the move, but you know the original location.
@@ -127,6 +127,8 @@ export declare const COMMENT_CHANGE = "comment_change";
127
127
  * Name of event that moves a comment.
128
128
  */
129
129
  export declare const COMMENT_MOVE = "comment_move";
130
+ /** Type of event that moves a comment. */
131
+ export declare const COMMENT_COLLAPSE = "comment_collapse";
130
132
  /**
131
133
  * Name of event that records a workspace load.
132
134
  */
@@ -3,7 +3,7 @@
3
3
  * Copyright 2011 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { BlockSvg } from './block_svg.js';
6
+ import { BlockSvg } from './block_svg.js';
7
7
  import { DeleteArea } from './delete_area.js';
8
8
  import { FlyoutButton } from './flyout_button.js';
9
9
  import type { IFlyout } from './interfaces/i_flyout.js';
@@ -119,6 +119,10 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
119
119
  * List of visible buttons.
120
120
  */
121
121
  protected buttons_: FlyoutButton[];
122
+ /**
123
+ * List of visible buttons and blocks.
124
+ */
125
+ protected contents: FlyoutItem[];
122
126
  /**
123
127
  * List of event listeners.
124
128
  */
@@ -279,6 +283,18 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
279
283
  * @param visible Whether the container is visible.
280
284
  */
281
285
  setContainerVisible(visible: boolean): void;
286
+ /**
287
+ * Get the list of buttons and blocks of the current flyout.
288
+ *
289
+ * @returns The array of flyout buttons and blocks.
290
+ */
291
+ getContents(): FlyoutItem[];
292
+ /**
293
+ * Store the list of buttons and blocks on the flyout.
294
+ *
295
+ * @param contents - The array of items for the flyout.
296
+ */
297
+ setContents(contents: FlyoutItem[]): void;
282
298
  /**
283
299
  * Update the display property of the flyout based whether it thinks it should
284
300
  * be visible and whether its containing workspace is visible.
@@ -6,10 +6,11 @@
6
6
  import { Coordinate } from './utils/coordinate.js';
7
7
  import type * as toolbox from './utils/toolbox.js';
8
8
  import type { WorkspaceSvg } from './workspace_svg.js';
9
+ import type { IASTNodeLocationSvg } from './blockly.js';
9
10
  /**
10
11
  * Class for a button or label in the flyout.
11
12
  */
12
- export declare class FlyoutButton {
13
+ export declare class FlyoutButton implements IASTNodeLocationSvg {
13
14
  private readonly workspace;
14
15
  private readonly targetWorkspace;
15
16
  private readonly isLabel_;
@@ -34,6 +35,11 @@ export declare class FlyoutButton {
34
35
  private svgGroup;
35
36
  /** The SVG element with the text of the label or button. */
36
37
  private svgText;
38
+ /**
39
+ * Holds the cursors svg element when the cursor is attached to the button.
40
+ * This is null if there is no cursor on the button.
41
+ */
42
+ cursorSvg: SVGElement | null;
37
43
  /**
38
44
  * @param workspace The workspace in which to place this button.
39
45
  * @param targetWorkspace The flyout's target workspace.
@@ -76,8 +82,27 @@ export declare class FlyoutButton {
76
82
  * @returns The target workspace of the flyout where this button resides.
77
83
  */
78
84
  getTargetWorkspace(): WorkspaceSvg;
85
+ /**
86
+ * Get the button's workspace.
87
+ *
88
+ * @returns The workspace in which to place this button.
89
+ */
90
+ getWorkspace(): WorkspaceSvg;
79
91
  /** Dispose of this button. */
80
92
  dispose(): void;
93
+ /**
94
+ * Add the cursor SVG to this buttons's SVG group.
95
+ *
96
+ * @param cursorSvg The SVG root of the cursor to be added to the button SVG
97
+ * group.
98
+ */
99
+ setCursorSvg(cursorSvg: SVGElement): void;
100
+ /**
101
+ * Required by IASTNodeLocationSvg, but not used. A marker cannot be set on a
102
+ * button. If the 'mark' shortcut is used on a button, its associated callback
103
+ * function is triggered.
104
+ */
105
+ setMarkerSvg(): void;
81
106
  /**
82
107
  * Do something when the button is clicked.
83
108
  *
package/core/gesture.d.ts CHANGED
@@ -11,15 +11,15 @@
11
11
  */
12
12
  import './events/events_click.js';
13
13
  import type { BlockSvg } from './block_svg.js';
14
- import { BubbleDragger } from './bubble_dragger.js';
15
14
  import type { Field } from './field.js';
16
- import type { IBlockDragger } from './interfaces/i_block_dragger.js';
17
15
  import type { IBubble } from './interfaces/i_bubble.js';
18
16
  import type { IFlyout } from './interfaces/i_flyout.js';
19
17
  import { Coordinate } from './utils/coordinate.js';
20
18
  import { WorkspaceDragger } from './workspace_dragger.js';
21
19
  import type { WorkspaceSvg } from './workspace_svg.js';
22
20
  import type { IIcon } from './interfaces/i_icon.js';
21
+ import { IDragger } from './interfaces/i_dragger.js';
22
+ import { RenderedWorkspaceComment } from './comments.js';
23
23
  /**
24
24
  * Class for one gesture.
25
25
  */
@@ -52,6 +52,11 @@ export declare class Gesture {
52
52
  * block.
53
53
  */
54
54
  private startBlock;
55
+ /**
56
+ * The comment that the gesture started on, or null if it did not start on a
57
+ * comment.
58
+ */
59
+ private startComment;
55
60
  /**
56
61
  * The block that this gesture targets. If the gesture started on a
57
62
  * shadow block, this is the first non-shadow parent of the block. If the
@@ -77,10 +82,7 @@ export declare class Gesture {
77
82
  * Ex: [[node, name, func], [node, name, func]].
78
83
  */
79
84
  private boundEvents;
80
- /** The object tracking a bubble drag, or null if none is in progress. */
81
- private bubbleDragger;
82
- /** The object tracking a block drag, or null if none is in progress. */
83
- private blockDragger;
85
+ private dragger;
84
86
  /**
85
87
  * The object tracking a workspace or flyout workspace drag, or null if none
86
88
  * is in progress.
@@ -96,7 +98,6 @@ export declare class Gesture {
96
98
  private gestureHasStarted;
97
99
  /** Boolean used internally to break a cycle in disposal. */
98
100
  protected isEnding_: boolean;
99
- private healStack;
100
101
  /** The event that most recently updated this gesture. */
101
102
  private mostRecentEvent;
102
103
  /** Boolean for whether or not this gesture is a multi-touch gesture. */
@@ -160,30 +161,6 @@ export declare class Gesture {
160
161
  * @returns True if a block is being dragged from the flyout.
161
162
  */
162
163
  private updateIsDraggingFromFlyout;
163
- /**
164
- * Update this gesture to record whether a bubble is being dragged.
165
- * This function should be called on a pointermove event the first time
166
- * the drag radius is exceeded. It should be called no more than once per
167
- * gesture. If a bubble should be dragged this function creates the necessary
168
- * BubbleDragger and starts the drag.
169
- *
170
- * @returns True if a bubble is being dragged.
171
- */
172
- private updateIsDraggingBubble;
173
- /**
174
- * Check whether to start a block drag. If a block should be dragged, either
175
- * from the flyout or in the workspace, create the necessary BlockDragger and
176
- * start the drag.
177
- *
178
- * This function should be called on a pointermove event the first time
179
- * the drag radius is exceeded. It should be called no more than once per
180
- * gesture. If a block should be dragged, either from the flyout or in the
181
- * workspace, this function creates the necessary BlockDragger and starts the
182
- * drag.
183
- *
184
- * @returns True if a block is being dragged.
185
- */
186
- private updateIsDraggingBlock;
187
164
  /**
188
165
  * Check whether to start a workspace drag. If a workspace is being dragged,
189
166
  * create the necessary WorkspaceDragger and start the drag.
@@ -201,10 +178,7 @@ export declare class Gesture {
201
178
  * gesture.
202
179
  */
203
180
  private updateIsDragging;
204
- /** Create a block dragger and start dragging the selected block. */
205
- private startDraggingBlock;
206
- /** Create a bubble dragger and start dragging the selected bubble. */
207
- private startDraggingBubble;
181
+ private createDragger;
208
182
  /**
209
183
  * Start a gesture: update the workspace to indicate that a gesture is in
210
184
  * progress and bind pointermove and pointerup handlers.
@@ -337,8 +311,14 @@ export declare class Gesture {
337
311
  * @internal
338
312
  */
339
313
  handleBubbleStart(e: PointerEvent, bubble: IBubble): void;
340
- /** Execute a bubble click. */
341
- private doBubbleClick;
314
+ /**
315
+ * Handle a pointerdown event on a workspace comment.
316
+ *
317
+ * @param e A pointerdown event.
318
+ * @param comment The comment the event hit.
319
+ * @internal
320
+ */
321
+ handleCommentStart(e: PointerEvent, comment: RenderedWorkspaceComment): void;
342
322
  /** Execute a field click. */
343
323
  private doFieldClick;
344
324
  /** Execute an icon click. */
@@ -378,6 +358,13 @@ export declare class Gesture {
378
358
  * @internal
379
359
  */
380
360
  setStartBubble(bubble: IBubble): void;
361
+ /**
362
+ * Record the comment that a gesture started on
363
+ *
364
+ * @param comment The comment the gesture started on.
365
+ * @internal
366
+ */
367
+ setStartComment(comment: RenderedWorkspaceComment): void;
381
368
  /**
382
369
  * Record the block that a gesture started on, and set the target block
383
370
  * appropriately.
@@ -413,6 +400,7 @@ export declare class Gesture {
413
400
  * @returns Whether this gesture was a click on a bubble.
414
401
  */
415
402
  private isBubbleClick;
403
+ private isCommentClick;
416
404
  /**
417
405
  * Whether this gesture is a click on a block. This should only be called
418
406
  * when ending a gesture (pointerup).
@@ -436,6 +424,8 @@ export declare class Gesture {
436
424
  * @returns Whether this gesture was a click on a workspace.
437
425
  */
438
426
  private isWorkspaceClick;
427
+ /** Returns the current dragger if the gesture is a drag. */
428
+ getCurrentDragger(): WorkspaceDragger | IDragger | null;
439
429
  /**
440
430
  * Whether this gesture is a drag of either a workspace or block.
441
431
  * This function is called externally to block actions that cannot be taken
@@ -454,22 +444,6 @@ export declare class Gesture {
454
444
  * @internal
455
445
  */
456
446
  hasStarted(): boolean;
457
- /**
458
- * Get a list of the insertion markers that currently exist. Block drags have
459
- * 0, 1, or 2 insertion markers.
460
- *
461
- * @returns A possibly empty list of insertion marker blocks.
462
- * @internal
463
- */
464
- getInsertionMarkers(): BlockSvg[];
465
- /**
466
- * Gets the current dragger if an item is being dragged. Null if nothing is
467
- * being dragged.
468
- *
469
- * @returns The dragger that is currently in use or null if no drag is in
470
- * progress.
471
- */
472
- getCurrentDragger(): WorkspaceDragger | BubbleDragger | IBlockDragger | null;
473
447
  /**
474
448
  * Is a drag or other gesture currently in progress on any workspace?
475
449
  *
@@ -103,10 +103,15 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
103
103
  */
104
104
  private getBubbleOwnerRect;
105
105
  }
106
+ /** The save state format for a comment icon. */
106
107
  export interface CommentState {
108
+ /** The text of the comment. */
107
109
  text?: string;
110
+ /** True if the comment is open, false otherwise. */
108
111
  pinned?: boolean;
112
+ /** The height of the comment bubble. */
109
113
  height?: number;
114
+ /** The width of the comment bubble. */
110
115
  width?: number;
111
116
  }
112
117
  //# sourceMappingURL=comment_icon.d.ts.map
@@ -3,14 +3,18 @@
3
3
  * Copyright 2024 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { CommentState } from '../icons/comment_icon.js';
6
7
  import { IIcon } from './i_icon.js';
7
8
  import { Size } from '../utils/size.js';
8
9
  import { IHasBubble } from './i_has_bubble.js';
9
- export interface ICommentIcon extends IIcon, IHasBubble {
10
+ import { ISerializable } from './i_serializable.js';
11
+ export interface ICommentIcon extends IIcon, IHasBubble, ISerializable {
10
12
  setText(text: string): void;
11
13
  getText(): string;
12
14
  setBubbleSize(size: Size): void;
13
15
  getBubbleSize(): Size;
16
+ saveState(): CommentState;
17
+ loadState(state: CommentState): void;
14
18
  }
15
19
  /** Checks whether the given object is an ICommentIcon. */
16
20
  export declare function isCommentIcon(obj: Object): obj is ICommentIcon;
@@ -13,5 +13,11 @@ export interface IDeletable {
13
13
  * @returns True if deletable.
14
14
  */
15
15
  isDeletable(): boolean;
16
+ /** Disposes of this object, cleaning up any references or DOM elements. */
17
+ dispose(): void;
18
+ /** Visually indicates that the object is pending deletion. */
19
+ setDeleteStyle(wouldDelete: boolean): void;
16
20
  }
21
+ /** Returns whether the given object is an IDeletable. */
22
+ export declare function isDeletable(obj: any): obj is IDeletable;
17
23
  //# sourceMappingURL=i_deletable.d.ts.map
@@ -17,10 +17,9 @@ export interface IDeleteArea extends IDragTarget {
17
17
  * before onDragEnter/onDragOver/onDragExit.
18
18
  *
19
19
  * @param element The block or bubble currently being dragged.
20
- * @param couldConnect Whether the element could could connect to another.
21
20
  * @returns Whether the element provided would be deleted if dropped on this
22
21
  * area.
23
22
  */
24
- wouldDelete(element: IDraggable, couldConnect: boolean): boolean;
23
+ wouldDelete(element: IDraggable): boolean;
25
24
  }
26
25
  //# sourceMappingURL=i_delete_area.d.ts.map
@@ -3,10 +3,54 @@
3
3
  * Copyright 2021 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { IDeletable } from './i_deletable.js';
6
+ import { Coordinate } from '../utils/coordinate';
7
7
  /**
8
- * The interface for an object that can be dragged.
8
+ * Represents an object that can be dragged.
9
9
  */
10
- export interface IDraggable extends IDeletable {
10
+ export interface IDraggable extends IDragStrategy {
11
+ /**
12
+ * Returns the current location of the draggable in workspace
13
+ * coordinates.
14
+ *
15
+ * @returns Coordinate of current location on workspace.
16
+ */
17
+ getRelativeToSurfaceXY(): Coordinate;
11
18
  }
19
+ export interface IDragStrategy {
20
+ /** Returns true iff the element is currently movable. */
21
+ isMovable(): boolean;
22
+ /**
23
+ * Handles any drag startup (e.g moving elements to the front of the
24
+ * workspace).
25
+ *
26
+ * @param e PointerEvent that started the drag; can be used to
27
+ * check modifier keys, etc. May be missing when dragging is
28
+ * triggered programatically rather than by user.
29
+ */
30
+ startDrag(e?: PointerEvent): void;
31
+ /**
32
+ * Handles moving elements to the new location, and updating any
33
+ * visuals based on that (e.g connection previews for blocks).
34
+ *
35
+ * @param newLoc Workspace coordinate to which the draggable has
36
+ * been dragged.
37
+ * @param e PointerEvent that continued the drag. Can be
38
+ * used to check modifier keys, etc.
39
+ */
40
+ drag(newLoc: Coordinate, e?: PointerEvent): void;
41
+ /**
42
+ * Handles any drag cleanup, including e.g. connecting or deleting
43
+ * blocks.
44
+ *
45
+ * @param newLoc Workspace coordinate at which the drag finished.
46
+ * been dragged.
47
+ * @param e PointerEvent that finished the drag. Can be
48
+ * used to check modifier keys, etc.
49
+ */
50
+ endDrag(e?: PointerEvent): void;
51
+ /** Moves the draggable back to where it was at the start of the drag. */
52
+ revertDrag(): void;
53
+ }
54
+ /** Returns whether the given object is an IDraggable or not. */
55
+ export declare function isDraggable(obj: any): obj is IDraggable;
12
56
  //# sourceMappingURL=i_draggable.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Coordinate } from '../utils/coordinate';
7
+ export interface IDragger {
8
+ /**
9
+ * Handles any drag startup.
10
+ *
11
+ * @param e PointerEvent that started the drag.
12
+ */
13
+ onDragStart(e: PointerEvent): void;
14
+ /**
15
+ * Handles dragging, including calculating where the element should
16
+ * actually be moved to.
17
+ *
18
+ * @param e PointerEvent that continued the drag.
19
+ * @param totalDelta The total distance, in pixels, that the mouse
20
+ * has moved since the start of the drag.
21
+ */
22
+ onDrag(e: PointerEvent, totalDelta: Coordinate): void;
23
+ /**
24
+ * Handles any drag cleanup.
25
+ *
26
+ * @param e PointerEvent that finished the drag.
27
+ * @param totalDelta The total distance, in pixels, that the mouse
28
+ * has moved since the start of the drag.
29
+ */
30
+ onDragEnd(e: PointerEvent, totalDelta: Coordinate): void;
31
+ }
32
+ //# sourceMappingURL=i_dragger.d.ts.map