blockly 9.3.0-beta.0 → 9.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/blockly.min.js +1674 -1520
  2. package/blockly_compressed.js +1313 -1152
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +166 -173
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/any_aliases.d.ts +5 -0
  7. package/core/block.d.ts +49 -17
  8. package/core/block_animations.d.ts +0 -4
  9. package/core/block_drag_surface.d.ts +135 -0
  10. package/core/block_dragger.d.ts +2 -7
  11. package/core/block_svg.d.ts +72 -9
  12. package/core/blockly.d.ts +29 -58
  13. package/core/blockly_options.d.ts +0 -2
  14. package/core/blocks.d.ts +0 -2
  15. package/core/browser_events.d.ts +0 -9
  16. package/core/bubble.d.ts +6 -4
  17. package/core/bubble_dragger.d.ts +2 -3
  18. package/core/bump_objects.d.ts +0 -3
  19. package/core/clipboard.d.ts +0 -3
  20. package/core/comment.d.ts +6 -10
  21. package/core/common.d.ts +0 -12
  22. package/core/component_manager.d.ts +0 -2
  23. package/core/connection.d.ts +19 -6
  24. package/core/connection_checker.d.ts +1 -3
  25. package/core/connection_db.d.ts +0 -2
  26. package/core/connection_type.d.ts +0 -2
  27. package/core/constants.d.ts +0 -4
  28. package/core/contextmenu.d.ts +0 -11
  29. package/core/contextmenu_items.d.ts +0 -27
  30. package/core/contextmenu_registry.d.ts +0 -2
  31. package/core/css.d.ts +0 -2
  32. package/core/delete_area.d.ts +0 -2
  33. package/core/dialog.d.ts +0 -6
  34. package/core/drag_target.d.ts +0 -2
  35. package/core/events/events_abstract.d.ts +0 -3
  36. package/core/events/events_block_base.d.ts +0 -2
  37. package/core/events/events_block_change.d.ts +0 -2
  38. package/core/events/events_block_create.d.ts +0 -2
  39. package/core/events/events_block_delete.d.ts +0 -2
  40. package/core/events/events_block_drag.d.ts +0 -2
  41. package/core/events/events_block_move.d.ts +0 -2
  42. package/core/events/events_bubble_open.d.ts +0 -2
  43. package/core/events/events_click.d.ts +0 -2
  44. package/core/events/events_comment_base.d.ts +0 -2
  45. package/core/events/events_comment_change.d.ts +0 -2
  46. package/core/events/events_comment_create.d.ts +0 -2
  47. package/core/events/events_comment_delete.d.ts +0 -2
  48. package/core/events/events_comment_move.d.ts +0 -2
  49. package/core/events/events_marker_move.d.ts +0 -2
  50. package/core/events/events_selected.d.ts +0 -2
  51. package/core/events/events_theme_change.d.ts +0 -2
  52. package/core/events/events_toolbox_item_select.d.ts +0 -2
  53. package/core/events/events_trashcan_open.d.ts +0 -2
  54. package/core/events/events_ui.d.ts +0 -1
  55. package/core/events/events_ui_base.d.ts +0 -2
  56. package/core/events/events_var_base.d.ts +0 -2
  57. package/core/events/events_var_create.d.ts +0 -2
  58. package/core/events/events_viewport.d.ts +0 -2
  59. package/core/events/utils.d.ts +0 -73
  60. package/core/events/workspace_events.d.ts +0 -2
  61. package/core/extensions.d.ts +0 -8
  62. package/core/field.d.ts +16 -15
  63. package/core/field_angle.d.ts +60 -50
  64. package/core/field_checkbox.d.ts +22 -10
  65. package/core/field_colour.d.ts +55 -42
  66. package/core/field_dropdown.d.ts +34 -18
  67. package/core/field_image.d.ts +9 -12
  68. package/core/field_input.d.ts +34 -11
  69. package/core/field_label.d.ts +7 -10
  70. package/core/field_label_serializable.d.ts +4 -6
  71. package/core/field_multilineinput.d.ts +34 -12
  72. package/core/field_number.d.ts +27 -19
  73. package/core/field_registry.d.ts +0 -3
  74. package/core/field_textinput.d.ts +28 -12
  75. package/core/field_variable.d.ts +28 -16
  76. package/core/flyout_base.d.ts +5 -6
  77. package/core/flyout_button.d.ts +2 -2
  78. package/core/flyout_horizontal.d.ts +0 -2
  79. package/core/flyout_metrics_manager.d.ts +0 -2
  80. package/core/flyout_vertical.d.ts +0 -2
  81. package/core/generator.d.ts +0 -1
  82. package/core/gesture.d.ts +4 -17
  83. package/core/grid.d.ts +0 -2
  84. package/core/icon.d.ts +0 -2
  85. package/core/inject.d.ts +0 -1
  86. package/core/input.d.ts +0 -3
  87. package/core/input_types.d.ts +0 -2
  88. package/core/insertion_marker_manager.d.ts +6 -6
  89. package/core/interfaces/i_ast_node_location.d.ts +0 -2
  90. package/core/interfaces/i_ast_node_location_svg.d.ts +0 -2
  91. package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -2
  92. package/core/interfaces/i_autohideable.d.ts +0 -2
  93. package/core/interfaces/i_block_dragger.d.ts +1 -3
  94. package/core/interfaces/i_bounded_element.d.ts +0 -2
  95. package/core/interfaces/i_bubble.d.ts +6 -4
  96. package/core/interfaces/i_collapsible_toolbox_item.d.ts +0 -2
  97. package/core/interfaces/i_component.d.ts +0 -2
  98. package/core/interfaces/i_connection_checker.d.ts +0 -2
  99. package/core/interfaces/i_contextmenu.d.ts +0 -1
  100. package/core/interfaces/i_copyable.d.ts +3 -2
  101. package/core/interfaces/i_deletable.d.ts +0 -2
  102. package/core/interfaces/i_delete_area.d.ts +0 -2
  103. package/core/interfaces/i_drag_target.d.ts +0 -2
  104. package/core/interfaces/i_draggable.d.ts +0 -2
  105. package/core/interfaces/i_flyout.d.ts +0 -2
  106. package/core/interfaces/i_keyboard_accessible.d.ts +0 -2
  107. package/core/interfaces/i_legacy_procedure_blocks.d.ts +34 -0
  108. package/core/interfaces/i_metrics_manager.d.ts +0 -2
  109. package/core/interfaces/i_movable.d.ts +0 -2
  110. package/core/interfaces/i_positionable.d.ts +0 -2
  111. package/core/interfaces/i_procedure_model.d.ts +0 -5
  112. package/core/interfaces/i_registrable.d.ts +0 -2
  113. package/core/interfaces/i_selectable.d.ts +0 -2
  114. package/core/interfaces/i_selectable_toolbox_item.d.ts +4 -2
  115. package/core/interfaces/i_serializer.d.ts +0 -2
  116. package/core/interfaces/i_styleable.d.ts +0 -2
  117. package/core/interfaces/i_toolbox.d.ts +0 -2
  118. package/core/interfaces/i_toolbox_item.d.ts +0 -2
  119. package/core/interfaces/i_variable_backed_parameter_model.d.ts +17 -0
  120. package/core/internal_constants.d.ts +0 -5
  121. package/core/keyboard_nav/ast_node.d.ts +0 -3
  122. package/core/keyboard_nav/basic_cursor.d.ts +0 -3
  123. package/core/keyboard_nav/cursor.d.ts +0 -3
  124. package/core/keyboard_nav/marker.d.ts +0 -2
  125. package/core/keyboard_nav/tab_navigate_cursor.d.ts +0 -2
  126. package/core/marker_manager.d.ts +0 -2
  127. package/core/menu.d.ts +0 -2
  128. package/core/menuitem.d.ts +0 -2
  129. package/core/metrics_manager.d.ts +0 -2
  130. package/core/mutator.d.ts +0 -2
  131. package/core/names.d.ts +0 -3
  132. package/core/options.d.ts +0 -2
  133. package/core/positionable_helpers.d.ts +0 -7
  134. package/core/procedures.d.ts +2 -25
  135. package/core/registry.d.ts +0 -11
  136. package/core/render_management.d.ts +15 -0
  137. package/core/rendered_connection.d.ts +22 -9
  138. package/core/renderers/common/block_rendering.d.ts +0 -3
  139. package/core/renderers/common/constants.d.ts +6 -51
  140. package/core/renderers/common/debug.d.ts +0 -3
  141. package/core/renderers/common/debugger.d.ts +9 -23
  142. package/core/renderers/common/drawer.d.ts +0 -5
  143. package/core/renderers/common/i_path_object.d.ts +0 -17
  144. package/core/renderers/common/info.d.ts +2 -12
  145. package/core/renderers/common/marker_svg.d.ts +2 -4
  146. package/core/renderers/common/path_object.d.ts +0 -24
  147. package/core/renderers/common/renderer.d.ts +5 -20
  148. package/core/renderers/geras/constants.d.ts +0 -5
  149. package/core/renderers/geras/drawer.d.ts +2 -4
  150. package/core/renderers/geras/highlight_constants.d.ts +6 -17
  151. package/core/renderers/geras/highlighter.d.ts +0 -13
  152. package/core/renderers/geras/info.d.ts +2 -5
  153. package/core/renderers/geras/measurables/inline_input.d.ts +0 -3
  154. package/core/renderers/geras/measurables/statement_input.d.ts +0 -3
  155. package/core/renderers/geras/path_object.d.ts +0 -8
  156. package/core/renderers/geras/renderer.d.ts +5 -7
  157. package/core/renderers/measurables/base.d.ts +0 -3
  158. package/core/renderers/measurables/bottom_row.d.ts +0 -9
  159. package/core/renderers/measurables/connection.d.ts +0 -3
  160. package/core/renderers/measurables/external_value_input.d.ts +0 -3
  161. package/core/renderers/measurables/field.d.ts +0 -3
  162. package/core/renderers/measurables/hat.d.ts +0 -3
  163. package/core/renderers/measurables/icon.d.ts +2 -5
  164. package/core/renderers/measurables/in_row_spacer.d.ts +0 -3
  165. package/core/renderers/measurables/inline_input.d.ts +1 -4
  166. package/core/renderers/measurables/input_connection.d.ts +1 -4
  167. package/core/renderers/measurables/input_row.d.ts +0 -7
  168. package/core/renderers/measurables/jagged_edge.d.ts +2 -5
  169. package/core/renderers/measurables/next_connection.d.ts +0 -3
  170. package/core/renderers/measurables/output_connection.d.ts +0 -3
  171. package/core/renderers/measurables/previous_connection.d.ts +0 -3
  172. package/core/renderers/measurables/round_corner.d.ts +0 -3
  173. package/core/renderers/measurables/row.d.ts +0 -39
  174. package/core/renderers/measurables/spacer_row.d.ts +0 -3
  175. package/core/renderers/measurables/square_corner.d.ts +0 -3
  176. package/core/renderers/measurables/statement_input.d.ts +0 -3
  177. package/core/renderers/measurables/top_row.d.ts +0 -6
  178. package/core/renderers/measurables/types.d.ts +0 -31
  179. package/core/renderers/minimalist/constants.d.ts +2 -4
  180. package/core/renderers/minimalist/drawer.d.ts +0 -3
  181. package/core/renderers/minimalist/info.d.ts +0 -4
  182. package/core/renderers/minimalist/renderer.d.ts +0 -3
  183. package/core/renderers/thrasos/info.d.ts +0 -4
  184. package/core/renderers/thrasos/renderer.d.ts +3 -3
  185. package/core/renderers/zelos/constants.d.ts +3 -17
  186. package/core/renderers/zelos/drawer.d.ts +0 -3
  187. package/core/renderers/zelos/info.d.ts +0 -4
  188. package/core/renderers/zelos/marker_svg.d.ts +0 -2
  189. package/core/renderers/zelos/measurables/bottom_row.d.ts +0 -3
  190. package/core/renderers/zelos/measurables/inputs.d.ts +0 -3
  191. package/core/renderers/zelos/measurables/row_elements.d.ts +0 -3
  192. package/core/renderers/zelos/measurables/top_row.d.ts +0 -3
  193. package/core/renderers/zelos/path_object.d.ts +0 -9
  194. package/core/renderers/zelos/renderer.d.ts +3 -5
  195. package/core/scrollbar.d.ts +0 -2
  196. package/core/scrollbar_pair.d.ts +0 -2
  197. package/core/serialization/blocks.d.ts +3 -9
  198. package/core/serialization/exceptions.d.ts +0 -8
  199. package/core/serialization/priorities.d.ts +0 -4
  200. package/core/serialization/registry.d.ts +0 -2
  201. package/core/serialization/variables.d.ts +0 -4
  202. package/core/serialization/workspaces.d.ts +0 -2
  203. package/core/shortcut_items.d.ts +0 -17
  204. package/core/shortcut_registry.d.ts +0 -2
  205. package/core/sprites.d.ts +0 -2
  206. package/core/theme/classic.d.ts +0 -2
  207. package/core/theme/zelos.d.ts +0 -2
  208. package/core/theme.d.ts +0 -2
  209. package/core/theme_manager.d.ts +3 -6
  210. package/core/toolbox/category.d.ts +5 -7
  211. package/core/toolbox/collapsible_category.d.ts +0 -4
  212. package/core/toolbox/separator.d.ts +0 -2
  213. package/core/toolbox/toolbox.d.ts +2 -5
  214. package/core/toolbox/toolbox_item.d.ts +0 -2
  215. package/core/tooltip.d.ts +0 -29
  216. package/core/touch.d.ts +0 -13
  217. package/core/trashcan.d.ts +0 -2
  218. package/core/utils/aria.d.ts +0 -6
  219. package/core/utils/array.d.ts +0 -1
  220. package/core/utils/colour.d.ts +0 -12
  221. package/core/utils/coordinate.d.ts +0 -2
  222. package/core/utils/deprecation.d.ts +0 -1
  223. package/core/utils/dom.d.ts +0 -25
  224. package/core/utils/idgenerator.d.ts +0 -2
  225. package/core/utils/keycodes.d.ts +0 -2
  226. package/core/utils/math.d.ts +0 -3
  227. package/core/utils/metrics.d.ts +0 -1
  228. package/core/utils/object.d.ts +0 -4
  229. package/core/utils/parsing.d.ts +0 -4
  230. package/core/utils/rect.d.ts +0 -2
  231. package/core/utils/size.d.ts +0 -2
  232. package/core/utils/string.d.ts +0 -6
  233. package/core/utils/style.d.ts +0 -8
  234. package/core/utils/svg.d.ts +0 -2
  235. package/core/utils/svg_math.d.ts +0 -6
  236. package/core/utils/svg_paths.d.ts +0 -8
  237. package/core/utils/toolbox.d.ts +2 -35
  238. package/core/utils/useragent.d.ts +0 -8
  239. package/core/utils/xml.d.ts +9 -8
  240. package/core/utils.d.ts +0 -12
  241. package/core/variable_map.d.ts +1 -3
  242. package/core/variable_model.d.ts +0 -1
  243. package/core/variables.d.ts +13 -17
  244. package/core/variables_dynamic.d.ts +0 -4
  245. package/core/warning.d.ts +0 -2
  246. package/core/widgetdiv.d.ts +0 -10
  247. package/core/workspace.d.ts +3 -3
  248. package/core/workspace_audio.d.ts +0 -2
  249. package/core/workspace_comment.d.ts +1 -3
  250. package/core/workspace_comment_svg.d.ts +16 -5
  251. package/core/workspace_drag_surface_svg.d.ts +74 -0
  252. package/core/workspace_dragger.d.ts +3 -2
  253. package/core/workspace_svg.d.ts +48 -8
  254. package/core/xml.d.ts +1 -13
  255. package/core/zoom_controls.d.ts +4 -15
  256. package/dart_compressed.js +199 -199
  257. package/dart_compressed.js.map +1 -1
  258. package/javascript_compressed.js +168 -168
  259. package/javascript_compressed.js.map +1 -1
  260. package/lua_compressed.js +211 -211
  261. package/lua_compressed.js.map +1 -1
  262. package/msg/bn.js +2 -2
  263. package/msg/bs.js +7 -7
  264. package/msg/de.js +1 -1
  265. package/msg/fi.js +1 -1
  266. package/msg/fr.js +3 -3
  267. package/msg/ia.js +5 -5
  268. package/msg/kn.js +5 -5
  269. package/msg/ko.js +1 -1
  270. package/msg/lb.js +22 -22
  271. package/msg/sd.js +9 -9
  272. package/msg/skr-arab.js +2 -2
  273. package/msg/sl.js +18 -18
  274. package/msg/sw.js +1 -1
  275. package/msg/zh-hans.js +6 -6
  276. package/msg/zh-hant.js +2 -2
  277. package/package.json +6 -6
  278. package/php_compressed.js +185 -185
  279. package/php_compressed.js.map +1 -1
  280. package/python_compressed.js +138 -138
  281. package/python_compressed.js.map +1 -1
  282. package/core/utils/sentinel.d.ts +0 -18
