blockly 11.2.0-beta.2 → 12.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/blockly.min.js +700 -698
  2. package/blockly.mjs +5 -1
  3. package/blockly_compressed.js +688 -686
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +12 -12
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +3 -3
  8. package/core/block_flyout_inflater.d.ts +89 -0
  9. package/core/block_svg.d.ts +18 -0
  10. package/core/blockly.d.ts +11 -4
  11. package/core/bubbles/textinput_bubble.d.ts +9 -0
  12. package/core/button_flyout_inflater.d.ts +36 -0
  13. package/core/clipboard.d.ts +2 -2
  14. package/core/comments/comment_view.d.ts +4 -0
  15. package/core/comments/rendered_workspace_comment.d.ts +2 -0
  16. package/core/dropdowndiv.d.ts +1 -1
  17. package/core/events/events.d.ts +1 -0
  18. package/core/events/events_var_base.d.ts +2 -2
  19. package/core/events/events_var_create.d.ts +7 -2
  20. package/core/events/events_var_delete.d.ts +2 -2
  21. package/core/events/events_var_rename.d.ts +2 -2
  22. package/core/events/events_var_type_change.d.ts +55 -0
  23. package/core/events/type.d.ts +2 -0
  24. package/core/field.d.ts +0 -13
  25. package/core/field_checkbox.d.ts +0 -4
  26. package/core/field_dropdown.d.ts +0 -2
  27. package/core/field_input.d.ts +0 -2
  28. package/core/field_number.d.ts +6 -0
  29. package/core/field_textinput.d.ts +1 -0
  30. package/core/field_variable.d.ts +9 -2
  31. package/core/flyout_base.d.ts +47 -176
  32. package/core/flyout_button.d.ts +25 -6
  33. package/core/flyout_horizontal.d.ts +2 -3
  34. package/core/flyout_separator.d.ts +45 -0
  35. package/core/flyout_vertical.d.ts +3 -4
  36. package/core/grid.d.ts +4 -1
  37. package/core/icons/comment_icon.d.ts +15 -0
  38. package/core/interfaces/i_comment_icon.d.ts +3 -0
  39. package/core/interfaces/i_flyout_inflater.d.ts +39 -0
  40. package/core/interfaces/i_toolbox.d.ts +8 -1
  41. package/core/interfaces/i_variable_backed_parameter_model.d.ts +2 -2
  42. package/core/interfaces/i_variable_map.d.ts +48 -0
  43. package/core/interfaces/i_variable_model.d.ts +36 -0
  44. package/core/label_flyout_inflater.d.ts +36 -0
  45. package/core/menuitem.d.ts +0 -7
  46. package/core/names.d.ts +8 -2
  47. package/core/registry.d.ts +6 -0
  48. package/core/renderers/common/constants.d.ts +6 -1
  49. package/core/renderers/common/i_path_object.d.ts +13 -13
  50. package/core/renderers/common/renderer.d.ts +12 -17
  51. package/core/renderers/geras/renderer.d.ts +1 -1
  52. package/core/renderers/zelos/constants.d.ts +8 -2
  53. package/core/renderers/zelos/renderer.d.ts +0 -7
  54. package/core/separator_flyout_inflater.d.ts +47 -0
  55. package/core/serialization/variables.d.ts +3 -10
  56. package/core/toolbox/toolbox.d.ts +2 -5
  57. package/core/variable_map.d.ts +27 -29
  58. package/core/variable_model.d.ts +37 -11
  59. package/core/variables.d.ts +38 -8
  60. package/core/widgetdiv.d.ts +2 -2
  61. package/core/workspace.d.ts +21 -19
  62. package/core/workspace_svg.d.ts +33 -6
  63. package/core/xml.d.ts +2 -2
  64. package/index.mjs +5 -1
  65. package/package.json +1 -1
  66. package/php_compressed.js +1 -1
  67. package/php_compressed.js.map +1 -1
  68. package/python_compressed.js +1 -1
  69. package/python_compressed.js.map +1 -1
  70. package/core/insertion_marker_manager.d.ts +0 -249
