blockly 10.0.2 → 10.1.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/core/block.d.ts CHANGED
@@ -287,14 +287,6 @@ export declare class Block implements IASTNodeLocation, IDeletable {
287
287
  * @returns The previous statement block or null.
288
288
  */
289
289
  getPreviousBlock(): Block | null;
290
- /**
291
- * Return the connection on the first statement input on this block, or null
292
- * if there are none.
293
- *
294
- * @returns The first statement connection or null.
295
- * @internal
296
- */
297
- getFirstStatementConnection(): Connection | null;
298
290
  /**
299
291
  * Return the top-most block in this block's tree.
300
292
  * This will return itself if this block is at the top level.
@@ -188,11 +188,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
188
188
  * @internal
189
189
  */
190
190
  moveDuringDrag(newLoc: Coordinate): void;
191
- /**
192
- * Clear the block of transform="..." attributes.
193
- * Used when the block is switching from 3d to 2d transform or vice versa.
194
- */
195
- private clearTransformAttributes_;
196
191
  /** Snap this block to the nearest grid point. */
197
192
  snapToGrid(): void;
198
193
  /**
@@ -575,11 +570,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
575
570
  * @internal
576
571
  */
577
572
  positionNearConnection(sourceConnection: RenderedConnection, targetConnection: RenderedConnection): void;
578
- /**
579
- * @returns The first statement connection or null.
580
- * @internal
581
- */
582
- getFirstStatementConnection(): RenderedConnection | null;
583
573
  /**
584
574
  * Find all the blocks that are directly nested inside this one.
585
575
  * Includes value and statement inputs, as well as any following statement.
@@ -602,11 +592,8 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
602
592
  /**
603
593
  * Immediately lays out and reflows a block based on its contents and
604
594
  * settings.
605
- *
606
- * @param opt_bubble If false, just render this block.
607
- * If true, also render block's parent, grandparent, etc. Defaults to true.
608
595
  */
609
- render(opt_bubble?: boolean): void;
596
+ render(): void;
610
597
  /**
611
598
  * Renders this block in a way that's compatible with the more efficient
612
599
  * render management system.
package/core/field.d.ts CHANGED
@@ -188,15 +188,11 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
188
188
  init(): void;
189
189
  /**
190
190
  * Create the block UI for this field.
191
- *
192
- * @internal
193
191
  */
194
- initView(): void;
192
+ protected initView(): void;
195
193
  /**
196
194
  * Initializes the model of the field after it has been installed on a block.
197
195
  * No-op by default.
198
- *
199
- * @internal
200
196
  */
201
197
  initModel(): void;
202
198
  /**
@@ -88,8 +88,6 @@ export declare class FieldAngle extends FieldInput<number> {
88
88
  protected configure_(config: FieldAngleConfig): void;
89
89
  /**
90
90
  * Create the block UI for this field.
91
- *
92
- * @internal
93
91
  */
94
92
  initView(): void;
95
93
  /** Updates the angle when the field rerenders. */
@@ -58,8 +58,6 @@ export declare class FieldCheckbox extends Field<CheckboxBool> {
58
58
  saveState(): any;
59
59
  /**
60
60
  * Create the block UI for this checkbox.
61
- *
62
- * @internal
63
61
  */
64
62
  initView(): void;
65
63
  render_(): void;
@@ -84,8 +84,6 @@ export declare class FieldColour extends Field<string> {
84
84
  protected configure_(config: FieldColourConfig): void;
85
85
  /**
86
86
  * Create the block UI for this colour field.
87
- *
88
- * @internal
89
87
  */
90
88
  initView(): void;
91
89
  /**
@@ -89,8 +89,6 @@ export declare class FieldDropdown extends Field<string> {
89
89
  loadState(state: any): void;
90
90
  /**
91
91
  * Create the block UI for this dropdown.
92
- *
93
- * @internal
94
92
  */
95
93
  initView(): void;
96
94
  /**
@@ -15,11 +15,11 @@ export declare class FieldImage extends Field<string> {
15
15
  */
16
16
  private static readonly Y_PADDING;
17
17
  protected size_: Size;
18
- private readonly imageHeight;
18
+ protected readonly imageHeight: number;
19
19
  /** The function to be called when this field is clicked. */
20
20
  private clickHandler;
21
21
  /** The rendered field's image element. */
22
- private imageElement;
22
+ protected imageElement: SVGImageElement | null;
23
23
  /**
24
24
  * Editable fields usually show some sort of UI indicating they are
25
25
  * editable. This field should not.
@@ -60,8 +60,6 @@ export declare class FieldImage extends Field<string> {
60
60
  protected configure_(config: FieldImageConfig): void;
61
61
  /**
62
62
  * Create the block UI for this image.
63
- *
64
- * @internal
65
63
  */
66
64
  initView(): void;
67
65
  updateSize_(): void;
@@ -74,7 +74,6 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
74
74
  */
75
75
  constructor(value?: string | typeof Field.SKIP_SETUP, validator?: FieldInputValidator<T> | null, config?: FieldInputConfig);
76
76
  protected configure_(config: FieldInputConfig): void;
77
- /** @internal */
78
77
  initView(): void;
79
78
  /**
80
79
  * Called by setValue if the text input is not valid. If the field is
@@ -33,8 +33,6 @@ export declare class FieldLabel extends Field<string> {
33
33
  protected configure_(config: FieldLabelConfig): void;
34
34
  /**
35
35
  * Create block UI for this label.
36
- *
37
- * @internal
38
36
  */
39
37
  initView(): void;
40
38
  /**
@@ -80,8 +80,6 @@ export declare class FieldMultilineInput extends FieldTextInput {
80
80
  loadState(state: any): void;
81
81
  /**
82
82
  * Create the block UI for this field.
83
- *
84
- * @internal
85
83
  */
86
84
  initView(): void;
87
85
  /**
@@ -62,8 +62,6 @@ export declare class FieldVariable extends FieldDropdown {
62
62
  * Initialize the model for this field if it has not already been initialized.
63
63
  * If the value has not been set to a variable by the first render, we make up
64
64
  * a variable rather than let the value be invalid.
65
- *
66
- * @internal
67
65
  */
68
66
  initModel(): void;
69
67
  shouldAddBorderRect_(): boolean;
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { Flyout, FlyoutItem } from './flyout_base.js';
7
7
  import type { Options } from './options.js';
8
- import type { Coordinate } from './utils/coordinate.js';
8
+ import { Coordinate } from './utils/coordinate.js';
9
9
  import { Rect } from './utils/rect.js';
10
10
  /**
11
11
  * Class for a flyout.
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { Flyout, FlyoutItem } from './flyout_base.js';
7
7
  import type { Options } from './options.js';
8
- import type { Coordinate } from './utils/coordinate.js';
8
+ import { Coordinate } from './utils/coordinate.js';
9
9
  import { Rect } from './utils/rect.js';
10
10
  /**
11
11
  * Class for a flyout.
@@ -20,4 +20,12 @@ export declare function queueRender(block: BlockSvg): Promise<void>;
20
20
  * been completed.
21
21
  */
22
22
  export declare function finishQueuedRenders(): Promise<void>;
23
+ /**
24
+ * Triggers an immediate render of all queued renders. Should only be used in
25
+ * cases where queueing renders breaks functionality + backwards compatibility
26
+ * (such as rendering icons).
27
+ *
28
+ * @internal
29
+ */
30
+ export declare function triggerQueuedRenders(): void;
23
31
  //# sourceMappingURL=render_management.d.ts.map
@@ -98,7 +98,6 @@ export declare class RenderedConnection extends Connection {
98
98
  * Get the offset of this connection relative to the top left of its block.
99
99
  *
100
100
  * @returns The offset of the connection.
101
- * @internal
102
101
  */
103
102
  getOffsetInBlock(): Coordinate;
104
103
  /**
@@ -202,6 +201,15 @@ export declare class RenderedConnection extends Connection {
202
201
  * Function to be called when this connection's compatible types have changed.
203
202
  */
204
203
  protected onCheckChanged_(): void;
204
+ /**
205
+ * Change a connection's compatibility.
206
+ * Rerender blocks as needed.
207
+ *
208
+ * @param check Compatible value type or list of value types. Null if all
209
+ * types are compatible.
210
+ * @returns The connection being modified (to allow chaining).
211
+ */
212
+ setCheck(check: string | string[] | null): RenderedConnection;
205
213
  }
206
214
  export declare namespace RenderedConnection {
207
215
  /**
@@ -259,6 +259,15 @@ export declare class Scrollbar {
259
259
  * @param visible True if visible.
260
260
  */
261
261
  setVisible(visible: boolean): void;
262
+ /**
263
+ * Set whether the scrollbar is visible. Bypasses checking whether this
264
+ * scrollbar is part of a pair so that it can be toggled by the scrollbar
265
+ * pair.
266
+ *
267
+ * @param visible True if visible.
268
+ * @internal
269
+ */
270
+ setVisibleInternal(visible: boolean): void;
262
271
  /**
263
272
  * Update visibility of scrollbar based on whether it thinks it should
264
273
  * be visible and whether its containing workspace is visible.
@@ -95,6 +95,12 @@ export declare class ScrollbarPair {
95
95
  * @returns True if visible.
96
96
  */
97
97
  isVisible(): boolean;
98
+ /**
99
+ * Sets the visibility of any existing scrollbars.
100
+ *
101
+ * @param visible True if visible.
102
+ */
103
+ setVisible(visible: boolean): void;
98
104
  /**
99
105
  * Recalculates the scrollbars' locations within their path and length.
100
106
  * This should be called when the contents of the workspace have changed.
@@ -47,7 +47,7 @@ export declare class CollapsibleToolboxCategory extends ToolboxCategory implemen
47
47
  */
48
48
  protected createSubCategoriesDom_(subcategories: IToolboxItem[]): HTMLDivElement;
49
49
  /**
50
- * Opens or closes the current category.
50
+ * Opens or closes the current category and the associated flyout.
51
51
  *
52
52
  * @param isExpanded True to expand the category, false to close.
53
53
  */
@@ -48,6 +48,15 @@ export declare function getDocumentScroll(): Coordinate;
48
48
  * @returns The workspace coordinates.
49
49
  */
50
50
  export declare function screenToWsCoordinates(ws: WorkspaceSvg, screenCoordinates: Coordinate): Coordinate;
51
+ /**
52
+ * Converts workspace coordinates to screen coordinates.
53
+ *
54
+ * @param ws The workspace to get the coordinates out of.
55
+ * @param workspaceCoordinates The workspace coordinates to be converted
56
+ * to screen coordinates.
57
+ * @returns The screen coordinates.
58
+ */
59
+ export declare function wsToScreenCoordinates(ws: WorkspaceSvg, workspaceCoordinates: Coordinate): Coordinate;
51
60
  export declare const TEST_ONLY: {
52
61
  XY_REGEX: RegExp;
53
62
  XY_STYLE_REGEX: RegExp;
@@ -18,8 +18,6 @@ export interface BlockInfo {
18
18
  disabled?: string | boolean;
19
19
  enabled?: boolean;
20
20
  id?: string;
21
- x?: number;
22
- y?: number;
23
21
  collapsed?: boolean;
24
22
  inline?: boolean;
25
23
  data?: string;
@@ -329,8 +329,6 @@ export declare class WorkspaceCommentSvg extends WorkspaceComment implements IBo
329
329
  * @param height height of the container
330
330
  */
331
331
  private setSize;
332
- /** Dispose of any rendered comment components. */
333
- private disposeInternal;
334
332
  /**
335
333
  * Set the focus on the text area.
336
334
  *
@@ -537,7 +537,9 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
537
537
  * @param isVisible True if workspace should be visible.
538
538
  */
539
539
  setVisible(isVisible: boolean): void;
540
- /** Render all blocks in workspace. */
540
+ /**
541
+ * Render all blocks in workspace.
542
+ */
541
543
  render(): void;
542
544
  /**
543
545
  * Highlight or unhighlight a block in the workspace. Block highlighting is
package/core/xml.d.ts CHANGED
@@ -91,6 +91,19 @@ export declare function appendDomToWorkspace(xml: Element, workspace: WorkspaceS
91
91
  * @returns The root block created.
92
92
  */
93
93
  export declare function domToBlock(xmlBlock: Element, workspace: Workspace): Block;
94
+ /**
95
+ * Decode an XML block tag and create a block (and possibly sub blocks) on the
96
+ * workspace.
97
+ *
98
+ * This is defined internally so that it doesn't trigger an immediate render,
99
+ * which we do want to happen for external calls.
100
+ *
101
+ * @param xmlBlock XML block element.
102
+ * @param workspace The workspace.
103
+ * @returns The root block created.
104
+ * @internal
105
+ */
106
+ export declare function domToBlockInternal(xmlBlock: Element, workspace: Workspace): Block;
94
107
  /**
95
108
  * Decode an XML list of variables and add the variables to the workspace.
96
109
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly",
3
- "version": "10.0.2",
3
+ "version": "10.1.0",
4
4
  "description": "Blockly is a library for building visual programming editors.",
5
5
  "keywords": [
6
6
  "blockly"
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "license": "Apache-2.0",
29
29
  "devDependencies": {
30
- "@blockly/block-test": "^3.0.0",
31
- "@blockly/dev-tools": "^5.0.0",
32
- "@blockly/theme-modern": "^3.0.0",
30
+ "@blockly/block-test": "^5.0.0",
31
+ "@blockly/dev-tools": "^7.0.2",
32
+ "@blockly/theme-modern": "^5.0.0",
33
33
  "@hyperjump/json-schema": "^1.5.0",
34
34
  "@microsoft/api-documenter": "^7.22.4",
35
35
  "@microsoft/api-extractor": "^7.29.5",
36
- "@typescript-eslint/eslint-plugin": "^5.33.1",
36
+ "@typescript-eslint/eslint-plugin": "^6.1.0",
37
37
  "@wdio/selenium-standalone-service": "^8.0.2",
38
38
  "async-done": "^2.0.0",
39
39
  "chai": "^4.2.0",
@@ -61,7 +61,7 @@
61
61
  "markdown-tables-to-json": "^0.1.7",
62
62
  "mocha": "^10.0.0",
63
63
  "patch-package": "^7.0.0",
64
- "prettier": "2.8.8",
64
+ "prettier": "3.0.0",
65
65
  "readline-sync": "^1.4.10",
66
66
  "rimraf": "^5.0.0",
67
67
  "selenium-standalone": "^8.0.3",
@@ -1,135 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2016 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { Coordinate } from './utils/coordinate.js';
7
- /**
8
- * Class for a drag surface for the currently dragged block. This is a separate
9
- * SVG that contains only the currently moving block, or nothing.
10
- *
11
- * @alias Blockly.BlockDragSurfaceSvg
12
- */
13
- export declare class BlockDragSurfaceSvg {
14
- private readonly container;
15
- /**
16
- * The root element of the drag surface.
17
- */
18
- private svg;
19
- /**
20
- * This is where blocks live while they are being dragged if the drag
21
- * surface is enabled.
22
- */
23
- private dragGroup;
24
- /**
25
- * Cached value for the scale of the drag surface.
26
- * Used to set/get the correct translation during and after a drag.
27
- */
28
- private scale;
29
- /**
30
- * Cached value for the translation of the drag surface.
31
- * This translation is in pixel units, because the scale is applied to the
32
- * drag group rather than the top-level SVG.
33
- */
34
- private surfaceXY;
35
- /**
36
- * Cached value for the translation of the child drag surface in pixel
37
- * units. Since the child drag surface tracks the translation of the
38
- * workspace this is ultimately the translation of the workspace.
39
- */
40
- private readonly childSurfaceXY;
41
- /** @param container Containing element. */
42
- constructor(container: Element);
43
- /**
44
- * Create the drag surface and inject it into the container.
45
- *
46
- * @deprecated The DOM is automatically created by the constructor.
47
- */
48
- createDom(): void;
49
- /**
50
- * Set the SVG blocks on the drag surface's group and show the surface.
51
- * Only one block group should be on the drag surface at a time.
52
- *
53
- * @param blocks Block or group of blocks to place on the drag surface.
54
- */
55
- setBlocksAndShow(blocks: SVGElement): void;
56
- /**
57
- * Translate and scale the entire drag surface group to the given position, to
58
- * keep in sync with the workspace.
59
- *
60
- * @param x X translation in pixel coordinates.
61
- * @param y Y translation in pixel coordinates.
62
- * @param scale Scale of the group.
63
- */
64
- translateAndScaleGroup(x: number, y: number, scale: number): void;
65
- /**
66
- * Translate the drag surface's SVG based on its internal state.
67
- *
68
- * @internal
69
- */
70
- translateSurfaceInternal_(): void;
71
- /**
72
- * Translates the entire surface by a relative offset.
73
- *
74
- * @param deltaX Horizontal offset in pixel units.
75
- * @param deltaY Vertical offset in pixel units.
76
- */
77
- translateBy(deltaX: number, deltaY: number): void;
78
- /**
79
- * Translate the entire drag surface during a drag.
80
- * We translate the drag surface instead of the blocks inside the surface
81
- * so that the browser avoids repainting the SVG.
82
- * Because of this, the drag coordinates must be adjusted by scale.
83
- *
84
- * @param x X translation for the entire surface.
85
- * @param y Y translation for the entire surface.
86
- */
87
- translateSurface(x: number, y: number): void;
88
- /**
89
- * Reports the surface translation in scaled workspace coordinates.
90
- * Use this when finishing a drag to return blocks to the correct position.
91
- *
92
- * @returns Current translation of the surface.
93
- */
94
- getSurfaceTranslation(): Coordinate;
95
- /**
96
- * Provide a reference to the drag group (primarily for
97
- * BlockSvg.getRelativeToSurfaceXY).
98
- *
99
- * @returns Drag surface group element.
100
- */
101
- getGroup(): SVGElement;
102
- /**
103
- * Returns the SVG drag surface.
104
- *
105
- * @returns The SVG drag surface.
106
- */
107
- getSvgRoot(): SVGElement;
108
- /**
109
- * Get the current blocks on the drag surface, if any (primarily
110
- * for BlockSvg.getRelativeToSurfaceXY).
111
- *
112
- * @returns Drag surface block DOM element, or null if no blocks exist.
113
- */
114
- getCurrentBlock(): Element | null;
115
- /**
116
- * Gets the translation of the child block surface
117
- * This surface is in charge of keeping track of how much the workspace has
118
- * moved.
119
- *
120
- * @returns The amount the workspace has been moved.
121
- */
122
- getWsTranslation(): Coordinate;
123
- /**
124
- * Clear the group and hide the surface; move the blocks off onto the provided
125
- * element.
126
- * If the block is being deleted it doesn't need to go back to the original
127
- * surface, since it would be removed immediately during dispose.
128
- *
129
- * @param opt_newSurface Surface the dragging blocks should be moved to, or
130
- * null if the blocks should be removed from this surface without being
131
- * moved to a different surface.
132
- */
133
- clearAndHide(opt_newSurface?: Element): void;
134
- }
135
- //# sourceMappingURL=block_drag_surface.d.ts.map
@@ -1,74 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2016 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import type { Coordinate } from './utils/coordinate.js';
7
- /**
8
- * Blocks are moved into this SVG during a drag, improving performance.
9
- * The entire SVG is translated using CSS transforms instead of SVG so the
10
- * blocks are never repainted during drag improving performance.
11
- *
12
- * @alias Blockly.WorkspaceDragSurfaceSvg
13
- */
14
- export declare class WorkspaceDragSurfaceSvg {
15
- private readonly container;
16
- /**
17
- * The SVG drag surface. Set once by WorkspaceDragSurfaceSvg.createDom.
18
- */
19
- private SVG;
20
- /**
21
- * The element to insert the block canvas and bubble canvas after when it
22
- * goes back in the DOM at the end of a drag.
23
- */
24
- private previousSibling;
25
- /** @param container Containing element. */
26
- constructor(container: Element);
27
- /** Create the drag surface and inject it into the container. */
28
- createDom(): void;
29
- /**
30
- * Translate the entire drag surface during a drag.
31
- * We translate the drag surface instead of the blocks inside the surface
32
- * so that the browser avoids repainting the SVG.
33
- * Because of this, the drag coordinates must be adjusted by scale.
34
- *
35
- * @param x X translation for the entire surface
36
- * @param y Y translation for the entire surface
37
- * @internal
38
- */
39
- translateSurface(x: number, y: number): void;
40
- /**
41
- * Reports the surface translation in scaled workspace coordinates.
42
- * Use this when finishing a drag to return blocks to the correct position.
43
- *
44
- * @returns Current translation of the surface
45
- * @internal
46
- */
47
- getSurfaceTranslation(): Coordinate;
48
- /**
49
- * Move the blockCanvas and bubbleCanvas out of the surface SVG and on to
50
- * newSurface.
51
- *
52
- * @param newSurface The element to put the drag surface contents into.
53
- * @internal
54
- */
55
- clearAndHide(newSurface: SVGElement): void;
56
- /**
57
- * Set the SVG to have the block canvas and bubble canvas in it and then
58
- * show the surface.
59
- *
60
- * @param blockCanvas The block canvas <g> element from the
61
- * workspace.
62
- * @param bubbleCanvas The <g> element that contains the
63
- bubbles.
64
- * @param previousSibling The element to insert the block canvas and
65
- bubble canvas after when it goes back in the DOM at the end of a
66
- drag.
67
- * @param width The width of the workspace SVG element.
68
- * @param height The height of the workspace SVG element.
69
- * @param scale The scale of the workspace being dragged.
70
- * @internal
71
- */
72
- setContentsAndShow(blockCanvas: SVGElement, bubbleCanvas: SVGElement, previousSibling: Element, width: number, height: number, scale: number): void;
73
- }
74
- //# sourceMappingURL=workspace_drag_surface_svg.d.ts.map