blockly 11.0.0-beta.5 → 11.0.0-beta.6

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 (105) hide show
  1. package/blockly.min.js +570 -623
  2. package/blockly_compressed.js +529 -545
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +27 -29
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +10 -3
  7. package/core/block_dragger.d.ts +10 -10
  8. package/core/block_svg.d.ts +5 -32
  9. package/core/blockly.d.ts +3 -38
  10. package/core/clipboard.d.ts +0 -19
  11. package/core/comments/comment_view.d.ts +201 -0
  12. package/core/comments/rendered_workspace_comment.d.ts +42 -0
  13. package/core/comments/workspace_comment.d.ts +101 -0
  14. package/core/comments.d.ts +9 -0
  15. package/core/events/events_click.d.ts +1 -1
  16. package/core/field_dropdown.d.ts +1 -0
  17. package/core/field_image.d.ts +1 -1
  18. package/core/generator.d.ts +1 -1
  19. package/core/gesture.d.ts +2 -0
  20. package/core/grid.d.ts +9 -9
  21. package/core/icons/comment_icon.d.ts +3 -3
  22. package/core/icons/icon.d.ts +0 -6
  23. package/core/icons/icon_types.d.ts +2 -2
  24. package/core/icons/mutator_icon.d.ts +1 -16
  25. package/core/icons/warning_icon.d.ts +1 -1
  26. package/core/inputs/input.d.ts +10 -19
  27. package/core/{connection_previewers/insertion_marker_previewer.d.ts → insertion_marker_previewer.d.ts} +3 -3
  28. package/core/interfaces/i_comment_icon.d.ts +17 -0
  29. package/core/interfaces/i_has_bubble.d.ts +1 -1
  30. package/core/interfaces/i_parameter_model.d.ts +7 -0
  31. package/core/interfaces/i_procedure_model.d.ts +7 -0
  32. package/core/options.d.ts +1 -0
  33. package/core/renderers/common/drawer.d.ts +0 -7
  34. package/core/renderers/measurables/icon.d.ts +0 -5
  35. package/core/serialization/priorities.d.ts +2 -0
  36. package/core/serialization/procedures.d.ts +28 -26
  37. package/core/serialization/workspace_comments.d.ts +45 -0
  38. package/core/serialization.d.ts +2 -1
  39. package/core/utils/dom.d.ts +0 -9
  40. package/core/utils/keycodes.d.ts +32 -32
  41. package/core/utils/size.d.ts +10 -0
  42. package/core/utils/string.d.ts +0 -10
  43. package/core/workspace_svg.d.ts +0 -27
  44. package/core/xml.d.ts +4 -3
  45. package/core-node.js +31 -0
  46. package/dart.d.ts +1 -24
  47. package/dart_compressed.js +18 -68
  48. package/dart_compressed.js.map +1 -1
  49. package/generators/dart/dart_generator.d.ts +17 -17
  50. package/generators/dart/text.d.ts +0 -1
  51. package/generators/javascript/javascript_generator.d.ts +34 -35
  52. package/generators/javascript/text.d.ts +0 -1
  53. package/generators/lua/lua_generator.d.ts +10 -10
  54. package/generators/lua/text.d.ts +0 -1
  55. package/generators/php/php_generator.d.ts +36 -36
  56. package/generators/php/text.d.ts +0 -1
  57. package/generators/python/python_generator.d.ts +20 -21
  58. package/generators/python/text.d.ts +0 -1
  59. package/index.js +19 -7
  60. package/javascript.d.ts +1 -41
  61. package/javascript_compressed.js +14 -49
  62. package/javascript_compressed.js.map +1 -1
  63. package/lua.d.ts +1 -18
  64. package/lua_compressed.js +18 -40
  65. package/lua_compressed.js.map +1 -1
  66. package/media/arrow-dropdown.svg +1 -0
  67. package/media/resize-handle.svg +3 -0
  68. package/msg/ce.d.ts +8 -0
  69. package/msg/dtp.d.ts +8 -0
  70. package/msg/hsb.d.ts +8 -0
  71. package/msg/tdd.d.ts +8 -0
  72. package/package.json +45 -11
  73. package/php.d.ts +1 -43
  74. package/php_compressed.js +10 -43
  75. package/php_compressed.js.map +1 -1
  76. package/python.d.ts +1 -27
  77. package/python_compressed.js +18 -37
  78. package/python_compressed.js.map +1 -1
  79. package/blockly.js +0 -22
  80. package/blocks.js +0 -22
  81. package/browser.js +0 -30
  82. package/core/field_angle.d.ts +0 -208
  83. package/core/field_colour.d.ts +0 -243
  84. package/core/field_multilineinput.d.ts +0 -182
  85. package/core/renderers/minimalist/constants.d.ts +0 -21
  86. package/core/renderers/minimalist/drawer.d.ts +0 -26
  87. package/core/renderers/minimalist/info.d.ts +0 -35
  88. package/core/renderers/minimalist/minimalist.d.ts +0 -12
  89. package/core/renderers/minimalist/renderer.d.ts +0 -48
  90. package/core-browser.js +0 -26
  91. package/core.js +0 -26
  92. package/dart.js +0 -22
  93. package/generators/dart/colour.d.ts +0 -16
  94. package/generators/javascript/colour.d.ts +0 -16
  95. package/generators/lua/colour.d.ts +0 -16
  96. package/generators/php/colour.d.ts +0 -16
  97. package/generators/python/colour.d.ts +0 -16
  98. package/javascript.js +0 -23
  99. package/lua.js +0 -22
  100. package/msg/constants.d.ts +0 -14
  101. package/msg/qqq.d.ts +0 -14
  102. package/msg/synonyms.d.ts +0 -14
  103. package/node.js +0 -21
  104. package/php.js +0 -22
  105. package/python.js +0 -23
