blockly 9.3.3 → 10.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.
Files changed (160) hide show
  1. package/README.md +9 -7
  2. package/blockly.min.js +1314 -1415
  3. package/blockly_compressed.js +1067 -1110
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +120 -136
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +59 -32
  8. package/core/block_dragger.d.ts +2 -2
  9. package/core/block_svg.d.ts +38 -67
  10. package/core/blockly.d.ts +18 -112
  11. package/core/browser_events.d.ts +1 -2
  12. package/core/bubble_dragger.d.ts +1 -2
  13. package/core/{bubble.d.ts → bubble_old.d.ts} +3 -7
  14. package/core/bubbles/bubble.d.ts +174 -0
  15. package/core/bubbles/mini_workspace_bubble.d.ts +80 -0
  16. package/core/bubbles/text_bubble.d.ts +35 -0
  17. package/core/bubbles/textinput_bubble.d.ts +89 -0
  18. package/core/bump_objects.d.ts +6 -4
  19. package/core/connection.d.ts +19 -9
  20. package/core/connection_db.d.ts +4 -4
  21. package/core/contextmenu.d.ts +1 -2
  22. package/core/events/events.d.ts +1 -4
  23. package/core/events/events_abstract.d.ts +0 -6
  24. package/core/events/events_block_base.d.ts +0 -6
  25. package/core/events/events_block_change.d.ts +0 -6
  26. package/core/events/events_block_create.d.ts +0 -6
  27. package/core/events/events_block_delete.d.ts +0 -6
  28. package/core/events/events_block_drag.d.ts +0 -6
  29. package/core/events/events_block_move.d.ts +21 -7
  30. package/core/events/events_bubble_open.d.ts +0 -6
  31. package/core/events/events_click.d.ts +0 -6
  32. package/core/events/events_comment_base.d.ts +0 -6
  33. package/core/events/events_comment_change.d.ts +0 -6
  34. package/core/events/events_comment_create.d.ts +0 -6
  35. package/core/events/events_comment_move.d.ts +0 -6
  36. package/core/events/events_marker_move.d.ts +0 -6
  37. package/core/events/events_selected.d.ts +0 -6
  38. package/core/events/events_theme_change.d.ts +0 -6
  39. package/core/events/events_toolbox_item_select.d.ts +0 -6
  40. package/core/events/events_trashcan_open.d.ts +0 -6
  41. package/core/events/events_var_base.d.ts +0 -6
  42. package/core/events/events_var_create.d.ts +0 -6
  43. package/core/events/events_var_delete.d.ts +0 -6
  44. package/core/events/events_var_rename.d.ts +0 -6
  45. package/core/events/events_viewport.d.ts +0 -6
  46. package/core/events/utils.d.ts +1 -1
  47. package/core/events/workspace_events.d.ts +1 -16
  48. package/core/field.d.ts +31 -5
  49. package/core/field_checkbox.d.ts +1 -1
  50. package/core/field_colour.d.ts +0 -2
  51. package/core/field_dropdown.d.ts +11 -13
  52. package/core/field_image.d.ts +5 -5
  53. package/core/field_input.d.ts +9 -2
  54. package/core/field_label.d.ts +3 -1
  55. package/core/field_number.d.ts +4 -4
  56. package/core/field_variable.d.ts +5 -5
  57. package/core/flyout_base.d.ts +23 -25
  58. package/core/flyout_button.d.ts +9 -9
  59. package/core/flyout_horizontal.d.ts +1 -1
  60. package/core/flyout_vertical.d.ts +1 -1
  61. package/core/generator.d.ts +15 -2
  62. package/core/gesture.d.ts +58 -41
  63. package/core/icons/comment_icon.d.ts +108 -0
  64. package/core/icons/exceptions.d.ts +14 -0
  65. package/core/icons/icon.d.ts +38 -0
  66. package/core/icons/icon_types.d.ts +22 -0
  67. package/core/icons/mutator_icon.d.ts +90 -0
  68. package/core/icons/registry.d.ts +23 -0
  69. package/core/icons/warning_icon.d.ts +67 -0
  70. package/core/icons.d.ts +12 -0
  71. package/core/inputs/dummy_input.d.ts +20 -0
  72. package/core/{input.d.ts → inputs/input.d.ts} +20 -13
  73. package/core/{input_types.d.ts → inputs/input_types.d.ts} +2 -1
  74. package/core/inputs/statement_input.d.ts +22 -0
  75. package/core/inputs/value_input.d.ts +20 -0
  76. package/core/interfaces/i_block_dragger.d.ts +1 -1
  77. package/core/interfaces/i_bounded_element.d.ts +2 -1
  78. package/core/interfaces/i_bubble.d.ts +2 -14
  79. package/core/interfaces/i_has_bubble.d.ts +14 -0
  80. package/core/interfaces/i_icon.d.ts +75 -0
  81. package/core/interfaces/i_serializable.d.ts +24 -0
  82. package/core/keyboard_nav/ast_node.d.ts +15 -15
  83. package/core/keyboard_nav/basic_cursor.d.ts +2 -2
  84. package/core/keyboard_nav/marker.d.ts +2 -2
  85. package/core/main.d.ts +0 -10
  86. package/core/marker_manager.d.ts +0 -1
  87. package/core/names.d.ts +4 -4
  88. package/core/options.d.ts +3 -3
  89. package/core/procedures.d.ts +1 -4
  90. package/core/registry.d.ts +5 -0
  91. package/core/render_management.d.ts +9 -1
  92. package/core/rendered_connection.d.ts +7 -7
  93. package/core/renderers/common/block_rendering.d.ts +0 -10
  94. package/core/renderers/common/constants.d.ts +5 -7
  95. package/core/renderers/common/drawer.d.ts +7 -2
  96. package/core/renderers/common/info.d.ts +1 -4
  97. package/core/renderers/common/marker_svg.d.ts +4 -4
  98. package/core/renderers/common/renderer.d.ts +0 -9
  99. package/core/renderers/geras/highlighter.d.ts +1 -1
  100. package/core/renderers/geras/info.d.ts +1 -1
  101. package/core/renderers/geras/measurables/inline_input.d.ts +1 -1
  102. package/core/renderers/geras/measurables/statement_input.d.ts +1 -1
  103. package/core/renderers/geras/renderer.d.ts +1 -1
  104. package/core/renderers/measurables/external_value_input.d.ts +1 -1
  105. package/core/renderers/measurables/field.d.ts +1 -1
  106. package/core/renderers/measurables/icon.d.ts +5 -1
  107. package/core/renderers/measurables/inline_input.d.ts +1 -1
  108. package/core/renderers/measurables/input_connection.d.ts +1 -1
  109. package/core/renderers/measurables/statement_input.d.ts +1 -1
  110. package/core/renderers/zelos/constants.d.ts +2 -2
  111. package/core/renderers/zelos/info.d.ts +2 -2
  112. package/core/renderers/zelos/marker_svg.d.ts +3 -3
  113. package/core/renderers/zelos/measurables/inputs.d.ts +1 -1
  114. package/core/renderers/zelos/path_object.d.ts +3 -3
  115. package/core/scrollbar.d.ts +0 -2
  116. package/core/scrollbar_pair.d.ts +0 -2
  117. package/core/serialization/blocks.d.ts +3 -3
  118. package/core/serialization/exceptions.d.ts +11 -0
  119. package/core/shortcut_registry.d.ts +2 -2
  120. package/core/theme_manager.d.ts +0 -1
  121. package/core/touch.d.ts +0 -43
  122. package/core/trashcan.d.ts +19 -21
  123. package/core/utils/dom.d.ts +2 -2
  124. package/core/utils/object.d.ts +0 -25
  125. package/core/utils/rect.d.ts +2 -0
  126. package/core/utils/style.d.ts +0 -12
  127. package/core/utils/svg_math.d.ts +0 -8
  128. package/core/utils/xml.d.ts +15 -22
  129. package/core/utils.d.ts +0 -138
  130. package/core/widgetdiv.d.ts +5 -0
  131. package/core/workspace.d.ts +9 -3
  132. package/core/workspace_comment.d.ts +3 -3
  133. package/core/workspace_comment_svg.d.ts +31 -44
  134. package/core/workspace_dragger.d.ts +1 -4
  135. package/core/workspace_svg.d.ts +13 -50
  136. package/core/xml.d.ts +0 -12
  137. package/core-browser.js +0 -1
  138. package/core.js +0 -1
  139. package/dart_compressed.js +124 -159
  140. package/dart_compressed.js.map +1 -1
  141. package/javascript_compressed.js +127 -169
  142. package/javascript_compressed.js.map +1 -1
  143. package/lua_compressed.js +119 -142
  144. package/lua_compressed.js.map +1 -1
  145. package/msg/constants.d.ts +1 -3
  146. package/msg/msg.d.ts +1 -2
  147. package/msg/qqq.d.ts +1 -3
  148. package/msg/synonyms.d.ts +1 -3
  149. package/package.json +12 -13
  150. package/php_compressed.js +131 -161
  151. package/php_compressed.js.map +1 -1
  152. package/python_compressed.js +118 -149
  153. package/python_compressed.js.map +1 -1
  154. package/core/comment.d.ts +0 -115
  155. package/core/events/events_ui.d.ts +0 -40
  156. package/core/icon.d.ts +0 -89
  157. package/core/mutator.d.ts +0 -142
  158. package/core/renderers/common/debug.d.ts +0 -29
  159. package/core/renderers/common/debugger.d.ts +0 -117
  160. package/core/warning.d.ts +0 -53
