blockly 11.0.0-beta.5 → 11.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.min.js +722 -763
- package/blockly_compressed.js +676 -680
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +27 -29
- package/blocks_compressed.js.map +1 -1
- package/core/block.d.ts +12 -6
- package/core/block_svg.d.ts +28 -42
- package/core/blockly.d.ts +11 -51
- package/core/bubbles/bubble.d.ts +17 -2
- package/core/bubbles/mini_workspace_bubble.d.ts +1 -1
- package/core/bubbles/text_bubble.d.ts +1 -1
- package/core/bubbles/textinput_bubble.d.ts +1 -1
- package/core/clipboard.d.ts +0 -19
- package/core/comments/comment_view.d.ts +207 -0
- package/core/comments/rendered_workspace_comment.d.ts +75 -0
- package/core/comments/workspace_comment.d.ts +107 -0
- package/core/comments.d.ts +9 -0
- package/core/connection.d.ts +1 -1
- package/core/delete_area.d.ts +1 -2
- package/core/dragging/block_drag_strategy.d.ts +105 -0
- package/core/dragging/bubble_drag_strategy.d.ts +20 -0
- package/core/dragging/comment_drag_strategy.d.ts +20 -0
- package/core/dragging/dragger.d.ts +47 -0
- package/core/events/events.d.ts +3 -0
- package/core/events/events_click.d.ts +1 -1
- package/core/events/events_comment_base.d.ts +6 -1
- package/core/events/events_comment_change.d.ts +1 -1
- package/core/events/events_comment_collapse.d.ts +39 -0
- package/core/events/events_comment_create.d.ts +5 -1
- package/core/events/events_comment_delete.d.ts +5 -1
- package/core/events/events_comment_move.d.ts +17 -1
- package/core/events/utils.d.ts +2 -0
- package/core/field_dropdown.d.ts +1 -0
- package/core/field_image.d.ts +1 -1
- package/core/flyout_base.d.ts +17 -1
- package/core/flyout_button.d.ts +26 -1
- package/core/generator.d.ts +1 -1
- package/core/gesture.d.ts +25 -54
- package/core/grid.d.ts +9 -9
- package/core/icons/comment_icon.d.ts +8 -3
- package/core/icons/icon.d.ts +0 -6
- package/core/icons/icon_types.d.ts +2 -2
- package/core/icons/mutator_icon.d.ts +1 -16
- package/core/icons/warning_icon.d.ts +1 -1
- package/core/inputs/input.d.ts +10 -19
- package/core/{connection_previewers/insertion_marker_previewer.d.ts → insertion_marker_previewer.d.ts} +3 -3
- package/core/interfaces/i_comment_icon.d.ts +21 -0
- package/core/interfaces/i_deletable.d.ts +6 -0
- package/core/interfaces/i_delete_area.d.ts +1 -2
- package/core/interfaces/i_draggable.d.ts +47 -3
- package/core/interfaces/i_dragger.d.ts +32 -0
- package/core/interfaces/i_has_bubble.d.ts +1 -1
- package/core/interfaces/i_parameter_model.d.ts +7 -0
- package/core/interfaces/i_procedure_model.d.ts +7 -0
- package/core/interfaces/i_selectable.d.ts +5 -3
- package/core/internal_constants.d.ts +0 -7
- package/core/keyboard_nav/ast_node.d.ts +21 -2
- package/core/options.d.ts +1 -0
- package/core/registry.d.ts +2 -2
- package/core/renderers/common/drawer.d.ts +0 -7
- package/core/renderers/common/marker_svg.d.ts +7 -0
- package/core/renderers/measurables/icon.d.ts +0 -5
- package/core/serialization/priorities.d.ts +2 -0
- package/core/serialization/procedures.d.ts +28 -26
- package/core/serialization/workspace_comments.d.ts +45 -0
- package/core/serialization.d.ts +2 -1
- package/core/toolbox/toolbox.d.ts +1 -2
- package/core/utils/dom.d.ts +0 -9
- package/core/utils/keycodes.d.ts +32 -32
- package/core/utils/size.d.ts +10 -0
- package/core/utils/string.d.ts +0 -10
- package/core/workspace_comment_svg.d.ts +1 -2
- package/core/workspace_svg.d.ts +0 -27
- package/core/xml.d.ts +9 -3
- package/core-node.js +31 -0
- package/dart.d.ts +1 -24
- package/dart_compressed.js +22 -72
- package/dart_compressed.js.map +1 -1
- package/generators/dart/dart_generator.d.ts +17 -17
- package/generators/dart/text.d.ts +0 -1
- package/generators/javascript/javascript_generator.d.ts +34 -35
- package/generators/javascript/text.d.ts +0 -1
- package/generators/lua/lua_generator.d.ts +10 -10
- package/generators/lua/text.d.ts +0 -1
- package/generators/php/php_generator.d.ts +36 -36
- package/generators/php/text.d.ts +0 -1
- package/generators/python/python_generator.d.ts +20 -21
- package/generators/python/text.d.ts +0 -1
- package/index.js +19 -7
- package/javascript.d.ts +1 -41
- package/javascript_compressed.js +19 -54
- package/javascript_compressed.js.map +1 -1
- package/lua.d.ts +1 -18
- package/lua_compressed.js +24 -47
- package/lua_compressed.js.map +1 -1
- package/media/delete-icon.svg +1 -0
- package/media/foldout-icon.svg +1 -0
- package/media/resize-handle.svg +3 -0
- package/msg/ce.d.ts +8 -0
- package/msg/dtp.d.ts +8 -0
- package/msg/hsb.d.ts +8 -0
- package/msg/tdd.d.ts +8 -0
- package/package.json +46 -12
- package/php.d.ts +1 -43
- package/php_compressed.js +13 -46
- package/php_compressed.js.map +1 -1
- package/python.d.ts +1 -27
- package/python_compressed.js +21 -40
- package/python_compressed.js.map +1 -1
- package/blockly.js +0 -22
- package/blocks.js +0 -22
- package/browser.js +0 -30
- package/core/block_dragger.d.ts +0 -212
- package/core/bubble_dragger.d.ts +0 -77
- package/core/field_angle.d.ts +0 -208
- package/core/field_colour.d.ts +0 -243
- package/core/field_multilineinput.d.ts +0 -182
- package/core/interfaces/i_block_dragger.d.ts +0 -47
- package/core/renderers/minimalist/constants.d.ts +0 -21
- package/core/renderers/minimalist/drawer.d.ts +0 -26
- package/core/renderers/minimalist/info.d.ts +0 -35
- package/core/renderers/minimalist/minimalist.d.ts +0 -12
- package/core/renderers/minimalist/renderer.d.ts +0 -48
- package/core-browser.js +0 -26
- package/core.js +0 -26
- package/dart.js +0 -22
- package/generators/dart/colour.d.ts +0 -16
- package/generators/javascript/colour.d.ts +0 -16
- package/generators/lua/colour.d.ts +0 -16
- package/generators/php/colour.d.ts +0 -16
- package/generators/python/colour.d.ts +0 -16
- package/javascript.js +0 -23
- package/lua.js +0 -22
- package/msg/constants.d.ts +0 -14
- package/msg/qqq.d.ts +0 -14
- package/msg/synonyms.d.ts +0 -14
- package/node.js +0 -21
- package/php.js +0 -22
- package/python.js +0 -23
|
@@ -0,0 +1,207 @@
|
|
|
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 group containing all of the top bar elements. */
|
|
15
|
+
private topBarGroup;
|
|
16
|
+
/** The rect background for the top bar. */
|
|
17
|
+
private topBarBackground;
|
|
18
|
+
/** The delete icon that goes in the top bar. */
|
|
19
|
+
private deleteIcon;
|
|
20
|
+
/** The foldout icon that goes in the top bar. */
|
|
21
|
+
private foldoutIcon;
|
|
22
|
+
/** The text element that goes in the top bar. */
|
|
23
|
+
private textPreview;
|
|
24
|
+
/** The actual text node in the text preview. */
|
|
25
|
+
private textPreviewNode;
|
|
26
|
+
/** The resize handle element. */
|
|
27
|
+
private resizeHandle;
|
|
28
|
+
/** The foreignObject containing the HTML text area. */
|
|
29
|
+
private foreignObject;
|
|
30
|
+
/** The text area where the user can type. */
|
|
31
|
+
private textArea;
|
|
32
|
+
/** The current size of the comment in workspace units. */
|
|
33
|
+
private size;
|
|
34
|
+
/** Whether the comment is collapsed or not. */
|
|
35
|
+
private collapsed;
|
|
36
|
+
/** Whether the comment is editable or not. */
|
|
37
|
+
private editable;
|
|
38
|
+
/** The current location of the comment in workspace coordinates. */
|
|
39
|
+
private location;
|
|
40
|
+
/** The current text of the comment. Updates on text area change. */
|
|
41
|
+
private text;
|
|
42
|
+
/** Listeners for changes to text. */
|
|
43
|
+
private textChangeListeners;
|
|
44
|
+
/** Listeners for changes to size. */
|
|
45
|
+
private sizeChangeListeners;
|
|
46
|
+
/** Listeners for disposal. */
|
|
47
|
+
private disposeListeners;
|
|
48
|
+
/** Listeners for collapsing. */
|
|
49
|
+
private collapseChangeListeners;
|
|
50
|
+
/**
|
|
51
|
+
* Event data for the pointer up event on the resize handle. Used to
|
|
52
|
+
* unregister the listener.
|
|
53
|
+
*/
|
|
54
|
+
private resizePointerUpListener;
|
|
55
|
+
/**
|
|
56
|
+
* Event data for the pointer move event on the resize handle. Used to
|
|
57
|
+
* unregister the listener.
|
|
58
|
+
*/
|
|
59
|
+
private resizePointerMoveListener;
|
|
60
|
+
/** Whether this comment view is currently being disposed or not. */
|
|
61
|
+
private disposing;
|
|
62
|
+
/** Whether this comment view has been disposed or not. */
|
|
63
|
+
private disposed;
|
|
64
|
+
constructor(workspace: WorkspaceSvg);
|
|
65
|
+
/**
|
|
66
|
+
* Creates the top bar and the elements visually within it.
|
|
67
|
+
* Registers event listeners.
|
|
68
|
+
*/
|
|
69
|
+
private createTopBar;
|
|
70
|
+
/**
|
|
71
|
+
* Creates the text area where users can type. Registers event listeners.
|
|
72
|
+
*/
|
|
73
|
+
private createTextArea;
|
|
74
|
+
/** Creates the DOM elements for the comment resize handle. */
|
|
75
|
+
private createResizeHandle;
|
|
76
|
+
/** Returns the root SVG group element of the comment view. */
|
|
77
|
+
getSvgRoot(): SVGGElement;
|
|
78
|
+
/** Returns the current size of the comment in workspace units. */
|
|
79
|
+
getSize(): Size;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the size of the comment in workspace units, and updates the view
|
|
82
|
+
* elements to reflect the new size.
|
|
83
|
+
*/
|
|
84
|
+
setSize(size: Size): void;
|
|
85
|
+
/**
|
|
86
|
+
* Calculates the minimum size for the uncollapsed comment based on text
|
|
87
|
+
* size and visible icons.
|
|
88
|
+
*
|
|
89
|
+
* The minimum width is based on the width of the truncated preview text.
|
|
90
|
+
*
|
|
91
|
+
* The minimum height is based on the height of the top bar.
|
|
92
|
+
*/
|
|
93
|
+
private calcMinSize;
|
|
94
|
+
/** Calculates the margin that should exist around the delete icon. */
|
|
95
|
+
private calcDeleteMargin;
|
|
96
|
+
/** Calculates the margin that should exist around the foldout icon. */
|
|
97
|
+
private calcFoldoutMargin;
|
|
98
|
+
/** Updates the size of the top bar to reflect the new size. */
|
|
99
|
+
private updateTopBarSize;
|
|
100
|
+
/** Updates the size of the text area elements to reflect the new size. */
|
|
101
|
+
private updateTextAreaSize;
|
|
102
|
+
/**
|
|
103
|
+
* Updates the position of the delete icon elements to reflect the new size.
|
|
104
|
+
*/
|
|
105
|
+
private updateDeleteIconPosition;
|
|
106
|
+
/**
|
|
107
|
+
* Updates the position of the foldout icon elements to reflect the new size.
|
|
108
|
+
*/
|
|
109
|
+
private updateFoldoutIconPosition;
|
|
110
|
+
/**
|
|
111
|
+
* Updates the size and position of the text preview elements to reflect the new size.
|
|
112
|
+
*/
|
|
113
|
+
private updateTextPreviewSize;
|
|
114
|
+
/** Updates the position of the resize handle to reflect the new size. */
|
|
115
|
+
private updateResizeHandlePosition;
|
|
116
|
+
/**
|
|
117
|
+
* Triggers listeners when the size of the comment changes, either
|
|
118
|
+
* progrmatically or manually by the user.
|
|
119
|
+
*/
|
|
120
|
+
private onSizeChange;
|
|
121
|
+
/**
|
|
122
|
+
* Registers a callback that listens for size changes.
|
|
123
|
+
*
|
|
124
|
+
* @param listener Receives callbacks when the size of the comment changes.
|
|
125
|
+
* The new and old size are in workspace units.
|
|
126
|
+
*/
|
|
127
|
+
addSizeChangeListener(listener: (oldSize: Size, newSize: Size) => void): void;
|
|
128
|
+
/** Removes the given listener from the list of size change listeners. */
|
|
129
|
+
removeSizeChangeListener(listener: () => void): void;
|
|
130
|
+
/**
|
|
131
|
+
* Handles starting an interaction with the resize handle to resize the
|
|
132
|
+
* comment.
|
|
133
|
+
*/
|
|
134
|
+
private onResizePointerDown;
|
|
135
|
+
/** Ends an interaction with the resize handle. */
|
|
136
|
+
private onResizePointerUp;
|
|
137
|
+
/** Resizes the comment in response to a drag on the resize handle. */
|
|
138
|
+
private onResizePointerMove;
|
|
139
|
+
/** Returns true if the comment is currently collapsed. */
|
|
140
|
+
isCollapsed(): boolean;
|
|
141
|
+
/** Sets whether the comment is currently collapsed or not. */
|
|
142
|
+
setCollapsed(collapsed: boolean): void;
|
|
143
|
+
/**
|
|
144
|
+
* Triggers listeners when the collapsed-ness of the comment changes, either
|
|
145
|
+
* progrmatically or manually by the user.
|
|
146
|
+
*/
|
|
147
|
+
private onCollapse;
|
|
148
|
+
/** Registers a callback that listens for collapsed-ness changes. */
|
|
149
|
+
addOnCollapseListener(listener: (newCollapse: boolean) => void): void;
|
|
150
|
+
/** Removes the given listener from the list of on collapse listeners. */
|
|
151
|
+
removeOnCollapseListener(listener: () => void): void;
|
|
152
|
+
/**
|
|
153
|
+
* Toggles the collapsedness of the block when we receive a pointer down
|
|
154
|
+
* event on the foldout icon.
|
|
155
|
+
*/
|
|
156
|
+
private onFoldoutDown;
|
|
157
|
+
/** Returns true if the comment is currently editable. */
|
|
158
|
+
isEditable(): boolean;
|
|
159
|
+
/** Sets the editability of the comment. */
|
|
160
|
+
setEditable(editable: boolean): void;
|
|
161
|
+
/** Returns the current location of the comment in workspace coordinates. */
|
|
162
|
+
getRelativeToSurfaceXY(): Coordinate;
|
|
163
|
+
/**
|
|
164
|
+
* Moves the comment view to the given location.
|
|
165
|
+
*
|
|
166
|
+
* @param location The location to move to in workspace coordinates.
|
|
167
|
+
*/
|
|
168
|
+
moveTo(location: Coordinate): void;
|
|
169
|
+
/** Retursn the current text of the comment. */
|
|
170
|
+
getText(): string;
|
|
171
|
+
/** Sets the current text of the comment. */
|
|
172
|
+
setText(text: string): void;
|
|
173
|
+
/** Registers a callback that listens for text changes. */
|
|
174
|
+
addTextChangeListener(listener: (oldText: string, newText: string) => void): void;
|
|
175
|
+
/** Removes the given listener from the list of text change listeners. */
|
|
176
|
+
removeTextChangeListener(listener: () => void): void;
|
|
177
|
+
/**
|
|
178
|
+
* Triggers listeners when the text of the comment changes, either
|
|
179
|
+
* progrmatically or manually by the user.
|
|
180
|
+
*/
|
|
181
|
+
private onTextChange;
|
|
182
|
+
/** Updates the preview text element to reflect the given text. */
|
|
183
|
+
private updateTextPreview;
|
|
184
|
+
/** Truncates the text to fit within the top view. */
|
|
185
|
+
private truncateText;
|
|
186
|
+
/** Brings the workspace comment to the front of its layer. */
|
|
187
|
+
private bringToFront;
|
|
188
|
+
/**
|
|
189
|
+
* Handles disposing of the comment when we get a pointer down event on the
|
|
190
|
+
* delete icon.
|
|
191
|
+
*/
|
|
192
|
+
private onDeleteDown;
|
|
193
|
+
/** Disposes of this comment view. */
|
|
194
|
+
dispose(): void;
|
|
195
|
+
/** Returns whether this comment view has been disposed or not. */
|
|
196
|
+
isDisposed(): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Returns true if this comment view is currently being disposed or has
|
|
199
|
+
* already been disposed.
|
|
200
|
+
*/
|
|
201
|
+
isDeadOrDying(): boolean;
|
|
202
|
+
/** Registers a callback that listens for disposal of this view. */
|
|
203
|
+
addDisposeListener(listener: () => void): void;
|
|
204
|
+
/** Removes the given listener from the list of disposal listeners. */
|
|
205
|
+
removeDisposeListener(listener: () => void): void;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=comment_view.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
import { IDraggable } from '../interfaces/i_draggable.js';
|
|
14
|
+
import { ISelectable } from '../interfaces/i_selectable.js';
|
|
15
|
+
export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement, IDraggable, ISelectable {
|
|
16
|
+
/** The class encompassing the svg elements making up the workspace comment. */
|
|
17
|
+
private view;
|
|
18
|
+
readonly workspace: WorkspaceSvg;
|
|
19
|
+
private dragStrategy;
|
|
20
|
+
/** Constructs the workspace comment, including the view. */
|
|
21
|
+
constructor(workspace: WorkspaceSvg, id?: string);
|
|
22
|
+
/**
|
|
23
|
+
* Adds listeners to the view that updates the model (i.e. the superclass)
|
|
24
|
+
* when changes are made to the view.
|
|
25
|
+
*/
|
|
26
|
+
private addModelUpdateBindings;
|
|
27
|
+
/** Sets the text of the comment. */
|
|
28
|
+
setText(text: string): void;
|
|
29
|
+
/** Sets the size of the comment. */
|
|
30
|
+
setSize(size: Size): void;
|
|
31
|
+
/** Sets whether the comment is collapsed or not. */
|
|
32
|
+
setCollapsed(collapsed: boolean): void;
|
|
33
|
+
/** Sets whether the comment is editable or not. */
|
|
34
|
+
setEditable(editable: boolean): void;
|
|
35
|
+
/** Returns the root SVG element of this comment. */
|
|
36
|
+
getSvgRoot(): SVGElement;
|
|
37
|
+
/** Returns the bounding rectangle of this comment in workspace coordinates. */
|
|
38
|
+
getBoundingRectangle(): Rect;
|
|
39
|
+
/** Move the comment by the given amounts in workspace coordinates. */
|
|
40
|
+
moveBy(dx: number, dy: number, reason?: string[] | undefined): void;
|
|
41
|
+
/** Moves the comment to the given location in workspace coordinates. */
|
|
42
|
+
moveTo(location: Coordinate, reason?: string[] | undefined): void;
|
|
43
|
+
/**
|
|
44
|
+
* Moves the comment during a drag. Doesn't fire move events.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
moveDuringDrag(location: Coordinate): void;
|
|
49
|
+
/**
|
|
50
|
+
* Adds the dragging CSS class to this comment.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
setDragging(dragging: boolean): void;
|
|
55
|
+
/** Disposes of the view. */
|
|
56
|
+
dispose(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Starts a gesture because we detected a pointer down on the comment
|
|
59
|
+
* (that wasn't otherwise gobbled up, e.g. by resizing).
|
|
60
|
+
*/
|
|
61
|
+
private startGesture;
|
|
62
|
+
/** Returns whether this comment is movable or not. */
|
|
63
|
+
isMovable(): boolean;
|
|
64
|
+
/** Starts a drag on the comment. */
|
|
65
|
+
startDrag(): void;
|
|
66
|
+
/** Drags the comment to the given location. */
|
|
67
|
+
drag(newLoc: Coordinate): void;
|
|
68
|
+
/** Ends the drag on the comment. */
|
|
69
|
+
endDrag(): void;
|
|
70
|
+
/** Moves the comment back to where it was at the start of a drag. */
|
|
71
|
+
revertDrag(): void;
|
|
72
|
+
select(): void;
|
|
73
|
+
unselect(): void;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=rendered_workspace_comment.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
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
|
+
protected location: Coordinate;
|
|
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
|
+
private fireCreateEvent;
|
|
40
|
+
private fireDeleteEvent;
|
|
41
|
+
/** Fires a comment change event. */
|
|
42
|
+
private fireChangeEvent;
|
|
43
|
+
/** Fires a comment collapse event. */
|
|
44
|
+
private fireCollapseEvent;
|
|
45
|
+
/** Sets the text of the comment. */
|
|
46
|
+
setText(text: string): void;
|
|
47
|
+
/** Returns the text of the comment. */
|
|
48
|
+
getText(): string;
|
|
49
|
+
/** Sets the comment's size in workspace units. */
|
|
50
|
+
setSize(size: Size): void;
|
|
51
|
+
/** Returns the comment's size in workspace units. */
|
|
52
|
+
getSize(): Size;
|
|
53
|
+
/** Sets whether the comment is collapsed or not. */
|
|
54
|
+
setCollapsed(collapsed: boolean): void;
|
|
55
|
+
/** Returns whether the comment is collapsed or not. */
|
|
56
|
+
isCollapsed(): boolean;
|
|
57
|
+
/** Sets whether the comment is editable or not. */
|
|
58
|
+
setEditable(editable: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Returns whether the comment is editable or not, respecting whether the
|
|
61
|
+
* workspace is read-only.
|
|
62
|
+
*/
|
|
63
|
+
isEditable(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Returns whether the comment is editable or not, only examining its own
|
|
66
|
+
* state and ignoring the state of the workspace.
|
|
67
|
+
*/
|
|
68
|
+
isOwnEditable(): boolean;
|
|
69
|
+
/** Sets whether the comment is movable or not. */
|
|
70
|
+
setMovable(movable: boolean): void;
|
|
71
|
+
/**
|
|
72
|
+
* Returns whether the comment is movable or not, respecting whether the
|
|
73
|
+
* workspace is read-only.
|
|
74
|
+
*/
|
|
75
|
+
isMovable(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Returns whether the comment is movable or not, only examining its own
|
|
78
|
+
* state and ignoring the state of the workspace.
|
|
79
|
+
*/
|
|
80
|
+
isOwnMovable(): boolean;
|
|
81
|
+
/** Sets whether the comment is deletable or not. */
|
|
82
|
+
setDeletable(deletable: boolean): void;
|
|
83
|
+
/**
|
|
84
|
+
* Returns whether the comment is deletable or not, respecting whether the
|
|
85
|
+
* workspace is read-only.
|
|
86
|
+
*/
|
|
87
|
+
isDeletable(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Returns whether the comment is deletable or not, only examining its own
|
|
90
|
+
* state and ignoring the state of the workspace.
|
|
91
|
+
*/
|
|
92
|
+
isOwnDeletable(): boolean;
|
|
93
|
+
/** Moves the comment to the given location in workspace coordinates. */
|
|
94
|
+
moveTo(location: Coordinate, reason?: string[] | undefined): void;
|
|
95
|
+
/** Returns the position of the comment in workspace coordinates. */
|
|
96
|
+
getRelativeToSurfaceXY(): Coordinate;
|
|
97
|
+
/** Disposes of this comment. */
|
|
98
|
+
dispose(): void;
|
|
99
|
+
/** Returns whether the comment has been disposed or not. */
|
|
100
|
+
isDisposed(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Returns true if this comment view is currently being disposed or has
|
|
103
|
+
* already been disposed.
|
|
104
|
+
*/
|
|
105
|
+
isDeadOrDying(): boolean;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=workspace_comment.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export { CommentView } from './comments/comment_view.js';
|
|
7
|
+
export { WorkspaceComment } from './comments/workspace_comment.js';
|
|
8
|
+
export { RenderedWorkspaceComment } from './comments/rendered_workspace_comment.js';
|
|
9
|
+
//# sourceMappingURL=comments.d.ts.map
|
package/core/connection.d.ts
CHANGED
|
@@ -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
|
|
114
|
+
* @returns Whether the blocks are now connected or not.
|
|
115
115
|
*/
|
|
116
116
|
connect(otherConnection: Connection): boolean;
|
|
117
117
|
/**
|
package/core/delete_area.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { IDeletable } from '../interfaces/i_deletable.js';
|
|
7
|
+
import { IDragger } from '../interfaces/i_dragger.js';
|
|
8
|
+
import { IDraggable } from '../interfaces/i_draggable.js';
|
|
9
|
+
import { Coordinate } from '../utils/coordinate.js';
|
|
10
|
+
import { WorkspaceSvg } from '../workspace_svg.js';
|
|
11
|
+
export declare class Dragger implements IDragger {
|
|
12
|
+
private draggable;
|
|
13
|
+
private workspace;
|
|
14
|
+
private startLoc;
|
|
15
|
+
private dragTarget;
|
|
16
|
+
constructor(draggable: IDraggable, workspace: WorkspaceSvg);
|
|
17
|
+
/** Handles any drag startup. */
|
|
18
|
+
onDragStart(e: PointerEvent): void;
|
|
19
|
+
/**
|
|
20
|
+
* Handles calculating where the element should actually be moved to.
|
|
21
|
+
*
|
|
22
|
+
* @param totalDelta The total amount in pixel coordinates the mouse has moved
|
|
23
|
+
* since the start of the drag.
|
|
24
|
+
*/
|
|
25
|
+
onDrag(e: PointerEvent, totalDelta: Coordinate): void;
|
|
26
|
+
/** Updates the drag target under the pointer (if there is one). */
|
|
27
|
+
protected updateDragTarget(e: PointerEvent): void;
|
|
28
|
+
/**
|
|
29
|
+
* Calculates the correct workspace coordinate for the movable and tells
|
|
30
|
+
* the draggable to go to that location.
|
|
31
|
+
*/
|
|
32
|
+
private moveDraggable;
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if we would delete the draggable if it was dropped
|
|
35
|
+
* at the current location.
|
|
36
|
+
*/
|
|
37
|
+
protected wouldDeleteDraggable(e: PointerEvent, draggable: IDraggable & IDeletable): boolean;
|
|
38
|
+
/** Handles any drag cleanup. */
|
|
39
|
+
onDragEnd(e: PointerEvent): void;
|
|
40
|
+
/**
|
|
41
|
+
* Returns true if we should return the draggable to its original location
|
|
42
|
+
* at the end of the drag.
|
|
43
|
+
*/
|
|
44
|
+
protected shouldReturnToStart(e: PointerEvent, draggable: IDraggable): boolean;
|
|
45
|
+
protected pixelsToWorkspaceUnits(pixelCoord: Coordinate): Coordinate;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=dragger.d.ts.map
|
package/core/events/events.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { CommentChange, CommentChangeJson } from './events_comment_change.js';
|
|
|
18
18
|
import { CommentCreate, CommentCreateJson } from './events_comment_create.js';
|
|
19
19
|
import { CommentDelete } from './events_comment_delete.js';
|
|
20
20
|
import { CommentMove, CommentMoveJson } from './events_comment_move.js';
|
|
21
|
+
import { CommentCollapse, CommentCollapseJson } from './events_comment_collapse.js';
|
|
21
22
|
import { MarkerMove, MarkerMoveJson } from './events_marker_move.js';
|
|
22
23
|
import { Selected, SelectedJson } from './events_selected.js';
|
|
23
24
|
import { ThemeChange, ThemeChangeJson } from './events_theme_change.js';
|
|
@@ -62,6 +63,8 @@ export { CommentCreateJson };
|
|
|
62
63
|
export { CommentDelete };
|
|
63
64
|
export { CommentMove };
|
|
64
65
|
export { CommentMoveJson };
|
|
66
|
+
export { CommentCollapse };
|
|
67
|
+
export { CommentCollapseJson };
|
|
65
68
|
export { FinishedLoading };
|
|
66
69
|
export { MarkerMove };
|
|
67
70
|
export { MarkerMoveJson };
|
|
@@ -13,7 +13,7 @@ import { AbstractEventJson } from './events_abstract.js';
|
|
|
13
13
|
import { UiBase } from './events_ui_base.js';
|
|
14
14
|
import { Workspace } from '../workspace.js';
|
|
15
15
|
/**
|
|
16
|
-
* Notifies listeners that
|
|
16
|
+
* Notifies listeners that some blockly element was clicked.
|
|
17
17
|
*/
|
|
18
18
|
export declare class Click extends UiBase {
|
|
19
19
|
/** The ID of the block that was clicked, if a block was clicked. */
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
* Copyright 2018 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Base class for comment events.
|
|
8
|
+
*
|
|
9
|
+
* @class
|
|
10
|
+
*/
|
|
11
|
+
import type { WorkspaceComment } from '../comments/workspace_comment.js';
|
|
7
12
|
import { Abstract as AbstractEvent, AbstractEventJson } from './events_abstract.js';
|
|
8
13
|
import type { CommentCreate } from './events_comment_create.js';
|
|
9
14
|
import type { CommentDelete } from './events_comment_delete.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2018 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import type { WorkspaceComment } from '../workspace_comment.js';
|
|
6
|
+
import type { WorkspaceComment } from '../comments/workspace_comment.js';
|
|
7
7
|
import { CommentBase, CommentBaseJson } from './events_comment_base.js';
|
|
8
8
|
import type { Workspace } from '../workspace.js';
|
|
9
9
|
/**
|