package/core/block.d.ts CHANGED
@@ -18,7 +18,7 @@ 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
20
  import type { IDeletable } from './interfaces/i_deletable.js';
21
- import type { IIcon } from './interfaces/i_icon.js';
21
+ import { type IIcon } from './interfaces/i_icon.js';
22
22
  import type { MutatorIcon } from './icons/mutator_icon.js';
23
23
  import * as Tooltip from './tooltip.js';
24
24
  import { Coordinate } from './utils/coordinate.js';
@@ -138,7 +138,13 @@ export declare class Block implements IASTNodeLocation, IDeletable {
138
138
  /**
139
139
  * Is the current block currently in the process of being disposed?
140
140
  */
141
- private disposing;
141
+ protected disposing: boolean;
142
+ /**
143
+ * Has this block been fully initialized? E.g. all fields initailized.
144
+ *
145
+ * @internal
146
+ */
147
+ initialized: boolean;
142
148
  private readonly xy_;
143
149
  isInFlyout: boolean;
144
150
  isInMutator: boolean;
@@ -147,7 +153,8 @@ export declare class Block implements IASTNodeLocation, IDeletable {
147
153
  protected isInsertionMarker_: boolean;
148
154
  /** Name of the type of hat. */
149
155
  hat?: string;
150
- rendered: boolean | null;
156
+ /** Is this block a BlockSVG? */
157
+ readonly rendered: boolean;
151
158
  /**
152
159
  * String for block help, or function that returns a URL. Null for no help.
153
160
  */
@@ -31,11 +31,13 @@ export declare class BlockDragger implements IBlockDragger {
31
31
  /** Whether the block would be deleted if dropped immediately. */
32
32
  protected wouldDeleteBlock_: boolean;
33
33
  protected startXY_: Coordinate;
34
+ /** The parent block at the start of the drag. */
35
+ private startParentConn;
34
36
  /**
35
- * @deprecated To be removed in v11. Updating icons is now handled by the
36
- * block's `moveDuringDrag` method.
37
+ * The child block at the start of the drag. Only gets set if
38
+ * `healStack` is true.
37
39
  */
38
- protected dragIconData_: IconPositionData[];
40
+ private startChildConn;
39
41
  /**
40
42
  * @param block The block to drag.
41
43
  * @param workspace The workspace to drag on.
@@ -137,6 +139,11 @@ export declare class BlockDragger implements IBlockDragger {
137
139
  * at the start of the drag, in pixel units.
138
140
  */
139
141
  endDrag(e: PointerEvent, currentDragDeltaXY: Coordinate): void;
142
+ /**
143
+ * Moves the dragged block back to its original position before the start of
144
+ * the drag. Reconnects any parent and child blocks.
145
+ */
146
+ private moveToOriginalPosition;
140
147
  /**
141
148
  * Calculates the drag delta and new location values after a block is dragged.
142
149
  *
@@ -189,13 +196,6 @@ export declare class BlockDragger implements IBlockDragger {
189
196
  * @returns The input coordinate divided by the workspace scale.
190
197
  */
191
198
  protected pixelsToWorkspaceUnits_(pixelCoord: Coordinate): Coordinate;
192
- /**
193
- * Move all of the icons connected to this drag.
194
- *
195
- * @deprecated To be removed in v11. This is now handled by the block's
196
- * `moveDuringDrag` method.
197
- */
198
- protected dragIcons_(): void;
199
199
  /**
200
200
  * Get a list of the insertion markers that currently exist. Drags have 0, 1,
201
201
  * or 2 insertion markers.
@@ -10,7 +10,6 @@
10
10
  */
11
11
  import './events/events_selected.js';
12
12
  import { Block } from './block.js';
13
- import { CommentIcon } from './icons/comment_icon.js';
14
13
  import type { Connection } from './connection.js';
15
14
  import { ConnectionType } from './connection_type.js';
16
15
  import { ContextMenuOption, LegacyContextMenuOption } from './contextmenu_registry.js';
@@ -27,7 +26,6 @@ import type { IPathObject } from './renderers/common/i_path_object.js';
27
26
  import type { BlockStyle } from './theme.js';
28
27
  import { Coordinate } from './utils/coordinate.js';
29
28
  import { Rect } from './utils/rect.js';
30
- import { WarningIcon } from './icons/warning_icon.js';
31
29
  import type { Workspace } from './workspace.js';
32
30
  import type { WorkspaceSvg } from './workspace_svg.js';
33
31
  import { IconType } from './icons/icon_types.js';
@@ -68,17 +66,12 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
68
66
  private warningTextDb;
69
67
  /** Block's mutator icon (if any). */
70
68
  mutator: MutatorIcon | null;
71
- /**
72
- * Block's warning icon (if any).
73
- *
74
- * @deprecated Use `setWarningText` to modify warnings on this block.
75
- */
76
- warning: WarningIcon | null;
77
69
  private svgGroup_;
78
70
  style: BlockStyle;
79
71
  /** @internal */
80
72
  pathObject: IPathObject;
81
- rendered: boolean;
73
+ /** Is this block a BlockSVG? */
74
+ readonly rendered = true;
82
75
  private visuallyDisabled;
83
76
  /**
84
77
  * Is this block currently rendering? Used to stop recursive render calls
@@ -92,11 +85,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
92
85
  nextConnection: RenderedConnection;
93
86
  previousConnection: RenderedConnection;
94
87
  private translation;
95
- /**
96
- * The ID of the setTimeout callback for bumping neighbours, or 0 if no bump
97
- * is currently scheduled.
98
- */
99
- private bumpNeighboursPid;
100
88
  /** Whether this block is currently being dragged. */
101
89
  private dragging;
102
90
  /**
@@ -349,14 +337,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
349
337
  * @internal
350
338
  */
351
339
  updateDisabled(): void;
352
- /**
353
- * Get the comment icon attached to this block, or null if the block has no
354
- * comment.
355
- *
356
- * @returns The comment icon attached to this block, or null.
357
- * @deprecated Use getIcon. To be remove in v11.
358
- */
359
- getCommentIcon(): CommentIcon | null;
360
340
  /**
361
341
  * Set this block's warning text.
362
342
  *
@@ -506,8 +486,7 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
506
486
  * Returns connections originating from this block.
507
487
  *
508
488
  * @param all If true, return all connections even hidden ones.
509
- * Otherwise, for a non-rendered block return an empty list, and for a
510
- * collapsed block don't return inputs connections.
489
+ * Otherwise, for a collapsed block don't return inputs connections.
511
490
  * @returns Array of connections.
512
491
  * @internal
513
492
  */
@@ -562,14 +541,8 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
562
541
  */
563
542
  bumpNeighbours(): void;
564
543
  /**
565
- * Bumps unconnected blocks out of alignment.
566
- */
567
- private bumpNeighboursInternal;
568
- /**
569
- * Schedule snapping to grid and bumping neighbours to occur after a brief
570
- * delay.
571
- *
572
- * @internal
544
+ * Snap to grid, and then bump neighbouring blocks away at the end of the next
545
+ * render.
573
546
  */
574
547
  scheduleSnapAndBump(): void;
575
548
  /**
package/core/blockly.d.ts CHANGED
@@ -14,7 +14,6 @@ import { BlockSvg } from './block_svg.js';
14
14
  import { BlocklyOptions } from './blockly_options.js';
15
15
  import { Blocks } from './blocks.js';
16
16
  import * as browserEvents from './browser_events.js';
17
- import { Bubble } from './bubbles/bubble.js';
18
17
  import * as bubbles from './bubbles.js';
19
18
  import { BubbleDragger } from './bubble_dragger.js';
20
19
  import * as bumpObjects from './bump_objects.js';
@@ -29,6 +28,7 @@ import { ConnectionType } from './connection_type.js';
29
28
  import * as ContextMenu from './contextmenu.js';
30
29
  import * as ContextMenuItems from './contextmenu_items.js';
31
30
  import { ContextMenuRegistry } from './contextmenu_registry.js';
31
+ import * as comments from './comments.js';
32
32
  import * as Css from './css.js';
33
33
  import { DeleteArea } from './delete_area.js';
34
34
  import * as dialog from './dialog.js';
@@ -37,14 +37,11 @@ import * as dropDownDiv from './dropdowndiv.js';
37
37
  import * as Events from './events/events.js';
38
38
  import * as Extensions from './extensions.js';
39
39
  import { Field, FieldConfig, FieldValidator, UnattachedFieldError } from './field.js';
40
- import { FieldAngle, FieldAngleConfig, FieldAngleFromJsonConfig, FieldAngleValidator } from './field_angle.js';
41
40
  import { FieldCheckbox, FieldCheckboxConfig, FieldCheckboxFromJsonConfig, FieldCheckboxValidator } from './field_checkbox.js';
42
- import { FieldColour, FieldColourConfig, FieldColourFromJsonConfig, FieldColourValidator } from './field_colour.js';
43
41
  import { FieldDropdown, FieldDropdownConfig, FieldDropdownFromJsonConfig, FieldDropdownValidator, MenuGenerator, MenuGeneratorFunction, MenuOption } from './field_dropdown.js';
44
42
  import { FieldImage, FieldImageConfig, FieldImageFromJsonConfig } from './field_image.js';
45
43
  import { FieldLabel, FieldLabelConfig, FieldLabelFromJsonConfig } from './field_label.js';
46
44
  import { FieldLabelSerializable } from './field_label_serializable.js';
47
- import { FieldMultilineInput, FieldMultilineInputConfig, FieldMultilineInputFromJsonConfig, FieldMultilineInputValidator } from './field_multilineinput.js';
48
45
  import { FieldNumber, FieldNumberConfig, FieldNumberFromJsonConfig, FieldNumberValidator } from './field_number.js';
49
46
  import * as fieldRegistry from './field_registry.js';
50
47
  import { FieldTextInput, FieldTextInputConfig, FieldTextInputFromJsonConfig, FieldTextInputValidator } from './field_textinput.js';
@@ -59,12 +56,10 @@ import { Gesture } from './gesture.js';
59
56
  import { Grid } from './grid.js';
60
57
  import * as icons from './icons.js';
61
58
  import { inject } from './inject.js';
62
- import { Align } from './inputs/align.js';
63
59
  import { Input } from './inputs/input.js';
64
- import { inputTypes } from './inputs/input_types.js';
65
60
  import * as inputs from './inputs.js';
66
61
  import { InsertionMarkerManager } from './insertion_marker_manager.js';
67
- import { InsertionMarkerPreviewer } from './connection_previewers/insertion_marker_previewer.js';
62
+ import { InsertionMarkerPreviewer } from './insertion_marker_previewer.js';
68
63
  import { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
69
64
  import { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
70
65
  import { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
@@ -119,7 +114,6 @@ import * as renderManagement from './render_management.js';
119
114
  import * as blockRendering from './renderers/common/block_rendering.js';
120
115
  import * as constants from './constants.js';
121
116
  import * as geras from './renderers/geras/geras.js';
122
- import * as minimalist from './renderers/minimalist/minimalist.js';
123
117
  import * as thrasos from './renderers/thrasos/thrasos.js';
124
118
  import * as zelos from './renderers/zelos/zelos.js';
125
119
  import { Scrollbar } from './scrollbar.js';
@@ -163,21 +157,6 @@ import { ZoomControls } from './zoom_controls.js';
163
157
  * @define {string}
164
158
  */
165
159
  export declare const VERSION = "uncompiled";
166
- /**
167
- * @see Blockly.Input.Align.LEFT
168
- * @deprecated Use `Blockly.inputs.Align.LEFT`. To be removed in v11.
169
- */
170
- export declare const ALIGN_LEFT = Align.LEFT;
171
- /**
172
- * @see Blockly.Input.Align.CENTRE
173
- * @deprecated Use `Blockly.inputs.Align.CENTER`. To be removed in v11.
174
- */
175
- export declare const ALIGN_CENTRE = Align.CENTRE;
176
- /**
177
- * @see Blockly.Input.Align.RIGHT
178
- * @deprecated Use `Blockly.inputs.Align.RIGHT`. To be removed in v11.
179
- */
180
- export declare const ALIGN_RIGHT = Align.RIGHT;
181
160
  /**
182
161
  * @see ConnectionType.INPUT_VALUE
183
162
  */
@@ -194,11 +173,6 @@ export declare const NEXT_STATEMENT = ConnectionType.NEXT_STATEMENT;
194
173
  * @see ConnectionType.PREVIOUS_STATEMENT
195
174
  */
196
175
  export declare const PREVIOUS_STATEMENT = ConnectionType.PREVIOUS_STATEMENT;
197
- /**
198
- * @see inputTypes.DUMMY_INPUT
199
- * @deprecated Use `Blockly.inputs.inputTypes.DUMMY`. To be removed in v11.
200
- */
201
- export declare const DUMMY_INPUT = inputTypes.DUMMY;
202
176
  /** Aliases for toolbox positions. */
203
177
  /**
204
178
  * @see toolbox.Position.TOP
@@ -314,7 +288,6 @@ export { constants };
314
288
  export { dialog };
315
289
  export { fieldRegistry };
316
290
  export { geras };
317
- export { minimalist };
318
291
  export { registry };
319
292
  export { thrasos };
320
293
  export { uiPosition };
@@ -328,8 +301,6 @@ export { BlockDragger };
328
301
  export { BlockSvg };
329
302
  export { Blocks };
330
303
  export { bubbles };
331
- /** @deprecated Use Blockly.bubbles.Bubble instead. To be removed in v11. */
332
- export { Bubble };
333
304
  export { BubbleDragger };
334
305
  export { CollapsibleToolboxCategory };
335
306
  export { ComponentManager };
@@ -338,19 +309,17 @@ export { ConnectionType };
338
309
  export { ConnectionChecker };
339
310
  export { ConnectionDB };
340
311
  export { ContextMenuRegistry };
312
+ export { comments };
341
313
  export { Cursor };
342
314
  export { DeleteArea };
343
315
  export { DragTarget };
344
316
  export declare const DropDownDiv: typeof dropDownDiv;
345
317
  export { Field, FieldConfig, FieldValidator, UnattachedFieldError };
346
- export { FieldAngle, FieldAngleConfig, FieldAngleFromJsonConfig, FieldAngleValidator, };
347
318
  export { FieldCheckbox, FieldCheckboxConfig, FieldCheckboxFromJsonConfig, FieldCheckboxValidator, };
348
- export { FieldColour, FieldColourConfig, FieldColourFromJsonConfig, FieldColourValidator, };
349
319
  export { FieldDropdown, FieldDropdownConfig, FieldDropdownFromJsonConfig, FieldDropdownValidator, MenuGenerator, MenuGeneratorFunction, MenuOption, };
350
320
  export { FieldImage, FieldImageConfig, FieldImageFromJsonConfig };
351
321
  export { FieldLabel, FieldLabelConfig, FieldLabelFromJsonConfig };
352
322
  export { FieldLabelSerializable };
353
- export { FieldMultilineInput, FieldMultilineInputConfig, FieldMultilineInputFromJsonConfig, FieldMultilineInputValidator, };
354
323
  export { FieldNumber, FieldNumberConfig, FieldNumberFromJsonConfig, FieldNumberValidator, };
355
324
  export { FieldTextInput, FieldTextInputConfig, FieldTextInputFromJsonConfig, FieldTextInputValidator, };
356
325
  export { FieldVariable, FieldVariableConfig, FieldVariableFromJsonConfig, FieldVariableValidator, };
@@ -433,10 +402,6 @@ export { WorkspaceDragger };
433
402
  export { WorkspaceSvg };
434
403
  export { ZoomControls };
435
404
  export { config };
436
- /** @deprecated Use Blockly.ConnectionType instead. */
437
- export declare const connectionTypes: typeof ConnectionType;
438
405
  export { inject };
439
- /** @deprecated Use Blockly.inputs.inputTypes instead. To be removed in v11. */
440
- export { inputTypes };
441
406
  export { serialization };
442
407
  //# sourceMappingURL=blockly.d.ts.map
@@ -8,14 +8,6 @@ import { BlockPaster } from './clipboard/block_paster.js';
8
8
  import { WorkspaceSvg } from './workspace_svg.js';
9
9
  import * as registry from './clipboard/registry.js';
10
10
  import { Coordinate } from './utils/coordinate.js';
11
- /**
12
- * Copy a copyable element onto the local clipboard.
13
- *
14
- * @param toCopy The copyable element to be copied.
15
- * @deprecated v11. Use `myCopyable.toCopyData()` instead. To be removed v12.
16
- * @internal
17
- */
18
- export declare function copy<T extends ICopyData>(toCopy: ICopyable<T>): T | null;
19
11
  /**
20
12
  * Private version of copy for stubbing in tests.
21
13
  */
@@ -35,17 +27,6 @@ export declare function paste<T extends ICopyData>(copyData: T, workspace: Works
35
27
  * @returns the pasted thing if the paste was successful, null otherwise.
36
28
  */
37
29
  export declare function paste(): ICopyable<ICopyData> | null;
38
- /**
39
- * Duplicate this copy-paste-able element.
40
- *
41
- * @param toDuplicate The element to be duplicated.
42
- * @returns The element that was duplicated, or null if the duplication failed.
43
- * @deprecated v11. Use
44
- * `Blockly.clipboard.paste(myCopyable.toCopyData(), myWorkspace)` instead.
45
- * To be removed v12.
46
- * @internal
47
- */
48
- export declare function duplicate<U extends ICopyData, T extends ICopyable<U> & IHasWorkspace>(toDuplicate: T): T | null;
49
30
  /**
50
31
  * Private version of duplicate for stubbing in tests.
51
32
  */
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { IRenderedElement } from '../interfaces/i_rendered_element.js';
7
+ import { WorkspaceSvg } from '../workspace_svg.js';
8
+ import { Coordinate } from '../utils/coordinate.js';
9
+ import { Size } from '../utils/size.js';
10
+ export declare class CommentView implements IRenderedElement {
11
+ private readonly workspace;
12
+ /** The root group element of the comment view. */
13
+ private svgRoot;
14
+ /** The rect background for the top bar. */
15
+ private topBar;
16
+ /** The delete icon that goes in the top bar. */
17
+ private deleteIcon;
18
+ /** The foldout icon that goes in the top bar. */
19
+ private foldoutIcon;
20
+ /** The text element that goes in the top bar. */
21
+ private textPreview;
22
+ /** The actual text node in the text preview. */
23
+ private textPreviewNode;
24
+ /** The resize handle element. */
25
+ private resizeHandle;
26
+ /** The foreignObject containing the HTML text area. */
27
+ private foreignObject;
28
+ /** The text area where the user can type. */
29
+ private textArea;
30
+ /** The current size of the comment in workspace units. */
31
+ private size;
32
+ /** Whether the comment is collapsed or not. */
33
+ private collapsed;
34
+ /** Whether the comment is editable or not. */
35
+ private editable;
36
+ /** The current location of the comment in workspace coordinates. */
37
+ private location;
38
+ /** The current text of the comment. Updates on text area change. */
39
+ private text;
40
+ /** Listeners for changes to text. */
41
+ private textChangeListeners;
42
+ /** Listeners for changes to size. */
43
+ private sizeChangeListeners;
44
+ /** Listeners for disposal. */
45
+ private disposeListeners;
46
+ /** Listeners for collapsing. */
47
+ private collapseChangeListeners;
48
+ /**
49
+ * Event data for the pointer up event on the resize handle. Used to
50
+ * unregister the listener.
51
+ */
52
+ private resizePointerUpListener;
53
+ /**
54
+ * Event data for the pointer move event on the resize handle. Used to
55
+ * unregister the listener.
56
+ */
57
+ private resizePointerMoveListener;
58
+ /** Whether this comment view is currently being disposed or not. */
59
+ private disposing;
60
+ /** Whether this comment view has been disposed or not. */
61
+ private disposed;
62
+ constructor(workspace: WorkspaceSvg);
63
+ /**
64
+ * Creates the top bar and the elements visually within it.
65
+ * Registers event listeners.
66
+ */
67
+ private createTopBar;
68
+ /**
69
+ * Creates the text area where users can type. Registers event listeners.
70
+ */
71
+ private createTextArea;
72
+ /** Creates the DOM elements for the comment resize handle. */
73
+ private createResizeHandle;
74
+ /** Returns the root SVG group element of the comment view. */
75
+ getSvgRoot(): SVGGElement;
76
+ /** Returns the current size of the comment in workspace units. */
77
+ getSize(): Size;
78
+ /**
79
+ * Sets the size of the comment in workspace units, and updates the view
80
+ * elements to reflect the new size.
81
+ */
82
+ setSize(size: Size): void;
83
+ /**
84
+ * Calculates the minimum size for the uncollapsed comment based on text
85
+ * size and visible icons.
86
+ *
87
+ * The minimum width is based on the width of the truncated preview text.
88
+ *
89
+ * The minimum height is based on the height of the top bar.
90
+ */
91
+ private calcMinSize;
92
+ /** Calculates the margin that should exist around the delete icon. */
93
+ private calcDeleteMargin;
94
+ /** Calculates the margin that should exist around the foldout icon. */
95
+ private calcFoldoutMargin;
96
+ /** Updates the size of the text area elements to reflect the new size. */
97
+ private updateTextAreaSize;
98
+ /**
99
+ * Updates the position of the delete icon elements to reflect the new size.
100
+ */
101
+ private updateDeleteIconPosition;
102
+ /**
103
+ * Updates the position of the foldout icon elements to reflect the new size.
104
+ */
105
+ private updateFoldoutIconPosition;
106
+ /**
107
+ * Updates the size and position of the text preview elements to reflect the new size.
108
+ */
109
+ private updateTextPreviewSize;
110
+ /**
111
+ * Triggers listeners when the size of the comment changes, either
112
+ * progrmatically or manually by the user.
113
+ */
114
+ private onSizeChange;
115
+ /**
116
+ * Registers a callback that listens for size changes.
117
+ *
118
+ * @param listener Receives callbacks when the size of the comment changes.
119
+ * The new and old size are in workspace units.
120
+ */
121
+ addSizeChangeListener(listener: (oldSize: Size, newSize: Size) => void): void;
122
+ /** Removes the given listener from the list of size change listeners. */
123
+ removeSizeChangeListener(listener: () => void): void;
124
+ /**
125
+ * Handles starting an interaction with the resize handle to resize the
126
+ * comment.
127
+ */
128
+ private onResizePointerDown;
129
+ /** Ends an interaction with the resize handle. */
130
+ private onResizePointerUp;
131
+ /** Resizes the comment in response to a drag on the resize handle. */
132
+ private onResizePointerMove;
133
+ /** Returns true if the comment is currently collapsed. */
134
+ isCollapsed(): boolean;
135
+ /** Sets whether the comment is currently collapsed or not. */
136
+ setCollapsed(collapsed: boolean): void;
137
+ /**
138
+ * Triggers listeners when the collapsed-ness of the comment changes, either
139
+ * progrmatically or manually by the user.
140
+ */
141
+ private onCollapse;
142
+ /** Registers a callback that listens for collapsed-ness changes. */
143
+ addOnCollapseListener(listener: (newCollapse: boolean) => void): void;
144
+ /** Removes the given listener from the list of on collapse listeners. */
145
+ removeOnCollapseListener(listener: () => void): void;
146
+ /**
147
+ * Toggles the collapsedness of the block when we receive a pointer down
148
+ * event on the foldout icon.
149
+ */
150
+ private onFoldoutDown;
151
+ /** Returns true if the comment is currently editable. */
152
+ isEditable(): boolean;
153
+ /** Sets the editability of the comment. */
154
+ setEditable(editable: boolean): void;
155
+ /** Returns the current location of the comment in workspace coordinates. */
156
+ getRelativeToSurfaceXY(): Coordinate;
157
+ /**
158
+ * Moves the comment view to the given location.
159
+ *
160
+ * @param location The location to move to in workspace coordinates.
161
+ */
162
+ moveTo(location: Coordinate): void;
163
+ /** Retursn the current text of the comment. */
164
+ getText(): string;
165
+ /** Sets the current text of the comment. */
166
+ setText(text: string): void;
167
+ /** Registers a callback that listens for text changes. */
168
+ addTextChangeListener(listener: (oldText: string, newText: string) => void): void;
169
+ /** Removes the given listener from the list of text change listeners. */
170
+ removeTextChangeListener(listener: () => void): void;
171
+ /**
172
+ * Triggers listeners when the text of the comment changes, either
173
+ * progrmatically or manually by the user.
174
+ */
175
+ private onTextChange;
176
+ /** Updates the preview text element to reflect the given text. */
177
+ private updateTextPreview;
178
+ /** Truncates the text to fit within the top view. */
179
+ private truncateText;
180
+ /** Brings the workspace comment to the front of its layer. */
181
+ private bringToFront;
182
+ /**
183
+ * Handles disposing of the comment when we get a pointer down event on the
184
+ * delete icon.
185
+ */
186
+ private onDeleteDown;
187
+ /** Disposes of this comment view. */
188
+ dispose(): void;
189
+ /** Returns whether this comment view has been disposed or not. */
190
+ isDisposed(): boolean;
191
+ /**
192
+ * Returns true if this comment view is currently being disposed or has
193
+ * already been disposed.
194
+ */
195
+ isDeadOrDying(): boolean;
196
+ /** Registers a callback that listens for disposal of this view. */
197
+ addDisposeListener(listener: () => void): void;
198
+ /** Removes the given listener from the list of disposal listeners. */
199
+ removeDisposeListener(listener: () => void): void;
200
+ }
201
+ //# sourceMappingURL=comment_view.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { WorkspaceComment } from './workspace_comment.js';
7
+ import { WorkspaceSvg } from '../workspace_svg.js';
8
+ import { Coordinate } from '../utils/coordinate.js';
9
+ import { Rect } from '../utils/rect.js';
10
+ import { Size } from '../utils/size.js';
11
+ import { IBoundedElement } from '../interfaces/i_bounded_element.js';
12
+ import { IRenderedElement } from '../interfaces/i_rendered_element.js';
13
+ export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement {
14
+ /** The class encompassing the svg elements making up the workspace comment. */
15
+ private view;
16
+ /** Constructs the workspace comment, including the view. */
17
+ constructor(workspace: WorkspaceSvg, id?: string);
18
+ /**
19
+ * Adds listeners to the view that updates the model (i.e. the superclass)
20
+ * when changes are made to the view.
21
+ */
22
+ private addModelUpdateBindings;
23
+ /** Sets the text of the comment. */
24
+ setText(text: string): void;
25
+ /** Sets the size of the comment. */
26
+ setSize(size: Size): void;
27
+ /** Sets whether the comment is collapsed or not. */
28
+ setCollapsed(collapsed: boolean): void;
29
+ /** Sets whether the comment is editable or not. */
30
+ setEditable(editable: boolean): void;
31
+ /** Returns the root SVG element of this comment. */
32
+ getSvgRoot(): SVGElement;
33
+ /** Returns the bounding rectangle of this comment in workspace coordinates. */
34
+ getBoundingRectangle(): Rect;
35
+ /** Move the comment by the given amounts in workspace coordinates. */
36
+ moveBy(dx: number, dy: number, _reason?: string[] | undefined): void;
37
+ /** Moves the comment to the given location in workspace coordinates. */
38
+ moveTo(location: Coordinate): void;
39
+ /** Disposes of the view. */
40
+ dispose(): void;
41
+ }
42
+ //# sourceMappingURL=rendered_workspace_comment.d.ts.map
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Workspace } from '../workspace.js';
7
+ import { Size } from '../utils/size.js';
8
+ import { Coordinate } from '../utils/coordinate.js';
9
+ export declare class WorkspaceComment {
10
+ protected readonly workspace: Workspace;
11
+ /** The unique identifier for this comment. */
12
+ readonly id: string;
13
+ /** The text of the comment. */
14
+ private text;
15
+ /** The size of the comment in workspace units. */
16
+ private size;
17
+ /** Whether the comment is collapsed or not. */
18
+ private collapsed;
19
+ /** Whether the comment is editable or not. */
20
+ private editable;
21
+ /** Whether the comment is movable or not. */
22
+ private movable;
23
+ /** Whether the comment is deletable or not. */
24
+ private deletable;
25
+ /** The location of the comment in workspace coordinates. */
26
+ private location;
27
+ /** Whether this comment has been disposed or not. */
28
+ protected disposed: boolean;
29
+ /** Whether this comment is being disposed or not. */
30
+ protected disposing: boolean;
31
+ /**
32
+ * Constructs the comment.
33
+ *
34
+ * @param workspace The workspace to construct the comment in.
35
+ * @param id An optional ID to give to the comment. If not provided, one will
36
+ * be generated.
37
+ */
38
+ constructor(workspace: Workspace, id?: string);
39
+ /** Sets the text of the comment. */
40
+ setText(text: string): void;
41
+ /** Returns the text of the comment. */
42
+ getText(): string;
43
+ /** Sets the comment's size in workspace units. */
44
+ setSize(size: Size): void;
45
+ /** Returns the comment's size in workspace units. */
46
+ getSize(): Size;
47
+ /** Sets whether the comment is collapsed or not. */
48
+ setCollapsed(collapsed: boolean): void;
49
+ /** Returns whether the comment is collapsed or not. */
50
+ isCollapsed(): boolean;
51
+ /** Sets whether the comment is editable or not. */
52
+ setEditable(editable: boolean): void;
53
+ /**
54
+ * Returns whether the comment is editable or not, respecting whether the
55
+ * workspace is read-only.
56
+ */
57
+ isEditable(): boolean;
58
+ /**
59
+ * Returns whether the comment is editable or not, only examining its own
60
+ * state and ignoring the state of the workspace.
61
+ */
62
+ isOwnEditable(): boolean;
63
+ /** Sets whether the comment is movable or not. */
64
+ setMovable(movable: boolean): void;
65
+ /**
66
+ * Returns whether the comment is movable or not, respecting whether the
67
+ * workspace is read-only.
68
+ */
69
+ isMovable(): boolean;
70
+ /**
71
+ * Returns whether the comment is movable or not, only examining its own
72
+ * state and ignoring the state of the workspace.
73
+ */
74
+ isOwnMovable(): boolean;
75
+ /** Sets whether the comment is deletable or not. */
76
+ setDeletable(deletable: boolean): void;
77
+ /**
78
+ * Returns whether the comment is deletable or not, respecting whether the
79
+ * workspace is read-only.
80
+ */
81
+ isDeletable(): boolean;
82
+ /**
83
+ * Returns whether the comment is deletable or not, only examining its own
84
+ * state and ignoring the state of the workspace.
85
+ */
86
+ isOwnDeletable(): boolean;
87
+ /** Moves the comment to the given location in workspace coordinates. */
88
+ moveTo(location: Coordinate): void;
89
+ /** Returns the position of the comment in workspace coordinates. */
90
+ getRelativeToSurfaceXY(): Coordinate;
91
+ /** Disposes of this comment. */
92
+ dispose(): void;
93
+ /** Returns whether the comment has been disposed or not. */
94
+ isDisposed(): boolean;
95
+ /**
96
+ * Returns true if this comment view is currently being disposed or has
97
+ * already been disposed.
98
+ */
99
+ isDeadOrDying(): boolean;
100
+ }
101
+ //# sourceMappingURL=workspace_comment.d.ts.map