@@ -12,10 +12,10 @@ import './events/events_block_change.js';
12
12
  import type { Block } from './block.js';
13
13
  import { Field, FieldConfig } from './field.js';
14
14
  import { FieldDropdown, FieldDropdownValidator, MenuGenerator, MenuOption } from './field_dropdown.js';
15
+ import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
15
16
  import type { Menu } from './menu.js';
16
17
  import type { MenuItem } from './menuitem.js';
17
18
  import { Size } from './utils/size.js';
18
- import { VariableModel } from './variable_model.js';
19
19
  /**
20
20
  * Class for a variable's dropdown field.
21
21
  */
@@ -69,6 +69,7 @@ export declare class FieldVariable extends FieldDropdown {
69
69
  * a variable rather than let the value be invalid.
70
70
  */
71
71
  initModel(): void;
72
+ initView(): void;
72
73
  shouldAddBorderRect_(): boolean;
73
74
  /**
74
75
  * Initialize this field based on the given XML.
@@ -129,7 +130,13 @@ export declare class FieldVariable extends FieldDropdown {
129
130
  * @returns The selected variable, or null if none was selected.
130
131
  * @internal
131
132
  */
132
- getVariable(): VariableModel | null;
133
+ getVariable(): IVariableModel<IVariableState> | null;
134
+ /**
135
+ * Gets the type of this field's default variable.
136
+ *
137
+ * @returns The default type for this variable field.
138
+ */
139
+ protected getDefaultType(): string;
133
140
  /**
134
141
  * Gets the validation function for this field, or null if not set.
135
142
  * Returns null if the variable is not set, because validators should not
@@ -3,21 +3,23 @@
3
3
  * Copyright 2011 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ /**
7
+ * Flyout tray containing blocks which may be created.
8
+ *
9
+ * @class
10
+ */
6
11
  import { BlockSvg } from './block_svg.js';
7
12
  import { DeleteArea } from './delete_area.js';
8
- import { FlyoutButton } from './flyout_button.js';
9
13
  import { IAutoHideable } from './interfaces/i_autohideable.js';
14
+ import type { IBoundedElement } from './interfaces/i_bounded_element.js';
10
15
  import type { IFlyout } from './interfaces/i_flyout.js';
16
+ import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
11
17
  import type { Options } from './options.js';
12
18
  import * as blocks from './serialization/blocks.js';
13
19
  import { Coordinate } from './utils/coordinate.js';
14
20
  import { Svg } from './utils/svg.js';
15
21
  import * as toolbox from './utils/toolbox.js';
16
22
  import { WorkspaceSvg } from './workspace_svg.js';
17
- declare enum FlyoutItemType {
18
- BLOCK = "block",
19
- BUTTON = "button"
20
- }
21
23
  /**
22
24
  * Class for a flyout.
23
25
  */
@@ -48,12 +50,11 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
48
50
  y?: number;
49
51
  }): void;
50
52
  /**
51
- * Lay out the blocks in the flyout.
53
+ * Lay out the elements in the flyout.
52
54
  *
53
- * @param contents The blocks and buttons to lay out.
54
- * @param gaps The visible gaps between blocks.
55
+ * @param contents The flyout elements to lay out.
55
56
  */
56
- protected abstract layout_(contents: FlyoutItem[], gaps: number[]): void;
57
+ protected abstract layout_(contents: FlyoutItem[]): void;
57
58
  /**
58
59
  * Scroll the flyout.
59
60
  *
@@ -61,8 +62,8 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
61
62
  */
62
63
  protected abstract wheel_(e: WheelEvent): void;
63
64
  /**
64
- * Compute height of flyout. Position mat under each block.
65
- * For RTL: Lay out the blocks right-aligned.
65
+ * Compute bounds of flyout.
66
+ * For RTL: Lay out the elements right-aligned.
66
67
  */
67
68
  protected abstract reflowInternal_(): void;
68
69
  /**
@@ -81,10 +82,6 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
81
82
  * Scroll the flyout to the beginning of its contents.
82
83
  */