@@ -1,2 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
1
6
  type any = any;
2
7
  //# sourceMappingURL=any_aliases.d.ts.map
package/core/block.d.ts CHANGED
@@ -22,8 +22,6 @@ import type { Workspace } from './workspace.js';
22
22
  /**
23
23
  * Class for one block.
24
24
  * Not normally called directly, workspace.newBlock() is preferred.
25
- *
26
- * @alias Blockly.Block
27
25
  */
28
26
  export declare class Block implements IASTNodeLocation, IDeletable {
29
27
  /**
@@ -31,7 +29,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
31
29
  * changes. This is usually only called from the constructor, the block type
32
30
  * initializer function, or an extension initializer function.
33
31
  */
34
- onchange?: ((p1: Abstract) => any) | null;
32
+ onchange?: ((p1: Abstract) => void) | null;
35
33
  /** The language-neutral ID given to the collapsed input. */
36
34
  static readonly COLLAPSED_INPUT_NAME: string;
37
35
  /** The language-neutral ID given to the collapsed field. */
@@ -57,7 +55,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
57
55
  /** Name of the block style. */
58
56
  protected styleName_: string;
59
57
  /** An optional method called during initialization. */
60
- init?: (() => any) | null;
58
+ init?: (() => void);
61
59
  /** An optional method called during disposal. */
62
60
  destroy?: (() => void);
63
61
  /**
@@ -65,25 +63,25 @@ export declare class Block implements IASTNodeLocation, IDeletable {
65
63
  * mutation state to XML. This must be coupled with defining
66
64
  * `domToMutation`.
67
65
  */
68
- mutationToDom?: ((...p1: any[]) => Element) | null;
66
+ mutationToDom?: (...p1: any[]) => Element;
69
67
  /**
70
68
  * An optional deserialization method for defining how to deserialize the
71
69
  * mutation state from XML. This must be coupled with defining
72
70
  * `mutationToDom`.
73
71
  */
74
- domToMutation?: ((p1: Element) => any) | null;
72
+ domToMutation?: (p1: Element) => void;
75
73
  /**
76
74
  * An optional serialization method for defining how to serialize the
77
75
  * block's extra state (eg mutation state) to something JSON compatible.
78
76
  * This must be coupled with defining `loadExtraState`.
79
77
  */
80
- saveExtraState?: (() => any) | null;
78
+ saveExtraState?: () => any;
81
79
  /**
82
80
  * An optional serialization method for defining how to deserialize the
83
81
  * block's extra state (eg mutation state) from something JSON compatible.
84
82
  * This must be coupled with defining `saveExtraState`.
85
83
  */
86
- loadExtraState?: ((p1: any) => any) | null;
84
+ loadExtraState?: (p1: any) => void;
87
85
  /**
88
86
  * An optional property for suppressing adding STATEMENT_PREFIX and
89
87
  * STATEMENT_SUFFIX to generated code.
@@ -95,21 +93,21 @@ export declare class Block implements IASTNodeLocation, IDeletable {
95
93
  * shown to the user, but are declared as global variables in the generated
96
94
  * code.
97
95
  */
98
- getDeveloperVariables?: (() => string[]);
96
+ getDeveloperVariables?: () => string[];
99
97
  /**
100
98
  * An optional function that reconfigures the block based on the contents of
101
99
  * the mutator dialog.
102
100
  */
103
- compose?: ((p1: Block) => void);
101
+ compose?: (p1: Block) => void;
104
102
  /**
105
103
  * An optional function that populates the mutator's dialog with
106
104
  * this block's components.
107
105
  */
108
- decompose?: ((p1: Workspace) => Block);
106
+ decompose?: (p1: Workspace) => Block;
109
107
  id: string;
110
- outputConnection: Connection;
111
- nextConnection: Connection;
112
- previousConnection: Connection;
108
+ outputConnection: Connection | null;
109
+ nextConnection: Connection | null;
110
+ previousConnection: Connection | null;
113
111
  inputList: Input[];
114
112
  inputsInline?: boolean;
115
113
  private disabled;
@@ -147,7 +145,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
147
145
  /**
148
146
  * String for block help, or function that returns a URL. Null for no help.
149
147
  */
150
- helpUrl: string | Function;
148
+ helpUrl: string | Function | null;
151
149
  /** A bound callback function to use when the parent workspace changes. */
152
150
  private onchangeWrapper_;
153
151
  /**
@@ -179,6 +177,11 @@ export declare class Block implements IASTNodeLocation, IDeletable {
179
177
  * @suppress {checkTypes}
180
178
  */
181
179
  dispose(healStack: boolean): void;
180
+ /**
181
+ * Disposes of this block without doing things required by the top block.
182
+ * E.g. does not fire events, unplug the block, etc.
183
+ */
184
+ protected disposeInternal(): void;
182
185
  /**
183
186
  * Returns true if the block is either in the process of being disposed, or
184
187
  * is disposed.
@@ -348,6 +351,12 @@ export declare class Block implements IASTNodeLocation, IDeletable {
348
351
  * @returns True if deletable.
349
352
  */
350
353
  isDeletable(): boolean;
354
+ /**
355
+ * Return whether this block's own deletable property is true or false.
356
+ *
357
+ * @returns True if the block's deletable property is true, false otherwise.
358
+ */
359
+ isOwnDeletable(): boolean;
351
360
  /**
352
361
  * Set whether this block is deletable or not.
353
362
  *
@@ -358,8 +367,16 @@ export declare class Block implements IASTNodeLocation, IDeletable {
358
367
  * Get whether this block is movable or not.
359
368
  *
360
369
  * @returns True if movable.
370
+ * @internal
361
371
  */
362
372
  isMovable(): boolean;
373
+ /**
374
+ * Return whether this block's own movable property is true or false.
375
+ *
376
+ * @returns True if the block's movable property is true, false otherwise.
377
+ * @internal
378
+ */
379
+ isOwnMovable(): boolean;
363
380
  /**
364
381
  * Set whether this block is movable or not.
365
382
  *
@@ -406,8 +423,15 @@ export declare class Block implements IASTNodeLocation, IDeletable {
406
423
  * Get whether this block is editable or not.
407
424
  *
408
425
  * @returns True if editable.
426
+ * @internal
409
427
  */
410
428
  isEditable(): boolean;
429
+ /**
430
+ * Return whether this block's own editable property is true or false.
431
+ *
432
+ * @returns True if the block's editable property is true, false otherwise.
433
+ */
434
+ isOwnEditable(): boolean;
411
435
  /**
412
436
  * Set whether this block is editable or not.
413
437
  *
@@ -492,7 +516,7 @@ export declare class Block implements IASTNodeLocation, IDeletable {
492
516
  * @param onchangeFn The callback to call when the block's workspace changes.
493
517
  * @throws {Error} if onchangeFn is not falsey and not a function.
494
518
  */
495
- setOnChange(onchangeFn: (p1: Abstract) => any): void;
519
+ setOnChange(onchangeFn: (p1: Abstract) => void): void;
496
520
  /**
497
521
  * Returns the named field from a block.
498
522
  *
@@ -627,11 +651,19 @@ export declare class Block implements IASTNodeLocation, IDeletable {
627
651
  * Create a human-readable text representation of this block and any children.
628
652
  *
629
653
  * @param opt_maxLength Truncate the string to this length.
630
- * @param opt_emptyToken The placeholder string used to denote an empty field.
654
+ * @param opt_emptyToken The placeholder string used to denote an empty input.
631
655
  * If not specified, '?' is used.
632
656
  * @returns Text of block.
633
657
  */
634
658
  toString(opt_maxLength?: number, opt_emptyToken?: string): string;
659
+ /**
660
+ * Converts this block into string tokens.
661
+ *
662
+ * @param emptyToken The token to use in place of an empty input.
663
+ * Defaults to '?'.
664
+ * @returns The array of string tokens representing this block.
665
+ */
666
+ private toTokens;
635
667
  /**
636
668
  * Shortcut for appending a value input row.
637
669
  *
@@ -8,7 +8,6 @@ import type { BlockSvg } from './block_svg.js';
8
8
  * Play some UI effects (sound, animation) when disposing of a block.
9
9
  *
10
10
  * @param block The block being disposed of.
11
- * @alias Blockly.blockAnimations.disposeUiEffect
12
11
  * @internal
13
12
  */
14
13
  export declare function disposeUiEffect(block: BlockSvg): void;
@@ -16,7 +15,6 @@ export declare function disposeUiEffect(block: BlockSvg): void;
16
15
  * Play some UI effects (sound, ripple) after a connection has been established.
17
16
  *
18
17
  * @param block The block being connected.
19
- * @alias Blockly.blockAnimations.connectionUiEffect
20
18
  * @internal
21
19
  */
22
20
  export declare function connectionUiEffect(block: BlockSvg): void;
@@ -24,14 +22,12 @@ export declare function connectionUiEffect(block: BlockSvg): void;
24
22
  * Play some UI effects (sound, animation) when disconnecting a block.
25
23
  *
26
24
  * @param block The block being disconnected.
27
- * @alias Blockly.blockAnimations.disconnectUiEffect
28
25
  * @internal
29
26
  */
30
27
  export declare function disconnectUiEffect(block: BlockSvg): void;
31
28
  /**
32
29
  * Stop the disconnect UI animation immediately.
33
30
  *
34
- * @alias Blockly.blockAnimations.disconnectUiStop
35
31
  * @internal
36
32
  */
37
33
  export declare function disconnectUiStop(): void;
@@ -0,0 +1,135 @@
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
@@ -13,8 +13,6 @@ import type { WorkspaceSvg } from './workspace_svg.js';
13
13
  /**
14
14
  * Class for a block dragger. It moves blocks around the workspace when they
15
15
  * are being dragged by a mouse or touch.
16
- *
17
- * @alias Blockly.BlockDragger
18
16
  */
19
17
  export declare class BlockDragger implements IBlockDragger {
20
18
  /** The top block in the stack that is being dragged. */
@@ -40,7 +38,7 @@ export declare class BlockDragger implements IBlockDragger {
40
38
  */
41
39
  dispose(): void;
42
40
  /**
43
- * Start dragging a block.
41
+ * Start dragging a block. This includes moving it to the drag surface.
44
42
  *
45
43
  * @param currentDragDeltaXY How far the pointer has moved from the position
46
44
  * at mouse down, in pixel units.
@@ -103,11 +101,8 @@ export declare class BlockDragger implements IBlockDragger {
103
101
  protected maybeDeleteBlock_(): boolean;
104
102
  /**
105
103
  * Updates the necessary information to place a block at a certain location.
106
- *
107
- * @param delta The change in location from where the block started the drag
108
- * to where it ended the drag.
109
104
  */
110
- protected updateBlockAfterMove_(delta: Coordinate): void;
105
+ protected updateBlockAfterMove_(): void;
111
106
  /** Fire a UI event at the end of a block drag. */
112
107
  protected fireDragEndEvent_(): void;
113
108
  /**
@@ -28,8 +28,6 @@ import type { WorkspaceSvg } from './workspace_svg.js';
28
28
  /**
29
29
  * Class for a block's SVG representation.
30
30
  * Not normally called directly, workspace.newBlock() is preferred.
31
- *
32
- * @alias Blockly.BlockSvg
33
31
  */
34
32
  export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBoundedElement, ICopyable, IDraggable {
35
33
  /**
@@ -43,9 +41,9 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
43
41
  * the block.
44
42
  */
45
43
  static readonly COLLAPSED_WARNING_ID = "TEMP_COLLAPSED_WARNING_";
46
- decompose?: ((p1: Workspace) => BlockSvg);
47
- saveConnections?: ((p1: BlockSvg) => any);
48
- customContextMenu?: ((p1: Array<ContextMenuOption | LegacyContextMenuOption>) => any) | null;
44
+ decompose?: (p1: Workspace) => BlockSvg;
45
+ saveConnections?: (p1: BlockSvg) => void;
46
+ customContextMenu?: (p1: Array<ContextMenuOption | LegacyContextMenuOption>) => void;
49
47
  /**
50
48
  * An property used internally to reference the block's rendering debugger.
51
49
  *
@@ -78,6 +76,7 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
78
76
  /** @internal */
79
77
  pathObject: IPathObject;
80
78
  rendered: boolean;
79
+ private visuallyDisabled;
81
80
  /**
82
81
  * Is this block currently rendering? Used to stop recursive render calls
83
82
  * from actually triggering a re-render.
@@ -89,7 +88,21 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
89
88
  outputConnection: RenderedConnection;
90
89
  nextConnection: RenderedConnection;
91
90
  previousConnection: RenderedConnection;
91
+ private readonly useDragSurface_;
92
92
  private translation;
93
+ /**
94
+ * The ID of the setTimeout callback for bumping neighbours, or 0 if no bump
95
+ * is currently scheduled.
96
+ */
97
+ private bumpNeighboursPid;
98
+ /**
99
+ * The location of the top left of this block (in workspace coordinates)
100
+ * relative to either its parent block, or the workspace origin if it has no
101
+ * parent.
102
+ *
103
+ * @internal
104
+ */
105
+ relativeCoords: Coordinate;
93
106
  /**
94
107
  * @param workspace The block's workspace.
95
108
  * @param prototypeName Name of the language object containing type-specific
@@ -169,6 +182,14 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
169
182
  * @internal
170
183
  */
171
184
  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;
172
193
  /**
173
194
  * Move a block to a position.
174
195
  *
@@ -176,7 +197,18 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
176
197
  */
177
198
  moveTo(xy: Coordinate): void;
178
199
  /**
179
- * Move this block during a drag.
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.
180
212
  * This block must be a top-level block.
181
213
  *
182
214
  * @param newLoc The location to translate to, in workspace coordinates.
@@ -306,6 +338,11 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
306
338
  * @suppress {checkTypes}
307
339
  */
308
340
  dispose(healStack?: boolean, animate?: boolean): void;
341
+ /**
342
+ * Disposes of this block without doing things required by the top block.
343
+ * E.g. does trigger UI effects, remove nodes, etc.
344
+ */
345
+ disposeInternal(): void;
309
346
  /**
310
347
  * Delete a block and hide chaff when doing so. The block will not be deleted
311
348
  * if it's in a flyout. This is called from the context menu and keyboard
@@ -495,7 +532,7 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
495
532
  *
496
533
  * @param all If true, return all connections even hidden ones.
497
534
  * Otherwise, for a non-rendered block return an empty list, and for a
498
- * collapsed block don't return inputs connections.
535
+ * collapsed block don't return inputs connections.
499
536
  * @returns Array of connections.
500
537
  * @internal
501
538
  */
@@ -586,20 +623,46 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
586
623
  */
587
624
  getChildren(ordered: boolean): BlockSvg[];
588
625
  /**
589
- * Lays out and reflows a block based on its contents and settings.
626
+ * Triggers a rerender after a delay to allow for batching.
627
+ *
628
+ * @internal
629
+ */
630
+ queueRender(): void;
631
+ /**
632
+ * Immediately lays out and reflows a block based on its contents and
633
+ * settings.
590
634
  *
591
635
  * @param opt_bubble If false, just render this block.
592
636
  * If true, also render block's parent, grandparent, etc. Defaults to true.
593
637
  */
594
638
  render(opt_bubble?: boolean): void;
639
+ /**
640
+ * Renders this block in a way that's compatible with the more efficient
641
+ * render management system.
642
+ *
643
+ * @internal
644
+ */
645
+ renderEfficiently(): void;
646
+ /**
647
+ * Tightens all children of this block so they are snuggly rendered against
648
+ * their parent connections.
649
+ *
650
+ * Does not update connection locations, so that they can be updated more
651
+ * efficiently by the render management system.
652
+ *
653
+ * @internal
654
+ */
655
+ tightenChildrenEfficiently(): void;
595
656
  /** Redraw any attached marker or cursor svgs if needed. */
596
657
  protected updateMarkers_(): void;
597
658
  /**
598
659
  * Update all of the connections on this block with the new locations
599
660
  * calculated during rendering. Also move all of the connected blocks based
600
661
  * on the new connection locations.
662
+ *
663
+ * @internal
601
664
  */
602
- private updateConnectionLocations_;
665
+ updateConnectionLocations(): void;
603
666
  /**
604
667
  * Add the cursor SVG to this block's SVG group.
605
668
  *