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
package/core/block.d.ts CHANGED
@@ -17,7 +17,6 @@ import type { Abstract } from './events/events_abstract.js';
17
17
  import type { Field } from './field.js';
18
18
  import { Input } from './inputs/input.js';
19
19
  import type { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
20
- import type { IDeletable } from './interfaces/i_deletable.js';
21
20
  import { type IIcon } from './interfaces/i_icon.js';
22
21
  import type { MutatorIcon } from './icons/mutator_icon.js';
23
22
  import * as Tooltip from './tooltip.js';
@@ -30,7 +29,7 @@ import { IconType } from './icons/icon_types.js';
30
29
  * Class for one block.
31
30
  * Not normally called directly, workspace.newBlock() is preferred.
32
31
  */
33
- export declare class Block implements IASTNodeLocation, IDeletable {
32
+ export declare class Block implements IASTNodeLocation {
34
33
  /**
35
34
  * An optional callback method to use whenever the block's parent workspace
36
35
  * changes. This is usually only called from the constructor, the block type
@@ -188,7 +187,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
188
187
  * statement with the previous statement. Otherwise, dispose of all
189
188
  * children of this block.
190
189
  */
191
- dispose(healStack: boolean): void;
190
+ dispose(healStack?: boolean): void;
192
191
  /**
193
192
  * Disposes of this block without doing things required by the top block.
194
193
  * E.g. does not fire events, unplug the block, etc.
@@ -18,7 +18,7 @@ import type { Input } from './inputs/input.js';
18
18
  import type { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
19
19
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
20
20
  import type { ICopyable } from './interfaces/i_copyable.js';
21
- import type { IDraggable } from './interfaces/i_draggable.js';
21
+ import type { IDragStrategy, IDraggable } from './interfaces/i_draggable.js';
22
22
  import { IIcon } from './interfaces/i_icon.js';
23
23
  import { MutatorIcon } from './icons/mutator_icon.js';
24
24
  import { RenderedConnection } from './rendered_connection.js';
@@ -30,11 +30,13 @@ import type { Workspace } from './workspace.js';
30
30
  import type { WorkspaceSvg } from './workspace_svg.js';
31
31
  import { IconType } from './icons/icon_types.js';
32
32
  import { BlockCopyData } from './clipboard/block_paster.js';
33
+ import { IDeletable } from './blockly.js';
34
+ import { FlyoutItemInfo } from './utils/toolbox.js';
33
35
  /**
34
36
  * Class for a block's SVG representation.
35
37
  * Not normally called directly, workspace.newBlock() is preferred.
36
38
  */
37
- export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBoundedElement, ICopyable<BlockCopyData>, IDraggable {
39
+ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBoundedElement, ICopyable<BlockCopyData>, IDraggable, IDeletable {
38
40
  /**
39
41
  * Constant for identifying rows that are to be rendered inline.
40
42
  * Don't collide with Blockly.inputTypes.
@@ -95,6 +97,7 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
95
97
  * @internal
96
98
  */
97
99
  relativeCoords: Coordinate;
100
+ private dragStrategy;
98
101
  /**
99
102
  * @param workspace The block's workspace.
100
103
  * @param prototypeName Name of the language object containing type-specific
@@ -120,15 +123,9 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
120
123
  * @returns #RRGGBB string.
121
124
  */
122
125
  getColourTertiary(): string | undefined;
123
- /**
124
- * Selects this block. Highlights the block visually and fires a select event
125
- * if the block is not already selected.
126
- */
126
+ /** Selects this block. Highlights the block visually. */
127
127
  select(): void;
128
- /**
129
- * Unselects this block. Unhighlights the block and fires a select (false)
130
- * event if the block is currently selected.
131
- */
128
+ /** Unselects this block. Unhighlights the blockv visually. */
132
129
  unselect(): void;
133
130
  /**
134
131
  * Sets the parent of this block to be a new block or null.
@@ -647,5 +644,21 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
647
644
  * @internal
648
645
  */
649
646
  highlightShapeForInput(conn: RenderedConnection, add: boolean): void;
647
+ /** Sets the drag strategy for this block. */
648
+ setDragStrategy(dragStrategy: IDragStrategy): void;
649
+ /** Returns whether this block is movable or not. */
650
+ isMovable(): boolean;
651
+ /** Starts a drag on the block. */
652
+ startDrag(e?: PointerEvent): void;
653
+ /** Drags the block to the given location. */
654
+ drag(newLoc: Coordinate, e?: PointerEvent): void;
655
+ /** Ends the drag on the block. */
656
+ endDrag(e?: PointerEvent): void;
657
+ /** Moves the block back to where it was at the start of a drag. */
658
+ revertDrag(): void;
659
+ /**
660
+ * Returns a representation of this block that can be displayed in a flyout.
661
+ */
662
+ toFlyoutInfo(): FlyoutItemInfo[];
650
663
  }
651
664
  //# sourceMappingURL=block_svg.d.ts.map
package/core/blockly.d.ts CHANGED
@@ -9,13 +9,11 @@ import './events/events_ui_base.js';
9
9
  import './events/events_var_create.js';
10
10
  import { Block } from './block.js';
11
11
  import * as blockAnimations from './block_animations.js';
12
- import { BlockDragger } from './block_dragger.js';
13
12
  import { BlockSvg } from './block_svg.js';
14
13
  import { BlocklyOptions } from './blockly_options.js';
15
14
  import { Blocks } from './blocks.js';
16
15
  import * as browserEvents from './browser_events.js';
17
16
  import * as bubbles from './bubbles.js';
18
- import { BubbleDragger } from './bubble_dragger.js';
19
17
  import * as bumpObjects from './bump_objects.js';
20
18
  import * as clipboard from './clipboard.js';
21
19
  import * as common from './common.js';
@@ -32,6 +30,7 @@ import * as comments from './comments.js';
32
30
  import * as Css from './css.js';
33
31
  import { DeleteArea } from './delete_area.js';
34
32
  import * as dialog from './dialog.js';
33
+ import * as dragging from './dragging.js';
35
34
  import { DragTarget } from './drag_target.js';
36
35
  import * as dropDownDiv from './dropdowndiv.js';
37
36
  import * as Events from './events/events.js';
@@ -64,7 +63,6 @@ import { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
64
63
  import { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
65
64
  import { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
66
65
  import { IAutoHideable } from './interfaces/i_autohideable.js';
67
- import { IBlockDragger } from './interfaces/i_block_dragger.js';
68
66
  import { IBoundedElement } from './interfaces/i_bounded_element.js';
69
67
  import { IBubble } from './interfaces/i_bubble.js';
70
68
  import { ICollapsibleToolboxItem } from './interfaces/i_collapsible_toolbox_item.js';
@@ -72,11 +70,12 @@ import { IComponent } from './interfaces/i_component.js';
72
70
  import { IConnectionChecker } from './interfaces/i_connection_checker.js';
73
71
  import { IConnectionPreviewer } from './interfaces/i_connection_previewer.js';
74
72
  import { IContextMenu } from './interfaces/i_contextmenu.js';
75
- import { ICopyable, isCopyable } from './interfaces/i_copyable.js';
76
- import { IDeletable } from './interfaces/i_deletable.js';
73
+ import { ICopyable, isCopyable, ICopyData } from './interfaces/i_copyable.js';
74
+ import { IDeletable, isDeletable } from './interfaces/i_deletable.js';
77
75
  import { IDeleteArea } from './interfaces/i_delete_area.js';
78
76
  import { IDragTarget } from './interfaces/i_drag_target.js';
79
- import { IDraggable } from './interfaces/i_draggable.js';
77
+ import { IDragger } from './interfaces/i_dragger.js';
78
+ import { IDraggable, isDraggable, IDragStrategy } from './interfaces/i_draggable.js';
80
79
  import { IFlyout } from './interfaces/i_flyout.js';
81
80
  import { IHasBubble, hasBubble } from './interfaces/i_has_bubble.js';
82
81
  import { IIcon, isIcon } from './interfaces/i_icon.js';
@@ -87,7 +86,8 @@ import { IObservable, isObservable } from './interfaces/i_observable.js';
87
86
  import { IPaster, isPaster } from './interfaces/i_paster.js';
88
87
  import { IPositionable } from './interfaces/i_positionable.js';
89
88
  import { IRegistrable } from './interfaces/i_registrable.js';
90
- import { ISelectable } from './interfaces/i_selectable.js';
89
+ import { IRenderedElement, isRenderedElement } from './interfaces/i_rendered_element.js';
90
+ import { ISelectable, isSelectable } from './interfaces/i_selectable.js';
91
91
  import { ISelectableToolboxItem } from './interfaces/i_selectable_toolbox_item.js';
92
92
  import { ISerializable, isSerializable } from './interfaces/i_serializable.js';
93
93
  import { IStyleable } from './interfaces/i_styleable.js';
@@ -100,6 +100,7 @@ import { Cursor } from './keyboard_nav/cursor.js';
100
100
  import { Marker } from './keyboard_nav/marker.js';
101
101
  import { TabNavigateCursor } from './keyboard_nav/tab_navigate_cursor.js';
102
102
  import { MarkerManager } from './marker_manager.js';
103
+ import type { LayerManager } from './layer_manager.js';
103
104
  import { Menu } from './menu.js';
104
105
  import { MenuItem } from './menuitem.js';
105
106
  import { MetricsManager } from './metrics_manager.js';
@@ -239,7 +240,6 @@ export declare const defineBlocksWithJsonArray: typeof common.defineBlocksWithJs
239
240
  */
240
241
  export declare const setParentContainer: typeof common.setParentContainer;
241
242
  export declare const COLLAPSE_CHARS = 30;
242
- export declare const DRAG_STACK = true;
243
243
  export declare const OPPOSITE_TYPE: number[];
244
244
  export declare const RENAME_VARIABLE_ID = "RENAME_VARIABLE_ID";
245
245
  export declare const DELETE_VARIABLE_ID = "DELETE_VARIABLE_ID";
@@ -297,11 +297,9 @@ export { ASTNode };
297
297
  export { BasicCursor };
298
298
  export { Block };
299
299
  export { BlocklyOptions };
300
- export { BlockDragger };
301
300
  export { BlockSvg };
302
301
  export { Blocks };
303
302
  export { bubbles };
304
- export { BubbleDragger };
305
303
  export { CollapsibleToolboxCategory };
306
304
  export { ComponentManager };
307
305
  export { Connection };
@@ -312,6 +310,7 @@ export { ContextMenuRegistry };
312
310
  export { comments };
313
311
  export { Cursor };
314
312
  export { DeleteArea };
313
+ export { dragging };
315
314
  export { DragTarget };
316
315
  export declare const DropDownDiv: typeof dropDownDiv;
317
316
  export { Field, FieldConfig, FieldValidator, UnattachedFieldError };
@@ -335,7 +334,6 @@ export { IASTNodeLocation };
335
334
  export { IASTNodeLocationSvg };
336
335
  export { IASTNodeLocationWithBlock };
337
336
  export { IAutoHideable };
338
- export { IBlockDragger };
339
337
  export { IBoundedElement };
340
338
  export { IBubble };
341
339
  export { ICollapsibleToolboxItem };
@@ -344,11 +342,12 @@ export { IConnectionChecker };
344
342
  export { IConnectionPreviewer };
345
343
  export { IContextMenu };
346
344
  export { icons };
347
- export { ICopyable, isCopyable };
348
- export { IDeletable };
345
+ export { ICopyable, isCopyable, ICopyData };
346
+ export { IDeletable, isDeletable };
349
347
  export { IDeleteArea };
350
348
  export { IDragTarget };
351
- export { IDraggable };
349
+ export { IDragger };
350
+ export { IDraggable, isDraggable, IDragStrategy };
352
351
  export { IFlyout };
353
352
  export { IHasBubble, hasBubble };
354
353
  export { IIcon, isIcon };
@@ -363,7 +362,8 @@ export { IObservable, isObservable };
363
362
  export { IPaster, isPaster };
364
363
  export { IPositionable };
365
364
  export { IRegistrable };
366
- export { ISelectable };
365
+ export { IRenderedElement, isRenderedElement };
366
+ export { ISelectable, isSelectable };
367
367
  export { ISelectableToolboxItem };
368
368
  export { ISerializable, isSerializable };
369
369
  export { IStyleable };
@@ -372,6 +372,7 @@ export { IToolboxItem };
372
372
  export { IVariableBackedParameterModel, isVariableBackedParameterModel };
373
373
  export { Marker };
374
374
  export { MarkerManager };
375
+ export { LayerManager };
375
376
  export { Menu };
376
377
  export { MenuItem };
377
378
  export { MetricsManager };
@@ -8,13 +8,14 @@ import { Coordinate } from '../utils/coordinate.js';
8
8
  import { Rect } from '../utils/rect.js';
9
9
  import { Size } from '../utils/size.js';
10
10
  import { WorkspaceSvg } from '../workspace_svg.js';
11
+ import { ISelectable } from '../blockly.js';
11
12
  /**
12
13
  * The abstract pop-up bubble class. This creates a UI that looks like a speech
13
14
  * bubble, where it has a "tail" that points to the block, and a "head" that
14
15
  * displays arbitrary svg elements.
15
16
  */
16
- export declare abstract class Bubble implements IBubble {
17
- protected readonly workspace: WorkspaceSvg;
17
+ export declare abstract class Bubble implements IBubble, ISelectable {
18
+ readonly workspace: WorkspaceSvg;
18
19
  protected anchor: Coordinate;
19
20
  protected ownerRect?: Rect | undefined;
20
21
  /** The width of the border around the bubble. */
@@ -37,6 +38,7 @@ export declare abstract class Bubble implements IBubble {
37
38
  static readonly TAIL_BEND = 4;
38
39
  /** Distance between arrow point and anchor point. */
39
40
  static readonly ANCHOR_RADIUS = 8;
41
+ id: string;
40
42
  /** The SVG group containing all parts of the bubble. */
41
43
  protected svgRoot: SVGGElement;
42
44
  /** The SVG path for the arrow from the anchor to the bubble. */
@@ -57,6 +59,7 @@ export declare abstract class Bubble implements IBubble {
57
59
  private relativeTop;
58
60
  /** The position of the left of the bubble realtive to its anchor. */
59
61
  private relativeLeft;
62
+ private dragStrategy;
60
63
  /**
61
64
  * @param workspace The workspace this bubble belongs to.
62
65
  * @param anchor The anchor location of the thing this bubble is attached to.
@@ -175,5 +178,17 @@ export declare abstract class Bubble implements IBubble {
175
178
  isDeletable(): boolean;
176
179
  /** @internal */
177
180
  showContextMenu(_e: Event): void;
181
+ /** Returns whether this bubble is movable or not. */
182
+ isMovable(): boolean;
183
+ /** Starts a drag on the bubble. */
184
+ startDrag(): void;
185
+ /** Drags the bubble to the given location. */
186
+ drag(newLoc: Coordinate): void;
187
+ /** Ends the drag on the bubble. */
188
+ endDrag(): void;
189
+ /** Moves the bubble back to where it was at the start of a drag. */
190
+ revertDrag(): void;
191
+ select(): void;
192
+ unselect(): void;
178
193
  }
179
194
  //# sourceMappingURL=bubble.d.ts.map
@@ -15,7 +15,7 @@ import type { WorkspaceSvg } from '../workspace_svg.js';
15
15
  * Used by the mutator icon.
16
16
  */
17
17
  export declare class MiniWorkspaceBubble extends Bubble {
18
- protected readonly workspace: WorkspaceSvg;
18
+ readonly workspace: WorkspaceSvg;
19
19
  protected anchor: Coordinate;
20
20
  protected ownerRect?: Rect | undefined;
21
21
  /**
@@ -12,7 +12,7 @@ import { WorkspaceSvg } from '../workspace_svg.js';
12
12
  */
13
13
  export declare class TextBubble extends Bubble {
14
14
  private text;
15
- protected readonly workspace: WorkspaceSvg;
15
+ readonly workspace: WorkspaceSvg;
16
16
  protected anchor: Coordinate;
17
17
  protected ownerRect?: Rect | undefined;
18
18
  private paragraph;
@@ -13,7 +13,7 @@ import { WorkspaceSvg } from '../workspace_svg.js';
13
13
  * Used by the comment icon.
14
14
  */
15
15
  export declare class TextInputBubble extends Bubble {
16
- protected readonly workspace: WorkspaceSvg;
16
+ readonly workspace: WorkspaceSvg;
17
17
  protected anchor: Coordinate;
18
18
  protected ownerRect?: Rect | undefined;
19
19
  /** The root of the elements specific to the text element. */
@@ -11,8 +11,14 @@ export declare class CommentView implements IRenderedElement {
11
11
  private readonly workspace;
12
12
  /** The root group element of the comment view. */
13
13
  private svgRoot;
14
+ /**
15
+ * The svg rect element that we use to create a hightlight around the comment.
16
+ */
17
+ private highlightRect;
18
+ /** The group containing all of the top bar elements. */
19
+ private topBarGroup;
14
20
  /** The rect background for the top bar. */
15
- private topBar;
21
+ private topBarBackground;
16
22
  /** The delete icon that goes in the top bar. */
17
23
  private deleteIcon;
18
24
  /** The foldout icon that goes in the top bar. */
@@ -60,6 +66,10 @@ export declare class CommentView implements IRenderedElement {
60
66
  /** Whether this comment view has been disposed or not. */
61
67
  private disposed;
62
68
  constructor(workspace: WorkspaceSvg);
69
+ /**
70
+ * Creates the rect we use for highlighting the comment when it's selected.
71
+ */
72
+ private createHighlightRect;
63
73
  /**
64
74
  * Creates the top bar and the elements visually within it.
65
75
  * Registers event listeners.
@@ -93,6 +103,8 @@ export declare class CommentView implements IRenderedElement {
93
103
  private calcDeleteMargin;
94
104
  /** Calculates the margin that should exist around the foldout icon. */
95
105
  private calcFoldoutMargin;
106
+ /** Updates the size of the top bar to reflect the new size. */
107
+ private updateTopBarSize;
96
108
  /** Updates the size of the text area elements to reflect the new size. */
97
109
  private updateTextAreaSize;
98
110
  /**
@@ -107,6 +119,8 @@ export declare class CommentView implements IRenderedElement {
107
119
  * Updates the size and position of the text preview elements to reflect the new size.
108
120
  */
109
121
  private updateTextPreviewSize;
122
+ /** Updates the position of the resize handle to reflect the new size. */
123
+ private updateResizeHandlePosition;
110
124
  /**
111
125
  * Triggers listeners when the size of the comment changes, either
112
126
  * progrmatically or manually by the user.
@@ -10,9 +10,14 @@ import { Rect } from '../utils/rect.js';
10
10
  import { Size } from '../utils/size.js';
11
11
  import { IBoundedElement } from '../interfaces/i_bounded_element.js';
12
12
  import { IRenderedElement } from '../interfaces/i_rendered_element.js';
13
- export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement {
13
+ import { IDraggable } from '../interfaces/i_draggable.js';
14
+ import { ISelectable } from '../interfaces/i_selectable.js';
15
+ import { IDeletable } from '../interfaces/i_deletable.js';
16
+ export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement, IDraggable, ISelectable, IDeletable {
14
17
  /** The class encompassing the svg elements making up the workspace comment. */
15
18
  private view;
19
+ readonly workspace: WorkspaceSvg;
20
+ private dragStrategy;
16
21
  /** Constructs the workspace comment, including the view. */
17
22
  constructor(workspace: WorkspaceSvg, id?: string);
18
23
  /**
@@ -33,10 +38,45 @@ export declare class RenderedWorkspaceComment extends WorkspaceComment implement
33
38
  /** Returns the bounding rectangle of this comment in workspace coordinates. */
34
39
  getBoundingRectangle(): Rect;
35
40
  /** Move the comment by the given amounts in workspace coordinates. */
36
- moveBy(dx: number, dy: number, _reason?: string[] | undefined): void;
41
+ moveBy(dx: number, dy: number, reason?: string[] | undefined): void;
37
42
  /** Moves the comment to the given location in workspace coordinates. */
38
- moveTo(location: Coordinate): void;
43
+ moveTo(location: Coordinate, reason?: string[] | undefined): void;
44
+ /**
45
+ * Moves the comment during a drag. Doesn't fire move events.
46
+ *
47
+ * @internal
48
+ */
49
+ moveDuringDrag(location: Coordinate): void;
50
+ /**
51
+ * Adds the dragging CSS class to this comment.
52
+ *
53
+ * @internal
54
+ */
55
+ setDragging(dragging: boolean): void;
39
56
  /** Disposes of the view. */
40
57
  dispose(): void;
58
+ /**
59
+ * Starts a gesture because we detected a pointer down on the comment
60
+ * (that wasn't otherwise gobbled up, e.g. by resizing).
61
+ */
62
+ private startGesture;
63
+ /** Returns whether this comment is deletable or not. */
64
+ isDeletable(): boolean;
65
+ /** Visually indicates that this comment would be deleted if dropped. */
66
+ setDeleteStyle(wouldDelete: boolean): void;
67
+ /** Returns whether this comment is movable or not. */
68
+ isMovable(): boolean;
69
+ /** Starts a drag on the comment. */
70
+ startDrag(): void;
71
+ /** Drags the comment to the given location. */
72
+ drag(newLoc: Coordinate): void;
73
+ /** Ends the drag on the comment. */
74
+ endDrag(): void;
75
+ /** Moves the comment back to where it was at the start of a drag. */
76
+ revertDrag(): void;
77
+ /** Visually highlights the comment. */
78
+ select(): void;
79
+ /** Visually unhighlights the comment. */
80
+ unselect(): void;
41
81
  }
42
82
  //# sourceMappingURL=rendered_workspace_comment.d.ts.map
@@ -7,7 +7,7 @@ import { Workspace } from '../workspace.js';
7
7
  import { Size } from '../utils/size.js';
8
8
  import { Coordinate } from '../utils/coordinate.js';
9
9
  export declare class WorkspaceComment {
10
- protected readonly workspace: Workspace;
10
+ readonly workspace: Workspace;
11
11
  /** The unique identifier for this comment. */
12
12
  readonly id: string;
13
13
  /** The text of the comment. */
@@ -23,7 +23,7 @@ export declare class WorkspaceComment {
23
23
  /** Whether the comment is deletable or not. */
24
24
  private deletable;
25
25
  /** The location of the comment in workspace coordinates. */
26
- private location;
26
+ protected location: Coordinate;
27
27
  /** Whether this comment has been disposed or not. */
28
28
  protected disposed: boolean;
29
29
  /** Whether this comment is being disposed or not. */
@@ -36,6 +36,12 @@ export declare class WorkspaceComment {
36
36
  * be generated.
37
37
  */
38
38
  constructor(workspace: Workspace, id?: string);
39
+ private fireCreateEvent;
40
+ private fireDeleteEvent;
41
+ /** Fires a comment change event. */
42
+ private fireChangeEvent;
43
+ /** Fires a comment collapse event. */
44
+ private fireCollapseEvent;
39
45
  /** Sets the text of the comment. */
40
46
  setText(text: string): void;
41
47
  /** Returns the text of the comment. */
@@ -85,7 +91,7 @@ export declare class WorkspaceComment {
85
91
  */
86
92
  isOwnDeletable(): boolean;
87
93
  /** Moves the comment to the given location in workspace coordinates. */
88
- moveTo(location: Coordinate): void;
94
+ moveTo(location: Coordinate, reason?: string[] | undefined): void;
89
95
  /** Returns the position of the comment in workspace coordinates. */
90
96
  getRelativeToSurfaceXY(): Coordinate;
91
97
  /** Disposes of this comment. */
@@ -111,7 +111,7 @@ export declare class Connection implements IASTNodeLocationWithBlock {
111
111
  * Connect this connection to another connection.
112
112
  *
113
113
  * @param otherConnection Connection to connect to.
114
- * @returns Whether the the blocks are now connected or not.
114
+ * @returns Whether the blocks are now connected or not.
115
115
  */
116
116
  connect(otherConnection: Connection): boolean;
117
117
  /**
@@ -34,11 +34,10 @@ export declare class DeleteArea extends DragTarget implements IDeleteArea {
34
34
  * before onDragEnter/onDragOver/onDragExit.
35
35
  *
36
36
  * @param element The block or bubble currently being dragged.
37
- * @param couldConnect Whether the element could could connect to another.
38
37
  * @returns Whether the element provided would be deleted if dropped on this
39
38
  * area.
40
39
  */
41
- wouldDelete(element: IDraggable, couldConnect: boolean): boolean;
40
+ wouldDelete(element: IDraggable): boolean;
42
41
  /**
43
42
  * Updates the internal wouldDelete_ state.
44
43
  *
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { IDragStrategy } from '../interfaces/i_draggable.js';
7
+ import { Coordinate } from '../utils.js';
8
+ import { BlockSvg } from '../block_svg.js';
9
+ export declare class BlockDragStrategy implements IDragStrategy {
10
+ private block;
11
+ private workspace;
12
+ /** The parent block at the start of the drag. */
13
+ private startParentConn;
14
+ /**
15
+ * The child block at the start of the drag. Only gets set if
16
+ * `healStack` is true.
17
+ */
18
+ private startChildConn;
19
+ private startLoc;
20
+ private connectionCandidate;
21
+ private connectionPreviewer;
22
+ private dragging;
23
+ /**
24
+ * If this is a shadow block, the offset between this block and the parent
25
+ * block, to add to the drag location. In workspace units.
26
+ */
27
+ private dragOffset;
28
+ constructor(block: BlockSvg);
29
+ /** Returns true if the block is currently movable. False otherwise. */
30
+ isMovable(): boolean;
31
+ /**
32
+ * Handles any setup for starting the drag, including disconnecting the block
33
+ * from any parent blocks.
34
+ */
35
+ startDrag(e?: PointerEvent): void;
36
+ /** Starts a drag on a shadow, recording the drag offset. */
37
+ private startDraggingShadow;
38
+ /**
39
+ * Whether or not we should disconnect the block when a drag is started.
40
+ *
41
+ * @param healStack Whether or not to heal the stack after disconnecting.
42
+ * @returns True to disconnect the block, false otherwise.
43
+ */
44
+ private shouldDisconnect;
45
+ /**
46
+ * Disconnects the block from any parents. If `healStack` is true and this is
47
+ * a stack block, we also disconnect from any next blocks and attempt to
48
+ * attach them to any parent.
49
+ *
50
+ * @param healStack Whether or not to heal the stack after disconnecting.
51
+ */
52
+ private disconnectBlock;
53
+ /** Fire a UI event at the start of a block drag. */
54
+ private fireDragStartEvent;
55
+ /** Fire a UI event at the end of a block drag. */
56
+ private fireDragEndEvent;
57
+ /** Fire a move event at the end of a block drag. */
58
+ private fireMoveEvent;
59
+ /** Moves the block and updates any connection previews. */
60
+ drag(newLoc: Coordinate): void;
61
+ /**
62
+ * @param draggingBlock The block being dragged.
63
+ * @param delta How far the pointer has moved from the position
64
+ * at the start of the drag, in workspace units.
65
+ */
66
+ private updateConnectionPreview;
67
+ /**
68
+ * Returns true if the given orphan block can connect at the end of the
69
+ * top block's stack or row, false otherwise.
70
+ */
71
+ private orphanCanConnectAtEnd;
72
+ /**
73
+ * Returns true if the current candidate is better than the new candidate.
74
+ *
75
+ * We slightly prefer the current candidate even if it is farther away.
76
+ */
77
+ private currCandidateIsBetter;
78
+ /**
79
+ * Returns the closest valid candidate connection, if one can be found.
80
+ *
81
+ * Valid neighbour connections are within the configured start radius, with a
82
+ * compatible type (input, output, etc) and connection check.
83
+ */
84
+ private getConnectionCandidate;
85
+ /**
86
+ * Returns all of the connections we might connect to blocks on the workspace.
87
+ *
88
+ * Includes any connections on the dragging block, and any last next
89
+ * connection on the stack (if one exists).
90
+ */
91
+ private getLocalConnections;
92
+ /**
93
+ * Cleans up any state at the end of the drag. Applies any pending
94
+ * connections.
95
+ */
96
+ endDrag(e?: PointerEvent): void;
97
+ /** Connects the given candidate connections. */
98
+ private applyConnections;
99
+ /**
100
+ * Moves the block back to where it was at the beginning of the drag,
101
+ * including reconnecting connections.
102
+ */
103
+ revertDrag(): void;
104
+ }
105
+ //# sourceMappingURL=block_drag_strategy.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { IDragStrategy } from '../interfaces/i_draggable.js';
7
+ import { Coordinate } from '../utils.js';
8
+ import { IBubble, WorkspaceSvg } from '../blockly.js';
9
+ export declare class BubbleDragStrategy implements IDragStrategy {
10
+ private bubble;
11
+ private workspace;
12
+ private startLoc;
13
+ constructor(bubble: IBubble, workspace: WorkspaceSvg);
14
+ isMovable(): boolean;
15
+ startDrag(): void;
16
+ drag(newLoc: Coordinate): void;
17
+ endDrag(): void;
18
+ revertDrag(): void;
19
+ }
20
+ //# sourceMappingURL=bubble_drag_strategy.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { IDragStrategy } from '../interfaces/i_draggable.js';
7
+ import { Coordinate } from '../utils.js';
8
+ import { RenderedWorkspaceComment } from '../comments.js';
9
+ export declare class CommentDragStrategy implements IDragStrategy {
10
+ private comment;
11
+ private startLoc;
12
+ private workspace;
13
+ constructor(comment: RenderedWorkspaceComment);
14
+ isMovable(): boolean;
15
+ startDrag(): void;
16
+ drag(newLoc: Coordinate): void;
17
+ endDrag(): void;
18
+ revertDrag(): void;
19
+ }
20
+ //# sourceMappingURL=comment_drag_strategy.d.ts.map