83
84
  abstract scrollToStart(): void;
84
- /**
85
- * The type of a flyout content item.
86
- */
87
- static FlyoutItemType: typeof FlyoutItemType;
88
85
  protected workspace_: WorkspaceSvg;
89
86
  RTL: boolean;
90
87
  /**
@@ -102,36 +99,13 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
102
99
  private boundEvents;
103
100
  /**
104
101
  * Function that will be registered as a change listener on the workspace
105
- * to reflow when blocks in the flyout workspace change.
102
+ * to reflow when elements in the flyout workspace change.
106
103
  */
107
104
  private reflowWrapper;
108
105
  /**
109
- * Function that disables blocks in the flyout based on max block counts
110
- * allowed in the target workspace. Registered as a change listener on the
111
- * target workspace.
112
- */
113
- private filterWrapper;
114
- /**
115
- * List of background mats that lurk behind each block to catch clicks
116
- * landing in the blocks' lakes and bays.
117
- */
118
- private mats;
119
- /**
120
- * List of visible buttons.
121
- */
122
- protected buttons_: FlyoutButton[];
123
- /**
124
- * List of visible buttons and blocks.
106
+ * List of flyout elements.
125
107
  */
126
108
  protected contents: FlyoutItem[];
127
- /**
128
- * List of event listeners.
129
- */
130
- private listeners;
131
- /**
132
- * List of blocks that should always be disabled.
133
- */
134
- private permanentlyDisabled;
135
109
  protected readonly tabWidth_: number;
136
110
  /**
137
111
  * The target workspace.
@@ -139,10 +113,6 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
139
113
  * @internal
140
114
  */
141
115
  targetWorkspace: WorkspaceSvg;
142
- /**
143
- * A list of blocks that can be reused.
144
- */
145
- private recycledBlocks;
146
116
  /**
147
117
  * Does the flyout automatically close when a block is created?
148
118
  */
@@ -155,7 +125,6 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
155
125
  * Whether the workspace containing this flyout is visible.
156
126
  */
157
127
  private containerVisible;
158
- protected rectMap_: WeakMap<BlockSvg, SVGElement>;
159
128
  /**
160
129
  * Corner radius of the flyout background.
161
130
  */
@@ -205,6 +174,11 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
205
174
  * The root SVG group for the button or label.
206
175
  */
207
176
  protected svgGroup_: SVGGElement | null;
177
+ /**
178
+ * Map from flyout content type to the corresponding inflater class
179
+ * responsible for creating concrete instances of the content type.
180
+ */
181
+ protected inflaters: Map<string, IFlyoutInflater>;
208
182
  /**
209
183
  * @param workspaceOptions Dictionary of options for the
210
184
  * workspace.
@@ -291,13 +265,13 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
291
265
  */
292
266
  setContainerVisible(visible: boolean): void;
293
267
  /**
294
- * Get the list of buttons and blocks of the current flyout.
268
+ * Get the list of elements of the current flyout.
295
269
  *
296
- * @returns The array of flyout buttons and blocks.
270
+ * @returns The array of flyout elements.
297
271
  */
298
272
  getContents(): FlyoutItem[];
299
273
  /**
300
- * Store the list of buttons and blocks on the flyout.
274
+ * Store the list of elements on the flyout.
301
275
  *
302
276
  * @param contents - The array of items for the flyout.
303
277
  */
@@ -334,9 +308,21 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
334
308
  *
335
309
  * @param parsedContent The array
336
310
  * of objects to show in the flyout.
337
- * @returns The list of contents and gaps needed to lay out the flyout.
311
+ * @returns The list of contents needed to lay out the flyout.
338
312
  */
339
313
  private createFlyoutInfo;