package/core/block.d.ts CHANGED
@@ -6,19 +6,21 @@
6
6
  import './events/events_block_change.js';
7
7
  import './events/events_block_create.js';
8
8
  import './events/events_block_delete.js';
9
- import type { Comment } from './comment.js';
10
9
  import { Connection } from './connection.js';
10
+ import { ConnectionType } from './connection_type.js';
11
11
  import type { Abstract } from './events/events_abstract.js';
12
12
  import type { Field } from './field.js';
13
- import { Input } from './input.js';
13
+ import { Input } from './inputs/input.js';
14
14
  import type { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
15
15
  import type { IDeletable } from './interfaces/i_deletable.js';
16
- import type { Mutator } from './mutator.js';
16
+ import type { IIcon } from './interfaces/i_icon.js';
17
+ import type { MutatorIcon } from './icons/mutator_icon.js';
17
18
  import * as Tooltip from './tooltip.js';
18
19
  import { Coordinate } from './utils/coordinate.js';
19
20
  import { Size } from './utils/size.js';
20
21
  import type { VariableModel } from './variable_model.js';
21
22
  import type { Workspace } from './workspace.js';
23
+ import { IconType } from './icons/icon_types.js';
22
24
  /**
23
25
  * Class for one block.
24
26
  * Not normally called directly, workspace.newBlock() is preferred.
@@ -55,9 +57,9 @@ export declare class Block implements IASTNodeLocation, IDeletable {
55
57
  /** Name of the block style. */
56
58
  protected styleName_: string;
57
59
  /** An optional method called during initialization. */
58
- init?: (() => void);
60
+ init?: () => void;
59
61
  /** An optional method called during disposal. */
60
- destroy?: (() => void);
62
+ destroy?: () => void;
61
63
  /**
62
64
  * An optional serialization method for defining how to serialize the
63
65
  * mutation state to XML. This must be coupled with defining
@@ -110,6 +112,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
110
112
  previousConnection: Connection | null;
111
113
  inputList: Input[];
112
114
  inputsInline?: boolean;
115
+ icons: IIcon[];
113
116
  private disabled;
114
117
  tooltip: Tooltip.TipInfo;
115
118
  contextMenu: boolean;
@@ -125,14 +128,6 @@ export declare class Block implements IASTNodeLocation, IDeletable {
125
128
  * Is the current block currently in the process of being disposed?
126
129
  */
127
130
  private disposing;
128
- /**
129
- * A string representing the comment attached to this block.
130
- *
131
- * @deprecated August 2019. Use getCommentText instead.
132
- */
133
- comment: string | Comment | null;
134
- /** @internal */
135
- commentModel: CommentModel;
136
131
  private readonly xy_;
137
132
  isInFlyout: boolean;
138
133
  isInMutator: boolean;
@@ -174,7 +169,6 @@ export declare class Block implements IASTNodeLocation, IDeletable {
174
169
  * @param healStack If true, then try to heal any gap by connecting the next
175
170
  * statement with the previous statement. Otherwise, dispose of all
176
171
  * children of this block.
177
- * @suppress {checkTypes}
178
172
  */
179
173
  dispose(healStack: boolean): void;
180
174
  /**
@@ -665,7 +659,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
665
659
  */
666
660
  private toTokens;
667
661
  /**
668
- * Shortcut for appending a value input row.
662
+ * Appends a value input row.
669
663
  *
670
664
  * @param name Language-neutral identifier which may used to find this input
671
665
  * again. Should be unique to this block.
@@ -673,7 +667,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
673
667
  */
674
668
  appendValueInput(name: string): Input;
675
669
  /**
676
- * Shortcut for appending a statement input row.
670
+ * Appends a statement input row.
677
671
  *
678
672
  * @param name Language-neutral identifier which may used to find this input
679
673
  * again. Should be unique to this block.
@@ -681,13 +675,29 @@ export declare class Block implements IASTNodeLocation, IDeletable {
681
675
  */
682
676
  appendStatementInput(name: string): Input;
683
677
  /**
684
- * Shortcut for appending a dummy input row.
678
+ * Appends a dummy input row.
685
679
  *
686
- * @param opt_name Language-neutral identifier which may used to find this
687
- * input again. Should be unique to this block.
680
+ * @param name Optional language-neutral identifier which may used to find
681
+ * this input again. Should be unique to this block.
688
682
  * @returns The input object created.
689
683
  */
690
- appendDummyInput(opt_name?: string): Input;
684
+ appendDummyInput(name?: string): Input;
685
+ /**
686
+ * Appends the given input row.
687
+ *
688
+ * Allows for custom inputs to be appended to the block.
689
+ */
690
+ appendInput(input: Input): Input;
691
+ /**
692
+ * Appends an input with the given input type and name to the block after
693
+ * constructing it from the registry.
694
+ *
695
+ * @param type The name the input is registered under in the registry.
696
+ * @param name The name the input will have within the block.
697
+ * @returns The constucted input, or null if there was no constructor
698
+ * associated with the type.
699
+ */
700
+ private appendInputFromRegistry;
691
701
  /**
692
702
  * Initialize this block using a cross-platform, internationalization-friendly
693
703
  * JSON description.
@@ -788,15 +798,6 @@ export declare class Block implements IASTNodeLocation, IDeletable {
788
798
  * @returns The JSON definition or null.
789
799
  */
790
800
  private stringToFieldJson_;
791
- /**
792
- * Add a value input, statement input or local variable to this block.
793
- *
794
- * @param type One of Blockly.inputTypes.
795
- * @param name Language-neutral identifier which may used to find this input
796
- * again. Should be unique to this block.
797
- * @returns The input object created.
798
- */
799
- protected appendInput_(type: number, name: string): Input;
800
801
  /**
801
802
  * Move a named input to a different location on this block.
802
803
  *
@@ -862,7 +863,31 @@ export declare class Block implements IASTNodeLocation, IDeletable {
862
863
  *
863
864
  * @param _mutator A mutator dialog instance or null to remove.
864
865
  */
865
- setMutator(_mutator: Mutator): void;
866
+ setMutator(_mutator: MutatorIcon): void;
867
+ /** Adds the given icon to the block. */
868
+ addIcon<T extends IIcon>(icon: T): T;
869
+ /**
870
+ * Removes the icon whose getType matches the given type iconType from the
871
+ * block.
872
+ *
873
+ * @param type The type of the icon to remove from the block.
874
+ * @returns True if an icon with the given type was found, false otherwise.
875
+ */
876
+ removeIcon(type: IconType<IIcon>): boolean;
877
+ /**
878
+ * @returns True if an icon with the given type exists on the block,
879
+ * false otherwise.
880
+ */
881
+ hasIcon(type: IconType<IIcon>): boolean;
882
+ /**
883
+ * @param type The type of the icon to retrieve. Prefer passing an `IconType`
884
+ * for proper type checking when using typescript.
885
+ * @returns The icon with the given type if it exists on the block, undefined
886
+ * otherwise.
887
+ */
888
+ getIcon<T extends IIcon>(type: IconType<T> | string): T | undefined;
889
+ /** @returns An array of the icons attached to this block. */
890
+ getIcons(): IIcon[];
866
891
  /**
867
892
  * Return the coordinates of the top-left corner of this block relative to the
868
893
  * drawing surface's origin (0,0), in workspace units.
@@ -875,15 +900,17 @@ export declare class Block implements IASTNodeLocation, IDeletable {
875
900
  *
876
901
  * @param dx Horizontal offset, in workspace units.
877
902
  * @param dy Vertical offset, in workspace units.
903
+ * @param reason Why is this move happening? 'drag', 'bump', 'snap', ...
878
904
  */
879
- moveBy(dx: number, dy: number): void;
905
+ moveBy(dx: number, dy: number, reason?: string[]): void;
880
906
  /**
881
907
  * Create a connection of the specified type.
882
908
  *
883
909
  * @param type The type of the connection to create.
884
910
  * @returns A new connection of the specified type.
911
+ * @internal
885
912
  */
886
- protected makeConnection_(type: number): Connection;
913
+ makeConnection_(type: ConnectionType): Connection;
887
914
  /**
888
915
  * Recursively checks whether all statement and value inputs are filled with
889
916
  * blocks. Also checks all following statement blocks in this stack.
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import './events/events_block_drag.js';
7
7
  import type { BlockSvg } from './block_svg.js';
8
- import type { Icon } from './icon.js';
8
+ import type { Icon } from './icons/icon.js';
9
9
  import { InsertionMarkerManager } from './insertion_marker_manager.js';
10
10
  import type { IBlockDragger } from './interfaces/i_block_dragger.js';
11
11
  import { Coordinate } from './utils/coordinate.js';
@@ -38,7 +38,7 @@ export declare class BlockDragger implements IBlockDragger {
38
38
  */
39
39
  dispose(): void;
40
40
  /**
41
- * Start dragging a block. This includes moving it to the drag surface.
41
+ * Start dragging a block.
42
42
  *
43
43
  * @param currentDragDeltaXY How far the pointer has moved from the position
44
44
  * at mouse down, in pixel units.
@@ -5,26 +5,27 @@
5
5
  */
6
6
  import './events/events_selected.js';
7
7
  import { Block } from './block.js';
8
- import { Comment } from './comment.js';
8
+ import { CommentIcon } from './icons/comment_icon.js';
9
9
  import type { Connection } from './connection.js';
10
+ import { ConnectionType } from './connection_type.js';
10
11
  import { ContextMenuOption, LegacyContextMenuOption } from './contextmenu_registry.js';
11
12
  import type { Field } from './field.js';
12
- import type { Icon } from './icon.js';
13
- import type { Input } from './input.js';
13
+ import type { Input } from './inputs/input.js';
14
14
  import type { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
15
15
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
16
16
  import type { CopyData, ICopyable } from './interfaces/i_copyable.js';
17
17
  import type { IDraggable } from './interfaces/i_draggable.js';
18
- import type { Mutator } from './mutator.js';
18
+ import { IIcon } from './interfaces/i_icon.js';
19
+ import { MutatorIcon } from './icons/mutator_icon.js';
19
20
  import { RenderedConnection } from './rendered_connection.js';
20
- import type { Debug as BlockRenderingDebug } from './renderers/common/debugger.js';
21
21
  import type { IPathObject } from './renderers/common/i_path_object.js';
22
22
  import type { BlockStyle } from './theme.js';
23
23
  import { Coordinate } from './utils/coordinate.js';
24
24
  import { Rect } from './utils/rect.js';
25
- import { Warning } from './warning.js';
25
+ import { WarningIcon } from './icons/warning_icon.js';
26
26
  import type { Workspace } from './workspace.js';
27
27
  import type { WorkspaceSvg } from './workspace_svg.js';
28
+ import { IconType } from './icons/icon_types.js';
28
29
  /**
29
30
  * Class for a block's SVG representation.
30
31
  * Not normally called directly, workspace.newBlock() is preferred.
@@ -44,12 +45,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
44
45
  decompose?: (p1: Workspace) => BlockSvg;
45
46
  saveConnections?: (p1: BlockSvg) => void;
46
47
  customContextMenu?: (p1: Array<ContextMenuOption | LegacyContextMenuOption>) => void;
47
- /**
48
- * An property used internally to reference the block's rendering debugger.
49
- *
50
- * @internal
51
- */
52
- renderingDebugger: BlockRenderingDebug | null;
53
48
  /**
54
49
  * Height of this block, not including any statement blocks above or below.
55
50
  * Height is in workspace units.
@@ -66,11 +61,13 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
66
61
  */
67
62
  private warningTextDb;
68
63
  /** Block's mutator icon (if any). */
69
- mutator: Mutator | null;
70
- /** Block's comment icon (if any). */
71
- private commentIcon_;
72
- /** Block's warning icon (if any). */
73
- warning: Warning | null;
64
+ mutator: MutatorIcon | null;
65
+ /**
66
+ * Block's warning icon (if any).
67
+ *
68
+ * @deprecated Use `setWarningText` to modify warnings on this block.
69
+ */
70
+ warning: WarningIcon | null;
74
71
  private svgGroup_;
75
72
  style: BlockStyle;
76
73
  /** @internal */
@@ -88,7 +85,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
88
85
  outputConnection: RenderedConnection;
89
86
  nextConnection: RenderedConnection;
90
87
  previousConnection: RenderedConnection;
91
- private readonly useDragSurface_;
92
88
  private translation;
93
89
  /**
94
90
  * The ID of the setTimeout callback for bumping neighbours, or 0 if no bump
@@ -138,12 +134,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
138
134
  * event if the block is currently selected.
139
135
  */
140
136
  unselect(): void;
141
- /**
142
- * Returns a list of mutator, comment, and warning icons.
143
- *
144
- * @returns List of icons.
145
- */
146
- getIcons(): Icon[];
147
137
  /**
148
138
  * Sets the parent of this block to be a new block or null.
149
139
  *
@@ -166,8 +156,9 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
166
156
  *
167
157
  * @param dx Horizontal offset in workspace units.
168
158
  * @param dy Vertical offset in workspace units.
159
+ * @param reason Why is this move happening? 'drag', 'bump', 'snap', ...
169
160
  */
170
- moveBy(dx: number, dy: number): void;
161
+ moveBy(dx: number, dy: number, reason?: string[]): void;
171
162
  /**
172
163
  * Transforms a block by setting the translation on the transform attribute
173
164
  * of the block's SVG.
@@ -182,33 +173,15 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
182
173
  * @internal
183
174
  */
184
175
  getTranslation(): string;
185
- /**
186
- * Move this block to its workspace's drag surface, accounting for
187
- * positioning. Generally should be called at the same time as
188
- * setDragging_(true). Does nothing if useDragSurface_ is false.
189
- *
190
- * @internal
191
- */
192
- moveToDragSurface(): void;
193
176
  /**
194
177
  * Move a block to a position.
195
178
  *
196
179
  * @param xy The position to move to in workspace units.
180
+ * @param reason Why is this move happening? 'drag', 'bump', 'snap', ...
197
181
  */
198
- moveTo(xy: Coordinate): void;
182
+ moveTo(xy: Coordinate, reason?: string[]): void;
199
183
  /**
200
- * Move this block back to the workspace block canvas.
201
- * Generally should be called at the same time as setDragging_(false).
202
- * Does nothing if useDragSurface_ is false.
203
- *
204
- * @param newXY The position the block should take on on the workspace canvas,
205
- * in workspace coordinates.
206
- * @internal
207
- */
208
- moveOffDragSurface(newXY: Coordinate): void;
209
- /**
210
- * Move this block during a drag, taking into account whether we are using a
211
- * drag surface to translate blocks.
184
+ * Move this block during a drag.
212
185
  * This block must be a top-level block.
213
186
  *
214
187
  * @param newLoc The location to translate to, in workspace coordinates.
@@ -335,7 +308,6 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
335
308
  * statement with the previous statement. Otherwise, dispose of all
336
309
  * children of this block.
337
310
  * @param animate If true, show a disposal animation and sound.
338
- * @suppress {checkTypes}
339
311
  */
340
312
  dispose(healStack?: boolean, animate?: boolean): void;
341
313
  /**
@@ -376,14 +348,9 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
376
348
  * comment.
377
349
  *
378
350
  * @returns The comment icon attached to this block, or null.
351
+ * @deprecated Use getIcon. To be remove in v11.
379
352
  */
380
- getCommentIcon(): Comment | null;
381
- /**
382
- * Set this block's comment text.
383
- *
384
- * @param text The text, or null to delete.
385
- */
386
- setCommentText(text: string | null): void;
353
+ getCommentIcon(): CommentIcon | null;
387
354
  /**
388
355
  * Set this block's warning text.
389
356
  *
@@ -397,7 +364,14 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
397
364
  *
398
365
  * @param mutator A mutator dialog instance or null to remove.
399
366
  */
400
- setMutator(mutator: Mutator | null): void;
367
+ setMutator(mutator: MutatorIcon | null): void;
368
+ addIcon<T extends IIcon>(icon: T): T;
369
+ /**
370
+ * Creates a pointer down event listener for the icon to append to its
371
+ * root svg.
372
+ */
373
+ private createIconPointerDownListener;
374
+ removeIcon(type: IconType<IIcon>): boolean;
401
375
  /**
402
376
  * Set whether the block is enabled or not.
403
377
  *
@@ -507,15 +481,8 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
507
481
  * @param refIndex Index of input that should be after the moved input.
508
482
  */
509
483
  moveNumberedInputBefore(inputIndex: number, refIndex: number): void;
510
- /**
511
- * Add a value input, statement input or local variable to this block.
512
- *
513
- * @param type One of Blockly.inputTypes.
514
- * @param name Language-neutral identifier which may used to find this input
515
- * again. Should be unique to this block.
516
- * @returns The input object created.
517
- */
518
- protected appendInput_(type: number, name: string): Input;
484
+ /** @override */
485
+ appendInput(input: Input): Input;
519
486
  /**
520
487
  * Sets whether this block's connections are tracked in the database or not.
521
488
  *
@@ -564,8 +531,9 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
564
531
  *
565
532
  * @param type The type of the connection to create.
566
533
  * @returns A new connection of the specified type.
534
+ * @internal
567
535
  */
568
- protected makeConnection_(type: number): RenderedConnection;
536
+ makeConnection_(type: ConnectionType): RenderedConnection;
569
537
  /**
570
538
  * Return the next statement block directly connected to this block.
571
539
  *
@@ -625,9 +593,12 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
625
593
  /**
626
594
  * Triggers a rerender after a delay to allow for batching.
627
595
  *
596
+ * @returns A promise that resolves after the currently queued renders have
597
+ * been completed. Used for triggering other behavior that relies on
598
+ * updated size/position location for the block.
628
599
  * @internal
629
600
  */
630
- queueRender(): void;
601
+ queueRender(): Promise<void>;
631
602
  /**
632
603
  * Immediately lays out and reflows a block based on its contents and
633
604
  * settings.
@@ -662,7 +633,7 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
662
633
  *
663
634
  * @internal
664
635
  */
665
- updateConnectionLocations(): void;
636
+ private updateConnectionAndIconLocations;
666
637
  /**
667
638
  * Add the cursor SVG to this block's SVG group.
668
639
  *
package/core/blockly.d.ts CHANGED
@@ -5,22 +5,19 @@
5
5
  */
6
6
  import './events/events_block_create.js';
7
7
  import './events/workspace_events.js';
8
- import './events/events_ui.js';
9
8
  import './events/events_ui_base.js';
10
9
  import './events/events_var_create.js';
11
10
  import { Block } from './block.js';
12
11
  import * as blockAnimations from './block_animations.js';
13
- import { BlockDragSurfaceSvg } from './block_drag_surface.js';
14
12
  import { BlockDragger } from './block_dragger.js';
15
13
  import { BlockSvg } from './block_svg.js';
16
14
  import { BlocklyOptions } from './blockly_options.js';
17
15
  import { Blocks } from './blocks.js';
18
16
  import * as browserEvents from './browser_events.js';
19
- import { Bubble } from './bubble.js';
17
+ import { Bubble } from './bubble_old.js';
20
18
  import { BubbleDragger } from './bubble_dragger.js';
21
19
  import * as bumpObjects from './bump_objects.js';
22
20
  import * as clipboard from './clipboard.js';
23
- import { Comment } from './comment.js';
24
21
  import * as common from './common.js';
25
22
  import { ComponentManager } from './component_manager.js';
26
23
  import { config } from './config.js';
@@ -59,10 +56,14 @@ import { VerticalFlyout } from './flyout_vertical.js';
59
56
  import { CodeGenerator } from './generator.js';
60
57
  import { Gesture } from './gesture.js';
61
58
  import { Grid } from './grid.js';
62
- import { Icon } from './icon.js';
59
+ import { Icon } from './icons/icon.js';
60
+ import * as icons from './icons.js';
63
61
  import { inject } from './inject.js';
64
- import { Input } from './input.js';
65
- import { inputTypes } from './input_types.js';
62
+ import { Input } from './inputs/input.js';
63
+ import { inputTypes } from './inputs/input_types.js';
64
+ import { DummyInput } from './inputs/dummy_input.js';
65
+ import { StatementInput } from './inputs/statement_input.js';
66
+ import { ValueInput } from './inputs/value_input.js';
66
67
  import { InsertionMarkerManager } from './insertion_marker_manager.js';
67
68
  import { IASTNodeLocation } from './interfaces/i_ast_node_location.js';
68
69
  import { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
@@ -103,13 +104,13 @@ import { Menu } from './menu.js';
103
104
  import { MenuItem } from './menuitem.js';
104
105
  import { MetricsManager } from './metrics_manager.js';
105
106
  import { Msg, setLocale } from './msg.js';
106
- import { Mutator } from './mutator.js';
107
107
  import { Names } from './names.js';
108
108
  import { Options } from './options.js';
109
109
  import * as uiPosition from './positionable_helpers.js';
110
110
  import * as Procedures from './procedures.js';
111
111
  import * as registry from './registry.js';
112
112
  import { RenderedConnection } from './rendered_connection.js';
113
+ import * as renderManagement from './render_management.js';
113
114
  import * as blockRendering from './renderers/common/block_rendering.js';
114
115
  import * as constants from './constants.js';
115
116
  import * as geras from './renderers/geras/geras.js';
@@ -137,13 +138,11 @@ import { VariableMap } from './variable_map.js';
137
138
  import { VariableModel } from './variable_model.js';
138
139
  import * as Variables from './variables.js';
139
140
  import * as VariablesDynamic from './variables_dynamic.js';
140
- import { Warning } from './warning.js';
141
141
  import * as WidgetDiv from './widgetdiv.js';
142
142
  import { Workspace } from './workspace.js';
143
143
  import { WorkspaceAudio } from './workspace_audio.js';
144
144
  import { WorkspaceComment } from './workspace_comment.js';
145
145
  import { WorkspaceCommentSvg } from './workspace_comment_svg.js';
146
- import { WorkspaceDragSurfaceSvg } from './workspace_drag_surface_svg.js';
147
146
  import { WorkspaceDragger } from './workspace_dragger.js';
148
147
  import { WorkspaceSvg } from './workspace_svg.js';
149
148
  import * as Xml from './xml.js';
@@ -256,102 +255,6 @@ export declare const defineBlocksWithJsonArray: typeof common.defineBlocksWithJs
256
255
  * @see Blockly.common.setParentContainer
257
256
  */
258
257
  export declare const setParentContainer: typeof common.setParentContainer;
259
- /**
260
- * Size the workspace when the contents change. This also updates
261
- * scrollbars accordingly.
262
- *
263
- * @param workspace The workspace to resize.
264
- * @deprecated Use **workspace.resizeContents** instead.
265
- * @see Blockly.WorkspaceSvg.resizeContents
266
- */
267
- declare function resizeSvgContentsLocal(workspace: WorkspaceSvg): void;
268
- export declare const resizeSvgContents: typeof resizeSvgContentsLocal;
269
- /**
270
- * Copy a block or workspace comment onto the local clipboard.
271
- *
272
- * @param toCopy Block or Workspace Comment to be copied.
273
- * @deprecated Use **Blockly.clipboard.copy** instead.
274
- * @see Blockly.clipboard.copy
275
- */
276
- export declare function copy(toCopy: ICopyable): void;
277
- /**
278
- * Paste a block or workspace comment on to the main workspace.
279
- *
280
- * @returns True if the paste was successful, false otherwise.
281
- * @deprecated Use **Blockly.clipboard.paste** instead.
282
- * @see Blockly.clipboard.paste
283
- */
284
- export declare function paste(): boolean;
285
- /**
286
- * Duplicate this block and its children, or a workspace comment.
287
- *
288
- * @param toDuplicate Block or Workspace Comment to be copied.
289
- * @deprecated Use **Blockly.clipboard.duplicate** instead.
290
- * @see Blockly.clipboard.duplicate
291
- */
292
- export declare function duplicate(toDuplicate: ICopyable): void;
293
- /**
294
- * Is the given string a number (includes negative and decimals).
295
- *
296
- * @param str Input string.
297
- * @returns True if number, false otherwise.
298
- * @deprecated Use **Blockly.utils.string.isNumber** instead.
299
- * @see Blockly.utils.string.isNumber
300
- */
301
- export declare function isNumber(str: string): boolean;
302
- /**
303
- * Convert a hue (HSV model) into an RGB hex triplet.
304
- *
305
- * @param hue Hue on a colour wheel (0-360).
306
- * @returns RGB code, e.g. '#5ba65b'.
307
- * @deprecated Use **Blockly.utils.colour.hueToHex** instead.
308
- * @see Blockly.utils.colour.hueToHex
309
- */
310
- export declare function hueToHex(hue: number): string;
311
- /**
312
- * Bind an event handler that should be called regardless of whether it is part
313
- * of the active touch stream.
314
- * Use this for events that are not part of a multi-part gesture (e.g.
315
- * mouseover for tooltips).
316
- *
317
- * @param node Node upon which to listen.
318
- * @param name Event name to listen to (e.g. 'mousedown').
319
- * @param thisObject The value of 'this' in the function.
320
- * @param func Function to call when event is triggered.
321
- * @returns Opaque data that can be passed to unbindEvent_.
322
- * @deprecated Use **Blockly.browserEvents.bind** instead.
323
- * @see Blockly.browserEvents.bind
324
- */
325
- export declare function bindEvent_(node: EventTarget, name: string, thisObject: Object | null, func: Function): browserEvents.Data;
326
- /**
327
- * Unbind one or more events event from a function call.
328
- *
329
- * @param bindData Opaque data from bindEvent_.
330
- * This list is emptied during the course of calling this function.
331
- * @returns The function call.
332
- * @deprecated Use **Blockly.browserEvents.unbind** instead.
333
- * @see browserEvents.unbind
334
- */
335
- export declare function unbindEvent_(bindData: browserEvents.Data): Function;
336
- /**
337
- * Bind an event handler that can be ignored if it is not part of the active
338
- * touch stream.
339
- * Use this for events that either start or continue a multi-part gesture (e.g.
340
- * mousedown or mousemove, which may be part of a drag or click).
341
- *
342
- * @param node Node upon which to listen.
343
- * @param name Event name to listen to (e.g. 'mousedown').
344
- * @param thisObject The value of 'this' in the function.
345
- * @param func Function to call when event is triggered.
346
- * @param opt_noCaptureIdentifier True if triggering on this event should not
347
- * block execution of other event handlers on this touch or other
348
- * simultaneous touches. False by default.
349
- * @param _opt_noPreventDefault No-op, deprecated and will be removed in v10.
350
- * @returns Opaque data that can be passed to unbindEvent_.
351
- * @deprecated Use **Blockly.browserEvents.conditionalBind** instead.
352
- * @see browserEvents.conditionalBind
353
- */
354
- export declare function bindEventWithChecks_(node: EventTarget, name: string, thisObject: Object | null, func: Function, opt_noCaptureIdentifier?: boolean, _opt_noPreventDefault?: boolean): browserEvents.Data;
355
258
  export declare const COLLAPSE_CHARS = 30;
356
259
  export declare const DRAG_STACK = true;
357
260
  export declare const OPPOSITE_TYPE: number[];
@@ -413,13 +316,11 @@ export { BasicCursor };
413
316
  export { Block };
414
317
  export { BlocklyOptions };
415
318
  export { BlockDragger };
416
- export { BlockDragSurfaceSvg };
417
319
  export { BlockSvg };
418
320
  export { Blocks };
419
321
  export { Bubble };
420
322
  export { BubbleDragger };
421
323
  export { CollapsibleToolboxCategory };
422
- export { Comment };
423
324
  export { ComponentManager };
424
325
  export { Connection };
425
326
  export { ConnectionType };
@@ -448,7 +349,6 @@ export { FlyoutMetricsManager };
448
349
  export { CodeGenerator };
449
350
  export { CodeGenerator as Generator };
450
351
  export { Gesture };
451
- export { Gesture as TouchGesture };
452
352
  export { Grid };
453
353
  export { HorizontalFlyout };
454
354
  export { IASTNodeLocation };
@@ -463,6 +363,7 @@ export { IComponent };
463
363
  export { IConnectionChecker };
464
364
  export { IContextMenu };
465
365
  export { Icon };
366
+ export { icons };
466
367
  export { ICopyable };
467
368
  export { IDeletable };
468
369
  export { IDeleteArea };
@@ -473,6 +374,13 @@ export { IKeyboardAccessible };
473
374
  export { IMetricsManager };
474
375
  export { IMovable };
475
376
  export { Input };
377
+ export declare const inputs: {
378
+ Input: typeof Input;
379
+ inputTypes: typeof inputTypes;
380
+ DummyInput: typeof DummyInput;
381
+ StatementInput: typeof StatementInput;
382
+ ValueInput: typeof ValueInput;
383
+ };
476
384
  export { InsertionMarkerManager };
477
385
  export { IObservable, isObservable };
478
386
  export { IPositionable };
@@ -488,11 +396,11 @@ export { MarkerManager };
488
396
  export { Menu };
489
397
  export { MenuItem };
490
398
  export { MetricsManager };
491
- export { Mutator };
492
399
  export { Msg, setLocale };
493
400
  export { Names };
494
401
  export { Options };
495
402
  export { RenderedConnection };
403
+ export { renderManagement };
496
404
  export { Scrollbar };
497
405
  export { ScrollbarPair };
498
406
  export { ShortcutRegistry };
@@ -507,12 +415,10 @@ export { Trashcan };
507
415
  export { VariableMap };
508
416
  export { VariableModel };
509
417
  export { VerticalFlyout };
510
- export { Warning };
511
418
  export { Workspace };
512
419
  export { WorkspaceAudio };
513
420
  export { WorkspaceComment };
514
421
  export { WorkspaceCommentSvg };
515
- export { WorkspaceDragSurfaceSvg };
516
422
  export { WorkspaceDragger };
517
423
  export { WorkspaceSvg };
518
424
  export { ZoomControls };
@@ -21,10 +21,9 @@ export type Data = [EventTarget, string, (e: Event) => void][];
21
21
  * @param opt_noCaptureIdentifier True if triggering on this event should not
22
22
  * block execution of other event handlers on this touch or other
23
23
  * simultaneous touches. False by default.
24
- * @param opt_noPreventDefault No-op, deprecated and will be removed in v10.
25
24
  * @returns Opaque data that can be passed to unbindEvent_.
26
25
  */
27
- export declare function conditionalBind(node: EventTarget, name: string, thisObject: Object | null, func: Function, opt_noCaptureIdentifier?: boolean, opt_noPreventDefault?: boolean): Data;
26
+ export declare function conditionalBind(node: EventTarget, name: string, thisObject: Object | null, func: Function, opt_noCaptureIdentifier?: boolean): Data;
28
27
  /**
29
28
  * Bind an event handler that should be called regardless of whether it is part
30
29
  * of the active touch stream.