blockly 11.2.0-beta.1 → 12.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.min.js +737 -734
- package/blockly.mjs +5 -1
- package/blockly_compressed.js +719 -717
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +18 -17
- package/blocks_compressed.js.map +1 -1
- package/core/block.d.ts +22 -22
- package/core/block_flyout_inflater.d.ts +89 -0
- package/core/block_svg.d.ts +21 -10
- package/core/blockly.d.ts +11 -4
- package/core/bubbles/textinput_bubble.d.ts +9 -0
- package/core/button_flyout_inflater.d.ts +36 -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/component_manager.d.ts +1 -1
- package/core/contextmenu_registry.d.ts +1 -1
- package/core/dragging/block_drag_strategy.d.ts +2 -0
- package/core/dropdowndiv.d.ts +1 -1
- package/core/events/events.d.ts +1 -0
- package/core/events/events_block_move.d.ts +1 -1
- 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 -2
- package/core/events/events_var_rename.d.ts +2 -2
- package/core/events/events_var_type_change.d.ts +55 -0
- package/core/events/type.d.ts +2 -0
- package/core/field.d.ts +5 -18
- package/core/field_checkbox.d.ts +1 -5
- package/core/field_dropdown.d.ts +0 -2
- package/core/field_input.d.ts +5 -7
- 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 +48 -177
- package/core/flyout_button.d.ts +25 -6
- package/core/flyout_horizontal.d.ts +2 -3
- package/core/flyout_metrics_manager.d.ts +1 -1
- package/core/flyout_separator.d.ts +45 -0
- package/core/flyout_vertical.d.ts +3 -4
- package/core/generator.d.ts +1 -1
- package/core/gesture.d.ts +1 -1
- 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_inflater.d.ts +39 -0
- 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 +36 -0
- package/core/marker_manager.d.ts +3 -3
- package/core/menuitem.d.ts +0 -7
- package/core/names.d.ts +8 -2
- package/core/options.d.ts +4 -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 +12 -17
- package/core/renderers/geras/renderer.d.ts +1 -1
- package/core/renderers/zelos/constants.d.ts +8 -2
- package/core/renderers/zelos/renderer.d.ts +0 -7
- package/core/scrollbar_pair.d.ts +1 -1
- package/core/separator_flyout_inflater.d.ts +47 -0
- package/core/serialization/variables.d.ts +3 -10
- package/core/shortcut_registry.d.ts +2 -2
- package/core/theme_manager.d.ts +1 -1
- package/core/toolbox/category.d.ts +2 -2
- package/core/toolbox/collapsible_category.d.ts +1 -1
- package/core/toolbox/separator.d.ts +1 -1
- package/core/toolbox/toolbox.d.ts +10 -13
- package/core/variable_map.d.ts +29 -31
- package/core/variable_model.d.ts +38 -12
- package/core/variables.d.ts +38 -8
- package/core/widgetdiv.d.ts +2 -2
- package/core/workspace.d.ts +22 -20
- package/core/workspace_audio.d.ts +1 -1
- package/core/workspace_dragger.d.ts +2 -2
- package/core/workspace_svg.d.ts +40 -13
- package/core/xml.d.ts +2 -2
- package/index.mjs +5 -1
- package/package.json +7 -6
- 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
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { BlockSvg } from '../../block_svg.js';
|
|
7
7
|
import { Connection } from '../../connection.js';
|
|
8
|
-
import { PreviewType } from '../../insertion_marker_manager.js';
|
|
9
8
|
import type { IRegistrable } from '../../interfaces/i_registrable.js';
|
|
10
9
|
import type { Marker } from '../../keyboard_nav/marker.js';
|
|
11
|
-
import type { RenderedConnection } from '../../rendered_connection.js';
|
|
12
10
|
import type { BlockStyle, Theme } from '../../theme.js';
|
|
13
11
|
import type { WorkspaceSvg } from '../../workspace_svg.js';
|
|
14
12
|
import { ConstantProvider } from './constants.js';
|
|
@@ -53,16 +51,26 @@ export declare class Renderer implements IRegistrable {
|
|
|
53
51
|
*
|
|
54
52
|
* @param svg The root of the workspace's SVG.
|
|
55
53
|
* @param theme The workspace theme object.
|
|
54
|
+
* @param injectionDivIfIsParent The div containing the parent workspace and
|
|
55
|
+
* all related workspaces and block containers, if this renderer is for the
|
|
56
|
+
* parent workspace. CSS variables representing SVG patterns will be scoped
|
|
57
|
+
* to this container. Child workspaces should not override the CSS variables
|
|
58
|
+
* created by the parent and thus do not need access to the injection div.
|
|
56
59
|
* @internal
|
|
57
60
|
*/
|
|
58
|
-
createDom(svg: SVGElement, theme: Theme): void;
|
|
61
|
+
createDom(svg: SVGElement, theme: Theme, injectionDivIfIsParent?: HTMLElement): void;
|
|
59
62
|
/**
|
|
60
63
|
* Refresh the renderer after a theme change.
|
|
61
64
|
*
|
|
62
65
|
* @param svg The root of the workspace's SVG.
|
|
63
66
|
* @param theme The workspace theme object.
|
|
67
|
+
* @param injectionDivIfIsParent The div containing the parent workspace and
|
|
68
|
+
* all related workspaces and block containers, if this renderer is for the
|
|
69
|
+
* parent workspace. CSS variables representing SVG patterns will be scoped
|
|
70
|
+
* to this container. Child workspaces should not override the CSS variables
|
|
71
|
+
* created by the parent and thus do not need access to the injection div.
|
|
64
72
|
*/
|
|
65
|
-
refreshDom(svg: SVGElement, theme: Theme): void;
|
|
73
|
+
refreshDom(svg: SVGElement, theme: Theme, injectionDivIfIsParent?: HTMLElement): void;
|
|
66
74
|
/**
|
|
67
75
|
* Dispose of this renderer.
|
|
68
76
|
* Delete all DOM elements that this renderer and its constants created.
|
|
@@ -133,19 +141,6 @@ export declare class Renderer implements IRegistrable {
|
|
|
133
141
|
* @returns Whether there is a home for the orphan or not.
|
|
134
142
|
*/
|
|
135
143
|
protected orphanCanConnectAtEnd(topBlock: BlockSvg, orphanBlock: BlockSvg, localType: number): boolean;
|
|
136
|
-
/**
|
|
137
|
-
* Chooses a connection preview method based on the available connection, the
|
|
138
|
-
* current dragged connection, and the block being dragged.
|
|
139
|
-
*
|
|
140
|
-
* @param closest The available connection.
|
|
141
|
-
* @param local The connection currently being dragged.
|
|
142
|
-
* @param topBlock The block currently being dragged.
|
|
143
|
-
* @returns The preview type to display.
|
|
144
|
-
*
|
|
145
|
-
* @deprecated v10 - This function is no longer respected. A custom
|
|
146
|
-
* IConnectionPreviewer may be able to fulfill the functionality.
|
|
147
|
-
*/
|
|
148
|
-
getConnectionPreviewMethod(closest: RenderedConnection, local: RenderedConnection, topBlock: BlockSvg): PreviewType;
|
|
149
144
|
/**
|
|
150
145
|
* Render the block.
|
|
151
146
|
*
|
|
@@ -34,7 +34,7 @@ export declare class Renderer extends BaseRenderer {
|
|
|
34
34
|
init(theme: Theme, opt_rendererOverrides?: {
|
|
35
35
|
[rendererConstant: string]: any;
|
|
36
36
|
}): void;
|
|
37
|
-
refreshDom(svg: SVGElement, theme: Theme): void;
|
|
37
|
+
refreshDom(svg: SVGElement, theme: Theme, injectionDiv: HTMLElement): void;
|
|
38
38
|
makeConstants_(): ConstantProvider;
|
|
39
39
|
/**
|
|
40
40
|
* Create a new instance of the renderer's render info object.
|
|
@@ -102,7 +102,13 @@ export declare class ConstantProvider extends BaseConstantProvider {
|
|
|
102
102
|
* rectangular reporter block. Null before init is called.
|
|
103
103
|
*/
|
|
104
104
|
SQUARED: Shape | null;
|
|
105
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new ConstantProvider.
|
|
107
|
+
*
|
|
108
|
+
* @param gridUnit If set, defines the base unit used to calculate other
|
|
109
|
+
* constants.
|
|
110
|
+
*/
|
|
111
|
+
constructor(gridUnit?: number);
|
|
106
112
|
setFontConstants_(theme: Theme): void;
|
|
107
113
|
init(): void;
|
|
108
114
|
setDynamicProperties_(theme: Theme): void;
|
|
@@ -153,7 +159,7 @@ export declare class ConstantProvider extends BaseConstantProvider {
|
|
|
153
159
|
};
|
|
154
160
|
generateSecondaryColour_(colour: string): string;
|
|
155
161
|
generateTertiaryColour_(colour: string): string;
|
|
156
|
-
createDom(svg: SVGElement, tagName: string, selector: string): void;
|
|
162
|
+
createDom(svg: SVGElement, tagName: string, selector: string, injectionDivIfIsParent?: HTMLElement): void;
|
|
157
163
|
getCSS_(selector: string): string[];
|
|
158
164
|
}
|
|
159
165
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import type { BlockSvg } from '../../block_svg.js';
|
|
7
|
-
import { InsertionMarkerManager } from '../../insertion_marker_manager.js';
|
|
8
7
|
import type { Marker } from '../../keyboard_nav/marker.js';
|
|
9
|
-
import type { RenderedConnection } from '../../rendered_connection.js';
|
|
10
8
|
import type { BlockStyle } from '../../theme.js';
|
|
11
9
|
import type { WorkspaceSvg } from '../../workspace_svg.js';
|
|
12
10
|
import type { RenderInfo as BaseRenderInfo } from '../common/info.js';
|
|
@@ -73,10 +71,5 @@ export declare class Renderer extends BaseRenderer {
|
|
|
73
71
|
* @returns The constant provider.
|
|
74
72
|
*/
|
|
75
73
|
getConstants(): ConstantProvider;
|
|
76
|
-
/**
|
|
77
|
-
* @deprecated v10 - This function is no longer respected. A custom
|
|
78
|
-
* IConnectionPreviewer may be able to fulfill the functionality.
|
|
79
|
-
*/
|
|
80
|
-
getConnectionPreviewMethod(closest: RenderedConnection, local: RenderedConnection, topBlock: BlockSvg): InsertionMarkerManager.PREVIEW_TYPE;
|
|
81
74
|
}
|
|
82
75
|
//# sourceMappingURL=renderer.d.ts.map
|
package/core/scrollbar_pair.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class ScrollbarPair {
|
|
|
15
15
|
vScroll: Scrollbar | null;
|
|
16
16
|
corner_: SVGRectElement | null;
|
|
17
17
|
/** Previously recorded metrics from the workspace. */
|
|
18
|
-
private
|
|
18
|
+
private oldHostMetrics;
|
|
19
19
|
/**
|
|
20
20
|
* @param workspace Workspace to bind the scrollbars to.
|
|
21
21
|
* @param addHorizontal Whether to add a horizontal scrollbar.
|
|
@@ -0,0 +1,47 @@
|
|
|
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 type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
|
|
8
|
+
import type { WorkspaceSvg } from './workspace_svg.js';
|
|
9
|
+
/**
|
|
10
|
+
* Class responsible for creating separators for flyouts.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SeparatorFlyoutInflater implements IFlyoutInflater {
|
|
13
|
+
/**
|
|
14
|
+
* Inflates a dummy flyout separator.
|
|
15
|
+
*
|
|
16
|
+
* The flyout automatically creates separators between every element with a
|
|
17
|
+
* size determined by calling gapForElement on the relevant inflater.
|
|
18
|
+
* Additionally, users can explicitly add separators in the flyout definition.
|
|
19
|
+
* When separators (implicitly or explicitly created) follow one another, the
|
|
20
|
+
* gap of the last one propagates backwards and flattens to one separator.
|
|
21
|
+
* This flattening is not additive; if there are initially separators of 2, 3,
|
|
22
|
+
* and 4 pixels, after normalization there will be one separator of 4 pixels.
|
|
23
|
+
* Therefore, this method returns a zero-width separator, which will be
|
|
24
|
+
* replaced by the one implicitly created by the flyout based on the value
|
|
25
|
+
* returned by gapForElement, which knows the default gap, unlike this method.
|
|
26
|
+
*
|
|
27
|
+
* @param _state A JSON representation of a flyout separator.
|
|
28
|
+
* @param flyoutWorkspace The workspace the separator belongs to.
|
|
29
|
+
* @returns A newly created FlyoutSeparator.
|
|
30
|
+
*/
|
|
31
|
+
load(_state: object, flyoutWorkspace: WorkspaceSvg): IBoundedElement;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the size of the separator. See `load` for more details.
|
|
34
|
+
*
|
|
35
|
+
* @param state A JSON representation of a flyout separator.
|
|
36
|
+
* @param defaultGap The default spacing for flyout items.
|
|
37
|
+
* @returns The desired size of the separator.
|
|
38
|
+
*/
|
|
39
|
+
gapForElement(state: object, defaultGap: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Disposes of the given separator. Intentional no-op.
|
|
42
|
+
*
|
|
43
|
+
* @param _element The flyout separator to dispose of.
|
|
44
|
+
*/
|
|
45
|
+
disposeElement(_element: IBoundedElement): void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=separator_flyout_inflater.d.ts.map
|
|
@@ -4,15 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import type { ISerializer } from '../interfaces/i_serializer.js';
|
|
7
|
+
import type { IVariableState } from '../interfaces/i_variable_model.js';
|
|
7
8
|
import type { Workspace } from '../workspace.js';
|
|
8
|
-
/**
|
|
9
|
-
* Represents the state of a given variable.
|
|
10
|
-
*/
|
|
11
|
-
export interface State {
|
|
12
|
-
name: string;
|
|
13
|
-
id: string;
|
|
14
|
-
type: string | undefined;
|
|
15
|
-
}
|
|
16
9
|
/**
|
|
17
10
|
* Serializer for saving and loading variable state.
|
|
18
11
|
*/
|
|
@@ -26,7 +19,7 @@ export declare class VariableSerializer implements ISerializer {
|
|
|
26
19
|
* @returns The state of the workspace's variables, or null if there are no
|
|
27
20
|
* variables.
|
|
28
21
|
*/
|
|
29
|
-
save(workspace: Workspace):
|
|
22
|
+
save(workspace: Workspace): IVariableState[] | null;
|
|
30
23
|
/**
|
|
31
24
|
* Deserializes the variable defined by the given state into the given
|
|
32
25
|
* workspace.
|
|
@@ -34,7 +27,7 @@ export declare class VariableSerializer implements ISerializer {
|
|
|
34
27
|
* @param state The state of the variables to deserialize.
|
|
35
28
|
* @param workspace The workspace to deserialize into.
|
|
36
29
|
*/
|
|
37
|
-
load(state:
|
|
30
|
+
load(state: IVariableState[], workspace: Workspace): void;
|
|
38
31
|
/**
|
|
39
32
|
* Disposes of any variables that exist on the workspace.
|
|
40
33
|
*
|
|
@@ -154,14 +154,14 @@ export declare class ShortcutRegistry {
|
|
|
154
154
|
* @param e A key down event.
|
|
155
155
|
* @returns The serialized key code for the given event.
|
|
156
156
|
*/
|
|
157
|
-
private
|
|
157
|
+
private serializeKeyEvent;
|
|
158
158
|
/**
|
|
159
159
|
* Checks whether any of the given modifiers are not valid.
|
|
160
160
|
*
|
|
161
161
|
* @param modifiers List of modifiers to be used with the key.
|
|
162
162
|
* @throws {Error} if the modifier is not in the valid modifiers list.
|
|
163
163
|
*/
|
|
164
|
-
private
|
|
164
|
+
private checkModifiers;
|
|
165
165
|
/**
|
|
166
166
|
* Creates the serialized key code that will be used in the key map.
|
|
167
167
|
*
|
package/core/theme_manager.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class ThemeManager {
|
|
|
19
19
|
private readonly workspace;
|
|
20
20
|
private theme;
|
|
21
21
|
/** A list of workspaces that are subscribed to this theme. */
|
|
22
|
-
private
|
|
22
|
+
private subscribedWorkspaces;
|
|
23
23
|
private componentDB;
|
|
24
24
|
/**
|
|
25
25
|
* @param workspace The main workspace.
|
|
@@ -143,7 +143,7 @@ export declare class ToolboxCategory extends ToolboxItem implements ISelectableT
|
|
|
143
143
|
* @param styleName Name of the style.
|
|
144
144
|
* @returns The hex colour for the category.
|
|
145
145
|
*/
|
|
146
|
-
private
|
|
146
|
+
private getColourfromStyle;
|
|
147
147
|
/**
|
|
148
148
|
* Gets the HTML element that is clickable.
|
|
149
149
|
* The parent toolbox element receives clicks. The parent toolbox will add an
|
|
@@ -160,7 +160,7 @@ export declare class ToolboxCategory extends ToolboxItem implements ISelectableT
|
|
|
160
160
|
* reference string pointing to one of those two values.
|
|
161
161
|
* @returns The hex colour for the category.
|
|
162
162
|
*/
|
|
163
|
-
private
|
|
163
|
+
private parseColour;
|
|
164
164
|
/**
|
|
165
165
|
* Adds appropriate classes to display an open icon.
|
|
166
166
|
*
|
|
@@ -40,7 +40,7 @@ export declare class CollapsibleToolboxCategory extends ToolboxCategory implemen
|
|
|
40
40
|
*
|
|
41
41
|
* @param itemDef The information needed to create a toolbox item.
|
|
42
42
|
*/
|
|
43
|
-
private
|
|
43
|
+
private createToolboxItem;
|
|
44
44
|
init(): void;
|
|
45
45
|
createDom_(): HTMLDivElement;
|
|
46
46
|
createIconDom_(): HTMLSpanElement;
|
|
@@ -15,7 +15,7 @@ export declare class ToolboxSeparator extends ToolboxItem {
|
|
|
15
15
|
static registrationName: string;
|
|
16
16
|
/** All the CSS class names that are used to create a separator. */
|
|
17
17
|
protected cssConfig_: CssConfig;
|
|
18
|
-
private
|
|
18
|
+
private htmlDiv;
|
|
19
19
|
/**
|
|
20
20
|
* @param separatorDef The information needed to create a separator.
|
|
21
21
|
* @param toolbox The parent toolbox for the separator.
|
|
@@ -29,25 +29,22 @@ export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeybo
|
|
|
29
29
|
*/
|
|
30
30
|
id: string;
|
|
31
31
|
protected toolboxDef_: toolbox.ToolboxInfo;
|
|
32
|
-
private readonly
|
|
32
|
+
private readonly horizontalLayout;
|
|
33
33
|
/** The HTML container for the toolbox. */
|
|
34
34
|
HtmlDiv: HTMLDivElement | null;
|
|
35
35
|
/** The HTML container for the contents of a toolbox. */
|
|
36
36
|
protected contentsDiv_: HTMLDivElement | null;
|
|
37
37
|
/** Whether the Toolbox is visible. */
|
|
38
38
|
protected isVisible_: boolean;
|
|
39
|
-
/** The list of items in the toolbox. */
|
|
40
|
-
protected contents_: IToolboxItem[];
|
|
41
39
|
/** The width of the toolbox. */
|
|
42
40
|
protected width_: number;
|
|
43
41
|
/** The height of the toolbox. */
|
|
44
42
|
protected height_: number;
|
|
45
43
|
RTL: boolean;
|
|
46
44
|
/** The flyout for the toolbox. */
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
45
|
+
private flyout;
|
|
46
|
+
/** Map from ID to the corresponding toolbox item. */
|
|
47
|
+
protected contents: Map<string, IToolboxItem>;
|
|
51
48
|
toolboxPosition: toolbox.Position;
|
|
52
49
|
/** The currently selected item. */
|
|
53
50
|
protected selectedItem_: ISelectableToolboxItem | null;
|
|
@@ -140,7 +137,7 @@ export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeybo
|
|
|
140
137
|
* the toolbox.
|
|
141
138
|
* @param fragment The document fragment to add the child toolbox elements to.
|
|
142
139
|
*/
|
|
143
|
-
private
|
|
140
|
+
private createToolboxItem;
|
|
144
141
|
/**
|
|
145
142
|
* Adds an item to the toolbox.
|
|
146
143
|
*
|
|
@@ -364,32 +361,32 @@ export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeybo
|
|
|
364
361
|
* @param oldItem The previously selected toolbox item.
|
|
365
362
|
* @param newItem The newly selected toolbox item.
|
|
366
363
|
*/
|
|
367
|
-
private
|
|
364
|
+
private fireSelectEvent;
|
|
368
365
|
/**
|
|
369
366
|
* Closes the current item if it is expanded, or selects the parent.
|
|
370
367
|
*
|
|
371
368
|
* @returns True if a parent category was selected, false otherwise.
|
|
372
369
|
*/
|
|
373
|
-
private
|
|
370
|
+
private selectParent;
|
|
374
371
|
/**
|
|
375
372
|
* Selects the first child of the currently selected item, or nothing if the
|
|
376
373
|
* toolbox item has no children.
|
|
377
374
|
*
|
|
378
375
|
* @returns True if a child category was selected, false otherwise.
|
|
379
376
|
*/
|
|
380
|
-
private
|
|
377
|
+
private selectChild;
|
|
381
378
|
/**
|
|
382
379
|
* Selects the next visible toolbox item.
|
|
383
380
|
*
|
|
384
381
|
* @returns True if a next category was selected, false otherwise.
|
|
385
382
|
*/
|
|
386
|
-
private
|
|
383
|
+
private selectNext;
|
|
387
384
|
/**
|
|
388
385
|
* Selects the previous visible toolbox item.
|
|
389
386
|
*
|
|
390
387
|
* @returns True if a previous category was selected, false otherwise.
|
|
391
388
|
*/
|
|
392
|
-
private
|
|
389
|
+
private selectPrevious;
|
|
393
390
|
/** Disposes of this toolbox. */
|
|
394
391
|
dispose(): void;
|
|
395
392
|
}
|
package/core/variable_map.d.ts
CHANGED
|
@@ -11,17 +11,18 @@
|
|
|
11
11
|
import './events/events_var_delete.js';
|
|
12
12
|
import './events/events_var_rename.js';
|
|
13
13
|
import type { Block } from './block.js';
|
|
14
|
-
import {
|
|
14
|
+
import type { IVariableMap } from './interfaces/i_variable_map.js';
|
|
15
|
+
import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
|
|
15
16
|
import type { Workspace } from './workspace.js';
|
|
16
17
|
/**
|
|
17
18
|
* Class for a variable map. This contains a dictionary data structure with
|
|
18
19
|
* variable types as keys and lists of variables as values. The list of
|
|
19
20
|
* variables are the type indicated by the key.
|
|
20
21
|
*/
|
|
21
|
-
export declare class VariableMap {
|
|
22
|
+
export declare class VariableMap implements IVariableMap<IVariableModel<IVariableState>> {
|
|
22
23
|
workspace: Workspace;
|
|
23
24
|
/**
|
|
24
|
-
* A map from variable type to
|
|
25
|
+
* A map from variable type to map of IDs to variables. The maps contain
|
|
25
26
|
* all of the named variables in the workspace, including variables that are
|
|
26
27
|
* not currently in use.
|
|
27
28
|
*/
|
|
@@ -35,13 +36,15 @@ export declare class VariableMap {
|
|
|
35
36
|
*
|
|
36
37
|
* @param variable Variable to rename.
|
|
37
38
|
* @param newName New variable name.
|
|
38
|
-
* @
|
|
39
|
+
* @returns The newly renamed variable.
|
|
39
40
|
*/
|
|
40
|
-
renameVariable(variable:
|
|
41
|
+
renameVariable(variable: IVariableModel<IVariableState>, newName: string): IVariableModel<IVariableState>;
|
|
42
|
+
changeVariableType(variable: IVariableModel<IVariableState>, newType: string): IVariableModel<IVariableState>;
|
|
41
43
|
/**
|
|
42
44
|
* Rename a variable by updating its name in the variable map. Identify the
|
|
43
45
|
* variable to rename with the given ID.
|
|
44
46
|
*
|
|
47
|
+
* @deprecated v12, use VariableMap.renameVariable.
|
|
45
48
|
* @param id ID of the variable to rename.
|
|
46
49
|
* @param newName New variable name.
|
|
47
50
|
*/
|
|
@@ -54,7 +57,7 @@ export declare class VariableMap {
|
|
|
54
57
|
* @param newName New variable name.
|
|
55
58
|
* @param blocks The list of all blocks in the workspace.
|
|
56
59
|
*/
|
|
57
|
-
private
|
|
60
|
+
private renameVariableAndUses;
|
|
58
61
|
/**
|
|
59
62
|
* Update the name of the given variable to the same name as an existing
|
|
60
63
|
* variable. The two variables are coalesced into a single variable with the
|
|
@@ -66,7 +69,7 @@ export declare class VariableMap {
|
|
|
66
69
|
* @param conflictVar The variable that was already using newName.
|
|
67
70
|
* @param blocks The list of all blocks in the workspace.
|
|
68
71
|
*/
|
|
69
|
-
private
|
|
72
|
+
private renameVariableWithConflict;
|
|
70
73
|
/**
|
|
71
74
|
* Create a variable with a given name, optional type, and optional ID.
|
|
72
75
|
*
|
|
@@ -78,29 +81,27 @@ export declare class VariableMap {
|
|
|
78
81
|
* @param opt_id The unique ID of the variable. This will default to a UUID.
|
|
79
82
|
* @returns The newly created variable.
|
|
80
83
|
*/
|
|
81
|
-
createVariable(name: string, opt_type?: string
|
|
84
|
+
createVariable(name: string, opt_type?: string, opt_id?: string): IVariableModel<IVariableState>;
|
|
82
85
|
/**
|
|
83
|
-
*
|
|
86
|
+
* Adds the given variable to this variable map.
|
|
87
|
+
*
|
|
88
|
+
* @param variable The variable to add.
|
|
89
|
+
*/
|
|
90
|
+
addVariable(variable: IVariableModel<IVariableState>): void;
|
|
91
|
+
/**
|
|
92
|
+
* Delete a variable and all of its uses without confirmation.
|
|
84
93
|
*
|
|
85
94
|
* @param variable Variable to delete.
|
|
86
95
|
*/
|
|
87
|
-
deleteVariable(variable:
|
|
96
|
+
deleteVariable(variable: IVariableModel<IVariableState>): void;
|
|
88
97
|
/**
|
|
89
98
|
* Delete a variables by the passed in ID and all of its uses from this
|
|
90
99
|
* workspace. May prompt the user for confirmation.
|
|
91
100
|
*
|
|
101
|
+
* @deprecated v12, use Blockly.Variables.deleteVariable.
|
|
92
102
|
* @param id ID of variable to delete.
|
|
93
103
|
*/
|
|
94
104
|
deleteVariableById(id: string): void;
|
|
95
|
-
/**
|
|
96
|
-
* Deletes a variable and all of its uses from this workspace without asking
|
|
97
|
-
* the user for confirmation.
|
|
98
|
-
*
|
|
99
|
-
* @param variable Variable to delete.
|
|
100
|
-
* @param uses An array of uses of the variable.
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
deleteVariableInternal(variable: VariableModel, uses: Block[]): void;
|
|
104
105
|
/**
|
|
105
106
|
* Find the variable by the given name and type and return it. Return null if
|
|
106
107
|
* it is not found.
|
|
@@ -110,14 +111,14 @@ export declare class VariableMap {
|
|
|
110
111
|
* the empty string, which is a specific type.
|
|
111
112
|
* @returns The variable with the given name, or null if it was not found.
|
|
112
113
|
*/
|
|
113
|
-
getVariable(name: string, opt_type?: string
|
|
114
|
+
getVariable(name: string, opt_type?: string): IVariableModel<IVariableState> | null;
|
|
114
115
|
/**
|
|
115
116
|
* Find the variable by the given ID and return it. Return null if not found.
|
|
116
117
|
*
|
|
117
118
|
* @param id The ID to check for.
|
|
118
119
|
* @returns The variable with the given ID.
|
|
119
120
|
*/
|
|
120
|
-
getVariableById(id: string):
|
|
121
|
+
getVariableById(id: string): IVariableModel<IVariableState> | null;
|
|
121
122
|
/**
|
|
122
123
|
* Get a list containing all of the variables of a specified type. If type is
|
|
123
124
|
* null, return list of variables with empty string type.
|
|
@@ -126,33 +127,30 @@ export declare class VariableMap {
|
|
|
126
127
|
* @returns The sought after variables of the passed in type. An empty array
|
|
127
128
|
* if none are found.
|
|
128
129
|
*/
|
|
129
|
-
getVariablesOfType(type: string | null):
|
|
130
|
+
getVariablesOfType(type: string | null): IVariableModel<IVariableState>[];
|
|
130
131
|
/**
|
|
131
|
-
*
|
|
132
|
-
* contains the empty string.
|
|
132
|
+
* Returns a list of unique types of variables in this variable map.
|
|
133
133
|
*
|
|
134
|
-
* @
|
|
135
|
-
* different than the workspace stored on this object if the passed in ws
|
|
136
|
-
* is a flyout workspace.
|
|
137
|
-
* @returns List of variable types.
|
|
138
|
-
* @internal
|
|
134
|
+
* @returns A list of unique types of variables in this variable map.
|
|
139
135
|
*/
|
|
140
|
-
|
|
136
|
+
getTypes(): string[];
|
|
141
137
|
/**
|
|
142
138
|
* Return all variables of all types.
|
|
143
139
|
*
|
|
144
140
|
* @returns List of variable models.
|
|
145
141
|
*/
|
|
146
|
-
getAllVariables():
|
|
142
|
+
getAllVariables(): IVariableModel<IVariableState>[];
|
|
147
143
|
/**
|
|
148
144
|
* Returns all of the variable names of all types.
|
|
149
145
|
*
|
|
146
|
+
* @deprecated v12, use Blockly.Variables.getAllVariables.
|
|
150
147
|
* @returns All of the variable names of all types.
|
|
151
148
|
*/
|
|
152
149
|
getAllVariableNames(): string[];
|
|
153
150
|
/**
|
|
154
151
|
* Find all the uses of a named variable.
|
|
155
152
|
*
|
|
153
|
+
* @deprecated v12, use Blockly.Variables.getVariableUsesById.
|
|
156
154
|
* @param id ID of the variable to find.
|
|
157
155
|
* @returns Array of block usages.
|
|
158
156
|
*/
|
package/core/variable_model.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @class
|
|
10
10
|
*/
|
|
11
11
|
import './events/events_var_create.js';
|
|
12
|
+
import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
|
|
12
13
|
import type { Workspace } from './workspace.js';
|
|
13
14
|
/**
|
|
14
15
|
* Class for a variable model.
|
|
@@ -16,11 +17,11 @@ import type { Workspace } from './workspace.js';
|
|
|
16
17
|
*
|
|
17
18
|
* @see {Blockly.FieldVariable}
|
|
18
19
|
*/
|
|
19
|
-
export declare class VariableModel {
|
|
20
|
-
workspace
|
|
21
|
-
name
|
|
22
|
-
type
|
|
23
|
-
private readonly
|
|
20
|
+
export declare class VariableModel implements IVariableModel<IVariableState> {
|
|
21
|
+
private readonly workspace;
|
|
22
|
+
private name;
|
|
23
|
+
private type;
|
|
24
|
+
private readonly id;
|
|
24
25
|
/**
|
|
25
26
|
* @param workspace The variable's workspace.
|
|
26
27
|
* @param name The name of the variable. This is the user-visible name (e.g.
|
|
@@ -33,15 +34,40 @@ export declare class VariableModel {
|
|
|
33
34
|
constructor(workspace: Workspace, name: string, opt_type?: string, opt_id?: string);
|
|
34
35
|
/** @returns The ID for the variable. */
|
|
35
36
|
getId(): string;
|
|
37
|
+
/** @returns The name of this variable. */
|
|
38
|
+
getName(): string;
|
|
36
39
|
/**
|
|
37
|
-
*
|
|
40
|
+
* Updates the user-visible name of this variable.
|
|
38
41
|
*
|
|
39
|
-
* @
|
|
40
|
-
* @param var2 Second variable to compare.
|
|
41
|
-
* @returns -1 if name of var1 is less than name of var2, 0 if equal, and 1 if
|
|
42
|
-
* greater.
|
|
43
|
-
* @internal
|
|
42
|
+
* @returns The newly-updated variable.
|
|
44
43
|
*/
|
|
45
|
-
|
|
44
|
+
setName(newName: string): this;
|
|
45
|
+
/** @returns The type of this variable. */
|
|
46
|
+
getType(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Updates the type of this variable.
|
|
49
|
+
*
|
|
50
|
+
* @returns The newly-updated variable.
|
|
51
|
+
*/
|
|
52
|
+
setType(newType: string): this;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the workspace this VariableModel belongs to.
|
|
55
|
+
*
|
|
56
|
+
* @returns The workspace this VariableModel belongs to.
|
|
57
|
+
*/
|
|
58
|
+
getWorkspace(): Workspace;
|
|
59
|
+
/**
|
|
60
|
+
* Serializes this VariableModel.
|
|
61
|
+
*
|
|
62
|
+
* @returns a JSON representation of this VariableModel.
|
|
63
|
+
*/
|
|
64
|
+
save(): IVariableState;
|
|
65
|
+
/**
|
|
66
|
+
* Loads the persisted state into a new variable in the given workspace.
|
|
67
|
+
*
|
|
68
|
+
* @param state The serialized state of a variable model from save().
|
|
69
|
+
* @param workspace The workspace to create the new variable in.
|
|
70
|
+
*/
|
|
71
|
+
static load(state: IVariableState, workspace: Workspace): void;
|
|
46
72
|
}
|
|
47
73
|
//# sourceMappingURL=variable_model.d.ts.map
|