314
+ /**
315
+ * Updates and returns the provided list of flyout contents to flatten
316
+ * separators as needed.
317
+ *
318
+ * When multiple separators occur one after another, the value of the last one
319
+ * takes precedence and the earlier separators in the group are removed.
320
+ *
321
+ * @param contents The list of flyout contents to flatten separators in.
322
+ * @returns An updated list of flyout contents with only one separator between
323
+ * each non-separator item.
324
+ */
325
+ protected normalizeSeparators(contents: FlyoutItem[]): FlyoutItem[];
340
326
  /**
341
327
  * Gets the flyout definition for the dynamic category.
342
328
  *
@@ -346,89 +332,9 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
346
332
  */
347
333
  private getDynamicCategoryContents;
348
334
  /**
349
- * Creates a flyout button or a flyout label.
350
- *
351
- * @param btnInfo The object holding information about a button or a label.
352
- * @param isLabel True if the button is a label, false otherwise.
353
- * @returns The object used to display the button in the
354
- * flyout.
355
- */
356
- private createButton;
357
- /**
358
- * Create a block from the xml and permanently disable any blocks that were
359
- * defined as disabled.
360
- *
361
- * @param blockInfo The info of the block.
362
- * @returns The block created from the blockInfo.
363
- */
364
- private createFlyoutBlock;
365
- /**
366
- * Returns a block from the array of recycled blocks with the given type, or
367
- * undefined if one cannot be found.
368
- *
369
- * @param blockType The type of the block to try to recycle.
370
- * @returns The recycled block, or undefined if
371
- * one could not be recycled.
372
- */
373
- private getRecycledBlock;
374
- /**
375
- * Adds a gap in the flyout based on block info.
376
- *
377
- * @param blockInfo Information about a block.
378
- * @param gaps The list of gaps between items in the flyout.
379
- * @param defaultGap The default gap between one element and the
380
- * next.
381
- */
382
- private addBlockGap;
383
- /**
384
- * Add the necessary gap in the flyout for a separator.
385
- *
386
- * @param sepInfo The object holding
387
- * information about a separator.
388
- * @param gaps The list gaps between items in the flyout.
389
- * @param defaultGap The default gap between the button and next
390
- * element.
391
- */
392
- private addSeparatorGap;
393
- /**
394
- * Delete blocks, mats and buttons from a previous showing of the flyout.
335
+ * Delete elements from a previous showing of the flyout.
395
336
  */
396
337
  private clearOldBlocks;
397
- /**
398
- * Empties all of the recycled blocks, properly disposing of them.
399
- */
400
- private emptyRecycledBlocks;
401
- /**
402
- * Returns whether the given block can be recycled or not.
403
- *
404
- * @param _block The block to check for recyclability.
405
- * @returns True if the block can be recycled. False otherwise.
406
- */
407
- protected blockIsRecyclable_(_block: BlockSvg): boolean;
408
- /**
409
- * Puts a previously created block into the recycle bin and moves it to the
410
- * top of the workspace. Used during large workspace swaps to limit the number
411
- * of new DOM elements we need to create.
412
- *
413
- * @param block The block to recycle.
414
- */
415
- private recycleBlock;
416
- /**
417
- * Add listeners to a block that has been added to the flyout.
418
- *
419
- * @param root The root node of the SVG group the block is in.
420
- * @param block The block to add listeners for.
421
- * @param rect The invisible rectangle under the block that acts
422
- * as a mat for that block.
423
- */
424
- protected addBlockListeners_(root: SVGElement, block: BlockSvg, rect: SVGElement): void;
425
- /**
426
- * Handle a pointerdown on an SVG block in a non-closing flyout.
427
- *
428
- * @param block The flyout block to copy.
429
- * @returns Function to call when block is clicked.
430
- */
431
- private blockMouseDown;
432
338
  /**
433
339
  * Pointer down on the flyout background. Start a vertical scroll drag.
434
340
  *
@@ -455,48 +361,7 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
455
361
  */
456
362
  createBlock(originalBlock: BlockSvg): BlockSvg;
