blockly 11.0.0-beta.2 → 11.0.0-beta.4
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 +365 -399
- package/blockly_compressed.js +333 -330
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +18 -20
- package/blocks_compressed.js.map +1 -1
- package/core/block.d.ts +2 -2
- package/core/block_dragger.d.ts +66 -4
- package/core/blockly.d.ts +6 -6
- package/core/comments/comment_view.d.ts +200 -0
- package/core/comments/workspace_comment.d.ts +94 -0
- package/core/comments.d.ts +8 -0
- package/core/events/events_click.d.ts +1 -1
- package/core/field_dropdown.d.ts +1 -0
- package/core/field_image.d.ts +1 -1
- package/core/generator.d.ts +1 -1
- package/core/grid.d.ts +29 -8
- package/core/icons/comment_icon.d.ts +1 -1
- package/core/icons/icon_types.d.ts +2 -2
- package/core/insertion_marker_manager.d.ts +2 -0
- package/core/insertion_marker_previewer.d.ts +56 -0
- package/core/interfaces/i_comment_icon.d.ts +17 -0
- package/core/interfaces/i_connection_previewer.d.ts +39 -0
- package/core/registry.d.ts +4 -2
- package/core/render_management.d.ts +4 -1
- package/core/rendered_connection.d.ts +3 -1
- package/core/renderers/common/constants.d.ts +6 -2
- package/core/renderers/common/drawer.d.ts +18 -0
- package/core/renderers/common/i_path_object.d.ts +6 -15
- package/core/renderers/common/info.d.ts +5 -2
- package/core/renderers/common/path_object.d.ts +13 -0
- package/core/renderers/common/renderer.d.ts +3 -0
- package/core/renderers/measurables/connection.d.ts +1 -0
- package/core/renderers/zelos/drawer.d.ts +4 -0
- package/core/renderers/zelos/renderer.d.ts +4 -2
- package/core/serialization/procedures.d.ts +8 -0
- package/core/utils/keycodes.d.ts +32 -32
- package/core/utils/size.d.ts +10 -0
- package/core/workspace_audio.d.ts +10 -0
- package/core/workspace_svg.d.ts +0 -1
- package/core-node.js +31 -0
- package/dart_compressed.js +18 -68
- 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_compressed.js +14 -49
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +18 -40
- package/lua_compressed.js.map +1 -1
- package/media/arrow-dropdown.svg +1 -0
- package/media/resize-handle.svg +3 -0
- package/msg/ar.js +1 -1
- package/msg/be-tarask.js +8 -8
- package/msg/bn.js +5 -5
- package/msg/ce.d.ts +8 -0
- package/msg/da.js +4 -4
- package/msg/dtp.d.ts +8 -0
- package/msg/el.js +1 -1
- package/msg/he.js +1 -1
- package/msg/hsb.d.ts +8 -0
- package/msg/id.js +6 -6
- package/msg/inh.js +3 -3
- package/msg/ja.js +1 -1
- package/msg/nl.js +3 -3
- package/msg/pt.js +1 -1
- package/msg/ta.js +2 -2
- package/msg/tdd.d.ts +8 -0
- package/msg/tl.js +2 -2
- package/msg/ur.js +2 -2
- package/msg/zh-hant.js +14 -14
- package/package.json +44 -13
- package/php_compressed.js +10 -43
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +18 -37
- package/python_compressed.js.map +1 -1
- package/blockly.js +0 -22
- package/blocks.js +0 -22
- package/browser.js +0 -30
- 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-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/msg.d.ts +0 -440
- package/msg/qqq.d.ts +0 -14
- package/msg/synonyms.d.ts +0 -14
- package/msg/yue.js +0 -441
- package/node.js +0 -21
- package/php.js +0 -22
- 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
|
|
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,7 @@ 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
|
-
|
|
141
|
+
protected disposing: boolean;
|
|
142
142
|
/**
|
|
143
143
|
* Has this block been fully initialized? E.g. all fields initailized.
|
|
144
144
|
*
|
package/core/block_dragger.d.ts
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
import './events/events_block_drag.js';
|
|
12
12
|
import type { BlockSvg } from './block_svg.js';
|
|
13
13
|
import type { Icon } from './icons/icon.js';
|
|
14
|
-
import { InsertionMarkerManager } from './insertion_marker_manager.js';
|
|
15
14
|
import type { IBlockDragger } from './interfaces/i_block_dragger.js';
|
|
16
15
|
import { Coordinate } from './utils/coordinate.js';
|
|
17
16
|
import type { WorkspaceSvg } from './workspace_svg.js';
|
|
17
|
+
import { IConnectionPreviewer } from './blockly.js';
|
|
18
18
|
/**
|
|
19
19
|
* Class for a block dragger. It moves blocks around the workspace when they
|
|
20
20
|
* are being dragged by a mouse or touch.
|
|
@@ -22,14 +22,22 @@ import type { WorkspaceSvg } from './workspace_svg.js';
|
|
|
22
22
|
export declare class BlockDragger implements IBlockDragger {
|
|
23
23
|
/** The top block in the stack that is being dragged. */
|
|
24
24
|
protected draggingBlock_: BlockSvg;
|
|
25
|
-
protected
|
|
25
|
+
protected connectionPreviewer: IConnectionPreviewer;
|
|
26
26
|
/** The workspace on which the block is being dragged. */
|
|
27
27
|
protected workspace_: WorkspaceSvg;
|
|
28
28
|
/** Which drag area the mouse pointer is over, if any. */
|
|
29
29
|
private dragTarget_;
|
|
30
|
+
private connectionCandidate;
|
|
30
31
|
/** Whether the block would be deleted if dropped immediately. */
|
|
31
32
|
protected wouldDeleteBlock_: boolean;
|
|
32
33
|
protected startXY_: Coordinate;
|
|
34
|
+
/** The parent block at the start of the drag. */
|
|
35
|
+
private startParentConn;
|
|
36
|
+
/**
|
|
37
|
+
* The child block at the start of the drag. Only gets set if
|
|
38
|
+
* `healStack` is true.
|
|
39
|
+
*/
|
|
40
|
+
private startChildConn;
|
|
33
41
|
/**
|
|
34
42
|
* @param block The block to drag.
|
|
35
43
|
* @param workspace The workspace to drag on.
|
|
@@ -71,10 +79,58 @@ export declare class BlockDragger implements IBlockDragger {
|
|
|
71
79
|
* display accordingly.
|
|
72
80
|
*
|
|
73
81
|
* @param e The most recent move event.
|
|
74
|
-
* @param
|
|
82
|
+
* @param delta How far the pointer has moved from the position
|
|
83
|
+
* at the start of the drag, in pixel units.
|
|
84
|
+
*/
|
|
85
|
+
drag(e: PointerEvent, delta: Coordinate): void;
|
|
86
|
+
/**
|
|
87
|
+
* @param draggingBlock The block being dragged.
|
|
88
|
+
* @param dragDelta How far the pointer has moved from the position
|
|
89
|
+
* at the start of the drag, in pixel units.
|
|
90
|
+
*/
|
|
91
|
+
private moveBlock;
|
|
92
|
+
private updateDragTargets;
|
|
93
|
+
/**
|
|
94
|
+
* Returns true if we would delete the block if it was dropped at this time,
|
|
95
|
+
* false otherwise.
|
|
96
|
+
*
|
|
97
|
+
* @param e The most recent move event.
|
|
98
|
+
* @param draggingBlock The block being dragged.
|
|
99
|
+
* @param delta How far the pointer has moved from the position
|
|
100
|
+
* at the start of the drag, in pixel units.
|
|
101
|
+
*/
|
|
102
|
+
private wouldDeleteBlock;
|
|
103
|
+
/**
|
|
104
|
+
* @param draggingBlock The block being dragged.
|
|
105
|
+
* @param dragDelta How far the pointer has moved from the position
|
|
75
106
|
* at the start of the drag, in pixel units.
|
|
76
107
|
*/
|
|
77
|
-
|
|
108
|
+
private updateConnectionPreview;
|
|
109
|
+
/**
|
|
110
|
+
* Returns true if the given orphan block can connect at the end of the
|
|
111
|
+
* top block's stack or row, false otherwise.
|
|
112
|
+
*/
|
|
113
|
+
private orphanCanConnectAtEnd;
|
|
114
|
+
/**
|
|
115
|
+
* Returns true if the current candidate is better than the new candidate.
|
|
116
|
+
*
|
|
117
|
+
* We slightly prefer the current candidate even if it is farther away.
|
|
118
|
+
*/
|
|
119
|
+
private currCandidateIsBetter;
|
|
120
|
+
/**
|
|
121
|
+
* Returns the closest valid candidate connection, if one can be found.
|
|
122
|
+
*
|
|
123
|
+
* Valid neighbour connections are within the configured start radius, with a
|
|
124
|
+
* compatible type (input, output, etc) and connection check.
|
|
125
|
+
*/
|
|
126
|
+
private getConnectionCandidate;
|
|
127
|
+
/**
|
|
128
|
+
* Returns all of the connections we might connect to blocks on the workspace.
|
|
129
|
+
*
|
|
130
|
+
* Includes any connections on the dragging block, and any last next
|
|
131
|
+
* connection on the stack (if one exists).
|
|
132
|
+
*/
|
|
133
|
+
private getLocalConnections;
|
|
78
134
|
/**
|
|
79
135
|
* Finish a block drag and put the block back on the workspace.
|
|
80
136
|
*
|
|
@@ -83,6 +139,11 @@ export declare class BlockDragger implements IBlockDragger {
|
|
|
83
139
|
* at the start of the drag, in pixel units.
|
|
84
140
|
*/
|
|
85
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;
|
|
86
147
|
/**
|
|
87
148
|
* Calculates the drag delta and new location values after a block is dragged.
|
|
88
149
|
*
|
|
@@ -107,6 +168,7 @@ export declare class BlockDragger implements IBlockDragger {
|
|
|
107
168
|
* Updates the necessary information to place a block at a certain location.
|
|
108
169
|
*/
|
|
109
170
|
protected updateBlockAfterMove_(): void;
|
|
171
|
+
private applyConnections;
|
|
110
172
|
/** Fire a UI event at the end of a block drag. */
|
|
111
173
|
protected fireDragEndEvent_(): void;
|
|
112
174
|
/**
|
package/core/blockly.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { ConnectionType } from './connection_type.js';
|
|
|
28
28
|
import * as ContextMenu from './contextmenu.js';
|
|
29
29
|
import * as ContextMenuItems from './contextmenu_items.js';
|
|
30
30
|
import { ContextMenuRegistry } from './contextmenu_registry.js';
|
|
31
|
+
import * as comments from './comments.js';
|
|
31
32
|
import * as Css from './css.js';
|
|
32
33
|
import { DeleteArea } from './delete_area.js';
|
|
33
34
|
import * as dialog from './dialog.js';
|
|
@@ -36,14 +37,11 @@ import * as dropDownDiv from './dropdowndiv.js';
|
|
|
36
37
|
import * as Events from './events/events.js';
|
|
37
38
|
import * as Extensions from './extensions.js';
|
|
38
39
|
import { Field, FieldConfig, FieldValidator, UnattachedFieldError } from './field.js';
|
|
39
|
-
import { FieldAngle, FieldAngleConfig, FieldAngleFromJsonConfig, FieldAngleValidator } from './field_angle.js';
|
|
40
40
|
import { FieldCheckbox, FieldCheckboxConfig, FieldCheckboxFromJsonConfig, FieldCheckboxValidator } from './field_checkbox.js';
|
|
41
|
-
import { FieldColour, FieldColourConfig, FieldColourFromJsonConfig, FieldColourValidator } from './field_colour.js';
|
|
42
41
|
import { FieldDropdown, FieldDropdownConfig, FieldDropdownFromJsonConfig, FieldDropdownValidator, MenuGenerator, MenuGeneratorFunction, MenuOption } from './field_dropdown.js';
|
|
43
42
|
import { FieldImage, FieldImageConfig, FieldImageFromJsonConfig } from './field_image.js';
|
|
44
43
|
import { FieldLabel, FieldLabelConfig, FieldLabelFromJsonConfig } from './field_label.js';
|
|
45
44
|
import { FieldLabelSerializable } from './field_label_serializable.js';
|
|
46
|
-
import { FieldMultilineInput, FieldMultilineInputConfig, FieldMultilineInputFromJsonConfig, FieldMultilineInputValidator } from './field_multilineinput.js';
|
|
47
45
|
import { FieldNumber, FieldNumberConfig, FieldNumberFromJsonConfig, FieldNumberValidator } from './field_number.js';
|
|
48
46
|
import * as fieldRegistry from './field_registry.js';
|
|
49
47
|
import { FieldTextInput, FieldTextInputConfig, FieldTextInputFromJsonConfig, FieldTextInputValidator } from './field_textinput.js';
|
|
@@ -61,6 +59,7 @@ import { inject } from './inject.js';
|
|
|
61
59
|
import { Input } from './inputs/input.js';
|
|
62
60
|
import * as inputs from './inputs.js';
|
|
63
61
|
import { InsertionMarkerManager } from './insertion_marker_manager.js';
|
|
62
|
+
import { InsertionMarkerPreviewer } from './insertion_marker_previewer.js';
|
|
64
63
|
import { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
|
|
65
64
|
import { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
|
|
66
65
|
import { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
|
|
@@ -71,6 +70,7 @@ import { IBubble } from './interfaces/i_bubble.js';
|
|
|
71
70
|
import { ICollapsibleToolboxItem } from './interfaces/i_collapsible_toolbox_item.js';
|
|
72
71
|
import { IComponent } from './interfaces/i_component.js';
|
|
73
72
|
import { IConnectionChecker } from './interfaces/i_connection_checker.js';
|
|
73
|
+
import { IConnectionPreviewer } from './interfaces/i_connection_previewer.js';
|
|
74
74
|
import { IContextMenu } from './interfaces/i_contextmenu.js';
|
|
75
75
|
import { ICopyable, isCopyable } from './interfaces/i_copyable.js';
|
|
76
76
|
import { IDeletable } from './interfaces/i_deletable.js';
|
|
@@ -309,19 +309,17 @@ export { ConnectionType };
|
|
|
309
309
|
export { ConnectionChecker };
|
|
310
310
|
export { ConnectionDB };
|
|
311
311
|
export { ContextMenuRegistry };
|
|
312
|
+
export { comments };
|
|
312
313
|
export { Cursor };
|
|
313
314
|
export { DeleteArea };
|
|
314
315
|
export { DragTarget };
|
|
315
316
|
export declare const DropDownDiv: typeof dropDownDiv;
|
|
316
317
|
export { Field, FieldConfig, FieldValidator, UnattachedFieldError };
|
|
317
|
-
export { FieldAngle, FieldAngleConfig, FieldAngleFromJsonConfig, FieldAngleValidator, };
|
|
318
318
|
export { FieldCheckbox, FieldCheckboxConfig, FieldCheckboxFromJsonConfig, FieldCheckboxValidator, };
|
|
319
|
-
export { FieldColour, FieldColourConfig, FieldColourFromJsonConfig, FieldColourValidator, };
|
|
320
319
|
export { FieldDropdown, FieldDropdownConfig, FieldDropdownFromJsonConfig, FieldDropdownValidator, MenuGenerator, MenuGeneratorFunction, MenuOption, };
|
|
321
320
|
export { FieldImage, FieldImageConfig, FieldImageFromJsonConfig };
|
|
322
321
|
export { FieldLabel, FieldLabelConfig, FieldLabelFromJsonConfig };
|
|
323
322
|
export { FieldLabelSerializable };
|
|
324
|
-
export { FieldMultilineInput, FieldMultilineInputConfig, FieldMultilineInputFromJsonConfig, FieldMultilineInputValidator, };
|
|
325
323
|
export { FieldNumber, FieldNumberConfig, FieldNumberFromJsonConfig, FieldNumberValidator, };
|
|
326
324
|
export { FieldTextInput, FieldTextInputConfig, FieldTextInputFromJsonConfig, FieldTextInputValidator, };
|
|
327
325
|
export { FieldVariable, FieldVariableConfig, FieldVariableFromJsonConfig, FieldVariableValidator, };
|
|
@@ -343,6 +341,7 @@ export { IBubble };
|
|
|
343
341
|
export { ICollapsibleToolboxItem };
|
|
344
342
|
export { IComponent };
|
|
345
343
|
export { IConnectionChecker };
|
|
344
|
+
export { IConnectionPreviewer };
|
|
346
345
|
export { IContextMenu };
|
|
347
346
|
export { icons };
|
|
348
347
|
export { ICopyable, isCopyable };
|
|
@@ -359,6 +358,7 @@ export { IMovable };
|
|
|
359
358
|
export { Input };
|
|
360
359
|
export { inputs };
|
|
361
360
|
export { InsertionMarkerManager };
|
|
361
|
+
export { InsertionMarkerPreviewer };
|
|
362
362
|
export { IObservable, isObservable };
|
|
363
363
|
export { IPaster, isPaster };
|
|
364
364
|
export { IPositionable };
|
|
@@ -0,0 +1,200 @@
|
|
|
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, Size } from '../utils.js';
|
|
9
|
+
export declare class CommentView implements IRenderedElement {
|
|
10
|
+
private readonly workspace;
|
|
11
|
+
/** The root group element of the comment view. */
|
|
12
|
+
private svgRoot;
|
|
13
|
+
/** The rect background for the top bar. */
|
|
14
|
+
private topBar;
|
|
15
|
+
/** The delete icon that goes in the top bar. */
|
|
16
|
+
private deleteIcon;
|
|
17
|
+
/** The foldout icon that goes in the top bar. */
|
|
18
|
+
private foldoutIcon;
|
|
19
|
+
/** The text element that goes in the top bar. */
|
|
20
|
+
private textPreview;
|
|
21
|
+
/** The actual text node in the text preview. */
|
|
22
|
+
private textPreviewNode;
|
|
23
|
+
/** The resize handle element. */
|
|
24
|
+
private resizeHandle;
|
|
25
|
+
/** The foreignObject containing the HTML text area. */
|
|
26
|
+
private foreignObject;
|
|
27
|
+
/** The text area where the user can type. */
|
|
28
|
+
private textArea;
|
|
29
|
+
/** The current size of the comment in workspace units. */
|
|
30
|
+
private size;
|
|
31
|
+
/** Whether the comment is collapsed or not. */
|
|
32
|
+
private collapsed;
|
|
33
|
+
/** Whether the comment is editable or not. */
|
|
34
|
+
private editable;
|
|
35
|
+
/** The current location of the comment in workspace coordinates. */
|
|
36
|
+
private location;
|
|
37
|
+
/** The current text of the comment. Updates on text area change. */
|
|
38
|
+
private text;
|
|
39
|
+
/** Listeners for changes to text. */
|
|
40
|
+
private textChangeListeners;
|
|
41
|
+
/** Listeners for changes to size. */
|
|
42
|
+
private sizeChangeListeners;
|
|
43
|
+
/** Listeners for disposal. */
|
|
44
|
+
private disposeListeners;
|
|
45
|
+
/** Listeners for collapsing. */
|
|
46
|
+
private collapseChangeListeners;
|
|
47
|
+
/**
|
|
48
|
+
* Event data for the pointer up event on the resize handle. Used to
|
|
49
|
+
* unregister the listener.
|
|
50
|
+
*/
|
|
51
|
+
private resizePointerUpListener;
|
|
52
|
+
/**
|
|
53
|
+
* Event data for the pointer move event on the resize handle. Used to
|
|
54
|
+
* unregister the listener.
|
|
55
|
+
*/
|
|
56
|
+
private resizePointerMoveListener;
|
|
57
|
+
/** Whether this comment view is currently being disposed or not. */
|
|
58
|
+
private disposing;
|
|
59
|
+
/** Whether this comment view has been disposed or not. */
|
|
60
|
+
private disposed;
|
|
61
|
+
constructor(workspace: WorkspaceSvg);
|
|
62
|
+
/**
|
|
63
|
+
* Creates the top bar and the elements visually within it.
|
|
64
|
+
* Registers event listeners.
|
|
65
|
+
*/
|
|
66
|
+
private createTopBar;
|
|
67
|
+
/**
|
|
68
|
+
* Creates the text area where users can type. Registers event listeners.
|
|
69
|
+
*/
|
|
70
|
+
private createTextArea;
|
|
71
|
+
/** Creates the DOM elements for the comment resize handle. */
|
|
72
|
+
private createResizeHandle;
|
|
73
|
+
/** Returns the root SVG group element of the comment view. */
|
|
74
|
+
getSvgRoot(): SVGGElement;
|
|
75
|
+
/** Returns the current size of the comment in workspace units. */
|
|
76
|
+
getSize(): Size;
|
|
77
|
+
/**
|
|
78
|
+
* Sets the size of the comment in workspace units, and updates the view
|
|
79
|
+
* elements to reflect the new size.
|
|
80
|
+
*/
|
|
81
|
+
setSize(size: Size): void;
|
|
82
|
+
/**
|
|
83
|
+
* Calculates the minimum size for the uncollapsed comment based on text
|
|
84
|
+
* size and visible icons.
|
|
85
|
+
*
|
|
86
|
+
* The minimum width is based on the width of the truncated preview text.
|
|
87
|
+
*
|
|
88
|
+
* The minimum height is based on the height of the top bar.
|
|
89
|
+
*/
|
|
90
|
+
private calcMinSize;
|
|
91
|
+
/** Calculates the margin that should exist around the delete icon. */
|
|
92
|
+
private calcDeleteMargin;
|
|
93
|
+
/** Calculates the margin that should exist around the foldout icon. */
|
|
94
|
+
private calcFoldoutMargin;
|
|
95
|
+
/** Updates the size of the text area elements to reflect the new size. */
|
|
96
|
+
private updateTextAreaSize;
|
|
97
|
+
/**
|
|
98
|
+
* Updates the position of the delete icon elements to reflect the new size.
|
|
99
|
+
*/
|
|
100
|
+
private updateDeleteIconPosition;
|
|
101
|
+
/**
|
|
102
|
+
* Updates the position of the foldout icon elements to reflect the new size.
|
|
103
|
+
*/
|
|
104
|
+
private updateFoldoutIconPosition;
|
|
105
|
+
/**
|
|
106
|
+
* Updates the size and position of the text preview elements to reflect the new size.
|
|
107
|
+
*/
|
|
108
|
+
private updateTextPreviewSize;
|
|
109
|
+
/**
|
|
110
|
+
* Triggers listeners when the size of the comment changes, either
|
|
111
|
+
* progrmatically or manually by the user.
|
|
112
|
+
*/
|
|
113
|
+
private onSizeChange;
|
|
114
|
+
/**
|
|
115
|
+
* Registers a callback that listens for size changes.
|
|
116
|
+
*
|
|
117
|
+
* @param listener Receives callbacks when the size of the comment changes.
|
|
118
|
+
* The new and old size are in workspace units.
|
|
119
|
+
*/
|
|
120
|
+
addSizeChangeListener(listener: (oldSize: Size, newSize: Size) => void): void;
|
|
121
|
+
/** Removes the given listener from the list of size change listeners. */
|
|
122
|
+
removeSizeChangeListener(listener: () => void): void;
|
|
123
|
+
/**
|
|
124
|
+
* Handles starting an interaction with the resize handle to resize the
|
|
125
|
+
* comment.
|
|
126
|
+
*/
|
|
127
|
+
private onResizePointerDown;
|
|
128
|
+
/** Ends an interaction with the resize handle. */
|
|
129
|
+
private onResizePointerUp;
|
|
130
|
+
/** Resizes the comment in response to a drag on the resize handle. */
|
|
131
|
+
private onResizePointerMove;
|
|
132
|
+
/** Returns true if the comment is currently collapsed. */
|
|
133
|
+
isCollapsed(): boolean;
|
|
134
|
+
/** Sets whether the comment is currently collapsed or not. */
|
|
135
|
+
setCollapsed(collapsed: boolean): void;
|
|
136
|
+
/**
|
|
137
|
+
* Triggers listeners when the collapsed-ness of the comment changes, either
|
|
138
|
+
* progrmatically or manually by the user.
|
|
139
|
+
*/
|
|
140
|
+
private onCollapse;
|
|
141
|
+
/** Registers a callback that listens for collapsed-ness changes. */
|
|
142
|
+
addOnCollapseListener(listener: (newCollapse: boolean) => void): void;
|
|
143
|
+
/** Removes the given listener from the list of on collapse listeners. */
|
|
144
|
+
removeOnCollapseListener(listener: () => void): void;
|
|
145
|
+
/**
|
|
146
|
+
* Toggles the collapsedness of the block when we receive a pointer down
|
|
147
|
+
* event on the foldout icon.
|
|
148
|
+
*/
|
|
149
|
+
private onFoldoutDown;
|
|
150
|
+
/** Returns true if the comment is currently editable. */
|
|
151
|
+
isEditable(): boolean;
|
|
152
|
+
/** Sets the editability of the comment. */
|
|
153
|
+
setEditable(editable: boolean): void;
|
|
154
|
+
/** Returns the current location of the comment in workspace coordinates. */
|
|
155
|
+
getRelativeToSurfaceXY(): Coordinate;
|
|
156
|
+
/**
|
|
157
|
+
* Moves the comment view to the given location.
|
|
158
|
+
*
|
|
159
|
+
* @param location The location to move to in workspace coordinates.
|
|
160
|
+
*/
|
|
161
|
+
moveTo(location: Coordinate): void;
|
|
162
|
+
/** Retursn the current text of the comment. */
|
|
163
|
+
getText(): string;
|
|
164
|
+
/** Sets the current text of the comment. */
|
|
165
|
+
setText(text: string): void;
|
|
166
|
+
/** Registers a callback that listens for text changes. */
|
|
167
|
+
addTextChangeListener(listener: (oldText: string, newText: string) => void): void;
|
|
168
|
+
/** Removes the given listener from the list of text change listeners. */
|
|
169
|
+
removeTextChangeListener(listener: () => void): void;
|
|
170
|
+
/**
|
|
171
|
+
* Triggers listeners when the text of the comment changes, either
|
|
172
|
+
* progrmatically or manually by the user.
|
|
173
|
+
*/
|
|
174
|
+
private onTextChange;
|
|
175
|
+
/** Updates the preview text element to reflect the given text. */
|
|
176
|
+
private updateTextPreview;
|
|
177
|
+
/** Truncates the text to fit within the top view. */
|
|
178
|
+
private truncateText;
|
|
179
|
+
/** Brings the workspace comment to the front of its layer. */
|
|
180
|
+
private bringToFront;
|
|
181
|
+
/**
|
|
182
|
+
* Handles disposing of the comment when we get a pointer down event on the
|
|
183
|
+
* delete icon.
|
|
184
|
+
*/
|
|
185
|
+
private onDeleteDown;
|
|
186
|
+
/** Disposes of this comment view. */
|
|
187
|
+
dispose(): void;
|
|
188
|
+
/** Returns whether this comment view has been disposed or not. */
|
|
189
|
+
isDisposed(): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Returns true if this comment view is currently being disposed or has
|
|
192
|
+
* already been disposed.
|
|
193
|
+
*/
|
|
194
|
+
isDeadOrDying(): boolean;
|
|
195
|
+
/** Registers a callback that listens for disposal of this view. */
|
|
196
|
+
addDisposeListener(listener: () => void): void;
|
|
197
|
+
/** Removes the given listener from the list of disposal listeners. */
|
|
198
|
+
removeDisposeListener(listener: () => void): void;
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=comment_view.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
private disposed;
|
|
29
|
+
/**
|
|
30
|
+
* Constructs the comment.
|
|
31
|
+
*
|
|
32
|
+
* @param workspace The workspace to construct the comment in.
|
|
33
|
+
* @param id An optional ID to give to the comment. If not provided, one will
|
|
34
|
+
* be generated.
|
|
35
|
+
*/
|
|
36
|
+
constructor(workspace: Workspace, id?: string);
|
|
37
|
+
/** Sets the text of the comment. */
|
|
38
|
+
setText(text: string): void;
|
|
39
|
+
/** Returns the text of the comment. */
|
|
40
|
+
getText(): string;
|
|
41
|
+
/** Sets the comment's size in workspace units. */
|
|
42
|
+
setSize(size: Size): void;
|
|
43
|
+
/** Returns the comment's size in workspace units. */
|
|
44
|
+
getSize(): Size;
|
|
45
|
+
/** Sets whether the comment is collapsed or not. */
|
|
46
|
+
setCollapsed(collapsed: boolean): void;
|
|
47
|
+
/** Returns whether the comment is collapsed or not. */
|
|
48
|
+
isCollapsed(): boolean;
|
|
49
|
+
/** Sets whether the comment is editable or not. */
|
|
50
|
+
setEditable(editable: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* Returns whether the comment is editable or not, respecting whether the
|
|
53
|
+
* workspace is read-only.
|
|
54
|
+
*/
|
|
55
|
+
isEditable(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Returns whether the comment is editable or not, only examining its own
|
|
58
|
+
* state and ignoring the state of the workspace.
|
|
59
|
+
*/
|
|
60
|
+
isOwnEditable(): boolean;
|
|
61
|
+
/** Sets whether the comment is movable or not. */
|
|
62
|
+
setMovable(movable: boolean): void;
|
|
63
|
+
/**
|
|
64
|
+
* Returns whether the comment is movable or not, respecting whether the
|
|
65
|
+
* workspace is read-only.
|
|
66
|
+
*/
|
|
67
|
+
isMovable(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Returns whether the comment is movable or not, only examining its own
|
|
70
|
+
* state and ignoring the state of the workspace.
|
|
71
|
+
*/
|
|
72
|
+
isOwnMovable(): boolean;
|
|
73
|
+
/** Sets whether the comment is deletable or not. */
|
|
74
|
+
setDeletable(deletable: boolean): void;
|
|
75
|
+
/**
|
|
76
|
+
* Returns whether the comment is deletable or not, respecting whether the
|
|
77
|
+
* workspace is read-only.
|
|
78
|
+
*/
|
|
79
|
+
isDeletable(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Returns whether the comment is deletable or not, only examining its own
|
|
82
|
+
* state and ignoring the state of the workspace.
|
|
83
|
+
*/
|
|
84
|
+
isOwnDeletable(): boolean;
|
|
85
|
+
/** Moves the comment to the given location in workspace coordinates. */
|
|
86
|
+
moveTo(location: Coordinate): void;
|
|
87
|
+
/** Returns the position of the comment in workspace coordinates. */
|
|
88
|
+
getRelativeToSurfaceXY(): Coordinate;
|
|
89
|
+
/** Disposes of this comment. */
|
|
90
|
+
dispose(): void;
|
|
91
|
+
/** Returns whether the comment has been disposed or not. */
|
|
92
|
+
isDisposed(): boolean;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=workspace_comment.d.ts.map
|
|
@@ -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. */
|
package/core/field_dropdown.d.ts
CHANGED
|
@@ -148,6 +148,7 @@ export declare class FieldDropdown extends Field<string> {
|
|
|
148
148
|
* @param newValue The input value.
|
|
149
149
|
* @returns A valid language-neutral option, or null if invalid.
|
|
150
150
|
*/
|
|
151
|
+
protected doClassValidation_(newValue: string): string | null | undefined;
|
|
151
152
|
protected doClassValidation_(newValue?: string): string | null;
|
|
152
153
|
/**
|
|
153
154
|
* Update the value of this dropdown field.
|
package/core/field_image.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export interface FieldImageConfig extends FieldConfig {
|
|
|
134
134
|
alt?: string;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* fromJson config options for the
|
|
137
|
+
* fromJson config options for the image field.
|
|
138
138
|
*/
|
|
139
139
|
export interface FieldImageFromJsonConfig extends FieldImageConfig {
|
|
140
140
|
src?: string;
|
package/core/generator.d.ts
CHANGED
|
@@ -254,7 +254,7 @@ export declare class CodeGenerator {
|
|
|
254
254
|
* @param _opt_thisOnly True to generate code for only this statement.
|
|
255
255
|
* @returns Code with comments and subsequent blocks added.
|
|
256
256
|
*/
|
|
257
|
-
|
|
257
|
+
scrub_(_block: Block, code: string, _opt_thisOnly?: boolean): string;
|
|
258
258
|
/**
|
|
259
259
|
* Hook for code to run at end of code generation.
|
|
260
260
|
* Subclasses may override this, e.g. to prepend the generated code with
|
package/core/grid.d.ts
CHANGED
|
@@ -9,11 +9,12 @@ import { GridOptions } from './options.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class Grid {
|
|
11
11
|
private pattern;
|
|
12
|
-
private
|
|
13
|
-
private
|
|
12
|
+
private spacing;
|
|
13
|
+
private length;
|
|
14
|
+
private scale;
|
|
14
15
|
private readonly line1;
|
|
15
16
|
private readonly line2;
|
|
16
|
-
private
|
|
17
|
+
private snapToGrid;
|
|
17
18
|
/**
|
|
18
19
|
* @param pattern The grid's SVG pattern, created during injection.
|
|
19
20
|
* @param options A dictionary of normalized options for the grid.
|
|
@@ -22,19 +23,39 @@ export declare class Grid {
|
|
|
22
23
|
*/
|
|
23
24
|
constructor(pattern: SVGElement, options: GridOptions);
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Sets the spacing between the centers of the grid lines.
|
|
26
27
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
28
|
+
* This does not trigger snapping to the newly spaced grid. If you want to
|
|
29
|
+
* snap blocks to the grid programmatically that needs to be triggered
|
|
30
|
+
* on individual top-level blocks. The next time a block is dragged and
|
|
31
|
+
* dropped it will snap to the grid if snapping to the grid is enabled.
|
|
29
32
|
*/
|
|
30
|
-
|
|
33
|
+
setSpacing(spacing: number): void;
|
|
31
34
|
/**
|
|
32
35
|
* Get the spacing of the grid points (in px).
|
|
33
36
|
*
|
|
34
37
|
* @returns The spacing of the grid points.
|
|
35
|
-
* @internal
|
|
36
38
|
*/
|
|
37
39
|
getSpacing(): number;
|
|
40
|
+
/** Sets the length of the grid lines. */
|
|
41
|
+
setLength(length: number): void;
|
|
42
|
+
/** Get the length of the grid lines (in px). */
|
|
43
|
+
getLength(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Sets whether blocks should snap to the grid or not.
|
|
46
|
+
*
|
|
47
|
+
* Setting this to true does not trigger snapping. If you want to snap blocks
|
|
48
|
+
* to the grid programmatically that needs to be triggered on individual
|
|
49
|
+
* top-level blocks. The next time a block is dragged and dropped it will
|
|
50
|
+
* snap to the grid.
|
|
51
|
+
*/
|
|
52
|
+
setSnapToGrid(snap: boolean): void;
|
|
53
|
+
/**
|
|
54
|
+
* Whether blocks should snap to the grid.
|
|
55
|
+
*
|
|
56
|
+
* @returns True if blocks should snap, false otherwise.
|
|
57
|
+
*/
|
|
58
|
+
shouldSnap(): boolean;
|
|
38
59
|
/**
|
|
39
60
|
* Get the ID of the pattern element, which should be randomized to avoid
|
|
40
61
|
* conflicts with other Blockly instances on the page.
|
|
@@ -16,7 +16,7 @@ import { Size } from '../utils/size.js';
|
|
|
16
16
|
export declare class CommentIcon extends Icon implements IHasBubble, ISerializable {
|
|
17
17
|
protected readonly sourceBlock: Block;
|
|
18
18
|
/** The type string used to identify this icon. */
|
|
19
|
-
static readonly TYPE: IconType<
|
|
19
|
+
static readonly TYPE: IconType<import("../interfaces/i_comment_icon.js").ICommentIcon>;
|
|
20
20
|
/**
|
|
21
21
|
* The weight this icon has relative to other icons. Icons with more positive
|
|
22
22
|
* weight values are rendered farther toward the end of the block.
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Copyright 2023 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { ICommentIcon } from '../interfaces/i_comment_icon.js';
|
|
6
7
|
import { IIcon } from '../interfaces/i_icon.js';
|
|
7
|
-
import { CommentIcon } from './comment_icon.js';
|
|
8
8
|
import { MutatorIcon } from './mutator_icon.js';
|
|
9
9
|
import { WarningIcon } from './warning_icon.js';
|
|
10
10
|
/**
|
|
@@ -20,6 +20,6 @@ export declare class IconType<_T extends IIcon> {
|
|
|
20
20
|
equals(type: IconType<IIcon>): boolean;
|
|
21
21
|
static MUTATOR: IconType<MutatorIcon>;
|
|
22
22
|
static WARNING: IconType<WarningIcon>;
|
|
23
|
-
static COMMENT: IconType<
|
|
23
|
+
static COMMENT: IconType<ICommentIcon>;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=icon_types.d.ts.map
|
|
@@ -10,6 +10,8 @@ import type { Coordinate } from './utils/coordinate.js';
|
|
|
10
10
|
* Class that controls updates to connections during drags. It is primarily
|
|
11
11
|
* responsible for finding the closest eligible connection and highlighting or
|
|
12
12
|
* unhighlighting it as needed during a drag.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated v10 - Use an IConnectionPreviewer instead.
|
|
13
15
|
*/
|
|
14
16
|
export declare class InsertionMarkerManager {
|
|
15
17
|
/**
|