blockly 11.2.0 → 12.0.0-beta.1
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 +783 -767
- package/blockly.mjs +6 -1
- package/blockly_compressed.js +768 -752
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +15 -15
- package/blocks_compressed.js.map +1 -1
- package/core/block.d.ts +11 -6
- package/core/block_flyout_inflater.d.ts +95 -0
- package/core/block_svg.d.ts +26 -2
- package/core/blockly.d.ts +11 -3
- package/core/bubbles/textinput_bubble.d.ts +9 -0
- package/core/button_flyout_inflater.d.ts +42 -0
- package/core/clipboard.d.ts +2 -2
- package/core/comments/comment_view.d.ts +4 -0
- package/core/comments/rendered_workspace_comment.d.ts +2 -0
- package/core/connection.d.ts +1 -1
- package/core/dropdowndiv.d.ts +1 -1
- package/core/events/events.d.ts +1 -0
- package/core/events/events_var_base.d.ts +2 -2
- package/core/events/events_var_create.d.ts +7 -2
- package/core/events/events_var_delete.d.ts +2 -4
- package/core/events/events_var_rename.d.ts +2 -4
- package/core/events/events_var_type_change.d.ts +55 -0
- package/core/events/type.d.ts +2 -0
- package/core/field.d.ts +0 -13
- package/core/field_checkbox.d.ts +0 -4
- package/core/field_dropdown.d.ts +0 -2
- package/core/field_input.d.ts +0 -2
- package/core/field_number.d.ts +6 -0
- package/core/field_textinput.d.ts +1 -0
- package/core/field_variable.d.ts +9 -2
- package/core/flyout_base.d.ts +45 -181
- package/core/flyout_button.d.ts +25 -6
- package/core/flyout_horizontal.d.ts +4 -4
- package/core/flyout_item.d.ts +32 -0
- package/core/flyout_separator.d.ts +45 -0
- package/core/flyout_vertical.d.ts +5 -5
- package/core/grid.d.ts +4 -1
- package/core/icons/comment_icon.d.ts +15 -0
- package/core/interfaces/i_comment_icon.d.ts +3 -0
- package/core/interfaces/i_flyout.d.ts +1 -1
- package/core/interfaces/i_flyout_inflater.d.ts +48 -0
- package/core/interfaces/i_metrics_manager.d.ts +1 -1
- package/core/interfaces/i_rendered_element.d.ts +1 -4
- package/core/interfaces/i_toolbox.d.ts +8 -1
- package/core/interfaces/i_variable_backed_parameter_model.d.ts +2 -2
- package/core/interfaces/i_variable_map.d.ts +48 -0
- package/core/interfaces/i_variable_model.d.ts +36 -0
- package/core/label_flyout_inflater.d.ts +42 -0
- package/core/menu.d.ts +1 -3
- package/core/menuitem.d.ts +0 -7
- package/core/metrics_manager.d.ts +1 -1
- package/core/names.d.ts +8 -2
- package/core/procedures.d.ts +7 -4
- package/core/registry.d.ts +6 -0
- package/core/renderers/common/constants.d.ts +6 -1
- package/core/renderers/common/i_path_object.d.ts +13 -13
- package/core/renderers/common/renderer.d.ts +13 -18
- package/core/renderers/geras/renderer.d.ts +1 -1
- package/core/renderers/measurables/in_row_spacer.d.ts +1 -0
- package/core/renderers/measurables/jagged_edge.d.ts +1 -0
- package/core/renderers/measurables/next_connection.d.ts +1 -0
- package/core/renderers/measurables/previous_connection.d.ts +1 -0
- package/core/renderers/measurables/round_corner.d.ts +1 -0
- package/core/renderers/measurables/square_corner.d.ts +1 -0
- package/core/renderers/measurables/statement_input.d.ts +1 -0
- package/core/renderers/measurables/types.d.ts +49 -24
- package/core/renderers/zelos/constants.d.ts +8 -2
- package/core/renderers/zelos/renderer.d.ts +0 -7
- package/core/separator_flyout_inflater.d.ts +57 -0
- package/core/serialization/variables.d.ts +3 -10
- package/core/toolbox/toolbox.d.ts +2 -5
- package/core/variable_map.d.ts +27 -29
- package/core/variable_model.d.ts +37 -11
- package/core/variables.d.ts +56 -12
- package/core/variables_dynamic.d.ts +7 -5
- package/core/widgetdiv.d.ts +2 -2
- package/core/workspace.d.ts +21 -19
- package/core/workspace_svg.d.ts +34 -6
- package/core/xml.d.ts +2 -2
- package/index.mjs +6 -1
- package/media/1x1.gif +0 -0
- package/media/click.mp3 +0 -0
- package/media/click.ogg +0 -0
- package/media/click.wav +0 -0
- package/media/delete.mp3 +0 -0
- package/media/delete.ogg +0 -0
- package/media/delete.wav +0 -0
- package/media/disconnect.mp3 +0 -0
- package/media/disconnect.ogg +0 -0
- package/media/disconnect.wav +0 -0
- package/media/handclosed.cur +0 -0
- package/media/handdelete.cur +0 -0
- package/media/handopen.cur +0 -0
- package/media/pilcrow.png +0 -0
- package/media/quote0.png +0 -0
- package/media/quote1.png +0 -0
- package/media/sprites.png +0 -0
- package/package.json +1 -1
- package/php_compressed.js +1 -1
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +1 -1
- package/python_compressed.js.map +1 -1
- package/core/insertion_marker_manager.d.ts +0 -249
package/core/field.d.ts
CHANGED
|
@@ -141,8 +141,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
141
141
|
* case by default so that SERIALIZABLE is backwards compatible.
|
|
142
142
|
*/
|
|
143
143
|
SERIALIZABLE: boolean;
|
|
144
|
-
/** Mouse cursor style when over the hotspot that initiates the editor. */
|
|
145
|
-
CURSOR: string;
|
|
146
144
|
/**
|
|
147
145
|
* @param value The initial value of the field.
|
|
148
146
|
* Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by
|
|
@@ -231,7 +229,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
231
229
|
* called by Blockly.Xml.
|
|
232
230
|
*
|
|
233
231
|
* @param fieldElement The element containing info about the field's state.
|
|
234
|
-
* @internal
|
|
235
232
|
*/
|
|
236
233
|
fromXml(fieldElement: Element): void;
|
|
237
234
|
/**
|
|
@@ -240,7 +237,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
240
237
|
* @param fieldElement The element to populate with info about the field's
|
|
241
238
|
* state.
|
|
242
239
|
* @returns The element containing info about the field's state.
|
|
243
|
-
* @internal
|
|
244
240
|
*/
|
|
245
241
|
toXml(fieldElement: Element): Element;
|
|
246
242
|
/**
|
|
@@ -254,7 +250,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
254
250
|
* {@link https://developers.devsite.google.com/blockly/guides/create-custom-blocks/fields/customizing-fields/creating#full_serialization_and_backing_data | field serialization docs}
|
|
255
251
|
* for more information.
|
|
256
252
|
* @returns JSON serializable state.
|
|
257
|
-
* @internal
|
|
258
253
|
*/
|
|
259
254
|
saveState(_doFullSerialization?: boolean): any;
|
|
260
255
|
/**
|
|
@@ -262,7 +257,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
262
257
|
* called by the serialization system.
|
|
263
258
|
*
|
|
264
259
|
* @param state The state we want to apply to the field.
|
|
265
|
-
* @internal
|
|
266
260
|
*/
|
|
267
261
|
loadState(state: any): void;
|
|
268
262
|
/**
|
|
@@ -287,8 +281,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
287
281
|
loadLegacyState(callingClass: FieldProto, state: any): boolean;
|
|
288
282
|
/**
|
|
289
283
|
* Dispose of all DOM objects and events belonging to this editable field.
|
|
290
|
-
*
|
|
291
|
-
* @internal
|
|
292
284
|
*/
|
|
293
285
|
dispose(): void;
|
|
294
286
|
/** Add or remove the UI indicating if this field is editable or not. */
|
|
@@ -540,8 +532,6 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
540
532
|
* rerender this field and adjust for any sizing changes.
|
|
541
533
|
* Other fields on the same block will not rerender, because their sizes have
|
|
542
534
|
* already been recorded.
|
|
543
|
-
*
|
|
544
|
-
* @internal
|
|
545
535
|
*/
|
|
546
536
|
forceRerender(): void;
|
|
547
537
|
/**
|
|
@@ -651,14 +641,11 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
|
|
|
651
641
|
* Subclasses may override this.
|
|
652
642
|
*
|
|
653
643
|
* @returns True if this field has any variable references.
|
|
654
|
-
* @internal
|
|
655
644
|
*/
|
|
656
645
|
referencesVariables(): boolean;
|
|
657
646
|
/**
|
|
658
647
|
* Refresh the variable name referenced by this field if this field references
|
|
659
648
|
* variables.
|
|
660
|
-
*
|
|
661
|
-
* @internal
|
|
662
649
|
*/
|
|
663
650
|
refreshVariableName(): void;
|
|
664
651
|
/**
|
package/core/field_checkbox.d.ts
CHANGED
|
@@ -24,10 +24,6 @@ export declare class FieldCheckbox extends Field<CheckboxBool> {
|
|
|
24
24
|
* are not. Editable fields should also be serializable.
|
|
25
25
|
*/
|
|
26
26
|
SERIALIZABLE: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Mouse cursor style when over the hotspot that initiates editability.
|
|
29
|
-
*/
|
|
30
|
-
CURSOR: string;
|
|
31
27
|
/**
|
|
32
28
|
* NOTE: The default value is set in `Field`, so maintain that value instead
|
|
33
29
|
* of overwriting it here or in the constructor.
|
package/core/field_dropdown.d.ts
CHANGED
|
@@ -35,8 +35,6 @@ export declare class FieldDropdown extends Field<string> {
|
|
|
35
35
|
* are not. Editable fields should also be serializable.
|
|
36
36
|
*/
|
|
37
37
|
SERIALIZABLE: boolean;
|
|
38
|
-
/** Mouse cursor style when over the hotspot that initiates the editor. */
|
|
39
|
-
CURSOR: string;
|
|
40
38
|
protected menuGenerator_?: MenuGenerator;
|
|
41
39
|
/** A cache of the most recently generated options. */
|
|
42
40
|
private generatedOptions;
|
package/core/field_input.d.ts
CHANGED
|
@@ -62,8 +62,6 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
|
|
|
62
62
|
* are not. Editable fields should also be serializable.
|
|
63
63
|
*/
|
|
64
64
|
SERIALIZABLE: boolean;
|
|
65
|
-
/** Mouse cursor style when over the hotspot that initiates the editor. */
|
|
66
|
-
CURSOR: string;
|
|
67
65
|
/**
|
|
68
66
|
* @param value The initial value of the field. Should cast to a string.
|
|
69
67
|
* Defaults to an empty string if null or undefined. Also accepts
|
package/core/field_number.d.ts
CHANGED
|
@@ -145,6 +145,12 @@ export declare class FieldNumber extends FieldInput<number> {
|
|
|
145
145
|
* @returns The newly created number input editor.
|
|
146
146
|
*/
|
|
147
147
|
protected widgetCreate_(): HTMLInputElement;
|
|
148
|
+
/**
|
|
149
|
+
* Initialize the field's DOM.
|
|
150
|
+
*
|
|
151
|
+
* @override
|
|
152
|
+
*/
|
|
153
|
+
initView(): void;
|
|
148
154
|
/**
|
|
149
155
|
* Construct a FieldNumber from a JSON arg object.
|
|
150
156
|
*
|
|
@@ -30,6 +30,7 @@ export declare class FieldTextInput extends FieldInput<string> {
|
|
|
30
30
|
* for a list of properties this parameter supports.
|
|
31
31
|
*/
|
|
32
32
|
constructor(value?: string | typeof Field.SKIP_SETUP, validator?: FieldTextInputValidator | null, config?: FieldTextInputConfig);
|
|
33
|
+
initView(): void;
|
|
33
34
|
/**
|
|
34
35
|
* Ensure that the input value casts to a valid string.
|
|
35
36
|
*
|
package/core/field_variable.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ import './events/events_block_change.js';
|
|
|
12
12
|
import type { Block } from './block.js';
|
|
13
13
|
import { Field, FieldConfig } from './field.js';
|
|
14
14
|
import { FieldDropdown, FieldDropdownValidator, MenuGenerator, MenuOption } from './field_dropdown.js';
|
|
15
|
+
import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
|
|
15
16
|
import type { Menu } from './menu.js';
|
|
16
17
|
import type { MenuItem } from './menuitem.js';
|
|
17
18
|
import { Size } from './utils/size.js';
|
|
18
|
-
import { VariableModel } from './variable_model.js';
|
|
19
19
|
/**
|
|
20
20
|
* Class for a variable's dropdown field.
|
|
21
21
|
*/
|
|
@@ -69,6 +69,7 @@ export declare class FieldVariable extends FieldDropdown {
|
|
|
69
69
|
* a variable rather than let the value be invalid.
|
|
70
70
|
*/
|
|
71
71
|
initModel(): void;
|
|
72
|
+
initView(): void;
|
|
72
73
|
shouldAddBorderRect_(): boolean;
|
|
73
74
|
/**
|
|
74
75
|
* Initialize this field based on the given XML.
|
|
@@ -129,7 +130,13 @@ export declare class FieldVariable extends FieldDropdown {
|
|
|
129
130
|
* @returns The selected variable, or null if none was selected.
|
|
130
131
|
* @internal
|
|
131
132
|
*/
|
|
132
|
-
getVariable():
|
|
133
|
+
getVariable(): IVariableModel<IVariableState> | null;
|
|
134
|
+
/**
|
|
135
|
+
* Gets the type of this field's default variable.
|
|
136
|
+
*
|
|
137
|
+
* @returns The default type for this variable field.
|
|
138
|
+
*/
|
|
139
|
+
protected getDefaultType(): string;
|
|
133
140
|
/**
|
|
134
141
|
* Gets the validation function for this field, or null if not set.
|
|
135
142
|
* Returns null if the variable is not set, because validators should not
|
package/core/flyout_base.d.ts
CHANGED
|
@@ -3,21 +3,23 @@
|
|
|
3
3
|
* Copyright 2011 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Flyout tray containing blocks which may be created.
|
|
8
|
+
*
|
|
9
|
+
* @class
|
|
10
|
+
*/
|
|
6
11
|
import { BlockSvg } from './block_svg.js';
|
|
7
12
|
import { DeleteArea } from './delete_area.js';
|
|
8
|
-
import {
|
|
13
|
+
import { FlyoutItem } from './flyout_item.js';
|
|
9
14
|
import { IAutoHideable } from './interfaces/i_autohideable.js';
|
|
10
15
|
import type { IFlyout } from './interfaces/i_flyout.js';
|
|
16
|
+
import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
|
|
11
17
|
import type { Options } from './options.js';
|
|
12
18
|
import * as blocks from './serialization/blocks.js';
|
|
13
19
|
import { Coordinate } from './utils/coordinate.js';
|
|
14
20
|
import { Svg } from './utils/svg.js';
|
|
15
21
|
import * as toolbox from './utils/toolbox.js';
|
|
16
22
|
import { WorkspaceSvg } from './workspace_svg.js';
|
|
17
|
-
declare enum FlyoutItemType {
|
|
18
|
-
BLOCK = "block",
|
|
19
|
-
BUTTON = "button"
|
|
20
|
-
}
|
|
21
23
|
/**
|
|
22
24
|
* Class for a flyout.
|
|
23
25
|
*/
|
|
@@ -48,12 +50,11 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
48
50
|
y?: number;
|
|
49
51
|
}): void;
|
|
50
52
|
/**
|
|
51
|
-
* Lay out the
|
|
53
|
+
* Lay out the elements in the flyout.
|
|
52
54
|
*
|
|
53
|
-
* @param contents The
|
|
54
|
-
* @param gaps The visible gaps between blocks.
|
|
55
|
+
* @param contents The flyout elements to lay out.
|
|
55
56
|
*/
|
|
56
|
-
protected abstract layout_(contents: FlyoutItem[]
|
|
57
|
+
protected abstract layout_(contents: FlyoutItem[]): void;
|
|
57
58
|
/**
|
|
58
59
|
* Scroll the flyout.
|
|
59
60
|
*
|
|
@@ -61,8 +62,8 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
61
62
|
*/
|
|
62
63
|
protected abstract wheel_(e: WheelEvent): void;
|
|
63
64
|
/**
|
|
64
|
-
* Compute
|
|
65
|
-
* For RTL: Lay out the
|
|
65
|
+
* Compute bounds of flyout.
|
|
66
|
+
* For RTL: Lay out the elements right-aligned.
|
|
66
67
|
*/
|
|
67
68
|
protected abstract reflowInternal_(): void;
|
|
68
69
|
/**
|
|
@@ -81,10 +82,6 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
81
82
|
* Scroll the flyout to the beginning of its contents.
|
|
82
83
|
*/
|
|
83
84
|
abstract scrollToStart(): void;
|
|
84
|
-
/**
|
|
85
|
-
* The type of a flyout content item.
|
|
86
|
-
*/
|
|
87
|
-
static FlyoutItemType: typeof FlyoutItemType;
|
|
88
85
|
protected workspace_: WorkspaceSvg;
|
|
89
86
|
RTL: boolean;
|
|
90
87
|
/**
|
|
@@ -102,36 +99,13 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
102
99
|
private boundEvents;
|
|
103
100
|
/**
|
|
104
101
|
* Function that will be registered as a change listener on the workspace
|
|
105
|
-
* to reflow when
|
|
102
|
+
* to reflow when elements in the flyout workspace change.
|
|
106
103
|
*/
|
|
107
104
|
private reflowWrapper;
|
|
108
105
|
/**
|
|
109
|
-
*
|
|
110
|
-
* allowed in the target workspace. Registered as a change listener on the
|
|
111
|
-
* target workspace.
|
|
112
|
-
*/
|
|
113
|
-
private filterWrapper;
|
|
114
|
-
/**
|
|
115
|
-
* List of background mats that lurk behind each block to catch clicks
|
|
116
|
-
* landing in the blocks' lakes and bays.
|
|
117
|
-
*/
|
|
118
|
-
private mats;
|
|
119
|
-
/**
|
|
120
|
-
* List of visible buttons.
|
|
121
|
-
*/
|
|
122
|
-
protected buttons_: FlyoutButton[];
|
|
123
|
-
/**
|
|
124
|
-
* List of visible buttons and blocks.
|
|
106
|
+
* List of flyout elements.
|
|
125
107
|
*/
|
|
126
108
|
protected contents: FlyoutItem[];
|
|
127
|
-
/**
|
|
128
|
-
* List of event listeners.
|
|
129
|
-
*/
|
|
130
|
-
private listeners;
|
|
131
|
-
/**
|
|
132
|
-
* List of blocks that should always be disabled.
|
|
133
|
-
*/
|
|
134
|
-
private permanentlyDisabled;
|
|
135
109
|
protected readonly tabWidth_: number;
|
|
136
110
|
/**
|
|
137
111
|
* The target workspace.
|
|
@@ -139,10 +113,6 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
139
113
|
* @internal
|
|
140
114
|
*/
|
|
141
115
|
targetWorkspace: WorkspaceSvg;
|
|
142
|
-
/**
|
|
143
|
-
* A list of blocks that can be reused.
|
|
144
|
-
*/
|
|
145
|
-
private recycledBlocks;
|
|
146
116
|
/**
|
|
147
117
|
* Does the flyout automatically close when a block is created?
|
|
148
118
|
*/
|
|
@@ -155,7 +125,6 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
155
125
|
* Whether the workspace containing this flyout is visible.
|
|
156
126
|
*/
|
|
157
127
|
private containerVisible;
|
|
158
|
-
protected rectMap_: WeakMap<BlockSvg, SVGElement>;
|
|
159
128
|
/**
|
|
160
129
|
* Corner radius of the flyout background.
|
|
161
130
|
*/
|
|
@@ -205,6 +174,11 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
205
174
|
* The root SVG group for the button or label.
|
|
206
175
|
*/
|
|
207
176
|
protected svgGroup_: SVGGElement | null;
|
|
177
|
+
/**
|
|
178
|
+
* Map from flyout content type to the corresponding inflater class
|
|
179
|
+
* responsible for creating concrete instances of the content type.
|
|
180
|
+
*/
|
|
181
|
+
protected inflaters: Map<string, IFlyoutInflater>;
|
|
208
182
|
/**
|
|
209
183
|
* @param workspaceOptions Dictionary of options for the
|
|
210
184
|
* workspace.
|
|
@@ -291,13 +265,13 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
291
265
|
*/
|
|
292
266
|
setContainerVisible(visible: boolean): void;
|
|
293
267
|
/**
|
|
294
|
-
* Get the list of
|
|
268
|
+
* Get the list of elements of the current flyout.
|
|
295
269
|
*
|
|
296
|
-
* @returns The array of flyout
|
|
270
|
+
* @returns The array of flyout elements.
|
|
297
271
|
*/
|
|
298
272
|
getContents(): FlyoutItem[];
|
|
299
273
|
/**
|
|
300
|
-
* Store the list of
|
|
274
|
+
* Store the list of elements on the flyout.
|
|
301
275
|
*
|
|
302
276
|
* @param contents - The array of items for the flyout.
|
|
303
277
|
*/
|
|
@@ -334,9 +308,21 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
334
308
|
*
|
|
335
309
|
* @param parsedContent The array
|
|
336
310
|
* of objects to show in the flyout.
|
|
337
|
-
* @returns The list of contents
|
|
311
|
+
* @returns The list of contents needed to lay out the flyout.
|
|
338
312
|
*/
|
|
339
313
|
private createFlyoutInfo;
|
|
314
|
+
/**
|
|
315
|
+
* Updates and returns the provided list of flyout contents to flatten
|
|
316
|
+
* separators as needed.
|
|
317
|
+
*
|
|
318
|
+
* When multiple separators occur one after another, the value of the last one
|
|
319
|
+
* takes precedence and the earlier separators in the group are removed.
|
|
320
|
+
*
|
|
321
|
+
* @param contents The list of flyout contents to flatten separators in.
|
|
322
|
+
* @returns An updated list of flyout contents with only one separator between
|
|
323
|
+
* each non-separator item.
|
|
324
|
+
*/
|
|
325
|
+
protected normalizeSeparators(contents: FlyoutItem[]): FlyoutItem[];
|
|
340
326
|
/**
|
|
341
327
|
* Gets the flyout definition for the dynamic category.
|
|
342
328
|
*
|
|
@@ -346,89 +332,9 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
346
332
|
*/
|
|
347
333
|
private getDynamicCategoryContents;
|
|
348
334
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* @param btnInfo The object holding information about a button or a label.
|
|
352
|
-
* @param isLabel True if the button is a label, false otherwise.
|
|
353
|
-
* @returns The object used to display the button in the
|
|
354
|
-
* flyout.
|
|
355
|
-
*/
|
|
356
|
-
private createButton;
|
|
357
|
-
/**
|
|
358
|
-
* Create a block from the xml and permanently disable any blocks that were
|
|
359
|
-
* defined as disabled.
|
|
360
|
-
*
|
|
361
|
-
* @param blockInfo The info of the block.
|
|
362
|
-
* @returns The block created from the blockInfo.
|
|
363
|
-
*/
|
|
364
|
-
private createFlyoutBlock;
|
|
365
|
-
/**
|
|
366
|
-
* Returns a block from the array of recycled blocks with the given type, or
|
|
367
|
-
* undefined if one cannot be found.
|
|
368
|
-
*
|
|
369
|
-
* @param blockType The type of the block to try to recycle.
|
|
370
|
-
* @returns The recycled block, or undefined if
|
|
371
|
-
* one could not be recycled.
|
|
372
|
-
*/
|
|
373
|
-
private getRecycledBlock;
|
|
374
|
-
/**
|
|
375
|
-
* Adds a gap in the flyout based on block info.
|
|
376
|
-
*
|
|
377
|
-
* @param blockInfo Information about a block.
|
|
378
|
-
* @param gaps The list of gaps between items in the flyout.
|
|
379
|
-
* @param defaultGap The default gap between one element and the
|
|
380
|
-
* next.
|
|
381
|
-
*/
|
|
382
|
-
private addBlockGap;
|
|
383
|
-
/**
|
|
384
|
-
* Add the necessary gap in the flyout for a separator.
|
|
385
|
-
*
|
|
386
|
-
* @param sepInfo The object holding
|
|
387
|
-
* information about a separator.
|
|
388
|
-
* @param gaps The list gaps between items in the flyout.
|
|
389
|
-
* @param defaultGap The default gap between the button and next
|
|
390
|
-
* element.
|
|
391
|
-
*/
|
|
392
|
-
private addSeparatorGap;
|
|
393
|
-
/**
|
|
394
|
-
* Delete blocks, mats and buttons from a previous showing of the flyout.
|
|
335
|
+
* Delete elements from a previous showing of the flyout.
|
|
395
336
|
*/
|
|
396
337
|
private clearOldBlocks;
|
|
397
|
-
/**
|
|
398
|
-
* Empties all of the recycled blocks, properly disposing of them.
|
|
399
|
-
*/
|
|
400
|
-
private emptyRecycledBlocks;
|
|
401
|
-
/**
|
|
402
|
-
* Returns whether the given block can be recycled or not.
|
|
403
|
-
*
|
|
404
|
-
* @param _block The block to check for recyclability.
|
|
405
|
-
* @returns True if the block can be recycled. False otherwise.
|
|
406
|
-
*/
|
|
407
|
-
protected blockIsRecyclable_(_block: BlockSvg): boolean;
|
|
408
|
-
/**
|
|
409
|
-
* Puts a previously created block into the recycle bin and moves it to the
|
|
410
|
-
* top of the workspace. Used during large workspace swaps to limit the number
|
|
411
|
-
* of new DOM elements we need to create.
|
|
412
|
-
*
|
|
413
|
-
* @param block The block to recycle.
|
|
414
|
-
*/
|
|
415
|
-
private recycleBlock;
|
|
416
|
-
/**
|
|
417
|
-
* Add listeners to a block that has been added to the flyout.
|
|
418
|
-
*
|
|
419
|
-
* @param root The root node of the SVG group the block is in.
|
|
420
|
-
* @param block The block to add listeners for.
|
|
421
|
-
* @param rect The invisible rectangle under the block that acts
|
|
422
|
-
* as a mat for that block.
|
|
423
|
-
*/
|
|
424
|
-
protected addBlockListeners_(root: SVGElement, block: BlockSvg, rect: SVGElement): void;
|
|
425
|
-
/**
|
|
426
|
-
* Handle a pointerdown on an SVG block in a non-closing flyout.
|
|
427
|
-
*
|
|
428
|
-
* @param block The flyout block to copy.
|
|
429
|
-
* @returns Function to call when block is clicked.
|
|
430
|
-
*/
|
|
431
|
-
private blockMouseDown;
|
|
432
338
|
/**
|
|
433
339
|
* Pointer down on the flyout background. Start a vertical scroll drag.
|
|
434
340
|
*
|
|
@@ -455,48 +361,7 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
455
361
|
*/
|
|
456
362
|
createBlock(originalBlock: BlockSvg): BlockSvg;
|
|
457
363
|
/**
|
|
458
|
-
*
|
|
459
|
-
* add listeners, etc.
|
|
460
|
-
*
|
|
461
|
-
* @param button The button to initialize and place.
|
|
462
|
-
* @param x The x position of the cursor during this layout pass.
|
|
463
|
-
* @param y The y position of the cursor during this layout pass.
|
|
464
|
-
*/
|
|
465
|
-
protected initFlyoutButton_(button: FlyoutButton, x: number, y: number): void;
|
|
466
|
-
/**
|
|
467
|
-
* Create and place a rectangle corresponding to the given block.
|
|
468
|
-
*
|
|
469
|
-
* @param block The block to associate the rect to.
|
|
470
|
-
* @param x The x position of the cursor during this layout pass.
|
|
471
|
-
* @param y The y position of the cursor during this layout pass.
|
|
472
|
-
* @param blockHW The height and width of
|
|
473
|
-
* the block.
|
|
474
|
-
* @param index The index into the mats list where this rect should
|
|
475
|
-
* be placed.
|
|
476
|
-
* @returns Newly created SVG element for the rectangle behind
|
|
477
|
-
* the block.
|
|
478
|
-
*/
|
|
479
|
-
protected createRect_(block: BlockSvg, x: number, y: number, blockHW: {
|
|
480
|
-
height: number;
|
|
481
|
-
width: number;
|
|
482
|
-
}, index: number): SVGElement;
|
|
483
|
-
/**
|
|
484
|
-
* Move a rectangle to sit exactly behind a block, taking into account tabs,
|
|
485
|
-
* hats, and any other protrusions we invent.
|
|
486
|
-
*
|
|
487
|
-
* @param rect The rectangle to move directly behind the block.
|
|
488
|
-
* @param block The block the rectangle should be behind.
|
|
489
|
-
*/
|
|
490
|
-
protected moveRectToBlock_(rect: SVGElement, block: BlockSvg): void;
|
|
491
|
-
/**
|
|
492
|
-
* Filter the blocks on the flyout to disable the ones that are above the
|
|
493
|
-
* capacity limit. For instance, if the user may only place two more blocks
|
|
494
|
-
* on the workspace, an "a + b" block that has two shadow blocks would be
|
|
495
|
-
* disabled.
|
|
496
|
-
*/
|
|
497
|
-
private filterForCapacity;
|
|
498
|
-
/**
|
|
499
|
-
* Reflow blocks and their mats.
|
|
364
|
+
* Reflow flyout contents.
|
|
500
365
|
*/
|
|
501
366
|
reflow(): void;
|
|
502
367
|
/**
|
|
@@ -526,14 +391,13 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
|
|
|
526
391
|
* @param block The block to posiiton.
|
|
527
392
|
*/
|
|
528
393
|
private positionNewBlock;
|
|
394
|
+
/**
|
|
395
|
+
* Returns the inflater responsible for constructing items of the given type.
|
|
396
|
+
*
|
|
397
|
+
* @param type The type of flyout content item to provide an inflater for.
|
|
398
|
+
* @returns An inflater object for the given type, or null if no inflater
|
|
399
|
+
* is registered for that type.
|
|
400
|
+
*/
|
|
401
|
+
protected getInflaterForType(type: string): IFlyoutInflater | null;
|
|
529
402
|
}
|
|
530
|
-
/**
|
|
531
|
-
* A flyout content item.
|
|
532
|
-
*/
|
|
533
|
-
export interface FlyoutItem {
|
|
534
|
-
type: FlyoutItemType;
|
|
535
|
-
button?: FlyoutButton | undefined;
|
|
536
|
-
block?: BlockSvg | undefined;
|
|
537
|
-
}
|
|
538
|
-
export {};
|
|
539
403
|
//# sourceMappingURL=flyout_base.d.ts.map
|
package/core/flyout_button.d.ts
CHANGED
|
@@ -9,13 +9,16 @@
|
|
|
9
9
|
* @class
|
|
10
10
|
*/
|
|
11
11
|
import type { IASTNodeLocationSvg } from './blockly.js';
|
|
12
|
+
import type { IBoundedElement } from './interfaces/i_bounded_element.js';
|
|
13
|
+
import type { IRenderedElement } from './interfaces/i_rendered_element.js';
|
|
12
14
|
import { Coordinate } from './utils/coordinate.js';
|
|
15
|
+
import { Rect } from './utils/rect.js';
|
|
13
16
|
import type * as toolbox from './utils/toolbox.js';
|
|
14
17
|
import type { WorkspaceSvg } from './workspace_svg.js';
|
|
15
18
|
/**
|
|
16
19
|
* Class for a button or label in the flyout.
|
|
17
20
|
*/
|
|
18
|
-
export declare class FlyoutButton implements IASTNodeLocationSvg {
|
|
21
|
+
export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElement, IRenderedElement {
|
|
19
22
|
private readonly workspace;
|
|
20
23
|
private readonly targetWorkspace;
|
|
21
24
|
private readonly isFlyoutLabel;
|
|
@@ -30,6 +33,7 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
|
|
|
30
33
|
private readonly callbackKey;
|
|
31
34
|
private readonly cssClass;
|
|
32
35
|
/** Mouse up event data. */
|
|
36
|
+
private onMouseDownWrapper;
|
|
33
37
|
private onMouseUpWrapper;
|
|
34
38
|
info: toolbox.ButtonOrLabelInfo;
|
|
35
39
|
/** The width of the button's rect. */
|
|
@@ -53,11 +57,6 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
|
|
|
53
57
|
* @internal
|
|
54
58
|
*/
|
|
55
59
|
constructor(workspace: WorkspaceSvg, targetWorkspace: WorkspaceSvg, json: toolbox.ButtonOrLabelInfo, isFlyoutLabel: boolean);
|
|
56
|
-
/**
|
|
57
|
-
* Create the button elements.
|
|
58
|
-
*
|
|
59
|
-
* @returns The button's SVG group.
|
|
60
|
-
*/
|
|
61
60
|
createDom(): SVGElement;
|
|
62
61
|
/** Correctly position the flyout button and make it visible. */
|
|
63
62
|
show(): void;
|
|
@@ -70,6 +69,14 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
|
|
|
70
69
|
* @param y The new y coordinate.
|
|
71
70
|
*/
|
|
72
71
|
moveTo(x: number, y: number): void;
|
|
72
|
+
/**
|
|
73
|
+
* Move the element by a relative offset.
|
|
74
|
+
*
|
|
75
|
+
* @param dx Horizontal offset in workspace units.
|
|
76
|
+
* @param dy Vertical offset in workspace units.
|
|
77
|
+
* @param _reason Why is this move happening? 'user', 'bump', 'snap'...
|
|
78
|
+
*/
|
|
79
|
+
moveBy(dx: number, dy: number, _reason?: string[]): void;
|
|
73
80
|
/** @returns Whether or not the button is a label. */
|
|
74
81
|
isLabel(): boolean;
|
|
75
82
|
/**
|
|
@@ -79,6 +86,13 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
|
|
|
79
86
|
* @internal
|
|
80
87
|
*/
|
|
81
88
|
getPosition(): Coordinate;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the coordinates of a bounded element describing the dimensions of
|
|
91
|
+
* the element. Coordinate system: workspace coordinates.
|
|
92
|
+
*
|
|
93
|
+
* @returns Object with coordinates of the bounded element.
|
|
94
|
+
*/
|
|
95
|
+
getBoundingRectangle(): Rect;
|
|
82
96
|
/** @returns Text of the button. */
|
|
83
97
|
getButtonText(): string;
|
|
84
98
|
/**
|
|
@@ -114,5 +128,10 @@ export declare class FlyoutButton implements IASTNodeLocationSvg {
|
|
|
114
128
|
* @param e Pointer up event.
|
|
115
129
|
*/
|
|
116
130
|
private onMouseUp;
|
|
131
|
+
private onMouseDown;
|
|
132
|
+
/**
|
|
133
|
+
* @returns The root SVG element of this rendered element.
|
|
134
|
+
*/
|
|
135
|
+
getSvgRoot(): SVGGElement;
|
|
117
136
|
}
|
|
118
137
|
//# sourceMappingURL=flyout_button.d.ts.map
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Copyright 2017 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { Flyout
|
|
6
|
+
import { Flyout } from './flyout_base.js';
|
|
7
|
+
import type { FlyoutItem } from './flyout_item.js';
|
|
7
8
|
import type { Options } from './options.js';
|
|
8
9
|
import type { Coordinate } from './utils/coordinate.js';
|
|
9
10
|
import { Rect } from './utils/rect.js';
|
|
@@ -56,10 +57,9 @@ export declare class HorizontalFlyout extends Flyout {
|
|
|
56
57
|
/**
|
|
57
58
|
* Lay out the blocks in the flyout.
|
|
58
59
|
*
|
|
59
|
-
* @param contents The
|
|
60
|
-
* @param gaps The visible gaps between blocks.
|
|
60
|
+
* @param contents The flyout items to lay out.
|
|
61
61
|
*/
|
|
62
|
-
protected layout_(contents: FlyoutItem[]
|
|
62
|
+
protected layout_(contents: FlyoutItem[]): void;
|
|
63
63
|
/**
|
|
64
64
|
* Determine if a drag delta is toward the workspace, based on the position
|
|
65
65
|
* and orientation of the flyout. This is used in determineDragIntention_ to
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IBoundedElement } from './interfaces/i_bounded_element.js';
|
|
2
|
+
/**
|
|
3
|
+
* Representation of an item displayed in a flyout.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FlyoutItem {
|
|
6
|
+
private element;
|
|
7
|
+
private type;
|
|
8
|
+
private focusable;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new FlyoutItem.
|
|
11
|
+
*
|
|
12
|
+
* @param element The element that will be displayed in the flyout.
|
|
13
|
+
* @param type The type of element. Should correspond to the type of the
|
|
14
|
+
* flyout inflater that created this object.
|
|
15
|
+
* @param focusable True if the element should be allowed to be focused by
|
|
16
|
+
* e.g. keyboard navigation in the flyout.
|
|
17
|
+
*/
|
|
18
|
+
constructor(element: IBoundedElement, type: string, focusable: boolean);
|
|
19
|
+
/**
|
|
20
|
+
* Returns the element displayed in the flyout.
|
|
21
|
+
*/
|
|
22
|
+
getElement(): IBoundedElement;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the type of flyout element this item represents.
|
|
25
|
+
*/
|
|
26
|
+
getType(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Returns whether or not the flyout element can receive focus.
|
|
29
|
+
*/
|
|
30
|
+
isFocusable(): boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=flyout_item.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { IBoundedElement } from './interfaces/i_bounded_element.js';
|
|
7
|
+
import { Rect } from './utils/rect.js';
|
|
8
|
+
/**
|
|
9
|
+
* Representation of a gap between elements in a flyout.
|
|
10
|
+
*/
|
|
11
|
+
export declare class FlyoutSeparator implements IBoundedElement {
|
|
12
|
+
private gap;
|
|
13
|
+
private axis;
|
|
14
|
+
private x;
|
|
15
|
+
private y;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new separator.
|
|
18
|
+
*
|
|
19
|
+
* @param gap The amount of space this separator should occupy.
|
|
20
|
+
* @param axis The axis along which this separator occupies space.
|
|
21
|
+
*/
|
|
22
|
+
constructor(gap: number, axis: SeparatorAxis);
|
|
23
|
+
/**
|
|
24
|
+
* Returns the bounding box of this separator.
|
|
25
|
+
*
|
|
26
|
+
* @returns The bounding box of this separator.
|
|
27
|
+
*/
|
|
28
|
+
getBoundingRectangle(): Rect;
|
|
29
|
+
/**
|
|
30
|
+
* Repositions this separator.
|
|
31
|
+
*
|
|
32
|
+
* @param dx The distance to move this separator on the X axis.
|
|
33
|
+
* @param dy The distance to move this separator on the Y axis.
|
|
34
|
+
* @param _reason The reason this move was initiated.
|
|
35
|
+
*/
|
|
36
|
+
moveBy(dx: number, dy: number, _reason?: string[]): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Representation of an axis along which a separator occupies space.
|
|
40
|
+
*/
|
|
41
|
+
export declare const enum SeparatorAxis {
|
|
42
|
+
X = "x",
|
|
43
|
+
Y = "y"
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=flyout_separator.d.ts.map
|