457
363
  /**
458
- * Initialize the given button: move it to the correct location,
459
- * add listeners, etc.
460
- *
461
- * @param button The button to initialize and place.
462
- * @param x The x position of the cursor during this layout pass.
463
- * @param y The y position of the cursor during this layout pass.
464
- */
465
- protected initFlyoutButton_(button: FlyoutButton, x: number, y: number): void;
466
- /**
467
- * Create and place a rectangle corresponding to the given block.
468
- *
469
- * @param block The block to associate the rect to.
470
- * @param x The x position of the cursor during this layout pass.
471
- * @param y The y position of the cursor during this layout pass.
472
- * @param blockHW The height and width of
473
- * the block.
474
- * @param index The index into the mats list where this rect should
475
- * be placed.
476
- * @returns Newly created SVG element for the rectangle behind
477
- * the block.
478
- */
479
- protected createRect_(block: BlockSvg, x: number, y: number, blockHW: {
480
- height: number;
481
- width: number;
482
- }, index: number): SVGElement;
483
- /**
484
- * Move a rectangle to sit exactly behind a block, taking into account tabs,
485
- * hats, and any other protrusions we invent.
486
- *
487
- * @param rect The rectangle to move directly behind the block.
488
- * @param block The block the rectangle should be behind.
489
- */
490
- protected moveRectToBlock_(rect: SVGElement, block: BlockSvg): void;
491
- /**
492
- * Filter the blocks on the flyout to disable the ones that are above the
493
- * capacity limit. For instance, if the user may only place two more blocks
494
- * on the workspace, an "a + b" block that has two shadow blocks would be
495
- * disabled.
496
- */
497
- private filterForCapacity;
498
- /**
499
- * Reflow blocks and their mats.
364
+ * Reflow flyout contents.
500
365
  */
501
366
  reflow(): void;
502
367
  /**
@@ -526,14 +391,20 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
526
391
  * @param block The block to posiiton.
527
392
  */
528
393
  private positionNewBlock;
394
+ /**
395
+ * Returns the inflater responsible for constructing items of the given type.
396
+ *
397
+ * @param type The type of flyout content item to provide an inflater for.
398
+ * @returns An inflater object for the given type, or null if no inflater
399
+ * is registered for that type.
400
+ */
401
+ protected getInflaterForType(type: string): IFlyoutInflater | null;
529
402
  }
530
403
  /**
531
404
  * A flyout content item.
532
405
  */
533
406
  export interface FlyoutItem {
534
- type: FlyoutItemType;
535
- button?: FlyoutButton | undefined;
536
- block?: BlockSvg | undefined;
407
+ type: string;
408
+ element: IBoundedElement;
537
409
  }
538
- export {};
539
410
  //# sourceMappingURL=flyout_base.d.ts.map
@@ -9,13 +9,16 @@
9
9
  * @class
10
10
  */
11
11
  import type { IASTNodeLocationSvg } from './blockly.js';
12
+ import type { IBoundedElement } from './interfaces/i_bounded_element.js';
13
+ import type { IRenderedElement } from './interfaces/i_rendered_element.js';
12
14
  import { Coordinate } from './utils/coordinate.js';
15
+ import { Rect } from './utils/rect.js';
13
16
  import type * as toolbox from './utils/toolbox.js';
14
17
  import type { WorkspaceSvg } from './workspace_svg.js';
15
18
  /**
16
19
  * Class for a button or label in the flyout.
17
20
  */
18
- export declare class FlyoutButton implements IASTNodeLocationSvg {
21
+ export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElement, IRenderedElement {
19
22
  private readonly workspace;
20
23
  private readonly targetWorkspace;
21
24
  private readonly isFlyoutLabel;
@@ -30,6 +33,7 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
30
33
  private readonly callbackKey;
31
34
  private readonly cssClass;
32
35
  /** Mouse up event data. */
36
+ private onMouseDownWrapper;
33
37
  private onMouseUpWrapper;
34
38
  info: toolbox.ButtonOrLabelInfo;
35
39
  /** The width of the button's rect. */
@@ -53,11 +57,6 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
53
57
  * @internal
54
58
  */
55
59
  constructor(workspace: WorkspaceSvg, targetWorkspace: WorkspaceSvg, json: toolbox.ButtonOrLabelInfo, isFlyoutLabel: boolean);
56
- /**
57
- * Create the button elements.
58
- *
59
- * @returns The button's SVG group.
60
- */
61
60
  createDom(): SVGElement;
62
61
  /** Correctly position the flyout button and make it visible. */
63
62
  show(): void;
@@ -70,6 +69,14 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
70
69
  * @param y The new y coordinate.
71
70
  */
72
71
  moveTo(x: number, y: number): void;
72
+ /**
73
+ * Move the element by a relative offset.
74
+ *
75
+ * @param dx Horizontal offset in workspace units.
76
+ * @param dy Vertical offset in workspace units.
77
+ * @param _reason Why is this move happening? 'user', 'bump', 'snap'...
78
+ */
79
+ moveBy(dx: number, dy: number, _reason?: string[]): void;
73
80
  /** @returns Whether or not the button is a label. */
74
81
  isLabel(): boolean;
75
82
  /**
@@ -79,6 +86,13 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
79
86
  * @internal
80
87
  */
81
88
  getPosition(): Coordinate;
89
+ /**
90
+ * Returns the coordinates of a bounded element describing the dimensions of
91
+ * the element. Coordinate system: workspace coordinates.
92
+ *
93
+ * @returns Object with coordinates of the bounded element.
94
+ */
95
+ getBoundingRectangle(): Rect;
82
96
  /** @returns Text of the button. */
83
97
  getButtonText(): string;
84
98
  /**
@@ -114,5 +128,10 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
114
128
  * @param e Pointer up event.
115
129
  */
116
130
  private onMouseUp;
131
+ private onMouseDown;
132
+ /**
133
+ * @returns The root SVG element of this rendered element.
134
+ */
135
+ getSvgRoot(): SVGGElement;
117
136
  }
118
137
  //# sourceMappingURL=flyout_button.d.ts.map
@@ -56,10 +56,9 @@ export declare class HorizontalFlyout extends Flyout {
56
56
  /**
57
57
  * Lay out the blocks in the flyout.
58
58
  *
59
- * @param contents The blocks and buttons to lay out.
60
- * @param gaps The visible gaps between blocks.
59
+ * @param contents The flyout items to lay out.
61
60
  */
62
- protected layout_(contents: FlyoutItem[], gaps: number[]): void;
61
+ protected layout_(contents: FlyoutItem[]): void;
63
62
  /**
64
63
  * Determine if a drag delta is toward the workspace, based on the position
65
64
  * and orientation of the flyout. This is used in determineDragIntention_ to
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IBoundedElement } from './interfaces/i_bounded_element.js';
7
+ import { Rect } from './utils/rect.js';
8
+ /**
9
+ * Representation of a gap between elements in a flyout.
10
+ */
11
+ export declare class FlyoutSeparator implements IBoundedElement {
12
+ private gap;
13
+ private axis;
14
+ private x;
15
+ private y;
16
+ /**
17
+ * Creates a new separator.
18
+ *
19
+ * @param gap The amount of space this separator should occupy.
20
+ * @param axis The axis along which this separator occupies space.
21
+ */
22
+ constructor(gap: number, axis: SeparatorAxis);
23
+ /**
24
+ * Returns the bounding box of this separator.
25
+ *
26
+ * @returns The bounding box of this separator.
27
+ */
28
+ getBoundingRectangle(): Rect;
29
+ /**
30
+ * Repositions this separator.
31
+ *
32
+ * @param dx The distance to move this separator on the X axis.
33
+ * @param dy The distance to move this separator on the Y axis.
34
+ * @param _reason The reason this move was initiated.
35
+ */
36
+ moveBy(dx: number, dy: number, _reason?: string[]): void;
37
+ }
38
+ /**
39
+ * Representation of an axis along which a separator occupies space.
40
+ */
41
+ export declare const enum SeparatorAxis {
42
+ X = "x",
43
+ Y = "y"
44
+ }
45
+ //# sourceMappingURL=flyout_separator.d.ts.map
@@ -57,10 +57,9 @@ export declare class VerticalFlyout extends Flyout {
57
57
  /**
58
58
  * Lay out the blocks in the flyout.
59
59
  *
60
- * @param contents The blocks and buttons to lay out.
61
- * @param gaps The visible gaps between blocks.
60
+ * @param contents The flyout items to lay out.
62
61
  */
63
- protected layout_(contents: FlyoutItem[], gaps: number[]): void;
62
+ protected layout_(contents: FlyoutItem[]): void;
64
63
  /**
65
64
  * Determine if a drag delta is toward the workspace, based on the position
66
65
  * and orientation of the flyout. This is used in determineDragIntention_ to
@@ -80,7 +79,7 @@ export declare class VerticalFlyout extends Flyout {
80
79
  */
81
80
  getClientRect(): Rect | null;
82
81
  /**
83
- * Compute width of flyout. toolbox.Position mat under each block.
82
+ * Compute width of flyout.
84
83
  * For RTL: Lay out the blocks and buttons to be right-aligned.
85
84
  */
86
85
  protected reflowInternal_(): void;
package/core/grid.d.ts CHANGED
@@ -113,9 +113,12 @@ export declare class Grid {
113
113
  * @param rnd A random ID to append to the pattern's ID.
114
114
  * @param gridOptions The object containing grid configuration.
115
115
  * @param defs The root SVG element for this workspace's defs.
116
+ * @param injectionDiv The div containing the parent workspace and all related
117
+ * workspaces and block containers. CSS variables representing SVG patterns
118
+ * will be scoped to this container.
116
119
  * @returns The SVG element for the grid pattern.
117
120
  * @internal
118
121
  */
119
- static createDom(rnd: string, gridOptions: GridOptions, defs: SVGElement): SVGElement;
122
+ static createDom(rnd: string, gridOptions: GridOptions, defs: SVGElement, injectionDiv?: HTMLElement): SVGElement;
120
123
  }
121
124
  //# sourceMappingURL=grid.d.ts.map
@@ -28,6 +28,8 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
28
28
  private text;
29
29
  /** The size of this comment (which is applied to the editable bubble). */
30
30
  private bubbleSize;
31
+ /** The location of the comment bubble in workspace coordinates. */
32
+ private bubbleLocation?;
31
33
  /**
32
34
  * The visibility of the bubble for this comment.
33
35
  *
@@ -60,6 +62,14 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
60
62
  setBubbleSize(size: Size): void;
61
63
  /** @returns the size of the editable bubble for this comment. */
62
64
  getBubbleSize(): Size;
65
+ /**
66
+ * Sets the location of the comment bubble in the workspace.
67
+ */
68
+ setBubbleLocation(location: Coordinate): void;
69
+ /**
70
+ * @returns the location of the comment bubble in the workspace.
71
+ */
72
+ getBubbleLocation(): Coordinate | undefined;
63
73
  /**
64
74
  * @returns the state of the comment as a JSON serializable value if the
65
75
  * comment has text. Otherwise returns null.
@@ -79,6 +89,7 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
79
89
  * input bubble.
80
90
  */
81
91
  onSizeChange(): void;
92
+ onBubbleLocationChange(): void;
82
93
  bubbleIsVisible(): boolean;
83
94
  setBubbleVisible(visible: boolean): Promise<void>;
84
95
  /**
@@ -112,5 +123,9 @@ export interface CommentState {
112
123
  height?: number;
113
124
  /** The width of the comment bubble. */
114
125
  width?: number;
126
+ /** The X coordinate of the comment bubble. */
127
+ x?: number;
128
+ /** The Y coordinate of the comment bubble. */
129
+ y?: number;
115
130
  }
116
131
  //# sourceMappingURL=comment_icon.d.ts.map
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { CommentState } from '../icons/comment_icon.js';
7
+ import { Coordinate } from '../utils/coordinate.js';
7
8
  import { Size } from '../utils/size.js';
8
9
  import { IHasBubble } from './i_has_bubble.js';
9
10
  import { IIcon } from './i_icon.js';
@@ -13,6 +14,8 @@ export interface ICommentIcon extends IIcon, IHasBubble, ISerializable {
13
14
  getText(): string;
14
15
  setBubbleSize(size: Size): void;
15
16
  getBubbleSize(): Size;
17
+ setBubbleLocation(location: Coordinate): void;
18
+ getBubbleLocation(): Coordinate | undefined;
16
19
  saveState(): CommentState;
17
20
  loadState(state: CommentState): void;
18
21
  }
@@ -0,0 +1,39 @@
1
+ import type { WorkspaceSvg } from '../workspace_svg.js';
2
+ import type { IBoundedElement } from './i_bounded_element.js';
3
+ export interface IFlyoutInflater {
4
+ /**
5
+ * Loads the object represented by the given state onto the workspace.
6
+ *
7
+ * Note that this method's interface is identical to that in ISerializer, to
8
+ * allow for code reuse.
9
+ *
10
+ * @param state A JSON representation of an element to inflate on the flyout.
11
+ * @param flyoutWorkspace The flyout's workspace, where the inflated element
12
+ * should be created. If the inflated element is an `IRenderedElement` it
13
+ * itself or the inflater should append it to the workspace; the flyout
14
+ * will not do so itself. The flyout is responsible for positioning the
15
+ * element, however.
16
+ * @returns The newly inflated flyout element.
17
+ */
18
+ load(state: object, flyoutWorkspace: WorkspaceSvg): IBoundedElement;
19
+ /**
20
+ * Returns the amount of spacing that should follow the element corresponding
21
+ * to the given JSON representation.
22
+ *
23
+ * @param state A JSON representation of the element preceding the gap.
24
+ * @param defaultGap The default gap for elements in this flyout.
25
+ * @returns The gap that should follow the given element.
26
+ */
27
+ gapForElement(state: object, defaultGap: number): number;
28
+ /**
29
+ * Disposes of the given element.
30
+ *
31
+ * If the element in question resides on the flyout workspace, it should remove
32
+ * itself. Implementers are not otherwise required to fully dispose of the
33
+ * element; it may be e.g. cached for performance purposes.
34
+ *
35
+ * @param element The flyout element to dispose of.
36
+ */
37
+ disposeElement(element: IBoundedElement): void;
38
+ }
39
+ //# sourceMappingURL=i_flyout_inflater.d.ts.map
@@ -77,7 +77,7 @@ export interface IToolbox extends IRegistrable {
77
77
  */
78
78
  setVisible(isVisible: boolean): void;
79
79
  /**
80
- * Selects the toolbox item by it's position in the list of toolbox items.
80
+ * Selects the toolbox item by its position in the list of toolbox items.
81
81
  *
82
82
  * @param position The position of the item to select.
83
83
  */
@@ -88,6 +88,13 @@ export interface IToolbox extends IRegistrable {
88
88
  * @returns The selected item, or null if no item is currently selected.
89
89
  */
90
90
  getSelectedItem(): IToolboxItem | null;
91
+ /**
92
+ * Sets the selected item.
93
+ *
94
+ * @param item The toolbox item to select, or null to remove the current
95
+ * selection.
96
+ */
97
+ setSelectedItem(item: IToolboxItem | null): void;
91
98
  /** Disposes of this toolbox. */
92
99
  dispose(): void;
93
100
  }
@@ -3,12 +3,12 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { VariableModel } from '../variable_model.js';
7
6
  import { IParameterModel } from './i_parameter_model.js';
7
+ import type { IVariableModel, IVariableState } from './i_variable_model.js';
8
8
  /** Interface for a parameter model that holds a variable model. */
9
9
  export interface IVariableBackedParameterModel extends IParameterModel {
10
10
  /** Returns the variable model held by this type. */
11
- getVariableModel(): VariableModel;
11
+ getVariableModel(): IVariableModel<IVariableState>;
12
12
  }
13
13
  /**
14
14
  * Returns whether the given object is a variable holder or not.