blockly 12.4.0 → 12.5.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 (1630) hide show
  1. package/blockly.min.js +2751 -0
  2. package/blockly.mjs +163 -0
  3. package/blockly_compressed.js +1825 -0
  4. package/blockly_compressed.js.map +1 -0
  5. package/blocks.js +4 -0
  6. package/blocks.mjs +12 -0
  7. package/blocks_compressed.js +194 -0
  8. package/blocks_compressed.js.map +1 -0
  9. package/core/any_aliases.d.ts +7 -0
  10. package/core/block.d.ts +1006 -0
  11. package/core/block_animations.d.ts +34 -0
  12. package/core/block_flyout_inflater.d.ts +94 -0
  13. package/core/block_svg.d.ts +737 -0
  14. package/core/blockly.d.ts +286 -0
  15. package/core/blockly_options.d.ts +70 -0
  16. package/core/blocks.d.ts +17 -0
  17. package/core/browser_events.d.ts +88 -0
  18. package/core/bubbles/bubble.d.ts +228 -0
  19. package/core/bubbles/mini_workspace_bubble.d.ts +84 -0
  20. package/core/bubbles/text_bubble.d.ts +38 -0
  21. package/core/bubbles/textinput_bubble.d.ts +102 -0
  22. package/core/bubbles.d.ts +11 -0
  23. package/core/bump_objects.d.ts +37 -0
  24. package/core/button_flyout_inflater.d.ts +42 -0
  25. package/core/clipboard/block_paster.d.ts +34 -0
  26. package/core/clipboard/registry.d.ts +21 -0
  27. package/core/clipboard/workspace_comment_paster.d.ts +19 -0
  28. package/core/clipboard.d.ts +103 -0
  29. package/core/comments/collapse_comment_bar_button.d.ts +52 -0
  30. package/core/comments/comment_bar_button.d.ts +62 -0
  31. package/core/comments/comment_editor.d.ts +62 -0
  32. package/core/comments/comment_view.d.ts +213 -0
  33. package/core/comments/delete_comment_bar_button.d.ts +52 -0
  34. package/core/comments/rendered_workspace_comment.d.ts +121 -0
  35. package/core/comments/workspace_comment.d.ts +107 -0
  36. package/core/comments.d.ts +13 -0
  37. package/core/common.d.ts +163 -0
  38. package/core/component_manager.d.ts +112 -0
  39. package/core/config.d.ts +24 -0
  40. package/core/connection.d.ts +291 -0
  41. package/core/connection_checker.d.ts +85 -0
  42. package/core/connection_db.d.ts +100 -0
  43. package/core/connection_type.d.ts +15 -0
  44. package/core/constants.d.ts +19 -0
  45. package/core/contextmenu.d.ts +58 -0
  46. package/core/contextmenu_items.d.ts +73 -0
  47. package/core/contextmenu_registry.d.ts +173 -0
  48. package/core/css.d.ts +25 -0
  49. package/core/delete_area.d.ts +48 -0
  50. package/core/dialog.d.ts +82 -0
  51. package/core/drag_target.d.ts +75 -0
  52. package/core/dragging/block_drag_strategy.d.ts +130 -0
  53. package/core/dragging/bubble_drag_strategy.d.ts +20 -0
  54. package/core/dragging/comment_drag_strategy.d.ts +26 -0
  55. package/core/dragging/dragger.d.ts +49 -0
  56. package/core/dragging.d.ts +11 -0
  57. package/core/dropdowndiv.d.ts +208 -0
  58. package/core/events/events.d.ts +72 -0
  59. package/core/events/events_abstract.d.ts +72 -0
  60. package/core/events/events_block_base.d.ts +46 -0
  61. package/core/events/events_block_change.d.ts +100 -0
  62. package/core/events/events_block_create.d.ts +59 -0
  63. package/core/events/events_block_delete.d.ts +62 -0
  64. package/core/events/events_block_drag.d.ts +61 -0
  65. package/core/events/events_block_field_intermediate_change.d.ts +71 -0
  66. package/core/events/events_block_move.d.ts +115 -0
  67. package/core/events/events_bubble_open.d.ts +62 -0
  68. package/core/events/events_click.d.ts +64 -0
  69. package/core/events/events_comment_base.d.ts +55 -0
  70. package/core/events/events_comment_change.d.ts +64 -0
  71. package/core/events/events_comment_collapse.d.ts +40 -0
  72. package/core/events/events_comment_create.d.ts +57 -0
  73. package/core/events/events_comment_delete.d.ts +57 -0
  74. package/core/events/events_comment_drag.d.ts +51 -0
  75. package/core/events/events_comment_move.d.ts +93 -0
  76. package/core/events/events_comment_resize.d.ts +68 -0
  77. package/core/events/events_selected.d.ts +53 -0
  78. package/core/events/events_theme_change.d.ts +43 -0
  79. package/core/events/events_toolbox_item_select.d.ts +49 -0
  80. package/core/events/events_trashcan_open.d.ts +47 -0
  81. package/core/events/events_ui_base.d.ts +32 -0
  82. package/core/events/events_var_base.d.ts +46 -0
  83. package/core/events/events_var_create.d.ts +55 -0
  84. package/core/events/events_var_delete.d.ts +50 -0
  85. package/core/events/events_var_rename.d.ts +51 -0
  86. package/core/events/events_var_type_change.d.ts +55 -0
  87. package/core/events/events_viewport.d.ts +67 -0
  88. package/core/events/predicates.d.ts +87 -0
  89. package/core/events/type.d.ts +81 -0
  90. package/core/events/utils.d.ts +211 -0
  91. package/core/events/workspace_events.d.ts +23 -0
  92. package/core/extensions.d.ts +99 -0
  93. package/core/field.d.ts +724 -0
  94. package/core/field_checkbox.d.ts +156 -0
  95. package/core/field_dropdown.d.ts +295 -0
  96. package/core/field_image.d.ts +148 -0
  97. package/core/field_input.d.ts +293 -0
  98. package/core/field_label.d.ts +80 -0
  99. package/core/field_label_serializable.d.ts +50 -0
  100. package/core/field_number.d.ts +194 -0
  101. package/core/field_registry.d.ts +83 -0
  102. package/core/field_textinput.d.ts +78 -0
  103. package/core/field_variable.d.ts +261 -0
  104. package/core/flyout_base.d.ts +453 -0
  105. package/core/flyout_button.d.ts +140 -0
  106. package/core/flyout_horizontal.d.ts +87 -0
  107. package/core/flyout_item.d.ts +26 -0
  108. package/core/flyout_metrics_manager.d.ts +46 -0
  109. package/core/flyout_navigator.d.ts +11 -0
  110. package/core/flyout_separator.d.ts +64 -0
  111. package/core/flyout_vertical.d.ts +88 -0
  112. package/core/focus_manager.d.ts +266 -0
  113. package/core/generator.d.ts +279 -0
  114. package/core/gesture.d.ts +449 -0
  115. package/core/grid.d.ts +124 -0
  116. package/core/icons/comment_icon.d.ts +134 -0
  117. package/core/icons/exceptions.d.ts +17 -0
  118. package/core/icons/icon.d.ts +84 -0
  119. package/core/icons/icon_types.d.ts +25 -0
  120. package/core/icons/mutator_icon.d.ts +96 -0
  121. package/core/icons/registry.d.ts +23 -0
  122. package/core/icons/warning_icon.d.ts +77 -0
  123. package/core/icons.d.ts +14 -0
  124. package/core/inject.d.ts +16 -0
  125. package/core/inputs/align.d.ts +14 -0
  126. package/core/inputs/dummy_input.d.ts +20 -0
  127. package/core/inputs/end_row_input.d.ts +25 -0
  128. package/core/inputs/input.d.ts +147 -0
  129. package/core/inputs/input_types.d.ts +16 -0
  130. package/core/inputs/statement_input.d.ts +22 -0
  131. package/core/inputs/value_input.d.ts +20 -0
  132. package/core/inputs.d.ts +14 -0
  133. package/core/insertion_marker_previewer.d.ts +67 -0
  134. package/core/interfaces/i_autohideable.d.ts +21 -0
  135. package/core/interfaces/i_bounded_element.d.ts +27 -0
  136. package/core/interfaces/i_bubble.d.ts +55 -0
  137. package/core/interfaces/i_collapsible_toolbox_item.d.ts +28 -0
  138. package/core/interfaces/i_comment_icon.d.ts +24 -0
  139. package/core/interfaces/i_component.d.ts +17 -0
  140. package/core/interfaces/i_connection_checker.d.ts +75 -0
  141. package/core/interfaces/i_connection_previewer.d.ts +39 -0
  142. package/core/interfaces/i_contextmenu.d.ts +16 -0
  143. package/core/interfaces/i_copyable.d.ts +30 -0
  144. package/core/interfaces/i_deletable.d.ts +23 -0
  145. package/core/interfaces/i_delete_area.d.ts +25 -0
  146. package/core/interfaces/i_drag_target.d.ts +59 -0
  147. package/core/interfaces/i_draggable.d.ts +56 -0
  148. package/core/interfaces/i_dragger.d.ts +32 -0
  149. package/core/interfaces/i_flyout.d.ts +159 -0
  150. package/core/interfaces/i_flyout_inflater.d.ts +48 -0
  151. package/core/interfaces/i_focusable_node.d.ts +105 -0
  152. package/core/interfaces/i_focusable_tree.d.ts +125 -0
  153. package/core/interfaces/i_has_bubble.d.ts +27 -0
  154. package/core/interfaces/i_icon.d.ts +84 -0
  155. package/core/interfaces/i_keyboard_accessible.d.ts +19 -0
  156. package/core/interfaces/i_legacy_procedure_blocks.d.ts +34 -0
  157. package/core/interfaces/i_metrics_manager.d.ts +129 -0
  158. package/core/interfaces/i_movable.d.ts +17 -0
  159. package/core/interfaces/i_navigation_policy.d.ts +63 -0
  160. package/core/interfaces/i_observable.d.ts +21 -0
  161. package/core/interfaces/i_parameter_model.d.ts +44 -0
  162. package/core/interfaces/i_paster.d.ts +15 -0
  163. package/core/interfaces/i_positionable.d.ts +29 -0
  164. package/core/interfaces/i_procedure_block.d.ts +16 -0
  165. package/core/interfaces/i_procedure_map.d.ts +16 -0
  166. package/core/interfaces/i_procedure_model.d.ts +59 -0
  167. package/core/interfaces/i_registrable.d.ts +11 -0
  168. package/core/interfaces/i_rendered_element.d.ts +16 -0
  169. package/core/interfaces/i_selectable.d.ts +26 -0
  170. package/core/interfaces/i_selectable_toolbox_item.d.ts +51 -0
  171. package/core/interfaces/i_serializable.d.ts +24 -0
  172. package/core/interfaces/i_serializer.d.ts +45 -0
  173. package/core/interfaces/i_styleable.d.ts +23 -0
  174. package/core/interfaces/i_toolbox.d.ts +102 -0
  175. package/core/interfaces/i_toolbox_item.d.ts +71 -0
  176. package/core/interfaces/i_variable_backed_parameter_model.d.ts +17 -0
  177. package/core/interfaces/i_variable_map.d.ts +48 -0
  178. package/core/interfaces/i_variable_model.d.ts +36 -0
  179. package/core/internal_constants.d.ts +34 -0
  180. package/core/keyboard_nav/block_comment_navigation_policy.d.ts +56 -0
  181. package/core/keyboard_nav/block_navigation_policy.d.ts +84 -0
  182. package/core/keyboard_nav/comment_bar_button_navigation_policy.d.ts +56 -0
  183. package/core/keyboard_nav/comment_editor_navigation_policy.d.ts +34 -0
  184. package/core/keyboard_nav/connection_navigation_policy.d.ts +67 -0
  185. package/core/keyboard_nav/field_navigation_policy.d.ts +56 -0
  186. package/core/keyboard_nav/flyout_button_navigation_policy.d.ts +56 -0
  187. package/core/keyboard_nav/flyout_navigation_policy.d.ts +65 -0
  188. package/core/keyboard_nav/flyout_separator_navigation_policy.d.ts +33 -0
  189. package/core/keyboard_nav/icon_navigation_policy.d.ts +56 -0
  190. package/core/keyboard_nav/line_cursor.d.ts +187 -0
  191. package/core/keyboard_nav/marker.d.ts +53 -0
  192. package/core/keyboard_nav/workspace_comment_navigation_policy.d.ts +56 -0
  193. package/core/keyboard_nav/workspace_navigation_policy.d.ts +56 -0
  194. package/core/keyboard_navigation_controller.d.ts +48 -0
  195. package/core/label_flyout_inflater.d.ts +42 -0
  196. package/core/layer_manager.d.ts +101 -0
  197. package/core/layers.d.ts +16 -0
  198. package/core/main.d.ts +7 -0
  199. package/core/marker_manager.d.ts +72 -0
  200. package/core/menu.d.ts +170 -0
  201. package/core/menu_separator.d.ts +25 -0
  202. package/core/menuitem.d.ts +147 -0
  203. package/core/metrics_manager.d.ts +221 -0
  204. package/core/msg.d.ts +24 -0
  205. package/core/names.d.ts +139 -0
  206. package/core/navigator.d.ts +65 -0
  207. package/core/observable_procedure_map.d.ts +34 -0
  208. package/core/options.d.ts +148 -0
  209. package/core/positionable_helpers.d.ts +89 -0
  210. package/core/procedures.d.ts +108 -0
  211. package/core/registry.d.ts +158 -0
  212. package/core/render_management.d.ts +34 -0
  213. package/core/rendered_connection.d.ts +262 -0
  214. package/core/renderers/common/block_rendering.d.ts +63 -0
  215. package/core/renderers/common/constants.d.ts +454 -0
  216. package/core/renderers/common/drawer.d.ts +156 -0
  217. package/core/renderers/common/i_path_object.d.ts +88 -0
  218. package/core/renderers/common/info.d.ts +201 -0
  219. package/core/renderers/common/path_object.d.ts +130 -0
  220. package/core/renderers/common/renderer.d.ts +141 -0
  221. package/core/renderers/geras/constants.d.ts +22 -0
  222. package/core/renderers/geras/drawer.d.ts +44 -0
  223. package/core/renderers/geras/geras.d.ts +17 -0
  224. package/core/renderers/geras/highlight_constants.d.ts +100 -0
  225. package/core/renderers/geras/highlighter.d.ts +96 -0
  226. package/core/renderers/geras/info.d.ts +45 -0
  227. package/core/renderers/geras/measurables/inline_input.d.ts +22 -0
  228. package/core/renderers/geras/measurables/statement_input.d.ts +22 -0
  229. package/core/renderers/geras/path_object.d.ts +42 -0
  230. package/core/renderers/geras/renderer.d.ts +77 -0
  231. package/core/renderers/measurables/base.d.ts +26 -0
  232. package/core/renderers/measurables/bottom_row.d.ts +58 -0
  233. package/core/renderers/measurables/connection.d.ts +25 -0
  234. package/core/renderers/measurables/external_value_input.d.ts +25 -0
  235. package/core/renderers/measurables/field.d.ts +28 -0
  236. package/core/renderers/measurables/hat.d.ts +19 -0
  237. package/core/renderers/measurables/icon.d.ts +25 -0
  238. package/core/renderers/measurables/in_row_spacer.d.ts +20 -0
  239. package/core/renderers/measurables/inline_input.d.ts +22 -0
  240. package/core/renderers/measurables/input_connection.d.ts +28 -0
  241. package/core/renderers/measurables/input_row.d.ts +26 -0
  242. package/core/renderers/measurables/jagged_edge.d.ts +19 -0
  243. package/core/renderers/measurables/next_connection.d.ts +22 -0
  244. package/core/renderers/measurables/output_connection.d.ts +24 -0
  245. package/core/renderers/measurables/previous_connection.d.ts +22 -0
  246. package/core/renderers/measurables/round_corner.d.ts +20 -0
  247. package/core/renderers/measurables/row.d.ts +124 -0
  248. package/core/renderers/measurables/spacer_row.d.ts +27 -0
  249. package/core/renderers/measurables/square_corner.d.ts +20 -0
  250. package/core/renderers/measurables/statement_input.d.ts +21 -0
  251. package/core/renderers/measurables/top_row.d.ts +53 -0
  252. package/core/renderers/measurables/types.d.ts +258 -0
  253. package/core/renderers/thrasos/info.d.ts +37 -0
  254. package/core/renderers/thrasos/renderer.d.ts +28 -0
  255. package/core/renderers/thrasos/thrasos.d.ts +10 -0
  256. package/core/renderers/zelos/constants.d.ts +165 -0
  257. package/core/renderers/zelos/drawer.d.ts +51 -0
  258. package/core/renderers/zelos/info.d.ts +89 -0
  259. package/core/renderers/zelos/measurables/bottom_row.d.ts +26 -0
  260. package/core/renderers/zelos/measurables/inputs.d.ts +21 -0
  261. package/core/renderers/zelos/measurables/row_elements.d.ts +20 -0
  262. package/core/renderers/zelos/measurables/top_row.d.ts +28 -0
  263. package/core/renderers/zelos/path_object.d.ts +76 -0
  264. package/core/renderers/zelos/renderer.d.ts +64 -0
  265. package/core/renderers/zelos/zelos.d.ts +17 -0
  266. package/core/scrollbar.d.ts +348 -0
  267. package/core/scrollbar_pair.d.ts +121 -0
  268. package/core/separator_flyout_inflater.d.ts +57 -0
  269. package/core/serialization/blocks.d.ts +138 -0
  270. package/core/serialization/exceptions.d.ts +81 -0
  271. package/core/serialization/priorities.d.ts +20 -0
  272. package/core/serialization/procedures.d.ts +97 -0
  273. package/core/serialization/registry.d.ts +21 -0
  274. package/core/serialization/variables.d.ts +38 -0
  275. package/core/serialization/workspace_comments.d.ts +45 -0
  276. package/core/serialization/workspaces.d.ts +29 -0
  277. package/core/serialization.d.ts +19 -0
  278. package/core/shortcut_items.d.ts +59 -0
  279. package/core/shortcut_registry.d.ts +236 -0
  280. package/core/sprites.d.ts +15 -0
  281. package/core/theme/classic.d.ts +12 -0
  282. package/core/theme/themes.d.ts +9 -0
  283. package/core/theme/zelos.d.ts +11 -0
  284. package/core/theme.d.ts +151 -0
  285. package/core/theme_manager.d.ts +92 -0
  286. package/core/toast.d.ts +74 -0
  287. package/core/toolbox/category.d.ts +265 -0
  288. package/core/toolbox/collapsible_category.d.ts +99 -0
  289. package/core/toolbox/separator.d.ts +40 -0
  290. package/core/toolbox/toolbox.d.ts +419 -0
  291. package/core/toolbox/toolbox_item.d.ts +109 -0
  292. package/core/tooltip.d.ts +118 -0
  293. package/core/touch.d.ts +72 -0
  294. package/core/trashcan.d.ts +212 -0
  295. package/core/utils/aria.d.ts +69 -0
  296. package/core/utils/array.d.ts +15 -0
  297. package/core/utils/colour.d.ts +102 -0
  298. package/core/utils/coordinate.d.ts +87 -0
  299. package/core/utils/deprecation.d.ts +18 -0
  300. package/core/utils/dom.d.ts +154 -0
  301. package/core/utils/drag.d.ts +33 -0
  302. package/core/utils/focusable_tree_traverser.d.ts +53 -0
  303. package/core/utils/idgenerator.d.ts +33 -0
  304. package/core/utils/keycodes.d.ts +137 -0
  305. package/core/utils/math.d.ts +31 -0
  306. package/core/utils/metrics.d.ts +64 -0
  307. package/core/utils/object.d.ts +17 -0
  308. package/core/utils/parsing.d.ts +52 -0
  309. package/core/utils/rect.d.ts +82 -0
  310. package/core/utils/size.d.ts +44 -0
  311. package/core/utils/string.d.ts +46 -0
  312. package/core/utils/style.d.ts +89 -0
  313. package/core/utils/svg.d.ts +75 -0
  314. package/core/utils/svg_math.d.ts +64 -0
  315. package/core/utils/svg_paths.d.ts +103 -0
  316. package/core/utils/toolbox.d.ts +180 -0
  317. package/core/utils/useragent.d.ts +14 -0
  318. package/core/utils/xml.d.ts +96 -0
  319. package/core/utils.d.ts +31 -0
  320. package/core/variable_map.d.ts +164 -0
  321. package/core/variable_model.d.ts +73 -0
  322. package/core/variables.d.ts +238 -0
  323. package/core/variables_dynamic.d.ts +56 -0
  324. package/core/widgetdiv.d.ts +87 -0
  325. package/core/workspace.d.ts +482 -0
  326. package/core/workspace_audio.d.ts +62 -0
  327. package/core/workspace_dragger.d.ts +48 -0
  328. package/core/workspace_svg.d.ts +1103 -0
  329. package/core/xml.d.ts +127 -0
  330. package/core/zoom_controls.d.ts +134 -0
  331. package/core.js +4 -0
  332. package/dart.js +4 -0
  333. package/dart.mjs +6 -0
  334. package/dart_compressed.js +330 -0
  335. package/dart_compressed.js.map +1 -0
  336. package/generators/dart/dart_generator.d.ts +104 -0
  337. package/generators/dart/lists.d.ts +21 -0
  338. package/generators/dart/logic.d.ts +20 -0
  339. package/generators/dart/loops.d.ts +14 -0
  340. package/generators/dart/math.d.ts +26 -0
  341. package/generators/dart/procedures.d.ts +14 -0
  342. package/generators/dart/text.d.ts +25 -0
  343. package/generators/dart/variables.d.ts +14 -0
  344. package/generators/dart/variables_dynamic.d.ts +10 -0
  345. package/generators/dart.d.ts +18 -0
  346. package/generators/javascript/javascript_generator.d.ts +123 -0
  347. package/generators/javascript/lists.d.ts +21 -0
  348. package/generators/javascript/logic.d.ts +20 -0
  349. package/generators/javascript/loops.d.ts +14 -0
  350. package/generators/javascript/math.d.ts +26 -0
  351. package/generators/javascript/procedures.d.ts +14 -0
  352. package/generators/javascript/text.d.ts +25 -0
  353. package/generators/javascript/variables.d.ts +14 -0
  354. package/generators/javascript/variables_dynamic.d.ts +10 -0
  355. package/generators/javascript.d.ts +18 -0
  356. package/generators/lua/lists.d.ts +21 -0
  357. package/generators/lua/logic.d.ts +20 -0
  358. package/generators/lua/loops.d.ts +14 -0
  359. package/generators/lua/lua_generator.d.ts +91 -0
  360. package/generators/lua/math.d.ts +26 -0
  361. package/generators/lua/procedures.d.ts +14 -0
  362. package/generators/lua/text.d.ts +25 -0
  363. package/generators/lua/variables.d.ts +14 -0
  364. package/generators/lua/variables_dynamic.d.ts +10 -0
  365. package/generators/lua.d.ts +12 -0
  366. package/generators/php/lists.d.ts +21 -0
  367. package/generators/php/logic.d.ts +20 -0
  368. package/generators/php/loops.d.ts +14 -0
  369. package/generators/php/math.d.ts +26 -0
  370. package/generators/php/php_generator.d.ts +122 -0
  371. package/generators/php/procedures.d.ts +14 -0
  372. package/generators/php/text.d.ts +25 -0
  373. package/generators/php/variables.d.ts +14 -0
  374. package/generators/php/variables_dynamic.d.ts +10 -0
  375. package/generators/php.d.ts +13 -0
  376. package/generators/python/lists.d.ts +21 -0
  377. package/generators/python/logic.d.ts +20 -0
  378. package/generators/python/loops.d.ts +14 -0
  379. package/generators/python/math.d.ts +26 -0
  380. package/generators/python/procedures.d.ts +14 -0
  381. package/generators/python/python_generator.d.ts +111 -0
  382. package/generators/python/text.d.ts +25 -0
  383. package/generators/python/variables.d.ts +14 -0
  384. package/generators/python/variables_dynamic.d.ts +10 -0
  385. package/generators/python.d.ts +13 -0
  386. package/index.js +36 -0
  387. package/index.mjs +163 -0
  388. package/javascript.js +4 -0
  389. package/javascript.mjs +6 -0
  390. package/javascript_compressed.js +264 -0
  391. package/javascript_compressed.js.map +1 -0
  392. package/lua.js +4 -0
  393. package/lua.mjs +6 -0
  394. package/lua_compressed.js +373 -0
  395. package/lua_compressed.js.map +1 -0
  396. package/msg/ab.js +465 -0
  397. package/msg/ab.mjs +446 -0
  398. package/msg/ace.js +465 -0
  399. package/msg/ace.mjs +446 -0
  400. package/msg/af.js +465 -0
  401. package/msg/af.mjs +446 -0
  402. package/msg/am.js +465 -0
  403. package/msg/am.mjs +446 -0
  404. package/msg/ar.js +465 -0
  405. package/msg/ar.mjs +446 -0
  406. package/msg/ast.js +465 -0
  407. package/msg/ast.mjs +446 -0
  408. package/msg/az.js +465 -0
  409. package/msg/az.mjs +446 -0
  410. package/msg/ba.js +465 -0
  411. package/msg/ba.mjs +446 -0
  412. package/msg/bcc.js +465 -0
  413. package/msg/bcc.mjs +446 -0
  414. package/msg/be-tarask.js +465 -0
  415. package/msg/be-tarask.mjs +446 -0
  416. package/msg/be.js +465 -0
  417. package/msg/be.mjs +446 -0
  418. package/msg/bg.js +465 -0
  419. package/msg/bg.mjs +446 -0
  420. package/msg/bn.js +465 -0
  421. package/msg/bn.mjs +446 -0
  422. package/msg/br.js +465 -0
  423. package/msg/br.mjs +446 -0
  424. package/msg/bs.js +465 -0
  425. package/msg/bs.mjs +446 -0
  426. package/msg/ca.js +465 -0
  427. package/msg/ca.mjs +446 -0
  428. package/msg/cdo.js +465 -0
  429. package/msg/cdo.mjs +446 -0
  430. package/msg/ce.js +465 -0
  431. package/msg/ce.mjs +446 -0
  432. package/msg/cs.js +465 -0
  433. package/msg/cs.mjs +446 -0
  434. package/msg/da.js +465 -0
  435. package/msg/da.mjs +446 -0
  436. package/msg/de.js +465 -0
  437. package/msg/de.mjs +446 -0
  438. package/msg/diq.js +465 -0
  439. package/msg/diq.mjs +446 -0
  440. package/msg/dtp.js +465 -0
  441. package/msg/dtp.mjs +446 -0
  442. package/msg/dty.js +465 -0
  443. package/msg/dty.mjs +446 -0
  444. package/msg/ee.js +465 -0
  445. package/msg/ee.mjs +446 -0
  446. package/msg/el.js +465 -0
  447. package/msg/el.mjs +446 -0
  448. package/msg/en-gb.js +465 -0
  449. package/msg/en-gb.mjs +446 -0
  450. package/msg/en.js +465 -0
  451. package/msg/en.mjs +446 -0
  452. package/msg/eo.js +465 -0
  453. package/msg/eo.mjs +446 -0
  454. package/msg/es.js +465 -0
  455. package/msg/es.mjs +446 -0
  456. package/msg/et.js +465 -0
  457. package/msg/et.mjs +446 -0
  458. package/msg/eu.js +465 -0
  459. package/msg/eu.mjs +446 -0
  460. package/msg/fa.js +465 -0
  461. package/msg/fa.mjs +446 -0
  462. package/msg/fi.js +465 -0
  463. package/msg/fi.mjs +446 -0
  464. package/msg/fo.js +465 -0
  465. package/msg/fo.mjs +446 -0
  466. package/msg/fr.js +465 -0
  467. package/msg/fr.mjs +446 -0
  468. package/msg/frr.js +465 -0
  469. package/msg/frr.mjs +446 -0
  470. package/msg/gl.js +465 -0
  471. package/msg/gl.mjs +446 -0
  472. package/msg/gn.js +465 -0
  473. package/msg/gn.mjs +446 -0
  474. package/msg/gor.js +465 -0
  475. package/msg/gor.mjs +446 -0
  476. package/msg/ha.js +465 -0
  477. package/msg/ha.mjs +446 -0
  478. package/msg/hak.js +465 -0
  479. package/msg/hak.mjs +446 -0
  480. package/msg/he.js +465 -0
  481. package/msg/he.mjs +446 -0
  482. package/msg/hi.js +465 -0
  483. package/msg/hi.mjs +446 -0
  484. package/msg/hr.js +465 -0
  485. package/msg/hr.mjs +446 -0
  486. package/msg/hrx.js +465 -0
  487. package/msg/hrx.mjs +446 -0
  488. package/msg/hsb.js +465 -0
  489. package/msg/hsb.mjs +446 -0
  490. package/msg/hu.js +465 -0
  491. package/msg/hu.mjs +446 -0
  492. package/msg/hy.js +465 -0
  493. package/msg/hy.mjs +446 -0
  494. package/msg/ia.js +465 -0
  495. package/msg/ia.mjs +446 -0
  496. package/msg/id.js +465 -0
  497. package/msg/id.mjs +446 -0
  498. package/msg/ig.js +465 -0
  499. package/msg/ig.mjs +446 -0
  500. package/msg/inh.js +465 -0
  501. package/msg/inh.mjs +446 -0
  502. package/msg/is.js +465 -0
  503. package/msg/is.mjs +446 -0
  504. package/msg/it.js +465 -0
  505. package/msg/it.mjs +446 -0
  506. package/msg/ja.js +465 -0
  507. package/msg/ja.mjs +446 -0
  508. package/msg/ka.js +465 -0
  509. package/msg/ka.mjs +446 -0
  510. package/msg/kab.js +465 -0
  511. package/msg/kab.mjs +446 -0
  512. package/msg/kbd-cyrl.js +465 -0
  513. package/msg/kbd-cyrl.mjs +446 -0
  514. package/msg/km.js +465 -0
  515. package/msg/km.mjs +446 -0
  516. package/msg/kn.js +465 -0
  517. package/msg/kn.mjs +446 -0
  518. package/msg/ko.js +465 -0
  519. package/msg/ko.mjs +446 -0
  520. package/msg/ksh.js +465 -0
  521. package/msg/ksh.mjs +446 -0
  522. package/msg/ku-latn.js +465 -0
  523. package/msg/ku-latn.mjs +446 -0
  524. package/msg/ky.js +465 -0
  525. package/msg/ky.mjs +446 -0
  526. package/msg/la.js +465 -0
  527. package/msg/la.mjs +446 -0
  528. package/msg/lb.js +465 -0
  529. package/msg/lb.mjs +446 -0
  530. package/msg/lki.js +465 -0
  531. package/msg/lki.mjs +446 -0
  532. package/msg/lo.js +465 -0
  533. package/msg/lo.mjs +446 -0
  534. package/msg/lrc.js +465 -0
  535. package/msg/lrc.mjs +446 -0
  536. package/msg/lt.js +465 -0
  537. package/msg/lt.mjs +446 -0
  538. package/msg/lv.js +465 -0
  539. package/msg/lv.mjs +446 -0
  540. package/msg/mg.js +465 -0
  541. package/msg/mg.mjs +446 -0
  542. package/msg/mk.js +465 -0
  543. package/msg/mk.mjs +446 -0
  544. package/msg/ml.js +465 -0
  545. package/msg/ml.mjs +446 -0
  546. package/msg/mnw.js +465 -0
  547. package/msg/mnw.mjs +446 -0
  548. package/msg/ms.js +465 -0
  549. package/msg/ms.mjs +446 -0
  550. package/msg/my.js +465 -0
  551. package/msg/my.mjs +446 -0
  552. package/msg/mzn.js +465 -0
  553. package/msg/mzn.mjs +446 -0
  554. package/msg/nb.js +465 -0
  555. package/msg/nb.mjs +446 -0
  556. package/msg/ne.js +465 -0
  557. package/msg/ne.mjs +446 -0
  558. package/msg/nl.js +465 -0
  559. package/msg/nl.mjs +446 -0
  560. package/msg/oc.js +465 -0
  561. package/msg/oc.mjs +446 -0
  562. package/msg/olo.js +465 -0
  563. package/msg/olo.mjs +446 -0
  564. package/msg/pa.js +465 -0
  565. package/msg/pa.mjs +446 -0
  566. package/msg/pl.js +465 -0
  567. package/msg/pl.mjs +446 -0
  568. package/msg/pms.js +465 -0
  569. package/msg/pms.mjs +446 -0
  570. package/msg/ps.js +465 -0
  571. package/msg/ps.mjs +446 -0
  572. package/msg/pt-br.js +465 -0
  573. package/msg/pt-br.mjs +446 -0
  574. package/msg/pt.js +465 -0
  575. package/msg/pt.mjs +446 -0
  576. package/msg/ro.js +465 -0
  577. package/msg/ro.mjs +446 -0
  578. package/msg/ru.js +465 -0
  579. package/msg/ru.mjs +446 -0
  580. package/msg/sc.js +465 -0
  581. package/msg/sc.mjs +446 -0
  582. package/msg/sco.js +465 -0
  583. package/msg/sco.mjs +446 -0
  584. package/msg/sd.js +465 -0
  585. package/msg/sd.mjs +446 -0
  586. package/msg/shn.js +465 -0
  587. package/msg/shn.mjs +446 -0
  588. package/msg/si.js +465 -0
  589. package/msg/si.mjs +446 -0
  590. package/msg/sk.js +465 -0
  591. package/msg/sk.mjs +446 -0
  592. package/msg/skr-arab.js +465 -0
  593. package/msg/skr-arab.mjs +446 -0
  594. package/msg/sl.js +465 -0
  595. package/msg/sl.mjs +446 -0
  596. package/msg/smn.js +465 -0
  597. package/msg/smn.mjs +446 -0
  598. package/msg/sq.js +465 -0
  599. package/msg/sq.mjs +446 -0
  600. package/msg/sr-latn.js +465 -0
  601. package/msg/sr-latn.mjs +446 -0
  602. package/msg/sr.js +465 -0
  603. package/msg/sr.mjs +446 -0
  604. package/msg/sv.js +465 -0
  605. package/msg/sv.mjs +446 -0
  606. package/msg/sw.js +465 -0
  607. package/msg/sw.mjs +446 -0
  608. package/msg/ta.js +465 -0
  609. package/msg/ta.mjs +446 -0
  610. package/msg/tcy.js +465 -0
  611. package/msg/tcy.mjs +446 -0
  612. package/msg/tdd.js +465 -0
  613. package/msg/tdd.mjs +446 -0
  614. package/msg/te.js +465 -0
  615. package/msg/te.mjs +446 -0
  616. package/msg/th.js +465 -0
  617. package/msg/th.mjs +446 -0
  618. package/msg/ti.js +465 -0
  619. package/msg/ti.mjs +446 -0
  620. package/msg/tl.js +465 -0
  621. package/msg/tl.mjs +446 -0
  622. package/msg/tlh.js +465 -0
  623. package/msg/tlh.mjs +446 -0
  624. package/msg/tr.js +465 -0
  625. package/msg/tr.mjs +446 -0
  626. package/msg/ug-arab.js +465 -0
  627. package/msg/ug-arab.mjs +446 -0
  628. package/msg/uk.js +465 -0
  629. package/msg/uk.mjs +446 -0
  630. package/msg/ur.js +465 -0
  631. package/msg/ur.mjs +446 -0
  632. package/msg/uz.js +465 -0
  633. package/msg/uz.mjs +446 -0
  634. package/msg/vi.js +465 -0
  635. package/msg/vi.mjs +446 -0
  636. package/msg/xmf.js +465 -0
  637. package/msg/xmf.mjs +446 -0
  638. package/msg/yo.js +465 -0
  639. package/msg/yo.mjs +446 -0
  640. package/msg/zgh.js +465 -0
  641. package/msg/zgh.mjs +446 -0
  642. package/msg/zh-hans.js +465 -0
  643. package/msg/zh-hans.mjs +446 -0
  644. package/msg/zh-hant.js +465 -0
  645. package/msg/zh-hant.mjs +446 -0
  646. package/package.json +8 -37
  647. package/php.js +4 -0
  648. package/php.mjs +6 -0
  649. package/php_compressed.js +283 -0
  650. package/php_compressed.js.map +1 -0
  651. package/python.js +4 -0
  652. package/python.mjs +6 -0
  653. package/python_compressed.js +208 -0
  654. package/python_compressed.js.map +1 -0
  655. package/.prettierignore +0 -30
  656. package/.prettierrc.js +0 -15
  657. package/api-extractor.json +0 -390
  658. package/appengine/.gcloudignore +0 -20
  659. package/appengine/README.txt +0 -42
  660. package/appengine/add_timestamps.py +0 -69
  661. package/appengine/app.yaml +0 -106
  662. package/appengine/apple-touch-icon.png +0 -0
  663. package/appengine/blockly_compressed.js +0 -11
  664. package/appengine/expiration.py +0 -52
  665. package/appengine/favicon.ico +0 -0
  666. package/appengine/index.yaml +0 -11
  667. package/appengine/main.py +0 -39
  668. package/appengine/redirect.html +0 -107
  669. package/appengine/requirements.txt +0 -1
  670. package/appengine/robots.txt +0 -2
  671. package/appengine/storage.js +0 -190
  672. package/appengine/storage.py +0 -125
  673. package/blocks/blocks.ts +0 -44
  674. package/blocks/lists.ts +0 -1065
  675. package/blocks/logic.ts +0 -712
  676. package/blocks/loops.ts +0 -408
  677. package/blocks/math.ts +0 -591
  678. package/blocks/procedures.ts +0 -1366
  679. package/blocks/text.ts +0 -1001
  680. package/blocks/variables.ts +0 -181
  681. package/blocks/variables_dynamic.ts +0 -192
  682. package/core/any_aliases.ts +0 -8
  683. package/core/block.ts +0 -2511
  684. package/core/block_animations.ts +0 -233
  685. package/core/block_flyout_inflater.ts +0 -283
  686. package/core/block_svg.ts +0 -1873
  687. package/core/blockly.ts +0 -644
  688. package/core/blockly_options.ts +0 -71
  689. package/core/blocks.ts +0 -18
  690. package/core/browser_events.ts +0 -256
  691. package/core/bubbles/bubble.ts +0 -732
  692. package/core/bubbles/mini_workspace_bubble.ts +0 -292
  693. package/core/bubbles/text_bubble.ts +0 -112
  694. package/core/bubbles/textinput_bubble.ts +0 -296
  695. package/core/bubbles.ts +0 -12
  696. package/core/bump_objects.ts +0 -188
  697. package/core/button_flyout_inflater.ts +0 -76
  698. package/core/clipboard/block_paster.ts +0 -154
  699. package/core/clipboard/registry.ts +0 -31
  700. package/core/clipboard/workspace_comment_paster.ts +0 -95
  701. package/core/clipboard.ts +0 -197
  702. package/core/comments/collapse_comment_bar_button.ts +0 -102
  703. package/core/comments/comment_bar_button.ts +0 -105
  704. package/core/comments/comment_editor.ts +0 -220
  705. package/core/comments/comment_view.ts +0 -773
  706. package/core/comments/delete_comment_bar_button.ts +0 -106
  707. package/core/comments/rendered_workspace_comment.ts +0 -361
  708. package/core/comments/workspace_comment.ts +0 -247
  709. package/core/comments.ts +0 -13
  710. package/core/common.ts +0 -347
  711. package/core/component_manager.ts +0 -247
  712. package/core/config.ts +0 -65
  713. package/core/connection.ts +0 -807
  714. package/core/connection_checker.ts +0 -348
  715. package/core/connection_db.ts +0 -297
  716. package/core/connection_type.ts +0 -21
  717. package/core/constants.ts +0 -23
  718. package/core/contextmenu.ts +0 -295
  719. package/core/contextmenu_items.ts +0 -684
  720. package/core/contextmenu_registry.ts +0 -278
  721. package/core/css.ts +0 -518
  722. package/core/delete_area.ts +0 -77
  723. package/core/dialog.ts +0 -167
  724. package/core/drag_target.ts +0 -97
  725. package/core/dragging/block_drag_strategy.ts +0 -523
  726. package/core/dragging/bubble_drag_strategy.ts +0 -49
  727. package/core/dragging/comment_drag_strategy.ts +0 -92
  728. package/core/dragging/dragger.ts +0 -174
  729. package/core/dragging.ts +0 -12
  730. package/core/dropdowndiv.ts +0 -792
  731. package/core/events/events.ts +0 -109
  732. package/core/events/events_abstract.ts +0 -129
  733. package/core/events/events_block_base.ts +0 -87
  734. package/core/events/events_block_change.ts +0 -259
  735. package/core/events/events_block_create.ts +0 -185
  736. package/core/events/events_block_delete.ts +0 -182
  737. package/core/events/events_block_drag.ts +0 -116
  738. package/core/events/events_block_field_intermediate_change.ts +0 -166
  739. package/core/events/events_block_move.ts +0 -306
  740. package/core/events/events_bubble_open.ts +0 -121
  741. package/core/events/events_click.ts +0 -110
  742. package/core/events/events_comment_base.ts +0 -126
  743. package/core/events/events_comment_change.ts +0 -156
  744. package/core/events/events_comment_collapse.ts +0 -103
  745. package/core/events/events_comment_create.ts +0 -114
  746. package/core/events/events_comment_delete.ts +0 -113
  747. package/core/events/events_comment_drag.ts +0 -99
  748. package/core/events/events_comment_move.ts +0 -206
  749. package/core/events/events_comment_resize.ts +0 -169
  750. package/core/events/events_selected.ts +0 -97
  751. package/core/events/events_theme_change.ts +0 -84
  752. package/core/events/events_toolbox_item_select.ts +0 -96
  753. package/core/events/events_trashcan_open.ts +0 -87
  754. package/core/events/events_ui_base.ts +0 -47
  755. package/core/events/events_var_base.ts +0 -88
  756. package/core/events/events_var_create.ts +0 -131
  757. package/core/events/events_var_delete.ts +0 -124
  758. package/core/events/events_var_rename.ts +0 -133
  759. package/core/events/events_var_type_change.ts +0 -122
  760. package/core/events/events_viewport.ts +0 -149
  761. package/core/events/predicates.ts +0 -166
  762. package/core/events/type.ts +0 -87
  763. package/core/events/utils.ts +0 -455
  764. package/core/events/workspace_events.ts +0 -46
  765. package/core/extensions.ts +0 -497
  766. package/core/field.ts +0 -1445
  767. package/core/field_checkbox.ts +0 -266
  768. package/core/field_dropdown.ts +0 -907
  769. package/core/field_image.ts +0 -307
  770. package/core/field_input.ts +0 -826
  771. package/core/field_label.ts +0 -150
  772. package/core/field_label_serializable.ts +0 -73
  773. package/core/field_number.ts +0 -381
  774. package/core/field_registry.ts +0 -115
  775. package/core/field_textinput.ts +0 -125
  776. package/core/field_variable.ts +0 -654
  777. package/core/flyout_base.ts +0 -1013
  778. package/core/flyout_button.ts +0 -447
  779. package/core/flyout_horizontal.ts +0 -375
  780. package/core/flyout_item.ts +0 -33
  781. package/core/flyout_metrics_manager.ts +0 -90
  782. package/core/flyout_navigator.ts +0 -24
  783. package/core/flyout_separator.ts +0 -94
  784. package/core/flyout_vertical.ts +0 -354
  785. package/core/focus_manager.ts +0 -675
  786. package/core/generator.ts +0 -611
  787. package/core/gesture.ts +0 -1190
  788. package/core/grid.ts +0 -267
  789. package/core/icons/comment_icon.ts +0 -429
  790. package/core/icons/exceptions.ts +0 -23
  791. package/core/icons/icon.ts +0 -204
  792. package/core/icons/icon_types.ts +0 -32
  793. package/core/icons/mutator_icon.ts +0 -360
  794. package/core/icons/registry.ts +0 -33
  795. package/core/icons/warning_icon.ts +0 -226
  796. package/core/icons.ts +0 -24
  797. package/core/inject.ts +0 -332
  798. package/core/inputs/align.ts +0 -14
  799. package/core/inputs/dummy_input.ts +0 -26
  800. package/core/inputs/end_row_input.ts +0 -31
  801. package/core/inputs/input.ts +0 -317
  802. package/core/inputs/input_types.ts +0 -27
  803. package/core/inputs/statement_input.ts +0 -34
  804. package/core/inputs/value_input.ts +0 -30
  805. package/core/inputs.ts +0 -23
  806. package/core/insertion_marker_previewer.ts +0 -268
  807. package/core/interfaces/i_autohideable.ts +0 -27
  808. package/core/interfaces/i_bounded_element.ts +0 -31
  809. package/core/interfaces/i_bubble.ts +0 -64
  810. package/core/interfaces/i_collapsible_toolbox_item.ts +0 -33
  811. package/core/interfaces/i_comment_icon.ts +0 -47
  812. package/core/interfaces/i_component.ts +0 -19
  813. package/core/interfaces/i_connection_checker.ts +0 -101
  814. package/core/interfaces/i_connection_previewer.ts +0 -50
  815. package/core/interfaces/i_contextmenu.ts +0 -21
  816. package/core/interfaces/i_copyable.ts +0 -39
  817. package/core/interfaces/i_deletable.ts +0 -35
  818. package/core/interfaces/i_delete_area.ts +0 -28
  819. package/core/interfaces/i_drag_target.ts +0 -67
  820. package/core/interfaces/i_draggable.ts +0 -73
  821. package/core/interfaces/i_dragger.ts +0 -35
  822. package/core/interfaces/i_flyout.ts +0 -190
  823. package/core/interfaces/i_flyout_inflater.ts +0 -51
  824. package/core/interfaces/i_focusable_node.ts +0 -120
  825. package/core/interfaces/i_focusable_tree.ts +0 -144
  826. package/core/interfaces/i_has_bubble.ts +0 -37
  827. package/core/interfaces/i_icon.ts +0 -116
  828. package/core/interfaces/i_keyboard_accessible.ts +0 -22
  829. package/core/interfaces/i_legacy_procedure_blocks.ts +0 -51
  830. package/core/interfaces/i_metrics_manager.ts +0 -150
  831. package/core/interfaces/i_movable.ts +0 -19
  832. package/core/interfaces/i_navigation_policy.ts +0 -69
  833. package/core/interfaces/i_observable.ts +0 -28
  834. package/core/interfaces/i_parameter_model.ts +0 -51
  835. package/core/interfaces/i_paster.ts +0 -25
  836. package/core/interfaces/i_positionable.ts +0 -33
  837. package/core/interfaces/i_procedure_block.ts +0 -29
  838. package/core/interfaces/i_procedure_map.ts +0 -18
  839. package/core/interfaces/i_procedure_model.ts +0 -71
  840. package/core/interfaces/i_registrable.ts +0 -12
  841. package/core/interfaces/i_rendered_element.ts +0 -19
  842. package/core/interfaces/i_selectable.ts +0 -41
  843. package/core/interfaces/i_selectable_toolbox_item.ts +0 -63
  844. package/core/interfaces/i_serializable.ts +0 -32
  845. package/core/interfaces/i_serializer.ts +0 -51
  846. package/core/interfaces/i_styleable.ts +0 -26
  847. package/core/interfaces/i_toolbox.ts +0 -121
  848. package/core/interfaces/i_toolbox_item.ts +0 -83
  849. package/core/interfaces/i_variable_backed_parameter_model.ts +0 -23
  850. package/core/interfaces/i_variable_map.ts +0 -65
  851. package/core/interfaces/i_variable_model.ts +0 -57
  852. package/core/internal_constants.ts +0 -47
  853. package/core/keyboard_nav/block_comment_navigation_policy.ts +0 -76
  854. package/core/keyboard_nav/block_navigation_policy.ts +0 -213
  855. package/core/keyboard_nav/comment_bar_button_navigation_policy.ts +0 -88
  856. package/core/keyboard_nav/comment_editor_navigation_policy.ts +0 -54
  857. package/core/keyboard_nav/connection_navigation_policy.ts +0 -155
  858. package/core/keyboard_nav/field_navigation_policy.ts +0 -85
  859. package/core/keyboard_nav/flyout_button_navigation_policy.ts +0 -76
  860. package/core/keyboard_nav/flyout_navigation_policy.ts +0 -111
  861. package/core/keyboard_nav/flyout_separator_navigation_policy.ts +0 -53
  862. package/core/keyboard_nav/icon_navigation_policy.ts +0 -93
  863. package/core/keyboard_nav/line_cursor.ts +0 -414
  864. package/core/keyboard_nav/marker.ts +0 -86
  865. package/core/keyboard_nav/workspace_comment_navigation_policy.ts +0 -77
  866. package/core/keyboard_nav/workspace_navigation_policy.ts +0 -77
  867. package/core/keyboard_navigation_controller.ts +0 -63
  868. package/core/label_flyout_inflater.ts +0 -75
  869. package/core/layer_manager.ts +0 -229
  870. package/core/layers.ts +0 -17
  871. package/core/main.ts +0 -31
  872. package/core/marker_manager.ts +0 -116
  873. package/core/menu.ts +0 -486
  874. package/core/menu_separator.ts +0 -38
  875. package/core/menuitem.ts +0 -289
  876. package/core/metrics_manager.ts +0 -486
  877. package/core/msg.ts +0 -27
  878. package/core/names.ts +0 -275
  879. package/core/navigator.ts +0 -123
  880. package/core/observable_procedure_map.ts +0 -66
  881. package/core/options.ts +0 -377
  882. package/core/positionable_helpers.ts +0 -186
  883. package/core/procedures.ts +0 -622
  884. package/core/registry.ts +0 -400
  885. package/core/render_management.ts +0 -193
  886. package/core/rendered_connection.ts +0 -690
  887. package/core/renderers/common/block_rendering.ts +0 -122
  888. package/core/renderers/common/constants.ts +0 -1226
  889. package/core/renderers/common/drawer.ts +0 -511
  890. package/core/renderers/common/i_path_object.ts +0 -109
  891. package/core/renderers/common/info.ts +0 -768
  892. package/core/renderers/common/path_object.ts +0 -260
  893. package/core/renderers/common/renderer.ts +0 -236
  894. package/core/renderers/geras/constants.ts +0 -42
  895. package/core/renderers/geras/drawer.ts +0 -166
  896. package/core/renderers/geras/geras.ts +0 -31
  897. package/core/renderers/geras/highlight_constants.ts +0 -342
  898. package/core/renderers/geras/highlighter.ts +0 -312
  899. package/core/renderers/geras/info.ts +0 -476
  900. package/core/renderers/geras/measurables/inline_input.ts +0 -36
  901. package/core/renderers/geras/measurables/statement_input.ts +0 -35
  902. package/core/renderers/geras/path_object.ts +0 -121
  903. package/core/renderers/geras/renderer.ts +0 -127
  904. package/core/renderers/measurables/base.ts +0 -40
  905. package/core/renderers/measurables/bottom_row.ts +0 -103
  906. package/core/renderers/measurables/connection.ts +0 -41
  907. package/core/renderers/measurables/external_value_input.ts +0 -51
  908. package/core/renderers/measurables/field.ts +0 -48
  909. package/core/renderers/measurables/hat.ts +0 -32
  910. package/core/renderers/measurables/icon.ts +0 -40
  911. package/core/renderers/measurables/in_row_spacer.ts +0 -36
  912. package/core/renderers/measurables/inline_input.ts +0 -61
  913. package/core/renderers/measurables/input_connection.ts +0 -56
  914. package/core/renderers/measurables/input_row.ts +0 -62
  915. package/core/renderers/measurables/jagged_edge.ts +0 -35
  916. package/core/renderers/measurables/next_connection.ts +0 -41
  917. package/core/renderers/measurables/output_connection.ts +0 -42
  918. package/core/renderers/measurables/previous_connection.ts +0 -41
  919. package/core/renderers/measurables/round_corner.ts +0 -41
  920. package/core/renderers/measurables/row.ts +0 -190
  921. package/core/renderers/measurables/spacer_row.ts +0 -43
  922. package/core/renderers/measurables/square_corner.ts +0 -39
  923. package/core/renderers/measurables/statement_input.ts +0 -47
  924. package/core/renderers/measurables/top_row.ts +0 -108
  925. package/core/renderers/measurables/types.ts +0 -362
  926. package/core/renderers/thrasos/info.ts +0 -327
  927. package/core/renderers/thrasos/renderer.ts +0 -39
  928. package/core/renderers/thrasos/thrasos.ts +0 -14
  929. package/core/renderers/zelos/constants.ts +0 -913
  930. package/core/renderers/zelos/drawer.ts +0 -272
  931. package/core/renderers/zelos/info.ts +0 -651
  932. package/core/renderers/zelos/measurables/bottom_row.ts +0 -44
  933. package/core/renderers/zelos/measurables/inputs.ts +0 -40
  934. package/core/renderers/zelos/measurables/row_elements.ts +0 -29
  935. package/core/renderers/zelos/measurables/top_row.ts +0 -50
  936. package/core/renderers/zelos/path_object.ts +0 -209
  937. package/core/renderers/zelos/renderer.ts +0 -91
  938. package/core/renderers/zelos/zelos.ts +0 -31
  939. package/core/scrollbar.ts +0 -898
  940. package/core/scrollbar_pair.ts +0 -349
  941. package/core/separator_flyout_inflater.ts +0 -83
  942. package/core/serialization/blocks.ts +0 -834
  943. package/core/serialization/exceptions.ts +0 -112
  944. package/core/serialization/priorities.ts +0 -25
  945. package/core/serialization/procedures.ts +0 -158
  946. package/core/serialization/registry.ts +0 -30
  947. package/core/serialization/variables.ts +0 -69
  948. package/core/serialization/workspace_comments.ts +0 -143
  949. package/core/serialization/workspaces.ts +0 -94
  950. package/core/serialization.ts +0 -32
  951. package/core/shortcut_items.ts +0 -405
  952. package/core/shortcut_registry.ts +0 -451
  953. package/core/sprites.ts +0 -15
  954. package/core/theme/classic.ts +0 -40
  955. package/core/theme/themes.ts +0 -12
  956. package/core/theme/zelos.ts +0 -80
  957. package/core/theme.ts +0 -232
  958. package/core/theme_manager.ts +0 -192
  959. package/core/toast.ts +0 -219
  960. package/core/toolbox/category.ts +0 -746
  961. package/core/toolbox/collapsible_category.ts +0 -287
  962. package/core/toolbox/separator.ts +0 -108
  963. package/core/toolbox/toolbox.ts +0 -1210
  964. package/core/toolbox/toolbox_item.ts +0 -181
  965. package/core/tooltip.ts +0 -466
  966. package/core/touch.ts +0 -155
  967. package/core/trashcan.ts +0 -730
  968. package/core/utils/aria.ts +0 -158
  969. package/core/utils/array.ts +0 -24
  970. package/core/utils/colour.ts +0 -265
  971. package/core/utils/coordinate.ts +0 -129
  972. package/core/utils/deprecation.ts +0 -47
  973. package/core/utils/dom.ts +0 -356
  974. package/core/utils/drag.ts +0 -74
  975. package/core/utils/focusable_tree_traverser.ts +0 -126
  976. package/core/utils/idgenerator.ts +0 -70
  977. package/core/utils/keycodes.ts +0 -154
  978. package/core/utils/math.ts +0 -50
  979. package/core/utils/metrics.ts +0 -86
  980. package/core/utils/object.ts +0 -33
  981. package/core/utils/parsing.ts +0 -286
  982. package/core/utils/rect.ts +0 -142
  983. package/core/utils/size.ts +0 -62
  984. package/core/utils/string.ts +0 -289
  985. package/core/utils/style.ts +0 -219
  986. package/core/utils/svg.ts +0 -84
  987. package/core/utils/svg_math.ts +0 -207
  988. package/core/utils/svg_paths.ts +0 -133
  989. package/core/utils/toolbox.ts +0 -417
  990. package/core/utils/useragent.ts +0 -86
  991. package/core/utils/xml.ts +0 -165
  992. package/core/utils.ts +0 -59
  993. package/core/variable_map.ts +0 -476
  994. package/core/variable_model.ts +0 -150
  995. package/core/variables.ts +0 -931
  996. package/core/variables_dynamic.ts +0 -230
  997. package/core/widgetdiv.ts +0 -349
  998. package/core/workspace.ts +0 -994
  999. package/core/workspace_audio.ts +0 -137
  1000. package/core/workspace_dragger.ts +0 -81
  1001. package/core/workspace_svg.ts +0 -2954
  1002. package/core/xml.ts +0 -1126
  1003. package/core/zoom_controls.ts +0 -495
  1004. package/demos/blockfactory/analytics.js +0 -195
  1005. package/demos/blockfactory/app_controller.js +0 -726
  1006. package/demos/blockfactory/block_definition_extractor.js +0 -742
  1007. package/demos/blockfactory/block_exporter_controller.js +0 -311
  1008. package/demos/blockfactory/block_exporter_tools.js +0 -212
  1009. package/demos/blockfactory/block_exporter_view.js +0 -101
  1010. package/demos/blockfactory/block_library_controller.js +0 -325
  1011. package/demos/blockfactory/block_library_storage.js +0 -149
  1012. package/demos/blockfactory/block_library_view.js +0 -178
  1013. package/demos/blockfactory/block_option.js +0 -151
  1014. package/demos/blockfactory/blocks.js +0 -920
  1015. package/demos/blockfactory/cp.css +0 -46
  1016. package/demos/blockfactory/cp.js +0 -179
  1017. package/demos/blockfactory/factory.css +0 -586
  1018. package/demos/blockfactory/factory.js +0 -338
  1019. package/demos/blockfactory/factory_utils.js +0 -1036
  1020. package/demos/blockfactory/icon.png +0 -0
  1021. package/demos/blockfactory/index.html +0 -767
  1022. package/demos/blockfactory/link.png +0 -0
  1023. package/demos/blockfactory/standard_categories.js +0 -384
  1024. package/demos/blockfactory/workspacefactory/wfactory_controller.js +0 -1332
  1025. package/demos/blockfactory/workspacefactory/wfactory_generator.js +0 -224
  1026. package/demos/blockfactory/workspacefactory/wfactory_init.js +0 -541
  1027. package/demos/blockfactory/workspacefactory/wfactory_model.js +0 -548
  1028. package/demos/blockfactory/workspacefactory/wfactory_view.js +0 -424
  1029. package/demos/code/code.js +0 -626
  1030. package/demos/code/icon.png +0 -0
  1031. package/demos/code/icons.png +0 -0
  1032. package/demos/code/index.html +0 -359
  1033. package/demos/code/msg/ar.js +0 -24
  1034. package/demos/code/msg/be-tarask.js +0 -24
  1035. package/demos/code/msg/br.js +0 -24
  1036. package/demos/code/msg/ca.js +0 -24
  1037. package/demos/code/msg/cs.js +0 -24
  1038. package/demos/code/msg/da.js +0 -24
  1039. package/demos/code/msg/de.js +0 -24
  1040. package/demos/code/msg/el.js +0 -24
  1041. package/demos/code/msg/en.js +0 -24
  1042. package/demos/code/msg/es.js +0 -24
  1043. package/demos/code/msg/et.js +0 -24
  1044. package/demos/code/msg/fa.js +0 -24
  1045. package/demos/code/msg/fr.js +0 -24
  1046. package/demos/code/msg/he.js +0 -24
  1047. package/demos/code/msg/hr.js +0 -24
  1048. package/demos/code/msg/hrx.js +0 -24
  1049. package/demos/code/msg/hu.js +0 -24
  1050. package/demos/code/msg/ia.js +0 -24
  1051. package/demos/code/msg/is.js +0 -24
  1052. package/demos/code/msg/it.js +0 -24
  1053. package/demos/code/msg/ja.js +0 -24
  1054. package/demos/code/msg/kab.js +0 -24
  1055. package/demos/code/msg/ko.js +0 -24
  1056. package/demos/code/msg/mk.js +0 -24
  1057. package/demos/code/msg/ms.js +0 -24
  1058. package/demos/code/msg/nb.js +0 -24
  1059. package/demos/code/msg/nl.js +0 -24
  1060. package/demos/code/msg/oc.js +0 -24
  1061. package/demos/code/msg/pl.js +0 -24
  1062. package/demos/code/msg/pms.js +0 -24
  1063. package/demos/code/msg/pt-br.js +0 -24
  1064. package/demos/code/msg/ro.js +0 -24
  1065. package/demos/code/msg/ru.js +0 -24
  1066. package/demos/code/msg/sc.js +0 -24
  1067. package/demos/code/msg/sk.js +0 -24
  1068. package/demos/code/msg/sr.js +0 -24
  1069. package/demos/code/msg/sv.js +0 -24
  1070. package/demos/code/msg/ta.js +0 -24
  1071. package/demos/code/msg/th.js +0 -24
  1072. package/demos/code/msg/tlh.js +0 -24
  1073. package/demos/code/msg/tr.js +0 -24
  1074. package/demos/code/msg/uk.js +0 -24
  1075. package/demos/code/msg/vi.js +0 -24
  1076. package/demos/code/msg/zh-hans.js +0 -24
  1077. package/demos/code/msg/zh-hant.js +0 -24
  1078. package/demos/code/style.css +0 -184
  1079. package/demos/index.html +0 -68
  1080. package/demos/storage/icon.png +0 -0
  1081. package/demos/storage/index.html +0 -104
  1082. package/eslint.config.mjs +0 -314
  1083. package/generators/dart/dart_generator.ts +0 -321
  1084. package/generators/dart/lists.ts +0 -525
  1085. package/generators/dart/logic.ts +0 -157
  1086. package/generators/dart/loops.ts +0 -217
  1087. package/generators/dart/math.ts +0 -559
  1088. package/generators/dart/procedures.ts +0 -138
  1089. package/generators/dart/text.ts +0 -405
  1090. package/generators/dart/variables.ts +0 -32
  1091. package/generators/dart/variables_dynamic.ts +0 -17
  1092. package/generators/dart.ts +0 -50
  1093. package/generators/javascript/javascript_generator.ts +0 -346
  1094. package/generators/javascript/lists.ts +0 -465
  1095. package/generators/javascript/logic.ts +0 -155
  1096. package/generators/javascript/loops.ts +0 -245
  1097. package/generators/javascript/math.ts +0 -450
  1098. package/generators/javascript/procedures.ts +0 -142
  1099. package/generators/javascript/text.ts +0 -418
  1100. package/generators/javascript/variables.ts +0 -32
  1101. package/generators/javascript/variables_dynamic.ts +0 -17
  1102. package/generators/javascript.ts +0 -46
  1103. package/generators/lua/lists.ts +0 -445
  1104. package/generators/lua/logic.ts +0 -144
  1105. package/generators/lua/loops.ts +0 -192
  1106. package/generators/lua/lua_generator.ts +0 -225
  1107. package/generators/lua/math.ts +0 -473
  1108. package/generators/lua/procedures.ts +0 -144
  1109. package/generators/lua/text.ts +0 -380
  1110. package/generators/lua/variables.ts +0 -31
  1111. package/generators/lua/variables_dynamic.ts +0 -17
  1112. package/generators/lua.ts +0 -44
  1113. package/generators/php/lists.ts +0 -585
  1114. package/generators/php/logic.ts +0 -157
  1115. package/generators/php/loops.ts +0 -218
  1116. package/generators/php/math.ts +0 -408
  1117. package/generators/php/php_generator.ts +0 -320
  1118. package/generators/php/procedures.ts +0 -159
  1119. package/generators/php/text.ts +0 -315
  1120. package/generators/php/variables.ts +0 -32
  1121. package/generators/php/variables_dynamic.ts +0 -17
  1122. package/generators/php.ts +0 -46
  1123. package/generators/python/lists.ts +0 -398
  1124. package/generators/python/logic.ts +0 -152
  1125. package/generators/python/loops.ts +0 -251
  1126. package/generators/python/math.ts +0 -434
  1127. package/generators/python/procedures.ts +0 -159
  1128. package/generators/python/python_generator.ts +0 -355
  1129. package/generators/python/text.ts +0 -338
  1130. package/generators/python/variables.ts +0 -31
  1131. package/generators/python/variables_dynamic.ts +0 -17
  1132. package/generators/python.ts +0 -51
  1133. package/gulpfile.mjs +0 -100
  1134. package/jsconfig.json +0 -7
  1135. package/msg/json/README.md +0 -33
  1136. package/msg/json/ab.json +0 -222
  1137. package/msg/json/ace.json +0 -7
  1138. package/msg/json/af.json +0 -34
  1139. package/msg/json/am.json +0 -30
  1140. package/msg/json/ar.json +0 -355
  1141. package/msg/json/ast.json +0 -10
  1142. package/msg/json/az.json +0 -334
  1143. package/msg/json/ba.json +0 -211
  1144. package/msg/json/bcc.json +0 -290
  1145. package/msg/json/be-tarask.json +0 -335
  1146. package/msg/json/be.json +0 -326
  1147. package/msg/json/bg.json +0 -347
  1148. package/msg/json/bn.json +0 -189
  1149. package/msg/json/br.json +0 -334
  1150. package/msg/json/bs.json +0 -166
  1151. package/msg/json/ca.json +0 -341
  1152. package/msg/json/cdo.json +0 -6
  1153. package/msg/json/ce.json +0 -328
  1154. package/msg/json/constants.json +0 -12
  1155. package/msg/json/cs.json +0 -344
  1156. package/msg/json/da.json +0 -346
  1157. package/msg/json/de.json +0 -369
  1158. package/msg/json/diq.json +0 -264
  1159. package/msg/json/dtp.json +0 -198
  1160. package/msg/json/dty.json +0 -97
  1161. package/msg/json/ee.json +0 -160
  1162. package/msg/json/el.json +0 -356
  1163. package/msg/json/en-gb.json +0 -199
  1164. package/msg/json/en.json +0 -423
  1165. package/msg/json/eo.json +0 -337
  1166. package/msg/json/es.json +0 -361
  1167. package/msg/json/et.json +0 -335
  1168. package/msg/json/eu.json +0 -219
  1169. package/msg/json/fa.json +0 -342
  1170. package/msg/json/fi.json +0 -350
  1171. package/msg/json/fo.json +0 -46
  1172. package/msg/json/fr.json +0 -374
  1173. package/msg/json/frr.json +0 -6
  1174. package/msg/json/gl.json +0 -338
  1175. package/msg/json/gn.json +0 -54
  1176. package/msg/json/gor.json +0 -87
  1177. package/msg/json/ha.json +0 -313
  1178. package/msg/json/hak.json +0 -17
  1179. package/msg/json/he.json +0 -355
  1180. package/msg/json/hi.json +0 -318
  1181. package/msg/json/hr.json +0 -337
  1182. package/msg/json/hrx.json +0 -287
  1183. package/msg/json/hsb.json +0 -128
  1184. package/msg/json/hu.json +0 -349
  1185. package/msg/json/hy.json +0 -337
  1186. package/msg/json/ia.json +0 -337
  1187. package/msg/json/id.json +0 -338
  1188. package/msg/json/ig.json +0 -323
  1189. package/msg/json/inh.json +0 -80
  1190. package/msg/json/is.json +0 -331
  1191. package/msg/json/it.json +0 -346
  1192. package/msg/json/ja.json +0 -362
  1193. package/msg/json/ka.json +0 -14
  1194. package/msg/json/kab.json +0 -323
  1195. package/msg/json/kbd-cyrl.json +0 -84
  1196. package/msg/json/km.json +0 -29
  1197. package/msg/json/kn.json +0 -333
  1198. package/msg/json/ko.json +0 -377
  1199. package/msg/json/ksh.json +0 -43
  1200. package/msg/json/ku-latn.json +0 -41
  1201. package/msg/json/ky.json +0 -71
  1202. package/msg/json/la.json +0 -6
  1203. package/msg/json/lb.json +0 -156
  1204. package/msg/json/lki.json +0 -282
  1205. package/msg/json/lo.json +0 -92
  1206. package/msg/json/lrc.json +0 -123
  1207. package/msg/json/lt.json +0 -321
  1208. package/msg/json/lv.json +0 -324
  1209. package/msg/json/mg.json +0 -58
  1210. package/msg/json/mk.json +0 -178
  1211. package/msg/json/ml.json +0 -35
  1212. package/msg/json/mnw.json +0 -90
  1213. package/msg/json/ms.json +0 -300
  1214. package/msg/json/my.json +0 -57
  1215. package/msg/json/mzn.json +0 -6
  1216. package/msg/json/nb.json +0 -331
  1217. package/msg/json/ne.json +0 -247
  1218. package/msg/json/nl.json +0 -358
  1219. package/msg/json/oc.json +0 -194
  1220. package/msg/json/olo.json +0 -37
  1221. package/msg/json/pa.json +0 -75
  1222. package/msg/json/pl.json +0 -358
  1223. package/msg/json/pms.json +0 -325
  1224. package/msg/json/ps.json +0 -50
  1225. package/msg/json/pt-br.json +0 -371
  1226. package/msg/json/pt.json +0 -360
  1227. package/msg/json/qqq.json +0 -430
  1228. package/msg/json/ro.json +0 -333
  1229. package/msg/json/ru.json +0 -363
  1230. package/msg/json/sc.json +0 -283
  1231. package/msg/json/sco.json +0 -11
  1232. package/msg/json/sd.json +0 -158
  1233. package/msg/json/shn.json +0 -109
  1234. package/msg/json/si.json +0 -16
  1235. package/msg/json/sk.json +0 -339
  1236. package/msg/json/skr-arab.json +0 -117
  1237. package/msg/json/sl.json +0 -355
  1238. package/msg/json/smn.json +0 -133
  1239. package/msg/json/sq.json +0 -343
  1240. package/msg/json/sr-latn.json +0 -324
  1241. package/msg/json/sr.json +0 -349
  1242. package/msg/json/sv.json +0 -350
  1243. package/msg/json/sw.json +0 -12
  1244. package/msg/json/synonyms.json +0 -22
  1245. package/msg/json/ta.json +0 -306
  1246. package/msg/json/tcy.json +0 -316
  1247. package/msg/json/tdd.json +0 -110
  1248. package/msg/json/te.json +0 -101
  1249. package/msg/json/th.json +0 -333
  1250. package/msg/json/ti.json +0 -50
  1251. package/msg/json/tl.json +0 -149
  1252. package/msg/json/tlh.json +0 -179
  1253. package/msg/json/tr.json +0 -370
  1254. package/msg/json/ug-arab.json +0 -180
  1255. package/msg/json/uk.json +0 -346
  1256. package/msg/json/ur.json +0 -118
  1257. package/msg/json/uz.json +0 -36
  1258. package/msg/json/vi.json +0 -345
  1259. package/msg/json/xmf.json +0 -99
  1260. package/msg/json/yo.json +0 -316
  1261. package/msg/json/zgh.json +0 -83
  1262. package/msg/json/zh-hans.json +0 -374
  1263. package/msg/json/zh-hant.json +0 -362
  1264. package/msg/messages.js +0 -1695
  1265. package/scripts/gulpfiles/appengine_tasks.mjs +0 -189
  1266. package/scripts/gulpfiles/build_tasks.mjs +0 -753
  1267. package/scripts/gulpfiles/config.mjs +0 -40
  1268. package/scripts/gulpfiles/docs_tasks.mjs +0 -146
  1269. package/scripts/gulpfiles/git_tasks.mjs +0 -167
  1270. package/scripts/gulpfiles/helper_tasks.mjs +0 -25
  1271. package/scripts/gulpfiles/package_tasks.mjs +0 -257
  1272. package/scripts/gulpfiles/release_tasks.mjs +0 -174
  1273. package/scripts/gulpfiles/test_tasks.mjs +0 -409
  1274. package/scripts/helpers.js +0 -74
  1275. package/scripts/i18n/common.py +0 -233
  1276. package/scripts/i18n/create_messages.py +0 -167
  1277. package/scripts/i18n/dedup_json.py +0 -72
  1278. package/scripts/i18n/js_to_json.py +0 -135
  1279. package/scripts/i18n/tests.py +0 -46
  1280. package/scripts/migration/renamings.json5 +0 -1599
  1281. package/scripts/package/index.js +0 -23
  1282. package/scripts/package/templates/umd-msg.template +0 -16
  1283. package/scripts/package/templates/umd.template +0 -13
  1284. package/scripts/themes/blockStyles_example.json +0 -11
  1285. package/scripts/themes/create_blockStyles.py +0 -184
  1286. package/scripts/tsick.js +0 -86
  1287. package/tests/browser/.mocharc.js +0 -7
  1288. package/tests/browser/test/basic_block_factory_test.mjs +0 -44
  1289. package/tests/browser/test/basic_block_test.mjs +0 -38
  1290. package/tests/browser/test/basic_playground_test.mjs +0 -461
  1291. package/tests/browser/test/block_undo_test.mjs +0 -50
  1292. package/tests/browser/test/clipboard_test.mjs +0 -611
  1293. package/tests/browser/test/delete_blocks_test.mjs +0 -217
  1294. package/tests/browser/test/extensive_test.mjs +0 -191
  1295. package/tests/browser/test/field_edits_test.mjs +0 -61
  1296. package/tests/browser/test/hooks.mjs +0 -23
  1297. package/tests/browser/test/mutator_test.mjs +0 -87
  1298. package/tests/browser/test/procedure_test.mjs +0 -109
  1299. package/tests/browser/test/test_setup.mjs +0 -623
  1300. package/tests/browser/test/toolbox_drag_test.mjs +0 -219
  1301. package/tests/browser/test/workspace_comment_test.mjs +0 -220
  1302. package/tests/compile/index.html +0 -43
  1303. package/tests/compile/main.js +0 -53
  1304. package/tests/compile/test_blocks.js +0 -47
  1305. package/tests/compile/webdriver.js +0 -81
  1306. package/tests/generators/functions.xml +0 -561
  1307. package/tests/generators/golden/generated.dart +0 -1604
  1308. package/tests/generators/golden/generated.js +0 -1552
  1309. package/tests/generators/golden/generated.lua +0 -1828
  1310. package/tests/generators/golden/generated.php +0 -1611
  1311. package/tests/generators/golden/generated.py +0 -1407
  1312. package/tests/generators/index.html +0 -408
  1313. package/tests/generators/lists.xml +0 -8675
  1314. package/tests/generators/logic.xml +0 -1019
  1315. package/tests/generators/loops1.xml +0 -345
  1316. package/tests/generators/loops2.xml +0 -891
  1317. package/tests/generators/loops3.xml +0 -735
  1318. package/tests/generators/math.xml +0 -2077
  1319. package/tests/generators/text.xml +0 -4651
  1320. package/tests/generators/unittest.js +0 -103
  1321. package/tests/generators/unittest_dart.js +0 -163
  1322. package/tests/generators/unittest_javascript.js +0 -167
  1323. package/tests/generators/unittest_lua.js +0 -165
  1324. package/tests/generators/unittest_php.js +0 -154
  1325. package/tests/generators/unittest_python.js +0 -138
  1326. package/tests/generators/variables.xml +0 -68
  1327. package/tests/generators/webdriver.js +0 -123
  1328. package/tests/media/200px.png +0 -0
  1329. package/tests/media/30px.png +0 -0
  1330. package/tests/media/50px.png +0 -0
  1331. package/tests/media/a.png +0 -0
  1332. package/tests/media/arrow.png +0 -0
  1333. package/tests/media/b.png +0 -0
  1334. package/tests/media/c.png +0 -0
  1335. package/tests/media/d.png +0 -0
  1336. package/tests/media/e.png +0 -0
  1337. package/tests/media/f.png +0 -0
  1338. package/tests/media/g.png +0 -0
  1339. package/tests/media/h.png +0 -0
  1340. package/tests/media/i.png +0 -0
  1341. package/tests/media/j.png +0 -0
  1342. package/tests/media/k.png +0 -0
  1343. package/tests/media/l.png +0 -0
  1344. package/tests/media/m.png +0 -0
  1345. package/tests/migration/renamings.schema.json +0 -59
  1346. package/tests/migration/validate-renamings.mjs +0 -63
  1347. package/tests/mocha/.mocharc.js +0 -6
  1348. package/tests/mocha/block_json_test.js +0 -777
  1349. package/tests/mocha/block_test.js +0 -2949
  1350. package/tests/mocha/blocks/lists_test.js +0 -238
  1351. package/tests/mocha/blocks/logic_ternary_test.js +0 -320
  1352. package/tests/mocha/blocks/loops_test.js +0 -56
  1353. package/tests/mocha/blocks/procedures_test.js +0 -2509
  1354. package/tests/mocha/blocks/variables_test.js +0 -345
  1355. package/tests/mocha/clipboard_test.js +0 -263
  1356. package/tests/mocha/comment_deserialization_test.js +0 -122
  1357. package/tests/mocha/comment_test.js +0 -215
  1358. package/tests/mocha/comment_view_test.js +0 -188
  1359. package/tests/mocha/connection_checker_test.js +0 -694
  1360. package/tests/mocha/connection_db_test.js +0 -363
  1361. package/tests/mocha/connection_test.js +0 -3738
  1362. package/tests/mocha/contextmenu_items_test.js +0 -653
  1363. package/tests/mocha/contextmenu_test.js +0 -73
  1364. package/tests/mocha/cursor_test.js +0 -922
  1365. package/tests/mocha/dialog_test.js +0 -168
  1366. package/tests/mocha/dropdowndiv_test.js +0 -458
  1367. package/tests/mocha/event_block_change_test.js +0 -126
  1368. package/tests/mocha/event_block_create_test.js +0 -109
  1369. package/tests/mocha/event_block_delete_test.js +0 -55
  1370. package/tests/mocha/event_block_drag_test.js +0 -36
  1371. package/tests/mocha/event_block_field_intermediate_change_test.js +0 -67
  1372. package/tests/mocha/event_block_move_test.js +0 -39
  1373. package/tests/mocha/event_bubble_open_test.js +0 -42
  1374. package/tests/mocha/event_click_test.js +0 -40
  1375. package/tests/mocha/event_comment_change_test.js +0 -39
  1376. package/tests/mocha/event_comment_collapse_test.js +0 -34
  1377. package/tests/mocha/event_comment_create_test.js +0 -38
  1378. package/tests/mocha/event_comment_delete_test.js +0 -38
  1379. package/tests/mocha/event_comment_drag_test.js +0 -35
  1380. package/tests/mocha/event_comment_move_test.js +0 -40
  1381. package/tests/mocha/event_comment_resize_test.js +0 -38
  1382. package/tests/mocha/event_selected_test.js +0 -41
  1383. package/tests/mocha/event_test.js +0 -1668
  1384. package/tests/mocha/event_theme_change_test.js +0 -36
  1385. package/tests/mocha/event_toolbox_item_select_test.js +0 -64
  1386. package/tests/mocha/event_trashcan_open_test.js +0 -36
  1387. package/tests/mocha/event_var_create_test.js +0 -54
  1388. package/tests/mocha/event_var_delete_test.js +0 -54
  1389. package/tests/mocha/event_var_rename_test.js +0 -39
  1390. package/tests/mocha/event_var_type_change_test.js +0 -43
  1391. package/tests/mocha/event_viewport_test.js +0 -39
  1392. package/tests/mocha/extensions_test.js +0 -613
  1393. package/tests/mocha/field_checkbox_test.js +0 -299
  1394. package/tests/mocha/field_colour_test.js +0 -395
  1395. package/tests/mocha/field_dropdown_test.js +0 -328
  1396. package/tests/mocha/field_image_test.js +0 -351
  1397. package/tests/mocha/field_label_serializable_test.js +0 -252
  1398. package/tests/mocha/field_label_test.js +0 -226
  1399. package/tests/mocha/field_number_test.js +0 -505
  1400. package/tests/mocha/field_registry_test.js +0 -115
  1401. package/tests/mocha/field_test.js +0 -821
  1402. package/tests/mocha/field_textinput_test.js +0 -593
  1403. package/tests/mocha/field_variable_test.js +0 -644
  1404. package/tests/mocha/flyout_test.js +0 -650
  1405. package/tests/mocha/focus_manager_test.js +0 -5979
  1406. package/tests/mocha/focusable_tree_traverser_test.js +0 -602
  1407. package/tests/mocha/generator_test.js +0 -233
  1408. package/tests/mocha/gesture_test.js +0 -133
  1409. package/tests/mocha/icon_test.js +0 -431
  1410. package/tests/mocha/index.html +0 -354
  1411. package/tests/mocha/input_test.js +0 -296
  1412. package/tests/mocha/insertion_marker_test.js +0 -432
  1413. package/tests/mocha/jso_deserialization_test.js +0 -848
  1414. package/tests/mocha/jso_serialization_test.js +0 -1068
  1415. package/tests/mocha/json_test.js +0 -303
  1416. package/tests/mocha/keyboard_navigation_controller_test.js +0 -37
  1417. package/tests/mocha/layering_test.js +0 -104
  1418. package/tests/mocha/menu_item_test.js +0 -176
  1419. package/tests/mocha/metrics_test.js +0 -671
  1420. package/tests/mocha/mutator_test.js +0 -87
  1421. package/tests/mocha/names_test.js +0 -97
  1422. package/tests/mocha/navigation_test.js +0 -876
  1423. package/tests/mocha/old_workspace_comment_test.js +0 -256
  1424. package/tests/mocha/procedure_map_test.js +0 -52
  1425. package/tests/mocha/rect_test.js +0 -1668
  1426. package/tests/mocha/registry_test.js +0 -281
  1427. package/tests/mocha/render_management_test.js +0 -127
  1428. package/tests/mocha/serializer_test.js +0 -2100
  1429. package/tests/mocha/shortcut_items_test.js +0 -563
  1430. package/tests/mocha/shortcut_registry_test.js +0 -533
  1431. package/tests/mocha/test_helpers/block_definitions.js +0 -204
  1432. package/tests/mocha/test_helpers/code_generation.js +0 -114
  1433. package/tests/mocha/test_helpers/common.js +0 -106
  1434. package/tests/mocha/test_helpers/events.js +0 -290
  1435. package/tests/mocha/test_helpers/fields.js +0 -310
  1436. package/tests/mocha/test_helpers/icon_mocks.js +0 -130
  1437. package/tests/mocha/test_helpers/procedures.js +0 -304
  1438. package/tests/mocha/test_helpers/serialization.js +0 -124
  1439. package/tests/mocha/test_helpers/setup_teardown.js +0 -232
  1440. package/tests/mocha/test_helpers/toolbox_definitions.js +0 -269
  1441. package/tests/mocha/test_helpers/user_input.js +0 -62
  1442. package/tests/mocha/test_helpers/variables.js +0 -27
  1443. package/tests/mocha/test_helpers/warnings.js +0 -83
  1444. package/tests/mocha/test_helpers/workspace.js +0 -1659
  1445. package/tests/mocha/theme_test.js +0 -307
  1446. package/tests/mocha/toast_test.js +0 -129
  1447. package/tests/mocha/toolbox_test.js +0 -821
  1448. package/tests/mocha/tooltip_test.js +0 -276
  1449. package/tests/mocha/touch_test.js +0 -109
  1450. package/tests/mocha/trashcan_test.js +0 -376
  1451. package/tests/mocha/utils_test.js +0 -557
  1452. package/tests/mocha/variable_map_test.js +0 -470
  1453. package/tests/mocha/variable_model_test.js +0 -85
  1454. package/tests/mocha/webdriver.js +0 -110
  1455. package/tests/mocha/widget_div_test.js +0 -427
  1456. package/tests/mocha/workspace_comment_test.js +0 -197
  1457. package/tests/mocha/workspace_svg_test.js +0 -922
  1458. package/tests/mocha/workspace_test.js +0 -24
  1459. package/tests/mocha/xml_test.js +0 -893
  1460. package/tests/mocha/zoom_controls_test.js +0 -81
  1461. package/tests/multi_playground.html +0 -482
  1462. package/tests/node/.mocharc.js +0 -6
  1463. package/tests/node/run_node_test.mjs +0 -191
  1464. package/tests/playground.html +0 -1280
  1465. package/tests/playgrounds/advanced_playground.html +0 -188
  1466. package/tests/playgrounds/iframe.html +0 -40
  1467. package/tests/playgrounds/screenshot.js +0 -123
  1468. package/tests/scripts/check_metadata.sh +0 -170
  1469. package/tests/scripts/load.mjs +0 -140
  1470. package/tests/scripts/setup_linux_env.sh +0 -7
  1471. package/tests/scripts/update_metadata.sh +0 -46
  1472. package/tests/themes/test_themes.js +0 -62
  1473. package/tests/typescript/README.md +0 -4
  1474. package/tests/typescript/src/field/different_user_input.ts +0 -81
  1475. package/tests/typescript/src/generators/dart.ts +0 -24
  1476. package/tests/typescript/src/generators/javascript.ts +0 -28
  1477. package/tests/typescript/src/generators/lua.ts +0 -24
  1478. package/tests/typescript/src/generators/php.ts +0 -24
  1479. package/tests/typescript/src/generators/python.ts +0 -24
  1480. package/tests/typescript/src/generators.ts +0 -33
  1481. package/tests/typescript/src/msg.ts +0 -20
  1482. package/tests/typescript/tsconfig.json +0 -20
  1483. package/tests/xml/README.txt +0 -11
  1484. package/tests/xml/blockly.xsd +0 -178
  1485. package/tests/xml/invalid.xml +0 -6
  1486. package/tests/xml/toolbox.xml +0 -311
  1487. package/tests/xml/workspace.xml +0 -114
  1488. package/tsconfig.json +0 -37
  1489. package/tsdoc.json +0 -25
  1490. package/typings/README.md +0 -5
  1491. package/typings/templates/blockly-header.template +0 -11
  1492. package/typings/templates/blockly-interfaces.template +0 -83
  1493. package/typings/templates/msg.template +0 -15
  1494. package/typings/tsconfig.json +0 -23
  1495. /package/{scripts/package/README.md → README.md} +0 -0
  1496. /package/{typings/blocks.d.ts → blocks.d.ts} +0 -0
  1497. /package/{scripts/package/core-node.js → core-node.js} +0 -0
  1498. /package/{typings/core.d.ts → core.d.ts} +0 -0
  1499. /package/{typings/dart.d.ts → dart.d.ts} +0 -0
  1500. /package/{typings/index.d.ts → index.d.ts} +0 -0
  1501. /package/{typings/javascript.d.ts → javascript.d.ts} +0 -0
  1502. /package/{typings/lua.d.ts → lua.d.ts} +0 -0
  1503. /package/{typings/msg → msg}/ab.d.ts +0 -0
  1504. /package/{typings/msg → msg}/ace.d.ts +0 -0
  1505. /package/{typings/msg → msg}/af.d.ts +0 -0
  1506. /package/{typings/msg → msg}/am.d.ts +0 -0
  1507. /package/{typings/msg → msg}/ar.d.ts +0 -0
  1508. /package/{typings/msg → msg}/ast.d.ts +0 -0
  1509. /package/{typings/msg → msg}/az.d.ts +0 -0
  1510. /package/{typings/msg → msg}/ba.d.ts +0 -0
  1511. /package/{typings/msg → msg}/bcc.d.ts +0 -0
  1512. /package/{typings/msg → msg}/be-tarask.d.ts +0 -0
  1513. /package/{typings/msg → msg}/be.d.ts +0 -0
  1514. /package/{typings/msg → msg}/bg.d.ts +0 -0
  1515. /package/{typings/msg → msg}/bn.d.ts +0 -0
  1516. /package/{typings/msg → msg}/br.d.ts +0 -0
  1517. /package/{typings/msg → msg}/bs.d.ts +0 -0
  1518. /package/{typings/msg → msg}/ca.d.ts +0 -0
  1519. /package/{typings/msg → msg}/cdo.d.ts +0 -0
  1520. /package/{typings/msg → msg}/ce.d.ts +0 -0
  1521. /package/{typings/msg → msg}/cs.d.ts +0 -0
  1522. /package/{typings/msg → msg}/da.d.ts +0 -0
  1523. /package/{typings/msg → msg}/de.d.ts +0 -0
  1524. /package/{typings/msg → msg}/diq.d.ts +0 -0
  1525. /package/{typings/msg → msg}/dtp.d.ts +0 -0
  1526. /package/{typings/msg → msg}/dty.d.ts +0 -0
  1527. /package/{typings/msg → msg}/ee.d.ts +0 -0
  1528. /package/{typings/msg → msg}/el.d.ts +0 -0
  1529. /package/{typings/msg → msg}/en-gb.d.ts +0 -0
  1530. /package/{typings/msg → msg}/en.d.ts +0 -0
  1531. /package/{typings/msg → msg}/eo.d.ts +0 -0
  1532. /package/{typings/msg → msg}/es.d.ts +0 -0
  1533. /package/{typings/msg → msg}/et.d.ts +0 -0
  1534. /package/{typings/msg → msg}/eu.d.ts +0 -0
  1535. /package/{typings/msg → msg}/fa.d.ts +0 -0
  1536. /package/{typings/msg → msg}/fi.d.ts +0 -0
  1537. /package/{typings/msg → msg}/fo.d.ts +0 -0
  1538. /package/{typings/msg → msg}/fr.d.ts +0 -0
  1539. /package/{typings/msg → msg}/frr.d.ts +0 -0
  1540. /package/{typings/msg → msg}/gl.d.ts +0 -0
  1541. /package/{typings/msg → msg}/gn.d.ts +0 -0
  1542. /package/{typings/msg → msg}/gor.d.ts +0 -0
  1543. /package/{typings/msg → msg}/ha.d.ts +0 -0
  1544. /package/{typings/msg → msg}/hak.d.ts +0 -0
  1545. /package/{typings/msg → msg}/he.d.ts +0 -0
  1546. /package/{typings/msg → msg}/hi.d.ts +0 -0
  1547. /package/{typings/msg → msg}/hr.d.ts +0 -0
  1548. /package/{typings/msg → msg}/hrx.d.ts +0 -0
  1549. /package/{typings/msg → msg}/hsb.d.ts +0 -0
  1550. /package/{typings/msg → msg}/hu.d.ts +0 -0
  1551. /package/{typings/msg → msg}/hy.d.ts +0 -0
  1552. /package/{typings/msg → msg}/ia.d.ts +0 -0
  1553. /package/{typings/msg → msg}/id.d.ts +0 -0
  1554. /package/{typings/msg → msg}/ig.d.ts +0 -0
  1555. /package/{typings/msg → msg}/inh.d.ts +0 -0
  1556. /package/{typings/msg → msg}/is.d.ts +0 -0
  1557. /package/{typings/msg → msg}/it.d.ts +0 -0
  1558. /package/{typings/msg → msg}/ja.d.ts +0 -0
  1559. /package/{typings/msg → msg}/ka.d.ts +0 -0
  1560. /package/{typings/msg → msg}/kab.d.ts +0 -0
  1561. /package/{typings/msg → msg}/kbd-cyrl.d.ts +0 -0
  1562. /package/{typings/msg → msg}/km.d.ts +0 -0
  1563. /package/{typings/msg → msg}/kn.d.ts +0 -0
  1564. /package/{typings/msg → msg}/ko.d.ts +0 -0
  1565. /package/{typings/msg → msg}/ksh.d.ts +0 -0
  1566. /package/{typings/msg → msg}/ku-latn.d.ts +0 -0
  1567. /package/{typings/msg → msg}/ky.d.ts +0 -0
  1568. /package/{typings/msg → msg}/la.d.ts +0 -0
  1569. /package/{typings/msg → msg}/lb.d.ts +0 -0
  1570. /package/{typings/msg → msg}/lki.d.ts +0 -0
  1571. /package/{typings/msg → msg}/lo.d.ts +0 -0
  1572. /package/{typings/msg → msg}/lrc.d.ts +0 -0
  1573. /package/{typings/msg → msg}/lt.d.ts +0 -0
  1574. /package/{typings/msg → msg}/lv.d.ts +0 -0
  1575. /package/{typings/msg → msg}/mg.d.ts +0 -0
  1576. /package/{typings/msg → msg}/mk.d.ts +0 -0
  1577. /package/{typings/msg → msg}/ml.d.ts +0 -0
  1578. /package/{typings/msg → msg}/mnw.d.ts +0 -0
  1579. /package/{typings/msg → msg}/ms.d.ts +0 -0
  1580. /package/{typings/msg → msg}/msg.d.ts +0 -0
  1581. /package/{typings/msg → msg}/my.d.ts +0 -0
  1582. /package/{typings/msg → msg}/mzn.d.ts +0 -0
  1583. /package/{typings/msg → msg}/nb.d.ts +0 -0
  1584. /package/{typings/msg → msg}/ne.d.ts +0 -0
  1585. /package/{typings/msg → msg}/nl.d.ts +0 -0
  1586. /package/{typings/msg → msg}/oc.d.ts +0 -0
  1587. /package/{typings/msg → msg}/olo.d.ts +0 -0
  1588. /package/{typings/msg → msg}/pa.d.ts +0 -0
  1589. /package/{typings/msg → msg}/pl.d.ts +0 -0
  1590. /package/{typings/msg → msg}/pms.d.ts +0 -0
  1591. /package/{typings/msg → msg}/ps.d.ts +0 -0
  1592. /package/{typings/msg → msg}/pt-br.d.ts +0 -0
  1593. /package/{typings/msg → msg}/pt.d.ts +0 -0
  1594. /package/{typings/msg → msg}/ro.d.ts +0 -0
  1595. /package/{typings/msg → msg}/ru.d.ts +0 -0
  1596. /package/{typings/msg → msg}/sc.d.ts +0 -0
  1597. /package/{typings/msg → msg}/sco.d.ts +0 -0
  1598. /package/{typings/msg → msg}/sd.d.ts +0 -0
  1599. /package/{typings/msg → msg}/shn.d.ts +0 -0
  1600. /package/{typings/msg → msg}/si.d.ts +0 -0
  1601. /package/{typings/msg → msg}/sk.d.ts +0 -0
  1602. /package/{typings/msg → msg}/skr-arab.d.ts +0 -0
  1603. /package/{typings/msg → msg}/sl.d.ts +0 -0
  1604. /package/{typings/msg → msg}/smn.d.ts +0 -0
  1605. /package/{typings/msg → msg}/sq.d.ts +0 -0
  1606. /package/{typings/msg → msg}/sr-latn.d.ts +0 -0
  1607. /package/{typings/msg → msg}/sr.d.ts +0 -0
  1608. /package/{typings/msg → msg}/sv.d.ts +0 -0
  1609. /package/{typings/msg → msg}/sw.d.ts +0 -0
  1610. /package/{typings/msg → msg}/ta.d.ts +0 -0
  1611. /package/{typings/msg → msg}/tcy.d.ts +0 -0
  1612. /package/{typings/msg → msg}/tdd.d.ts +0 -0
  1613. /package/{typings/msg → msg}/te.d.ts +0 -0
  1614. /package/{typings/msg → msg}/th.d.ts +0 -0
  1615. /package/{typings/msg → msg}/ti.d.ts +0 -0
  1616. /package/{typings/msg → msg}/tl.d.ts +0 -0
  1617. /package/{typings/msg → msg}/tlh.d.ts +0 -0
  1618. /package/{typings/msg → msg}/tr.d.ts +0 -0
  1619. /package/{typings/msg → msg}/ug-arab.d.ts +0 -0
  1620. /package/{typings/msg → msg}/uk.d.ts +0 -0
  1621. /package/{typings/msg → msg}/ur.d.ts +0 -0
  1622. /package/{typings/msg → msg}/uz.d.ts +0 -0
  1623. /package/{typings/msg → msg}/vi.d.ts +0 -0
  1624. /package/{typings/msg → msg}/xmf.d.ts +0 -0
  1625. /package/{typings/msg → msg}/yo.d.ts +0 -0
  1626. /package/{typings/msg → msg}/zgh.d.ts +0 -0
  1627. /package/{typings/msg → msg}/zh-hans.d.ts +0 -0
  1628. /package/{typings/msg → msg}/zh-hant.d.ts +0 -0
  1629. /package/{typings/php.d.ts → php.d.ts} +0 -0
  1630. /package/{typings/python.d.ts → python.d.ts} +0 -0
@@ -1,2954 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2014 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /**
8
- * Object representing a workspace rendered as SVG.
9
- *
10
- * @class
11
- */
12
- // Former goog.module ID: Blockly.WorkspaceSvg
13
-
14
- // Unused import preserved for side-effects. Remove if unneeded.
15
- import './events/events_block_create.js';
16
- // Unused import preserved for side-effects. Remove if unneeded.
17
- import './events/events_theme_change.js';
18
- // Unused import preserved for side-effects. Remove if unneeded.
19
- import './events/events_viewport.js';
20
-
21
- import type {Block} from './block.js';
22
- import type {BlockSvg} from './block_svg.js';
23
- import type {BlocklyOptions} from './blockly_options.js';
24
- import * as browserEvents from './browser_events.js';
25
- import {TextInputBubble} from './bubbles/textinput_bubble.js';
26
- import {COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER} from './comments/collapse_comment_bar_button.js';
27
- import {COMMENT_EDITOR_FOCUS_IDENTIFIER} from './comments/comment_editor.js';
28
- import {COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER} from './comments/delete_comment_bar_button.js';
29
- import {RenderedWorkspaceComment} from './comments/rendered_workspace_comment.js';
30
- import {WorkspaceComment} from './comments/workspace_comment.js';
31
- import * as common from './common.js';
32
- import {ComponentManager} from './component_manager.js';
33
- import {ConnectionDB} from './connection_db.js';
34
- import * as ContextMenu from './contextmenu.js';
35
- import {
36
- ContextMenuOption,
37
- ContextMenuRegistry,
38
- } from './contextmenu_registry.js';
39
- import * as dropDownDiv from './dropdowndiv.js';
40
- import {Abstract as AbstractEvent} from './events/events.js';
41
- import {EventType} from './events/type.js';
42
- import * as eventUtils from './events/utils.js';
43
- import {Flyout} from './flyout_base.js';
44
- import type {FlyoutButton} from './flyout_button.js';
45
- import {getFocusManager} from './focus_manager.js';
46
- import {Gesture} from './gesture.js';
47
- import {Grid} from './grid.js';
48
- import {MutatorIcon} from './icons/mutator_icon.js';
49
- import {isAutoHideable} from './interfaces/i_autohideable.js';
50
- import type {IBoundedElement} from './interfaces/i_bounded_element.js';
51
- import {IContextMenu} from './interfaces/i_contextmenu.js';
52
- import type {IDragTarget} from './interfaces/i_drag_target.js';
53
- import type {IFlyout} from './interfaces/i_flyout.js';
54
- import {
55
- isFocusableNode,
56
- type IFocusableNode,
57
- } from './interfaces/i_focusable_node.js';
58
- import type {IFocusableTree} from './interfaces/i_focusable_tree.js';
59
- import {hasBubble} from './interfaces/i_has_bubble.js';
60
- import type {IMetricsManager} from './interfaces/i_metrics_manager.js';
61
- import type {IToolbox} from './interfaces/i_toolbox.js';
62
- import type {LineCursor} from './keyboard_nav/line_cursor.js';
63
- import type {Marker} from './keyboard_nav/marker.js';
64
- import {LayerManager} from './layer_manager.js';
65
- import {MarkerManager} from './marker_manager.js';
66
- import {Msg} from './msg.js';
67
- import {Navigator} from './navigator.js';
68
- import {Options} from './options.js';
69
- import * as Procedures from './procedures.js';
70
- import * as registry from './registry.js';
71
- import * as blockRendering from './renderers/common/block_rendering.js';
72
- import type {Renderer} from './renderers/common/renderer.js';
73
- import type {ScrollbarPair} from './scrollbar_pair.js';
74
- import type {Theme} from './theme.js';
75
- import {Classic} from './theme/classic.js';
76
- import {ThemeManager} from './theme_manager.js';
77
- import * as Tooltip from './tooltip.js';
78
- import type {Trashcan} from './trashcan.js';
79
- import * as aria from './utils/aria.js';
80
- import * as arrayUtils from './utils/array.js';
81
- import {Coordinate} from './utils/coordinate.js';
82
- import * as dom from './utils/dom.js';
83
- import * as drag from './utils/drag.js';
84
- import type {Metrics} from './utils/metrics.js';
85
- import {Rect} from './utils/rect.js';
86
- import {Size} from './utils/size.js';
87
- import {Svg} from './utils/svg.js';
88
- import * as svgMath from './utils/svg_math.js';
89
- import * as toolbox from './utils/toolbox.js';
90
- import * as userAgent from './utils/useragent.js';
91
- import * as Variables from './variables.js';
92
- import * as VariablesDynamic from './variables_dynamic.js';
93
- import * as WidgetDiv from './widgetdiv.js';
94
- import {Workspace} from './workspace.js';
95
- import {WorkspaceAudio} from './workspace_audio.js';
96
- import {ZoomControls} from './zoom_controls.js';
97
-
98
- /** Margin around the top/bottom/left/right after a zoomToFit call. */
99
- const ZOOM_TO_FIT_MARGIN = 20;
100
-
101
- /**
102
- * Class for a workspace. This is an onscreen area with optional trashcan,
103
- * scrollbars, bubbles, and dragging.
104
- */
105
- export class WorkspaceSvg
106
- extends Workspace
107
- implements IContextMenu, IFocusableNode, IFocusableTree
108
- {
109
- /**
110
- * A wrapper function called when a resize event occurs.
111
- * You can pass the result to `eventHandling.unbind`.
112
- */
113
- private resizeHandlerWrapper: browserEvents.Data | null = null;
114
-
115
- /**
116
- * The render status of an SVG workspace.
117
- * Returns `false` for headless workspaces and true for instances of
118
- * `WorkspaceSvg`.
119
- */
120
- override rendered = true;
121
-
122
- /**
123
- * Whether the workspace is visible. False if the workspace has been hidden
124
- * by calling `setVisible(false)`.
125
- */
126
- private visible = true;
127
-
128
- /**
129
- * Whether this workspace has resizes enabled.
130
- * Disable during batch operations for a performance improvement.
131
- */
132
- private resizesEnabled = true;
133
-
134
- /**
135
- * Current horizontal scrolling offset in pixel units, relative to the
136
- * workspace origin.
137
- *
138
- * It is useful to think about a view, and a canvas moving beneath that
139
- * view. As the canvas moves right, this value becomes more positive, and
140
- * the view is now "seeing" the left side of the canvas. As the canvas moves
141
- * left, this value becomes more negative, and the view is now "seeing" the
142
- * right side of the canvas.
143
- *
144
- * The confusing thing about this value is that it does not, and must not
145
- * include the absoluteLeft offset. This is because it is used to calculate
146
- * the viewLeft value.
147
- *
148
- * The viewLeft is relative to the workspace origin (although in pixel
149
- * units). The workspace origin is the top-left corner of the workspace (at
150
- * least when it is enabled). It is shifted from the top-left of the
151
- * blocklyDiv so as not to be beneath the toolbox.
152
- *
153
- * When the workspace is enabled the viewLeft and workspace origin are at
154
- * the same X location. As the canvas slides towards the right beneath the
155
- * view this value (scrollX) becomes more positive, and the viewLeft becomes
156
- * more negative relative to the workspace origin (imagine the workspace
157
- * origin as a dot on the canvas sliding to the right as the canvas moves).
158
- *
159
- * So if the scrollX were to include the absoluteLeft this would in a way
160
- * "unshift" the workspace origin. This means that the viewLeft would be
161
- * representing the left edge of the blocklyDiv, rather than the left edge
162
- * of the workspace.
163
- */
164
- scrollX = 0;
165
-
166
- /**
167
- * Current vertical scrolling offset in pixel units, relative to the
168
- * workspace origin.
169
- *
170
- * It is useful to think about a view, and a canvas moving beneath that
171
- * view. As the canvas moves down, this value becomes more positive, and the
172
- * view is now "seeing" the upper part of the canvas. As the canvas moves
173
- * up, this value becomes more negative, and the view is "seeing" the lower
174
- * part of the canvas.
175
- *
176
- * This confusing thing about this value is that it does not, and must not
177
- * include the absoluteTop offset. This is because it is used to calculate
178
- * the viewTop value.
179
- *
180
- * The viewTop is relative to the workspace origin (although in pixel
181
- * units). The workspace origin is the top-left corner of the workspace (at
182
- * least when it is enabled). It is shifted from the top-left of the
183
- * blocklyDiv so as not to be beneath the toolbox.
184
- *
185
- * When the workspace is enabled the viewTop and workspace origin are at the
186
- * same Y location. As the canvas slides towards the bottom this value
187
- * (scrollY) becomes more positive, and the viewTop becomes more negative
188
- * relative to the workspace origin (image in the workspace origin as a dot
189
- * on the canvas sliding downwards as the canvas moves).
190
- *
191
- * So if the scrollY were to include the absoluteTop this would in a way
192
- * "unshift" the workspace origin. This means that the viewTop would be
193
- * representing the top edge of the blocklyDiv, rather than the top edge of
194
- * the workspace.
195
- */
196
- scrollY = 0;
197
-
198
- /** Horizontal scroll value when scrolling started in pixel units. */
199
- startScrollX = 0;
200
-
201
- /** Vertical scroll value when scrolling started in pixel units. */
202
- startScrollY = 0;
203
-
204
- /** Current scale. */
205
- scale = 1;
206
-
207
- /** Cached scale value. Used to detect changes in viewport. */
208
- private oldScale = 1;
209
-
210
- /** Cached viewport top value. Used to detect changes in viewport. */
211
- private oldTop = 0;
212
-
213
- /** Cached viewport left value. Used to detect changes in viewport. */
214
- private oldLeft = 0;
215
-
216
- /** The workspace's trashcan (if any). */
217
- trashcan: Trashcan | null = null;
218
-
219
- /** This workspace's scrollbars, if they exist. */
220
- scrollbar: ScrollbarPair | null = null;
221
-
222
- /**
223
- * Fixed flyout providing blocks which may be dragged into this workspace.
224
- */
225
- private flyout: IFlyout | null = null;
226
-
227
- /**
228
- * Category-based toolbox providing blocks which may be dragged into this
229
- * workspace.
230
- */
231
- private toolbox: IToolbox | null = null;
232
-
233
- /**
234
- * The current gesture in progress on this workspace, if any.
235
- *
236
- * @internal
237
- */
238
- currentGesture_: Gesture | null = null;
239
-
240
- /**
241
- * The first parent div with 'injectionDiv' in the name, or null if not set.
242
- * Access this with getInjectionDiv.
243
- */
244
- private injectionDiv: HTMLElement | null = null;
245
-
246
- /**
247
- * Last known position of the page scroll.
248
- * This is used to determine whether we have recalculated screen coordinate
249
- * stuff since the page scrolled.
250
- */
251
- private lastRecordedPageScroll: Coordinate | null = null;
252
-
253
- /**
254
- * Developers may define this function to add custom menu options to the
255
- * workspace's context menu or edit the workspace-created set of menu
256
- * options.
257
- *
258
- * @param options List of menu options to add to.
259
- * @param e The right-click event that triggered the context menu.
260
- */
261
- configureContextMenu:
262
- | ((menuOptions: ContextMenuOption[], e: Event) => void)
263
- | null = null;
264
-
265
- /**
266
- * A dummy wheel event listener used as a workaround for a Safari scrolling issue.
267
- * Set in createDom and used for removal in dispose to ensure proper cleanup.
268
- */
269
- private dummyWheelListener: (() => void) | null = null;
270
-
271
- /**
272
- * In a flyout, the target workspace where blocks should be placed after a
273
- * drag. Otherwise null.
274
- *
275
- * @internal
276
- */
277
- targetWorkspace: WorkspaceSvg | null = null;
278
-
279
- /** Inverted screen CTM, for use in mouseToSvg. */
280
- private inverseScreenCTM: SVGMatrix | null = null;
281
-
282
- /** Inverted screen CTM is dirty, recalculate it. */
283
- private inverseScreenCTMDirty = true;
284
- private metricsManager: IMetricsManager;
285
- /** @internal */
286
- getMetrics: () => Metrics;
287
- /** @internal */
288
- setMetrics: (p1: {x?: number; y?: number}) => void;
289
- private readonly componentManager: ComponentManager;
290
-
291
- /**
292
- * List of currently highlighted blocks. Block highlighting is often used
293
- * to visually mark blocks currently being executed.
294
- */
295
- private readonly highlightedBlocks: BlockSvg[] = [];
296
- private audioManager: WorkspaceAudio;
297
- private grid: Grid | null;
298
- private markerManager: MarkerManager;
299
-
300
- /**
301
- * Map from function names to callbacks, for deciding what to do when a
302
- * custom toolbox category is opened.
303
- */
304
- private toolboxCategoryCallbacks = new Map<
305
- string,
306
- (p1: WorkspaceSvg) => toolbox.FlyoutDefinition
307
- >();
308
-
309
- /**
310
- * Map from function names to callbacks, for deciding what to do when a
311
- * button is clicked.
312
- */
313
- private flyoutButtonCallbacks = new Map<string, (p1: FlyoutButton) => void>();
314
- protected themeManager_: ThemeManager;
315
- private readonly renderer: Renderer;
316
-
317
- /** Cached parent SVG. */
318
- private cachedParentSvg: SVGElement | null = null;
319
-
320
- /** True if keyboard accessibility mode is on, false otherwise. */
321
- keyboardAccessibilityMode = false;
322
-
323
- /** True iff a keyboard-initiated move ("drag") is in progress. */
324
- keyboardMoveInProgress = false; // TODO(#8960): Delete this.
325
-
326
- /** The list of top-level bounded elements on the workspace. */
327
- private topBoundedElements: IBoundedElement[] = [];
328
-
329
- /** The recorded drag targets. */
330
- private dragTargetAreas: Array<{component: IDragTarget; clientRect: Rect}> =
331
- [];
332
- private readonly cachedParentSvgSize: Size;
333
- private layerManager: LayerManager | null = null;
334
- // TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
335
- svgGroup_!: SVGElement;
336
- // TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
337
- svgBackground_!: SVGElement;
338
- // TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
339
- svgBlockCanvas_!: SVGElement;
340
- // TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
341
- svgBubbleCanvas_!: SVGElement;
342
- zoomControls_: ZoomControls | null = null;
343
-
344
- /**
345
- * Navigator that handles moving focus between items in this workspace in
346
- * response to keyboard navigation commands.
347
- */
348
- private navigator = new Navigator();
349
-
350
- /**
351
- * @param options Dictionary of options.
352
- */
353
- constructor(options: Options) {
354
- super(options);
355
-
356
- const MetricsManagerClass = registry.getClassFromOptions(
357
- registry.Type.METRICS_MANAGER,
358
- options,
359
- true,
360
- );
361
- /** Object in charge of calculating metrics for the workspace. */
362
- this.metricsManager = new MetricsManagerClass!(this);
363
-
364
- /** Method to get all the metrics that have to do with a workspace. */
365
- this.getMetrics =
366
- options.getMetrics ||
367
- this.metricsManager.getMetrics.bind(this.metricsManager);
368
-
369
- /** Translates the workspace. */
370
- this.setMetrics =
371
- options.setMetrics || WorkspaceSvg.setTopLevelWorkspaceMetrics;
372
-
373
- this.componentManager = new ComponentManager();
374
-
375
- this.connectionDBList = ConnectionDB.init(this.connectionChecker);
376
-
377
- /**
378
- * Object in charge of loading, storing, and playing audio for a workspace.
379
- */
380
- this.audioManager = new WorkspaceAudio(
381
- options.parentWorkspace as WorkspaceSvg,
382
- );
383
-
384
- /** This workspace's grid object or null. */
385
- this.grid = this.options.gridPattern
386
- ? new Grid(this.options.gridPattern, options.gridOptions)
387
- : null;
388
-
389
- /** Manager in charge of markers and cursors. */
390
- this.markerManager = new MarkerManager(this);
391
-
392
- if (Variables && Variables.internalFlyoutCategory) {
393
- this.registerToolboxCategoryCallback(
394
- Variables.CATEGORY_NAME,
395
- Variables.internalFlyoutCategory,
396
- );
397
- }
398
-
399
- if (VariablesDynamic && VariablesDynamic.internalFlyoutCategory) {
400
- this.registerToolboxCategoryCallback(
401
- VariablesDynamic.CATEGORY_NAME,
402
- VariablesDynamic.internalFlyoutCategory,
403
- );
404
- }
405
-
406
- if (Procedures && Procedures.internalFlyoutCategory) {
407
- this.registerToolboxCategoryCallback(
408
- Procedures.CATEGORY_NAME,
409
- Procedures.internalFlyoutCategory,
410
- );
411
- this.addChangeListener(Procedures.mutatorOpenListener);
412
- }
413
-
414
- // Set up callbacks to refresh the toolbox when variables change
415
- this.addChangeListener(this.variableChangeCallback.bind(this));
416
-
417
- /** Object in charge of storing and updating the workspace theme. */
418
- this.themeManager_ = this.options.parentWorkspace
419
- ? this.options.parentWorkspace.getThemeManager()
420
- : new ThemeManager(this, this.options.theme || Classic);
421
- this.themeManager_.subscribeWorkspace(this);
422
-
423
- /** The block renderer used for rendering blocks on this workspace. */
424
- this.renderer = blockRendering.init(
425
- this.options.renderer || 'geras',
426
- this.getTheme(),
427
- this.options.rendererOverrides ?? undefined,
428
- );
429
-
430
- /**
431
- * The cached size of the parent svg element.
432
- * Used to compute svg metrics.
433
- */
434
- this.cachedParentSvgSize = new Size(0, 0);
435
- }
436
-
437
- /**
438
- * Get the marker manager for this workspace.
439
- *
440
- * @returns The marker manager.
441
- */
442
- getMarkerManager(): MarkerManager {
443
- return this.markerManager;
444
- }
445
-
446
- /**
447
- * Gets the metrics manager for this workspace.
448
- *
449
- * @returns The metrics manager.
450
- */
451
- getMetricsManager(): IMetricsManager {
452
- return this.metricsManager;
453
- }
454
-
455
- /**
456
- * Sets the metrics manager for the workspace.
457
- *
458
- * @param metricsManager The metrics manager.
459
- * @internal
460
- */
461
- setMetricsManager(metricsManager: IMetricsManager) {
462
- this.metricsManager = metricsManager;
463
- this.getMetrics = this.metricsManager.getMetrics.bind(this.metricsManager);
464
- }
465
-
466
- /**
467
- * Gets the component manager for this workspace.
468
- *
469
- * @returns The component manager.
470
- */
471
- getComponentManager(): ComponentManager {
472
- return this.componentManager;
473
- }
474
-
475
- /**
476
- * Get the marker with the given ID.
477
- *
478
- * @param id The ID of the marker.
479
- * @returns The marker with the given ID or null if no marker with the given
480
- * ID exists.
481
- * @internal
482
- */
483
- getMarker(id: string): Marker | null {
484
- return this.markerManager.getMarker(id);
485
- }
486
-
487
- /**
488
- * The cursor for this workspace.
489
- *
490
- * @returns The cursor for the workspace.
491
- */
492
- getCursor(): LineCursor {
493
- return this.markerManager.getCursor();
494
- }
495
-
496
- /**
497
- * Get the block renderer attached to this workspace.
498
- *
499
- * @returns The renderer attached to this workspace.
500
- */
501
- getRenderer(): Renderer {
502
- return this.renderer;
503
- }
504
-
505
- /**
506
- * Get the theme manager for this workspace.
507
- *
508
- * @returns The theme manager for this workspace.
509
- * @internal
510
- */
511
- getThemeManager(): ThemeManager {
512
- return this.themeManager_;
513
- }
514
-
515
- /**
516
- * Get the workspace theme object.
517
- *
518
- * @returns The workspace theme object.
519
- */
520
- getTheme(): Theme {
521
- return this.themeManager_.getTheme();
522
- }
523
-
524
- /**
525
- * Set the workspace theme object.
526
- * If no theme is passed, default to the `Classic` theme.
527
- *
528
- * @param theme The workspace theme object.
529
- */
530
- setTheme(theme: Theme) {
531
- if (!theme) {
532
- theme = Classic as Theme;
533
- }
534
- this.themeManager_.setTheme(theme);
535
- }
536
-
537
- /**
538
- * Refresh all blocks on the workspace after a theme update.
539
- */
540
- refreshTheme() {
541
- if (this.svgGroup_) {
542
- const isParentWorkspace = this.options.parentWorkspace === null;
543
- this.renderer.refreshDom(
544
- this.svgGroup_,
545
- this.getTheme(),
546
- isParentWorkspace ? this.getInjectionDiv() : undefined,
547
- );
548
- }
549
-
550
- // Update all blocks in workspace that have a style name.
551
- this.updateBlockStyles(
552
- this.getAllBlocks(false).filter((block) => !!block.getStyleName()),
553
- );
554
-
555
- // Update current toolbox selection.
556
- this.refreshToolboxSelection();
557
- if (this.toolbox) {
558
- this.toolbox.refreshTheme();
559
- }
560
-
561
- // Re-render if workspace is visible
562
- if (this.isVisible()) {
563
- this.setVisible(true);
564
- }
565
-
566
- const event = new (eventUtils.get(EventType.THEME_CHANGE))(
567
- this.getTheme().name,
568
- this.id,
569
- );
570
- eventUtils.fire(event);
571
- }
572
-
573
- /**
574
- * Updates all the blocks with new style.
575
- *
576
- * @param blocks List of blocks to update the style on.
577
- */
578
- private updateBlockStyles(blocks: Block[]) {
579
- for (let i = 0, block; (block = blocks[i]); i++) {
580
- const blockStyleName = block.getStyleName();
581
- if (blockStyleName) {
582
- const blockSvg = block as BlockSvg;
583
- blockSvg.setStyle(blockStyleName);
584
- }
585
- }
586
- }
587
-
588
- /**
589
- * Getter for the inverted screen CTM.
590
- *
591
- * @returns The matrix to use in mouseToSvg
592
- */
593
- getInverseScreenCTM(): SVGMatrix | null {
594
- // Defer getting the screen CTM until we actually need it, this should
595
- // avoid forced reflows from any calls to updateInverseScreenCTM.
596
- if (this.inverseScreenCTMDirty) {
597
- const ctm = this.getParentSvg().getScreenCTM();
598
- if (ctm) {
599
- this.inverseScreenCTM = ctm.inverse();
600
- this.inverseScreenCTMDirty = false;
601
- }
602
- }
603
-
604
- return this.inverseScreenCTM;
605
- }
606
-
607
- /** Mark the inverse screen CTM as dirty. */
608
- updateInverseScreenCTM() {
609
- this.inverseScreenCTMDirty = true;
610
- }
611
-
612
- /**
613
- * Getter for isVisible
614
- *
615
- * @returns Whether the workspace is visible.
616
- * False if the workspace has been hidden by calling `setVisible(false)`.
617
- */
618
- isVisible(): boolean {
619
- return this.visible;
620
- }
621
-
622
- /**
623
- * Return the absolute coordinates of the top-left corner of this element,
624
- * scales that after canvas SVG element, if it's a descendant.
625
- * The origin (0,0) is the top-left corner of the Blockly SVG.
626
- *
627
- * @param element SVG element to find the coordinates of.
628
- * @returns Object with .x and .y properties.
629
- * @internal
630
- */
631
- getSvgXY(element: SVGElement): Coordinate {
632
- let x = 0;
633
- let y = 0;
634
- let scale = 1;
635
- if (
636
- this.getCanvas().contains(element) ||
637
- this.getBubbleCanvas().contains(element)
638
- ) {
639
- // Before the SVG canvas, scale the coordinates.
640
- scale = this.scale;
641
- }
642
- let ancestor: Element = element;
643
- do {
644
- // Loop through this block and every parent.
645
- const xy = svgMath.getRelativeXY(ancestor);
646
- if (
647
- ancestor === this.getCanvas() ||
648
- ancestor === this.getBubbleCanvas()
649
- ) {
650
- // After the SVG canvas, don't scale the coordinates.
651
- scale = 1;
652
- }
653
- x += xy.x * scale;
654
- y += xy.y * scale;
655
- ancestor = ancestor.parentNode as Element;
656
- } while (
657
- ancestor &&
658
- ancestor !== this.getParentSvg() &&
659
- ancestor !== this.getInjectionDiv()
660
- );
661
- return new Coordinate(x, y);
662
- }
663
-
664
- /**
665
- * Gets the size of the workspace's parent SVG element.
666
- *
667
- * @returns The cached width and height of the workspace's parent SVG element.
668
- * @internal
669
- */
670
- getCachedParentSvgSize(): Size {
671
- const size = this.cachedParentSvgSize;
672
- return new Size(size.width, size.height);
673
- }
674
-
675
- /**
676
- * Return the position of the workspace origin relative to the injection div
677
- * origin in pixels.
678
- * The workspace origin is where a block would render at position (0, 0).
679
- * It is not the upper left corner of the workspace SVG.
680
- *
681
- * @returns Offset in pixels.
682
- * @internal
683
- */
684
- getOriginOffsetInPixels(): Coordinate {
685
- return svgMath.getInjectionDivXY(this.getCanvas());
686
- }
687
-
688
- /**
689
- * Return the injection div that is a parent of this workspace.
690
- * Walks the DOM the first time it's called, then returns a cached value.
691
- * Note: We assume this is only called after the workspace has been injected
692
- * into the DOM.
693
- *
694
- * @returns The first parent div with 'injectionDiv' in the name.
695
- * @internal
696
- */
697
- getInjectionDiv(): HTMLElement {
698
- // NB: it would be better to pass this in at createDom, but is more likely
699
- // to break existing uses of Blockly.
700
- if (!this.injectionDiv) {
701
- let element: Element = this.svgGroup_;
702
- while (element) {
703
- const classes = element.getAttribute('class') || '';
704
- if ((' ' + classes + ' ').includes(' injectionDiv ')) {
705
- this.injectionDiv = element as HTMLElement;
706
- break;
707
- }
708
- element = element.parentNode as Element;
709
- }
710
- }
711
- return this.injectionDiv!;
712
- }
713
-
714
- /**
715
- * Returns the SVG group for the workspace.
716
- *
717
- * @returns The SVG group for the workspace.
718
- */
719
- getSvgGroup(): Element {
720
- return this.svgGroup_;
721
- }
722
-
723
- /**
724
- * Get the SVG block canvas for the workspace.
725
- *
726
- * @returns The SVG group for the workspace.
727
- * @internal
728
- */
729
- getBlockCanvas(): SVGElement | null {
730
- return this.getCanvas();
731
- }
732
-
733
- /**
734
- * Save resize handler data so we can delete it later in dispose.
735
- *
736
- * @param handler Data that can be passed to eventHandling.unbind.
737
- */
738
- setResizeHandlerWrapper(handler: browserEvents.Data) {
739
- this.resizeHandlerWrapper = handler;
740
- }
741
-
742
- /**
743
- * Create the workspace DOM elements.
744
- *
745
- * @param opt_backgroundClass Either 'blocklyMainBackground' or
746
- * 'blocklyMutatorBackground'.
747
- * @returns The workspace's SVG group.
748
- */
749
- createDom(opt_backgroundClass?: string, injectionDiv?: HTMLElement): Element {
750
- if (!this.injectionDiv) {
751
- this.injectionDiv = injectionDiv ?? null;
752
- }
753
-
754
- /**
755
- * <g class="blocklyWorkspace">
756
- * <rect class="blocklyMainBackground" height="100%" width="100%"></rect>
757
- * [Trashcan and/or flyout may go here]
758
- * <g class="blocklyBlockCanvas"></g>
759
- * <g class="blocklyBubbleCanvas"></g>
760
- * </g>
761
- */
762
- this.svgGroup_ = dom.createSvgElement(Svg.G, {
763
- 'class': 'blocklyWorkspace',
764
- 'id': this.id,
765
- });
766
- if (injectionDiv) {
767
- aria.setState(
768
- this.svgGroup_,
769
- aria.State.LABEL,
770
- Msg['WORKSPACE_ARIA_LABEL'],
771
- );
772
- }
773
-
774
- // Note that a <g> alone does not receive mouse events--it must have a
775
- // valid target inside it. If no background class is specified, as in the
776
- // flyout, the workspace will not receive mouse events.
777
- if (opt_backgroundClass) {
778
- this.svgBackground_ = dom.createSvgElement(
779
- Svg.RECT,
780
- {'height': '100%', 'width': '100%', 'class': opt_backgroundClass},
781
- this.svgGroup_,
782
- );
783
-
784
- if (opt_backgroundClass === 'blocklyMainBackground' && this.grid) {
785
- this.svgBackground_.style.fill = 'var(--blocklyGridPattern)';
786
- } else {
787
- this.themeManager_.subscribe(
788
- this.svgBackground_,
789
- 'workspaceBackgroundColour',
790
- 'fill',
791
- );
792
- }
793
- }
794
-
795
- this.layerManager = new LayerManager(this);
796
- // Assign the canvases for backwards compatibility.
797
- this.svgBlockCanvas_ = this.layerManager.getBlockLayer();
798
- this.svgBubbleCanvas_ = this.layerManager.getBubbleLayer();
799
-
800
- if (!this.isFlyout) {
801
- browserEvents.conditionalBind(
802
- this.svgGroup_,
803
- 'pointerdown',
804
- this,
805
- this.onMouseDown,
806
- false,
807
- );
808
- // This no-op works around https://bugs.webkit.org/show_bug.cgi?id=226683,
809
- // which otherwise prevents zoom/scroll events from being observed in
810
- // Safari. Once that bug is fixed it should be removed.
811
- this.dummyWheelListener = () => {};
812
- document.body.addEventListener('wheel', this.dummyWheelListener, {
813
- passive: true,
814
- });
815
- browserEvents.conditionalBind(
816
- this.svgGroup_,
817
- 'wheel',
818
- this,
819
- this.onMouseWheel,
820
- false,
821
- {passive: false},
822
- );
823
- }
824
-
825
- // Determine if there needs to be a category tree, or a simple list of
826
- // blocks. This cannot be changed later, since the UI is very different.
827
- if (this.options.hasCategories) {
828
- const ToolboxClass = registry.getClassFromOptions(
829
- registry.Type.TOOLBOX,
830
- this.options,
831
- true,
832
- );
833
- this.toolbox = new ToolboxClass!(this);
834
- }
835
- if (this.grid) {
836
- this.grid.update(this.scale);
837
- }
838
- this.recordDragTargets();
839
- const CursorClass = registry.getClassFromOptions(
840
- registry.Type.CURSOR,
841
- this.options,
842
- );
843
-
844
- if (CursorClass) this.markerManager.setCursor(new CursorClass(this));
845
-
846
- const isParentWorkspace = this.options.parentWorkspace === null;
847
- this.renderer.createDom(
848
- this.svgGroup_,
849
- this.getTheme(),
850
- isParentWorkspace ? this.getInjectionDiv() : undefined,
851
- );
852
-
853
- // Only the top-level and flyout workspaces should be tabbable.
854
- getFocusManager().registerTree(this, !!this.injectionDiv || this.isFlyout);
855
-
856
- return this.svgGroup_;
857
- }
858
-
859
- /**
860
- * Dispose of this workspace.
861
- * Unlink from all DOM elements to prevent memory leaks.
862
- */
863
- override dispose() {
864
- // Stop rerendering.
865
- this.rendered = false;
866
- if (this.currentGesture_) {
867
- this.currentGesture_.cancel();
868
- }
869
- if (this.svgGroup_) {
870
- dom.removeNode(this.svgGroup_);
871
- }
872
- if (this.toolbox) {
873
- this.toolbox.dispose();
874
- this.toolbox = null;
875
- }
876
- if (this.flyout) {
877
- this.flyout.dispose();
878
- this.flyout = null;
879
- }
880
- if (this.trashcan) {
881
- this.trashcan.dispose();
882
- this.trashcan = null;
883
- }
884
- if (this.scrollbar) {
885
- this.scrollbar.dispose();
886
- this.scrollbar = null;
887
- }
888
- if (this.zoomControls_) {
889
- this.zoomControls_.dispose();
890
- }
891
-
892
- if (this.audioManager) {
893
- this.audioManager.dispose();
894
- }
895
-
896
- if (this.grid) {
897
- this.grid = null;
898
- }
899
-
900
- this.renderer.dispose();
901
- this.markerManager.dispose();
902
-
903
- super.dispose();
904
-
905
- // Dispose of theme manager after all blocks and mutators are disposed of.
906
- if (this.themeManager_) {
907
- this.themeManager_.unsubscribeWorkspace(this);
908
- this.themeManager_.unsubscribe(this.svgBackground_);
909
- if (!this.options.parentWorkspace) {
910
- this.themeManager_.dispose();
911
- }
912
- }
913
-
914
- this.connectionDBList.length = 0;
915
-
916
- this.toolboxCategoryCallbacks.clear();
917
- this.flyoutButtonCallbacks.clear();
918
-
919
- if (!this.options.parentWorkspace) {
920
- // Top-most workspace. Dispose of the div that the
921
- // SVG is injected into (i.e. injectionDiv).
922
- const parentSvg = this.getParentSvg();
923
- if (parentSvg && parentSvg.parentNode) {
924
- dom.removeNode(parentSvg.parentNode);
925
- }
926
- }
927
- if (this.resizeHandlerWrapper) {
928
- browserEvents.unbind(this.resizeHandlerWrapper);
929
- this.resizeHandlerWrapper = null;
930
- }
931
-
932
- // Remove the dummy wheel listener
933
- if (this.dummyWheelListener) {
934
- document.body.removeEventListener('wheel', this.dummyWheelListener);
935
- this.dummyWheelListener = null;
936
- }
937
-
938
- if (getFocusManager().isRegistered(this)) {
939
- getFocusManager().unregisterTree(this);
940
- }
941
- }
942
-
943
- /**
944
- * Add a trashcan.
945
- *
946
- * @internal
947
- */
948
- addTrashcan() {
949
- this.trashcan = WorkspaceSvg.newTrashcan(this);
950
- const svgTrashcan = this.trashcan.createDom();
951
- this.svgGroup_.insertBefore(svgTrashcan, this.getCanvas());
952
- }
953
-
954
- /**
955
- * @param _workspace
956
- * @internal
957
- */
958
- static newTrashcan(_workspace: WorkspaceSvg): Trashcan {
959
- throw new Error(
960
- 'The implementation of newTrashcan should be ' +
961
- 'monkey-patched in by blockly.ts',
962
- );
963
- }
964
-
965
- /**
966
- * Add zoom controls.
967
- *
968
- * @internal
969
- */
970
- addZoomControls() {
971
- this.zoomControls_ = new ZoomControls(this);
972
- const svgZoomControls = this.zoomControls_.createDom();
973
- this.svgGroup_.appendChild(svgZoomControls);
974
- }
975
-
976
- /**
977
- * Creates a new set of options from this workspace's options with just the
978
- * values that are relevant to a flyout.
979
- *
980
- * @returns A subset of this workspace's options.
981
- */
982
- copyOptionsForFlyout(): Options {
983
- return new Options({
984
- 'parentWorkspace': this,
985
- 'rtl': this.RTL,
986
- 'oneBasedIndex': this.options.oneBasedIndex,
987
- 'horizontalLayout': this.horizontalLayout,
988
- 'renderer': this.options.renderer,
989
- 'rendererOverrides': this.options.rendererOverrides,
990
- 'plugins': this.options.plugins,
991
- 'modalInputs': this.options.modalInputs,
992
- 'move': {
993
- 'scrollbars': true,
994
- },
995
- } as BlocklyOptions);
996
- }
997
-
998
- /**
999
- * Add a flyout element in an element with the given tag name.
1000
- *
1001
- * @param tagName What type of tag the flyout belongs in.
1002
- * @returns The element containing the flyout DOM.
1003
- * @internal
1004
- */
1005
- addFlyout(tagName: string | Svg<SVGSVGElement> | Svg<SVGGElement>): Element {
1006
- const workspaceOptions = this.copyOptionsForFlyout();
1007
- workspaceOptions.toolboxPosition = this.options.toolboxPosition;
1008
- if (this.horizontalLayout) {
1009
- const HorizontalFlyout = registry.getClassFromOptions(
1010
- registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
1011
- this.options,
1012
- true,
1013
- );
1014
- this.flyout = new HorizontalFlyout!(workspaceOptions);
1015
- } else {
1016
- const VerticalFlyout = registry.getClassFromOptions(
1017
- registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
1018
- this.options,
1019
- true,
1020
- );
1021
- this.flyout = new VerticalFlyout!(workspaceOptions);
1022
- }
1023
- this.flyout.autoClose = false;
1024
- this.flyout.getWorkspace().setVisible(true);
1025
-
1026
- // Return the element so that callers can place it in their desired
1027
- // spot in the DOM. For example, mutator flyouts do not go in the same
1028
- // place as main workspace flyouts.
1029
- return this.flyout.createDom(tagName);
1030
- }
1031
-
1032
- /**
1033
- * Getter for the flyout associated with this workspace. This flyout may be
1034
- * owned by either the toolbox or the workspace, depending on toolbox
1035
- * configuration. It will be null if there is no flyout.
1036
- *
1037
- * @param opt_own Whether to only return the workspace's own flyout.
1038
- * @returns The flyout on this workspace.
1039
- */
1040
- getFlyout(opt_own?: boolean): IFlyout | null {
1041
- if (this.flyout || opt_own) {
1042
- return this.flyout;
1043
- }
1044
- if (this.toolbox) {
1045
- return this.toolbox.getFlyout();
1046
- }
1047
- return null;
1048
- }
1049
-
1050
- /**
1051
- * Getter for the toolbox associated with this workspace, if one exists.
1052
- *
1053
- * @returns The toolbox on this workspace.
1054
- */
1055
- getToolbox(): IToolbox | null {
1056
- return this.toolbox;
1057
- }
1058
-
1059
- /**
1060
- * Update items that use screen coordinate calculations
1061
- * because something has changed (e.g. scroll position, window size).
1062
- */
1063
- private updateScreenCalculations() {
1064
- this.updateInverseScreenCTM();
1065
- this.recordDragTargets();
1066
- }
1067
-
1068
- /**
1069
- * If enabled, resize the parts of the workspace that change when the
1070
- * workspace contents (e.g. block positions) change. This will also scroll
1071
- * the workspace contents if needed.
1072
- *
1073
- * @internal
1074
- */
1075
- resizeContents() {
1076
- if (!this.resizesEnabled || !this.rendered) {
1077
- return;
1078
- }
1079
- if (this.scrollbar) {
1080
- this.scrollbar.resize();
1081
- }
1082
- this.updateInverseScreenCTM();
1083
- }
1084
-
1085
- /**
1086
- * Resize and reposition all of the workspace chrome (toolbox,
1087
- * trash, scrollbars etc.)
1088
- * This should be called when something changes that
1089
- * requires recalculating dimensions and positions of the
1090
- * trash, zoom, toolbox, etc. (e.g. window resize).
1091
- */
1092
- resize() {
1093
- if (this.toolbox) {
1094
- this.toolbox.position();
1095
- } else if (this.flyout) {
1096
- this.flyout.position();
1097
- }
1098
-
1099
- const positionables = this.componentManager.getComponents(
1100
- ComponentManager.Capability.POSITIONABLE,
1101
- true,
1102
- );
1103
- const metrics = this.getMetricsManager().getUiMetrics();
1104
- const savedPositions = [];
1105
- for (let i = 0, positionable; (positionable = positionables[i]); i++) {
1106
- positionable.position(metrics, savedPositions);
1107
- const boundingRect = positionable.getBoundingRectangle();
1108
- if (boundingRect) {
1109
- savedPositions.push(boundingRect);
1110
- }
1111
- }
1112
-
1113
- if (this.scrollbar) {
1114
- this.scrollbar.resize();
1115
- }
1116
- this.updateScreenCalculations();
1117
- }
1118
-
1119
- /**
1120
- * Resizes and repositions workspace chrome if the page has a new
1121
- * scroll position.
1122
- *
1123
- * @internal
1124
- */
1125
- updateScreenCalculationsIfScrolled() {
1126
- const currScroll = svgMath.getDocumentScroll();
1127
- if (!Coordinate.equals(this.lastRecordedPageScroll, currScroll)) {
1128
- this.lastRecordedPageScroll = currScroll;
1129
- this.updateScreenCalculations();
1130
- }
1131
- }
1132
-
1133
- /**
1134
- * @returns The layer manager for this workspace.
1135
- * @internal
1136
- */
1137
- getLayerManager(): LayerManager | null {
1138
- return this.layerManager;
1139
- }
1140
-
1141
- /**
1142
- * Get the SVG element that forms the drawing surface.
1143
- *
1144
- * @returns SVG group element.
1145
- */
1146
- getCanvas(): SVGGElement {
1147
- return this.layerManager!.getBlockLayer();
1148
- }
1149
-
1150
- /**
1151
- * Caches the width and height of the workspace's parent SVG element for use
1152
- * with getSvgMetrics.
1153
- *
1154
- * @param width The width of the parent SVG element.
1155
- * @param height The height of the parent SVG element
1156
- * @internal
1157
- */
1158
- setCachedParentSvgSize(width: number | null, height: number | null) {
1159
- const svg = this.getParentSvg();
1160
- if (width != null) {
1161
- this.cachedParentSvgSize.width = width;
1162
- // This is set to support the public (but deprecated) Blockly.svgSize
1163
- // method.
1164
- svg.setAttribute('data-cached-width', `${width}`);
1165
- }
1166
- if (height != null) {
1167
- this.cachedParentSvgSize.height = height;
1168
- // This is set to support the public (but deprecated) Blockly.svgSize
1169
- // method.
1170
- svg.setAttribute('data-cached-height', `${height}`);
1171
- }
1172
- }
1173
-
1174
- /**
1175
- * Get the SVG element that forms the bubble surface.
1176
- *
1177
- * @returns SVG group element.
1178
- */
1179
- getBubbleCanvas(): SVGGElement {
1180
- return this.layerManager!.getBubbleLayer();
1181
- }
1182
-
1183
- /**
1184
- * Get the SVG element that contains this workspace.
1185
- * Note: We assume this is only called after the workspace has been injected
1186
- * into the DOM.
1187
- *
1188
- * @returns SVG element.
1189
- */
1190
- getParentSvg(): SVGSVGElement {
1191
- if (!this.cachedParentSvg) {
1192
- let element = this.svgGroup_;
1193
- while (element) {
1194
- if (element.tagName === 'svg') {
1195
- this.cachedParentSvg = element;
1196
- break;
1197
- }
1198
- element = element.parentNode as SVGSVGElement;
1199
- }
1200
- }
1201
- return this.cachedParentSvg as SVGSVGElement;
1202
- }
1203
-
1204
- /**
1205
- * Fires a viewport event if events are enabled and there is a change in
1206
- * viewport values.
1207
- *
1208
- * @internal
1209
- */
1210
- maybeFireViewportChangeEvent() {
1211
- if (!eventUtils.isEnabled()) {
1212
- return;
1213
- }
1214
- const scale = this.scale;
1215
- const top = -this.scrollY;
1216
- const left = -this.scrollX;
1217
- if (
1218
- scale === this.oldScale &&
1219
- Math.abs(top - this.oldTop) < 1 &&
1220
- Math.abs(left - this.oldLeft) < 1
1221
- ) {
1222
- // Ignore sub-pixel changes in top and left. Due to #4192 there are a lot
1223
- // of negligible changes in viewport top/left.
1224
- return;
1225
- }
1226
- const event = new (eventUtils.get(EventType.VIEWPORT_CHANGE))(
1227
- top,
1228
- left,
1229
- scale,
1230
- this.id,
1231
- this.oldScale,
1232
- );
1233
- this.oldScale = scale;
1234
- this.oldTop = top;
1235
- this.oldLeft = left;
1236
- eventUtils.fire(event);
1237
- }
1238
-
1239
- /**
1240
- * Translate this workspace to new coordinates.
1241
- *
1242
- * @param x Horizontal translation, in pixel units relative to the top left of
1243
- * the Blockly div.
1244
- * @param y Vertical translation, in pixel units relative to the top left of
1245
- * the Blockly div.
1246
- */
1247
- translate(x: number, y: number) {
1248
- this.layerManager?.translateLayers(new Coordinate(x, y), this.scale);
1249
- this.grid?.moveTo(x, y);
1250
- this.maybeFireViewportChangeEvent();
1251
- }
1252
-
1253
- /**
1254
- * Returns the horizontal offset of the workspace.
1255
- * Intended for LTR/RTL compatibility in XML.
1256
- *
1257
- * @returns Width.
1258
- */
1259
- override getWidth(): number {
1260
- const metrics = this.getMetrics();
1261
- return metrics ? metrics.viewWidth / this.scale : 0;
1262
- }
1263
-
1264
- /**
1265
- * Toggles the visibility of the workspace.
1266
- * Currently only intended for main workspace.
1267
- *
1268
- * @param isVisible True if workspace should be visible.
1269
- */
1270
- setVisible(isVisible: boolean) {
1271
- this.visible = isVisible;
1272
- if (!this.svgGroup_) {
1273
- return;
1274
- }
1275
-
1276
- // Tell the scrollbar whether its container is visible so it can
1277
- // tell when to hide itself.
1278
- if (this.scrollbar) {
1279
- this.scrollbar.setContainerVisible(isVisible);
1280
- }
1281
-
1282
- // Tell the flyout whether its container is visible so it can
1283
- // tell when to hide itself.
1284
- if (this.getFlyout()) {
1285
- this.getFlyout()!.setContainerVisible(isVisible);
1286
- }
1287
-
1288
- this.getParentSvg().style.display = isVisible ? 'block' : 'none';
1289
- if (this.toolbox) {
1290
- // Currently does not support toolboxes in mutators.
1291
- this.toolbox.setVisible(isVisible);
1292
- }
1293
- if (!isVisible) {
1294
- this.hideChaff(true);
1295
- }
1296
- }
1297
-
1298
- /**
1299
- * Render all blocks in workspace.
1300
- */
1301
- render() {
1302
- // Generate list of all blocks.
1303
- const blocks = this.getAllBlocks(false);
1304
- // Render each block.
1305
- for (let i = blocks.length - 1; i >= 0; i--) {
1306
- blocks[i].queueRender();
1307
- }
1308
-
1309
- this.getTopBlocks()
1310
- .flatMap((block) => block.getDescendants(false))
1311
- .filter((block) => block.isInsertionMarker())
1312
- .forEach((block) => block.queueRender());
1313
- }
1314
-
1315
- /**
1316
- * Highlight or unhighlight a block in the workspace. Block highlighting is
1317
- * often used to visually mark blocks currently being executed.
1318
- *
1319
- * @param id ID of block to highlight/unhighlight, or null for no block (used
1320
- * to unhighlight all blocks).
1321
- * @param opt_state If undefined, highlight specified block and automatically
1322
- * unhighlight all others. If true or false, manually
1323
- * highlight/unhighlight the specified block.
1324
- */
1325
- highlightBlock(id: string | null, opt_state?: boolean) {
1326
- if (opt_state === undefined) {
1327
- // Unhighlight all blocks.
1328
- for (let i = 0, block; (block = this.highlightedBlocks[i]); i++) {
1329
- block.setHighlighted(false);
1330
- }
1331
- this.highlightedBlocks.length = 0;
1332
- }
1333
- // Highlight/unhighlight the specified block.
1334
- const block = id ? this.getBlockById(id) : null;
1335
- if (block) {
1336
- const state = opt_state === undefined || opt_state;
1337
- // Using Set here would be great, but at the cost of IE10 support.
1338
- if (!state) {
1339
- arrayUtils.removeElem(this.highlightedBlocks, block);
1340
- } else if (!this.highlightedBlocks.includes(block)) {
1341
- this.highlightedBlocks.push(block);
1342
- }
1343
- block.setHighlighted(state);
1344
- }
1345
- }
1346
-
1347
- /**
1348
- * Handles any necessary updates when a variable changes.
1349
- *
1350
- * @internal
1351
- */
1352
- private variableChangeCallback(event: AbstractEvent) {
1353
- switch (event.type) {
1354
- case EventType.VAR_CREATE:
1355
- case EventType.VAR_DELETE:
1356
- case EventType.VAR_RENAME:
1357
- case EventType.VAR_TYPE_CHANGE:
1358
- this.refreshToolboxSelection();
1359
- break;
1360
- default:
1361
- }
1362
- }
1363
-
1364
- /**
1365
- * Refresh the toolbox unless there's a drag in progress.
1366
- *
1367
- * @internal
1368
- */
1369
- refreshToolboxSelection() {
1370
- const ws = this.isFlyout ? this.targetWorkspace : this;
1371
- if (ws && !ws.currentGesture_ && ws.toolbox && ws.toolbox.getFlyout()) {
1372
- ws.toolbox.refreshSelection();
1373
- }
1374
- }
1375
-
1376
- /** Make a list of all the delete areas for this workspace. */
1377
- recordDragTargets() {
1378
- const dragTargets = this.componentManager.getComponents(
1379
- ComponentManager.Capability.DRAG_TARGET,
1380
- true,
1381
- );
1382
-
1383
- this.dragTargetAreas = [];
1384
- for (let i = 0, targetArea; (targetArea = dragTargets[i]); i++) {
1385
- const rect = targetArea.getClientRect();
1386
- if (rect) {
1387
- this.dragTargetAreas.push({
1388
- component: targetArea,
1389
- clientRect: rect,
1390
- });
1391
- }
1392
- }
1393
- }
1394
- /* eslint-disable jsdoc/require-returns-check */
1395
- /* eslint-disable @typescript-eslint/no-unused-vars */
1396
- /**
1397
- * Obtain a newly created block.
1398
- *
1399
- * @param prototypeName Name of the language object containing type-specific
1400
- * functions for this block.
1401
- * @param opt_id Optional ID. Use this ID if provided, otherwise create a new
1402
- * ID.
1403
- * @returns The created block.
1404
- */
1405
- override newBlock(prototypeName: string, opt_id?: string): BlockSvg {
1406
- throw new Error(
1407
- 'The implementation of newBlock should be ' +
1408
- 'monkey-patched in by blockly.ts',
1409
- );
1410
- }
1411
-
1412
- /**
1413
- * Obtain a newly created comment.
1414
- *
1415
- * @param id Optional ID. Use this ID if provided, otherwise create a new
1416
- * ID.
1417
- * @returns The created comment.
1418
- */
1419
- newComment(id?: string): WorkspaceComment {
1420
- throw new Error(
1421
- 'The implementation of newComment should be ' +
1422
- 'monkey-patched in by blockly.ts',
1423
- );
1424
- }
1425
- /* eslint-enable */
1426
-
1427
- /**
1428
- * Returns the drag target the pointer event is over.
1429
- *
1430
- * @param e Pointer move event.
1431
- * @returns Null if not over a drag target, or the drag target the event is
1432
- * over.
1433
- */
1434
- getDragTarget(e: PointerEvent): IDragTarget | null {
1435
- for (let i = 0, targetArea; (targetArea = this.dragTargetAreas[i]); i++) {
1436
- if (targetArea.clientRect.contains(e.clientX, e.clientY)) {
1437
- return targetArea.component;
1438
- }
1439
- }
1440
- return null;
1441
- }
1442
-
1443
- /**
1444
- * Handle a pointerdown on SVG drawing surface.
1445
- *
1446
- * @param e Pointer down event.
1447
- */
1448
- private onMouseDown(e: PointerEvent) {
1449
- const gesture = this.getGesture(e);
1450
- if (gesture) {
1451
- gesture.handleWsStart(e, this);
1452
- }
1453
- }
1454
-
1455
- /**
1456
- * Start tracking a drag of an object on this workspace.
1457
- *
1458
- * @param e Pointer down event.
1459
- * @param xy Starting location of object.
1460
- */
1461
- startDrag(e: PointerEvent, xy: Coordinate) {
1462
- drag.start(this, e, xy);
1463
- }
1464
-
1465
- /**
1466
- * Track a drag of an object on this workspace.
1467
- *
1468
- * @param e Pointer move event.
1469
- * @returns New location of object.
1470
- */
1471
- moveDrag(e: PointerEvent): Coordinate {
1472
- return drag.move(this, e);
1473
- }
1474
-
1475
- /**
1476
- * Indicate whether a keyboard move is in progress or not.
1477
- *
1478
- * Should be called with true when a keyboard move of an IDraggable
1479
- * is starts, and false when it finishes or is aborted.
1480
- *
1481
- * N.B.: This method is experimental and internal-only. It is
1482
- * intended only to called only from the keyboard navigation plugin.
1483
- * Its signature and behaviour may be modified, or the method
1484
- * removed, at an time without notice and without being treated
1485
- * as a breaking change.
1486
- *
1487
- * TODO(#8960): Delete this.
1488
- *
1489
- * @internal
1490
- * @param inProgress Is a keyboard-initated move in progress?
1491
- */
1492
- setKeyboardMoveInProgress(inProgress: boolean) {
1493
- this.keyboardMoveInProgress = inProgress;
1494
- }
1495
-
1496
- /**
1497
- * Returns true iff the user is currently engaged in a drag gesture,
1498
- * or if a keyboard-initated move is in progress.
1499
- *
1500
- * Dragging gestures normally entail moving a block or other item on
1501
- * the workspace, or scrolling the flyout/workspace.
1502
- *
1503
- * Keyboard-initated movements are implemnted using the dragging
1504
- * infrastructure and are intended to emulate (a subset of) drag
1505
- * gestures and so should typically be treated as if they were a
1506
- * gesture-based drag.
1507
- *
1508
- * @returns True iff a drag gesture or keyboard move is in porgress.
1509
- */
1510
- isDragging(): boolean {
1511
- return (
1512
- // TODO(#8960): Query Mover.isMoving to see if move is in
1513
- // progress rather than relying on a status flag.
1514
- this.keyboardMoveInProgress ||
1515
- (this.currentGesture_ !== null && this.currentGesture_.isDragging())
1516
- );
1517
- }
1518
-
1519
- /**
1520
- * Is this workspace draggable?
1521
- *
1522
- * @returns True if this workspace may be dragged.
1523
- */
1524
- isDraggable(): boolean {
1525
- return this.options.moveOptions && this.options.moveOptions.drag;
1526
- }
1527
-
1528
- /**
1529
- * Is this workspace movable?
1530
- *
1531
- * This means the user can reposition the X Y coordinates of the workspace
1532
- * through input. This can be through scrollbars, scroll wheel, dragging, or
1533
- * through zooming with the scroll wheel or pinch (since the zoom is centered
1534
- * on the mouse position). This does not include zooming with the zoom
1535
- * controls since the X Y coordinates are decided programmatically.
1536
- *
1537
- * @returns True if the workspace is movable, false otherwise.
1538
- */
1539
- isMovable(): boolean {
1540
- return (
1541
- (this.options.moveOptions && !!this.options.moveOptions.scrollbars) ||
1542
- (this.options.moveOptions && this.options.moveOptions.wheel) ||
1543
- (this.options.moveOptions && this.options.moveOptions.drag) ||
1544
- (this.options.zoomOptions && this.options.zoomOptions.wheel) ||
1545
- (this.options.zoomOptions && this.options.zoomOptions.pinch)
1546
- );
1547
- }
1548
-
1549
- /**
1550
- * Is this workspace movable horizontally?
1551
- *
1552
- * @returns True if the workspace is movable horizontally, false otherwise.
1553
- */
1554
- isMovableHorizontally(): boolean {
1555
- const hasScrollbars = !!this.scrollbar;
1556
- return (
1557
- this.isMovable() &&
1558
- (!hasScrollbars ||
1559
- (hasScrollbars && this.scrollbar!.canScrollHorizontally()))
1560
- );
1561
- }
1562
-
1563
- /**
1564
- * Is this workspace movable vertically?
1565
- *
1566
- * @returns True if the workspace is movable vertically, false otherwise.
1567
- */
1568
- isMovableVertically(): boolean {
1569
- const hasScrollbars = !!this.scrollbar;
1570
- return (
1571
- this.isMovable() &&
1572
- (!hasScrollbars ||
1573
- (hasScrollbars && this.scrollbar!.canScrollVertically()))
1574
- );
1575
- }
1576
-
1577
- /**
1578
- * Handle a mouse-wheel on SVG drawing surface.
1579
- *
1580
- * @param e Mouse wheel event.
1581
- */
1582
- private onMouseWheel(e: WheelEvent) {
1583
- // Don't scroll or zoom anything if drag is in progress.
1584
- if (Gesture.inProgress()) {
1585
- e.preventDefault();
1586
- e.stopPropagation();
1587
- return;
1588
- }
1589
- const canWheelZoom =
1590
- this.options.zoomOptions && this.options.zoomOptions.wheel;
1591
- const canWheelMove =
1592
- this.options.moveOptions && this.options.moveOptions.wheel;
1593
- if (!canWheelZoom && !canWheelMove) {
1594
- return;
1595
- }
1596
-
1597
- const scrollDelta = browserEvents.getScrollDeltaPixels(e);
1598
-
1599
- // Zoom should also be enabled by the command key on Mac devices,
1600
- // but not super on Unix.
1601
- let commandKey;
1602
- if (userAgent.MAC) {
1603
- commandKey = e.metaKey;
1604
- }
1605
-
1606
- if (canWheelZoom && (e.ctrlKey || commandKey || !canWheelMove)) {
1607
- // Zoom.
1608
- // The vertical scroll distance that corresponds to a click of a zoom
1609
- // button.
1610
- const PIXELS_PER_ZOOM_STEP = 50;
1611
- const delta = -scrollDelta.y / PIXELS_PER_ZOOM_STEP;
1612
- const position = browserEvents.mouseToSvg(
1613
- e,
1614
- this.getParentSvg(),
1615
- this.getInverseScreenCTM(),
1616
- );
1617
- this.zoom(position.x, position.y, delta);
1618
- } else {
1619
- // Scroll.
1620
- let x = this.scrollX - scrollDelta.x;
1621
- let y = this.scrollY - scrollDelta.y;
1622
-
1623
- if (e.shiftKey && !scrollDelta.x) {
1624
- // Scroll horizontally (based on vertical scroll delta).
1625
- // This is needed as for some browser/system combinations which do not
1626
- // set deltaX.
1627
- x = this.scrollX - scrollDelta.y;
1628
- y = this.scrollY; // Don't scroll vertically.
1629
- }
1630
- this.scroll(x, y);
1631
- }
1632
- e.preventDefault();
1633
- }
1634
-
1635
- /**
1636
- * Calculate the bounding box for the blocks on the workspace.
1637
- * Coordinate system: workspace coordinates.
1638
- *
1639
- * @returns Contains the position and size of the bounding box containing the
1640
- * blocks on the workspace.
1641
- */
1642
- getBlocksBoundingBox(): Rect {
1643
- const topElements = this.getTopBoundedElements();
1644
- // There are no blocks, return empty rectangle.
1645
- if (!topElements.length) {
1646
- return new Rect(0, 0, 0, 0);
1647
- }
1648
-
1649
- // Initialize boundary using the first block.
1650
- const boundary = topElements[0].getBoundingRectangle();
1651
-
1652
- // Start at 1 since the 0th block was used for initialization.
1653
- for (let i = 1; i < topElements.length; i++) {
1654
- const topElement = topElements[i];
1655
- if (
1656
- (topElement as any).isInsertionMarker &&
1657
- (topElement as any).isInsertionMarker()
1658
- ) {
1659
- continue;
1660
- }
1661
- const blockBoundary = topElement.getBoundingRectangle();
1662
- if (blockBoundary.top < boundary.top) {
1663
- boundary.top = blockBoundary.top;
1664
- }
1665
- if (blockBoundary.bottom > boundary.bottom) {
1666
- boundary.bottom = blockBoundary.bottom;
1667
- }
1668
- if (blockBoundary.left < boundary.left) {
1669
- boundary.left = blockBoundary.left;
1670
- }
1671
- if (blockBoundary.right > boundary.right) {
1672
- boundary.right = blockBoundary.right;
1673
- }
1674
- }
1675
- return boundary;
1676
- }
1677
-
1678
- /** Clean up the workspace by ordering all the blocks in a column such that none overlap. */
1679
- cleanUp() {
1680
- this.setResizesEnabled(false);
1681
- const existingGroup = eventUtils.getGroup();
1682
- if (!existingGroup) {
1683
- eventUtils.setGroup(true);
1684
- }
1685
-
1686
- const topBlocks = this.getTopBlocks(true);
1687
- const movableBlocks = topBlocks.filter((block) => block.isMovable());
1688
- const immovableBlocks = topBlocks.filter((block) => !block.isMovable());
1689
-
1690
- const immovableBlockBounds = immovableBlocks.map((block) =>
1691
- block.getBoundingRectangle(),
1692
- );
1693
-
1694
- const getNextIntersectingImmovableBlock = function (
1695
- rect: Rect,
1696
- ): Rect | null {
1697
- for (const immovableRect of immovableBlockBounds) {
1698
- if (rect.intersects(immovableRect)) {
1699
- return immovableRect;
1700
- }
1701
- }
1702
- return null;
1703
- };
1704
-
1705
- let cursorY = 0;
1706
- const minBlockHeight = this.renderer.getConstants().MIN_BLOCK_HEIGHT;
1707
- for (const block of movableBlocks) {
1708
- // Make the initial movement of shifting the block to its best possible position.
1709
- let boundingRect = block.getBoundingRectangle();
1710
- block.moveBy(-boundingRect.left, cursorY - boundingRect.top, ['cleanup']);
1711
- block.snapToGrid();
1712
-
1713
- boundingRect = block.getBoundingRectangle();
1714
- let conflictingRect = getNextIntersectingImmovableBlock(boundingRect);
1715
- while (conflictingRect != null) {
1716
- // If the block intersects with an immovable block, move it down past that immovable block.
1717
- cursorY =
1718
- conflictingRect.top + conflictingRect.getHeight() + minBlockHeight;
1719
- block.moveBy(0, cursorY - boundingRect.top, ['cleanup']);
1720
- block.snapToGrid();
1721
- boundingRect = block.getBoundingRectangle();
1722
- conflictingRect = getNextIntersectingImmovableBlock(boundingRect);
1723
- }
1724
-
1725
- // Ensure all next blocks start past the most recent (which will also put them past all
1726
- // previously intersecting immovable blocks).
1727
- cursorY =
1728
- block.getRelativeToSurfaceXY().y +
1729
- block.getHeightWidth().height +
1730
- minBlockHeight;
1731
- }
1732
- eventUtils.setGroup(existingGroup);
1733
- this.setResizesEnabled(true);
1734
- }
1735
-
1736
- /**
1737
- * Show the context menu for the workspace.
1738
- *
1739
- * @param e Mouse event.
1740
- * @internal
1741
- */
1742
- showContextMenu(e: Event) {
1743
- if (this.isReadOnly() || this.isFlyout) {
1744
- return;
1745
- }
1746
- const menuOptions = ContextMenuRegistry.registry.getContextMenuOptions(
1747
- {workspace: this, focusedNode: this},
1748
- e,
1749
- );
1750
-
1751
- // Allow the developer to add or modify menuOptions.
1752
- if (this.configureContextMenu) {
1753
- this.configureContextMenu(menuOptions, e);
1754
- }
1755
-
1756
- let location;
1757
- if (e instanceof PointerEvent) {
1758
- location = new Coordinate(e.clientX, e.clientY);
1759
- } else {
1760
- // TODO: Get the location based on the workspace cursor location
1761
- location = svgMath.wsToScreenCoordinates(this, new Coordinate(5, 5));
1762
- }
1763
-
1764
- ContextMenu.show(e, menuOptions, this.RTL, this, location);
1765
- }
1766
-
1767
- /**
1768
- * Modify the block tree on the existing toolbox.
1769
- *
1770
- * @param toolboxDef DOM tree of toolbox contents, string of toolbox contents,
1771
- * or JSON representing toolbox definition.
1772
- */
1773
- updateToolbox(toolboxDef: toolbox.ToolboxDefinition | null) {
1774
- const parsedToolboxDef = toolbox.convertToolboxDefToJson(toolboxDef);
1775
-
1776
- if (!parsedToolboxDef) {
1777
- if (this.options.languageTree) {
1778
- throw Error("Can't nullify an existing toolbox.");
1779
- }
1780
- return; // No change (null to null).
1781
- }
1782
- if (!this.options.languageTree) {
1783
- throw Error("Existing toolbox is null. Can't create new toolbox.");
1784
- }
1785
-
1786
- if (toolbox.hasCategories(parsedToolboxDef)) {
1787
- if (!this.toolbox) {
1788
- throw Error("Existing toolbox has no categories. Can't change mode.");
1789
- }
1790
- this.options.languageTree = parsedToolboxDef;
1791
- this.toolbox.render(parsedToolboxDef);
1792
- } else {
1793
- if (!this.flyout) {
1794
- throw Error("Existing toolbox has categories. Can't change mode.");
1795
- }
1796
- this.options.languageTree = parsedToolboxDef;
1797
- this.flyout.show(parsedToolboxDef);
1798
- }
1799
- }
1800
-
1801
- /** Mark this workspace as the currently focused main workspace. */
1802
- markFocused() {
1803
- if (this.options.parentWorkspace) {
1804
- this.options.parentWorkspace.markFocused();
1805
- } else {
1806
- common.setMainWorkspace(this);
1807
- // We call e.preventDefault in many event handlers which means we
1808
- // need to explicitly grab focus (e.g from a textarea) because
1809
- // the browser will not do it for us.
1810
- this.getParentSvg().focus({preventScroll: true});
1811
- }
1812
- }
1813
-
1814
- /**
1815
- * Zooms the workspace in or out relative to/centered on the given (x, y)
1816
- * coordinate.
1817
- *
1818
- * @param x X coordinate of center, in pixel units relative to the top-left
1819
- * corner of the parentSVG.
1820
- * @param y Y coordinate of center, in pixel units relative to the top-left
1821
- * corner of the parentSVG.
1822
- * @param amount Amount of zooming. The formula for the new scale is newScale
1823
- * = currentScale * (scaleSpeed^amount). scaleSpeed is set in the
1824
- * workspace options. Negative amount values zoom out, and positive amount
1825
- * values zoom in.
1826
- */
1827
- zoom(x: number, y: number, amount: number) {
1828
- // Scale factor.
1829
- const speed = this.options.zoomOptions.scaleSpeed;
1830
- let scaleChange = Math.pow(speed, amount);
1831
- const newScale = this.scale * scaleChange;
1832
- if (this.scale === newScale) {
1833
- return; // No change in zoom.
1834
- }
1835
-
1836
- // Clamp scale within valid range.
1837
- if (newScale > this.options.zoomOptions.maxScale) {
1838
- scaleChange = this.options.zoomOptions.maxScale / this.scale;
1839
- } else if (newScale < this.options.zoomOptions.minScale) {
1840
- scaleChange = this.options.zoomOptions.minScale / this.scale;
1841
- }
1842
-
1843
- // Transform the x/y coordinates from the parentSVG's space into the
1844
- // canvas' space, so that they are in workspace units relative to the top
1845
- // left of the visible portion of the workspace.
1846
- let matrix = this.getCanvas().getCTM();
1847
- let center = this.getParentSvg().createSVGPoint();
1848
- center.x = x;
1849
- center.y = y;
1850
- center = center.matrixTransform(matrix!.inverse());
1851
- x = center.x;
1852
- y = center.y;
1853
-
1854
- // Find the new scrollX/scrollY so that the center remains in the same
1855
- // position (relative to the center) after we zoom.
1856
- // newScale and matrix.a should be identical (within a rounding error).
1857
- matrix = matrix!
1858
- .translate(x * (1 - scaleChange), y * (1 - scaleChange))
1859
- .scale(scaleChange);
1860
- // scrollX and scrollY are in pixels.
1861
- // The scrollX and scrollY still need to have absoluteLeft and absoluteTop
1862
- // subtracted from them, but we'll leave that for setScale so that they're
1863
- // correctly updated for the new flyout size if we have a simple toolbox.
1864
- this.scrollX = matrix.e;
1865
- this.scrollY = matrix.f;
1866
- this.setScale(newScale);
1867
- }
1868
-
1869
- /**
1870
- * Zooming the blocks centered in the center of view with zooming in or out.
1871
- *
1872
- * @param type Type of zooming (-1 zooming out and 1 zooming in).
1873
- */
1874
- zoomCenter(type: number) {
1875
- const metrics = this.getMetrics();
1876
- let x;
1877
- let y;
1878
- if (this.flyout) {
1879
- // If you want blocks in the center of the view (visible portion of the
1880
- // workspace) to stay centered when the size of the view decreases (i.e.
1881
- // when the size of the flyout increases) you need the center of the
1882
- // *blockly div* to stay in the same pixel-position.
1883
- // Note: This only works because of how scrollCenter positions blocks.
1884
- x = metrics.svgWidth ? metrics.svgWidth / 2 : 0;
1885
- y = metrics.svgHeight ? metrics.svgHeight / 2 : 0;
1886
- } else {
1887
- x = metrics.viewWidth / 2 + metrics.absoluteLeft;
1888
- y = metrics.viewHeight / 2 + metrics.absoluteTop;
1889
- }
1890
- this.zoom(x, y, type);
1891
- }
1892
-
1893
- /** Zoom the blocks to fit in the workspace if possible. */
1894
- zoomToFit() {
1895
- if (!this.isMovable()) {
1896
- console.warn(
1897
- 'Tried to move a non-movable workspace. This could result' +
1898
- ' in blocks becoming inaccessible.',
1899
- );
1900
- return;
1901
- }
1902
-
1903
- const metrics = this.getMetrics();
1904
- let workspaceWidth = metrics.viewWidth;
1905
- let workspaceHeight = metrics.viewHeight;
1906
- const blocksBox = this.getBlocksBoundingBox();
1907
- const doubleMargin = ZOOM_TO_FIT_MARGIN * 2;
1908
- let blocksWidth = blocksBox.right - blocksBox.left + doubleMargin;
1909
- let blocksHeight = blocksBox.bottom - blocksBox.top + doubleMargin;
1910
- if (!blocksWidth) {
1911
- return; // Prevents zooming to infinity.
1912
- }
1913
- if (this.flyout) {
1914
- // We have to add the flyout size to both the workspace size and the
1915
- // block size because the blocks we want to resize include the blocks in
1916
- // the flyout, and the area we want to fit them includes the portion of
1917
- // the workspace that is behind the flyout.
1918
- if (this.horizontalLayout) {
1919
- workspaceHeight += this.flyout.getHeight();
1920
- // Convert from pixels to workspace coordinates.
1921
- blocksHeight += this.flyout.getHeight() / this.scale;
1922
- } else {
1923
- workspaceWidth += this.flyout.getWidth();
1924
- // Convert from pixels to workspace coordinates.
1925
- blocksWidth += this.flyout.getWidth() / this.scale;
1926
- }
1927
- }
1928
-
1929
- // Scale Units: (pixels / workspaceUnit)
1930
- const ratioX = workspaceWidth / blocksWidth;
1931
- const ratioY = workspaceHeight / blocksHeight;
1932
- eventUtils.disable();
1933
- try {
1934
- this.setScale(Math.min(ratioX, ratioY));
1935
- this.scrollCenter();
1936
- } finally {
1937
- eventUtils.enable();
1938
- }
1939
- this.maybeFireViewportChangeEvent();
1940
- }
1941
-
1942
- /**
1943
- * Add a transition class to the block and bubble canvas, to animate any
1944
- * transform changes.
1945
- *
1946
- * @internal
1947
- */
1948
- beginCanvasTransition() {
1949
- dom.addClass(this.getCanvas(), 'blocklyCanvasTransitioning');
1950
- dom.addClass(this.getBubbleCanvas(), 'blocklyCanvasTransitioning');
1951
- }
1952
-
1953
- /**
1954
- * Remove transition class from the block and bubble canvas.
1955
- *
1956
- * @internal
1957
- */
1958
- endCanvasTransition() {
1959
- dom.removeClass(this.getCanvas(), 'blocklyCanvasTransitioning');
1960
- dom.removeClass(this.getBubbleCanvas(), 'blocklyCanvasTransitioning');
1961
- }
1962
-
1963
- /** Center the workspace. */
1964
- scrollCenter() {
1965
- if (!this.isMovable()) {
1966
- console.warn(
1967
- 'Tried to move a non-movable workspace. This could result' +
1968
- ' in blocks becoming inaccessible.',
1969
- );
1970
- return;
1971
- }
1972
-
1973
- const metrics = this.getMetrics();
1974
- let x = (metrics.scrollWidth - metrics.viewWidth) / 2;
1975
- let y = (metrics.scrollHeight - metrics.viewHeight) / 2;
1976
-
1977
- // Convert from workspace directions to canvas directions.
1978
- x = -x - metrics.scrollLeft;
1979
- y = -y - metrics.scrollTop;
1980
- this.scroll(x, y);
1981
- }
1982
-
1983
- /**
1984
- * Scroll the workspace to center on the given block. If the block has other
1985
- * blocks stacked below it, the workspace will be centered on the stack,
1986
- * unless blockOnly is true.
1987
- *
1988
- * @param id ID of block center on.
1989
- * @param blockOnly True to center only on the block itself, not its stack.
1990
- */
1991
- centerOnBlock(id: string | null, blockOnly?: boolean) {
1992
- if (!this.isMovable()) {
1993
- console.warn(
1994
- 'Tried to move a non-movable workspace. This could result' +
1995
- ' in blocks becoming inaccessible.',
1996
- );
1997
- return;
1998
- }
1999
-
2000
- const block = id ? this.getBlockById(id) : null;
2001
- if (!block) {
2002
- return;
2003
- }
2004
-
2005
- // XY is in workspace coordinates.
2006
- const xy = block.getRelativeToSurfaceXY();
2007
- // Height/width is in workspace units.
2008
- const heightWidth = blockOnly
2009
- ? {height: block.height, width: block.width}
2010
- : block.getHeightWidth();
2011
-
2012
- // Find the enter of the block in workspace units.
2013
- const blockCenterY = xy.y + heightWidth.height / 2;
2014
-
2015
- // In RTL the block's position is the top right of the block, not top left.
2016
- const multiplier = this.RTL ? -1 : 1;
2017
- const blockCenterX = xy.x + (multiplier * heightWidth.width) / 2;
2018
-
2019
- // Workspace scale, used to convert from workspace coordinates to pixels.
2020
- const scale = this.scale;
2021
-
2022
- // Center of block in pixels, relative to workspace origin (center 0,0).
2023
- // Scrolling to here would put the block in the top-left corner of the
2024
- // visible workspace.
2025
- const pixelX = blockCenterX * scale;
2026
- const pixelY = blockCenterY * scale;
2027
-
2028
- const metrics = this.getMetrics();
2029
-
2030
- // viewHeight and viewWidth are in pixels.
2031
- const halfViewWidth = metrics.viewWidth / 2;
2032
- const halfViewHeight = metrics.viewHeight / 2;
2033
-
2034
- // Put the block in the center of the visible workspace instead.
2035
- const scrollToCenterX = pixelX - halfViewWidth;
2036
- const scrollToCenterY = pixelY - halfViewHeight;
2037
-
2038
- // Convert from workspace directions to canvas directions.
2039
- const x = -scrollToCenterX;
2040
- const y = -scrollToCenterY;
2041
-
2042
- this.scroll(x, y);
2043
- }
2044
-
2045
- /**
2046
- * Set the workspace's zoom factor.
2047
- *
2048
- * @param newScale Zoom factor. Units: (pixels / workspaceUnit).
2049
- */
2050
- setScale(newScale: number) {
2051
- if (
2052
- this.options.zoomOptions.maxScale &&
2053
- newScale > this.options.zoomOptions.maxScale
2054
- ) {
2055
- newScale = this.options.zoomOptions.maxScale;
2056
- } else if (
2057
- this.options.zoomOptions.minScale &&
2058
- newScale < this.options.zoomOptions.minScale
2059
- ) {
2060
- newScale = this.options.zoomOptions.minScale;
2061
- }
2062
- this.scale = newScale;
2063
-
2064
- this.hideChaff(false);
2065
- // Get the flyout, if any, whether our own or owned by the toolbox.
2066
- const flyout = this.getFlyout(false);
2067
- if (flyout && flyout.isVisible()) {
2068
- flyout.reflow();
2069
- this.recordDragTargets();
2070
- }
2071
- if (this.grid) {
2072
- this.grid.update(this.scale);
2073
- }
2074
-
2075
- // We call scroll instead of scrollbar.resize() so that we can center the
2076
- // zoom correctly without scrollbars, but scroll does not resize the
2077
- // scrollbars so we have to call resizeView/resizeContent as well.
2078
- const metrics = this.getMetrics();
2079
-
2080
- this.scrollX -= metrics.absoluteLeft;
2081
- this.scrollY -= metrics.absoluteTop;
2082
- // The scroll values and the view values are additive inverses of
2083
- // each other, so when we subtract from one we have to add to the other.
2084
- metrics.viewLeft += metrics.absoluteLeft;
2085
- metrics.viewTop += metrics.absoluteTop;
2086
-
2087
- this.scroll(this.scrollX, this.scrollY);
2088
- if (this.scrollbar) {
2089
- if (this.flyout) {
2090
- this.scrollbar.resizeView(metrics);
2091
- } else {
2092
- this.scrollbar.resizeContent(metrics);
2093
- }
2094
- }
2095
- }
2096
-
2097
- /**
2098
- * Get the workspace's zoom factor.
2099
- *
2100
- * @returns The workspace zoom factor. Units: (pixels / workspaceUnit).
2101
- */
2102
- getScale(): number {
2103
- return this.scale;
2104
- }
2105
-
2106
- /**
2107
- * Returns the absolute scale of the workspace.
2108
- *
2109
- * Workspace scaling is multiplicative; if a workspace B (e.g. a mutator editor)
2110
- * with scale Y is nested within a root workspace A with scale X, workspace B's
2111
- * effective scale is X * Y, because, as a child of A, it is already transformed
2112
- * by A's scaling factor, and then further transforms itself by its own scaling
2113
- * factor. Normally this Just Works, but for global elements (e.g. field
2114
- * editors) that are visually associated with a particular workspace but live at
2115
- * the top level of the DOM rather than being a child of their associated
2116
- * workspace, the absolute/effective scale may be needed to render
2117
- * appropriately.
2118
- *
2119
- * @returns The absolute/effective scale of the given workspace.
2120
- */
2121
- getAbsoluteScale() {
2122
- // Returns a workspace's own scale, without regard to multiplicative scaling.
2123
- const getLocalScale = (workspace: WorkspaceSvg): number => {
2124
- // Workspaces in flyouts may have a distinct scale; use this if relevant.
2125
- if (workspace.isFlyout) {
2126
- const flyout = workspace.targetWorkspace?.getFlyout();
2127
- if (flyout instanceof Flyout) {
2128
- return flyout.getFlyoutScale();
2129
- }
2130
- }
2131
-
2132
- return workspace.getScale();
2133
- };
2134
-
2135
- const computeScale = (workspace: WorkspaceSvg, scale: number): number => {
2136
- // If the workspace has no parent, or it does have a parent but is not
2137
- // actually a child of its parent workspace in the DOM (this is the case for
2138
- // flyouts in the main workspace), we're done; just return the scale so far
2139
- // multiplied by the workspace's own scale.
2140
- if (
2141
- !workspace.options.parentWorkspace ||
2142
- !workspace.options.parentWorkspace
2143
- .getSvgGroup()
2144
- .contains(workspace.getSvgGroup())
2145
- ) {
2146
- return scale * getLocalScale(workspace);
2147
- }
2148
-
2149
- // If there is a parent workspace, and this workspace is a child of it in
2150
- // the DOM, scales are multiplicative, so recurse up the workspace
2151
- // hierarchy.
2152
- return computeScale(
2153
- workspace.options.parentWorkspace,
2154
- scale * getLocalScale(workspace),
2155
- );
2156
- };
2157
-
2158
- return computeScale(this, 1);
2159
- }
2160
-
2161
- /**
2162
- * Scroll the workspace to a specified offset (in pixels), keeping in the
2163
- * workspace bounds. See comment on workspaceSvg.scrollX for more detail on
2164
- * the meaning of these values.
2165
- *
2166
- * @param x Target X to scroll to.
2167
- * @param y Target Y to scroll to.
2168
- */
2169
- scroll(x: number, y: number) {
2170
- this.hideChaff(/* opt_onlyClosePopups= */ true);
2171
-
2172
- // Keep scrolling within the bounds of the content.
2173
- const metrics = this.getMetrics();
2174
- // Canvas coordinates (aka scroll coordinates) have inverse directionality
2175
- // to workspace coordinates so we have to inverse them.
2176
- x = Math.min(x, -metrics.scrollLeft);
2177
- y = Math.min(y, -metrics.scrollTop);
2178
- const maxXDisplacement = Math.max(
2179
- 0,
2180
- metrics.scrollWidth - metrics.viewWidth,
2181
- );
2182
- const maxXScroll = metrics.scrollLeft + maxXDisplacement;
2183
- const maxYDisplacement = Math.max(
2184
- 0,
2185
- metrics.scrollHeight - metrics.viewHeight,
2186
- );
2187
- const maxYScroll = metrics.scrollTop + maxYDisplacement;
2188
- x = Math.max(x, -maxXScroll);
2189
- y = Math.max(y, -maxYScroll);
2190
- this.scrollX = x;
2191
- this.scrollY = y;
2192
-
2193
- if (this.scrollbar) {
2194
- // The content position (displacement from the content's top-left to the
2195
- // origin) plus the scroll position (displacement from the view's top-left
2196
- // to the origin) gives us the distance from the view's top-left to the
2197
- // content's top-left. Then we negate this so we get the displacement from
2198
- // the content's top-left to the view's top-left, matching the
2199
- // directionality of the scrollbars.
2200
- this.scrollbar.set(
2201
- -(x + metrics.scrollLeft),
2202
- -(y + metrics.scrollTop),
2203
- false,
2204
- );
2205
- }
2206
- // We have to shift the translation so that when the canvas is at 0, 0 the
2207
- // workspace origin is not underneath the toolbox.
2208
- x += metrics.absoluteLeft;
2209
- y += metrics.absoluteTop;
2210
- this.translate(x, y);
2211
- }
2212
-
2213
- /**
2214
- * Find the block on this workspace with the specified ID.
2215
- *
2216
- * @param id ID of block to find.
2217
- * @returns The sought after block, or null if not found.
2218
- */
2219
- override getBlockById(id: string): BlockSvg | null {
2220
- return super.getBlockById(id) as BlockSvg;
2221
- }
2222
-
2223
- /**
2224
- * Find all blocks in workspace. Blocks are optionally sorted
2225
- * by position; top to bottom (with slight LTR or RTL bias).
2226
- *
2227
- * @param ordered Sort the list if true.
2228
- * @returns Array of blocks.
2229
- */
2230
- override getAllBlocks(ordered = false): BlockSvg[] {
2231
- return super.getAllBlocks(ordered) as BlockSvg[];
2232
- }
2233
-
2234
- /**
2235
- * Finds the top-level blocks and returns them. Blocks are optionally sorted
2236
- * by position; top to bottom (with slight LTR or RTL bias).
2237
- *
2238
- * @param ordered Sort the list if true.
2239
- * @returns The top-level block objects.
2240
- */
2241
- override getTopBlocks(ordered = false): BlockSvg[] {
2242
- return super.getTopBlocks(ordered) as BlockSvg[];
2243
- }
2244
-
2245
- /**
2246
- * Adds a block to the list of top blocks.
2247
- *
2248
- * @param block Block to add.
2249
- */
2250
- override addTopBlock(block: Block) {
2251
- this.addTopBoundedElement(block as BlockSvg);
2252
- super.addTopBlock(block);
2253
- }
2254
-
2255
- /**
2256
- * Removes a block from the list of top blocks.
2257
- *
2258
- * @param block Block to remove.
2259
- */
2260
- override removeTopBlock(block: Block) {
2261
- this.removeTopBoundedElement(block as BlockSvg);
2262
- super.removeTopBlock(block);
2263
- }
2264
-
2265
- /**
2266
- * Adds a comment to the list of top comments.
2267
- *
2268
- * @param comment comment to add.
2269
- */
2270
- override addTopComment(comment: RenderedWorkspaceComment) {
2271
- this.addTopBoundedElement(comment);
2272
- super.addTopComment(comment);
2273
- }
2274
-
2275
- /**
2276
- * Removes a comment from the list of top comments.
2277
- *
2278
- * @param comment comment to remove.
2279
- */
2280
- override removeTopComment(comment: RenderedWorkspaceComment) {
2281
- this.removeTopBoundedElement(comment);
2282
- super.removeTopComment(comment);
2283
- }
2284
-
2285
- /**
2286
- * Returns a list of comments on this workspace.
2287
- *
2288
- * @param ordered If true, sorts the comments based on their position.
2289
- * @returns A list of workspace comments.
2290
- */
2291
- override getTopComments(ordered = false): RenderedWorkspaceComment[] {
2292
- return super.getTopComments(ordered) as RenderedWorkspaceComment[];
2293
- }
2294
-
2295
- /**
2296
- * Returns the workspace comment with the given ID, if any.
2297
- *
2298
- * @param id The ID of the comment to retrieve.
2299
- * @returns The workspace comment with the given ID, or null.
2300
- */
2301
- override getCommentById(id: string): RenderedWorkspaceComment | null {
2302
- return super.getCommentById(id) as RenderedWorkspaceComment | null;
2303
- }
2304
-
2305
- override getRootWorkspace(): WorkspaceSvg | null {
2306
- return super.getRootWorkspace() as WorkspaceSvg | null;
2307
- }
2308
-
2309
- /**
2310
- * Adds a bounded element to the list of top bounded elements.
2311
- *
2312
- * @param element Bounded element to add.
2313
- */
2314
- addTopBoundedElement(element: IBoundedElement) {
2315
- this.topBoundedElements.push(element);
2316
- }
2317
-
2318
- /**
2319
- * Removes a bounded element from the list of top bounded elements.
2320
- *
2321
- * @param element Bounded element to remove.
2322
- */
2323
- removeTopBoundedElement(element: IBoundedElement) {
2324
- arrayUtils.removeElem(this.topBoundedElements, element);
2325
- }
2326
-
2327
- /**
2328
- * Finds the top-level bounded elements and returns them.
2329
- *
2330
- * @returns The top-level bounded elements.
2331
- */
2332
- getTopBoundedElements(ordered = false): IBoundedElement[] {
2333
- const elements = new Array<IBoundedElement>().concat(
2334
- this.topBoundedElements,
2335
- );
2336
- if (ordered) {
2337
- elements.sort(this.sortByOrigin.bind(this));
2338
- }
2339
-
2340
- return elements;
2341
- }
2342
-
2343
- /**
2344
- * Update whether this workspace has resizes enabled.
2345
- * If enabled, workspace will resize when appropriate.
2346
- * If disabled, workspace will not resize until re-enabled.
2347
- * Use to avoid resizing during a batch operation, for performance.
2348
- *
2349
- * @param enabled Whether resizes should be enabled.
2350
- */
2351
- setResizesEnabled(enabled: boolean) {
2352
- const reenabled = !this.resizesEnabled && enabled;
2353
- this.resizesEnabled = enabled;
2354
- if (reenabled) {
2355
- // Newly enabled. Trigger a resize.
2356
- this.resizeContents();
2357
- }
2358
- }
2359
-
2360
- /**
2361
- * Dispose of all blocks in workspace, with an optimization to prevent
2362
- * resizes.
2363
- */
2364
- override clear() {
2365
- this.setResizesEnabled(false);
2366
- super.clear();
2367
- this.topBoundedElements = [];
2368
- this.setResizesEnabled(true);
2369
- }
2370
-
2371
- /**
2372
- * Register a callback function associated with a given key, for clicks on
2373
- * buttons and labels in the flyout.
2374
- * For instance, a button specified by the XML
2375
- * <button text="create variable" callbackKey="CREATE_VARIABLE"></button>
2376
- * should be matched by a call to
2377
- * registerButtonCallback("CREATE_VARIABLE", yourCallbackFunction).
2378
- *
2379
- * @param key The name to use to look up this function.
2380
- * @param func The function to call when the given button is clicked.
2381
- */
2382
- registerButtonCallback(key: string, func: (p1: FlyoutButton) => void) {
2383
- if (typeof func !== 'function') {
2384
- throw TypeError('Button callbacks must be functions.');
2385
- }
2386
- this.flyoutButtonCallbacks.set(key, func);
2387
- }
2388
-
2389
- /**
2390
- * Get the callback function associated with a given key, for clicks on
2391
- * buttons and labels in the flyout.
2392
- *
2393
- * @param key The name to use to look up the function.
2394
- * @returns The function corresponding to the given key for this workspace;
2395
- * null if no callback is registered.
2396
- */
2397
- getButtonCallback(key: string): ((p1: FlyoutButton) => void) | null {
2398
- return this.flyoutButtonCallbacks.get(key) ?? null;
2399
- }
2400
-
2401
- /**
2402
- * Remove a callback for a click on a button in the flyout.
2403
- *
2404
- * @param key The name associated with the callback function.
2405
- */
2406
- removeButtonCallback(key: string) {
2407
- this.flyoutButtonCallbacks.delete(key);
2408
- }
2409
-
2410
- /**
2411
- * Register a callback function associated with a given key, for populating
2412
- * custom toolbox categories in this workspace. See the variable and
2413
- * procedure categories as an example.
2414
- *
2415
- * @param key The name to use to look up this function.
2416
- * @param func The function to call when the given toolbox category is opened.
2417
- */
2418
- registerToolboxCategoryCallback(
2419
- key: string,
2420
- func: (p1: WorkspaceSvg) => toolbox.FlyoutDefinition,
2421
- ) {
2422
- if (typeof func !== 'function') {
2423
- throw TypeError('Toolbox category callbacks must be functions.');
2424
- }
2425
- this.toolboxCategoryCallbacks.set(key, func);
2426
- }
2427
-
2428
- /**
2429
- * Get the callback function associated with a given key, for populating
2430
- * custom toolbox categories in this workspace.
2431
- *
2432
- * @param key The name to use to look up the function.
2433
- * @returns The function corresponding to the given key for this workspace, or
2434
- * null if no function is registered.
2435
- */
2436
- getToolboxCategoryCallback(
2437
- key: string,
2438
- ): ((p1: WorkspaceSvg) => toolbox.FlyoutDefinition) | null {
2439
- return this.toolboxCategoryCallbacks.get(key) || null;
2440
- }
2441
-
2442
- /**
2443
- * Remove a callback for a click on a custom category's name in the toolbox.
2444
- *
2445
- * @param key The name associated with the callback function.
2446
- */
2447
- removeToolboxCategoryCallback(key: string) {
2448
- this.toolboxCategoryCallbacks.delete(key);
2449
- }
2450
-
2451
- /**
2452
- * Look up the gesture that is tracking this touch stream on this workspace.
2453
- *
2454
- * Returns the gesture in progress, except:
2455
- *
2456
- * - If there is a keyboard-initiate move in progress then null will
2457
- * be returned - after calling event.preventDefault() and
2458
- * event.stopPropagation() to ensure the pointer event is ignored.
2459
- * - If there is a gesture in progress but event.type is
2460
- * 'pointerdown' then the in-progress gesture will be cancelled;
2461
- * this will result in null being returned.
2462
- * - If no gesutre is in progress but event is a pointerdown then a
2463
- * new gesture will be created and returned.
2464
- *
2465
- * @param e Pointer event.
2466
- * @returns The gesture that is tracking this touch stream, or null if no
2467
- * valid gesture exists.
2468
- * @internal
2469
- */
2470
- getGesture(e?: PointerEvent): Gesture | null {
2471
- // TODO(#8960): Query Mover.isMoving to see if move is in progress
2472
- // rather than relying on .keyboardMoveInProgress status flag.
2473
- if (this.keyboardMoveInProgress) {
2474
- // Normally these would be called from Gesture.doStart.
2475
- e?.preventDefault();
2476
- e?.stopPropagation();
2477
- return null;
2478
- }
2479
-
2480
- const isStart = e?.type === 'pointerdown';
2481
- if (isStart && this.currentGesture_?.hasStarted()) {
2482
- console.warn('Tried to start the same gesture twice.');
2483
- // That's funny. We must have missed a mouse up.
2484
- // Cancel it, rather than try to retrieve all of the state we need.
2485
- this.currentGesture_.cancel(); // Sets this.currentGesture_ to null.
2486
- }
2487
- if (!this.currentGesture_ && isStart) {
2488
- // No gesture existed on this workspace, but this looks like the
2489
- // start of a new gesture.
2490
- this.currentGesture_ = new Gesture(e, this);
2491
- }
2492
-
2493
- return this.currentGesture_;
2494
- }
2495
-
2496
- /**
2497
- * Clear the reference to the current gesture.
2498
- *
2499
- * @internal
2500
- */
2501
- clearGesture() {
2502
- this.currentGesture_ = null;
2503
- }
2504
-
2505
- /**
2506
- * Cancel the current gesture, if one exists.
2507
- *
2508
- * @internal
2509
- */
2510
- cancelCurrentGesture() {
2511
- if (this.currentGesture_) {
2512
- this.currentGesture_.cancel();
2513
- }
2514
- }
2515
-
2516
- /**
2517
- * Get the audio manager for this workspace.
2518
- *
2519
- * @returns The audio manager for this workspace.
2520
- */
2521
- getAudioManager(): WorkspaceAudio {
2522
- return this.audioManager;
2523
- }
2524
-
2525
- /**
2526
- * Get the grid object for this workspace, or null if there is none.
2527
- *
2528
- * @returns The grid object for this workspace.
2529
- */
2530
- getGrid(): Grid | null {
2531
- return this.grid;
2532
- }
2533
-
2534
- /**
2535
- * Close tooltips, context menus, dropdown selections, etc.
2536
- *
2537
- * @param onlyClosePopups Whether only popups should be closed. Defaults to
2538
- * false.
2539
- */
2540
- hideChaff(onlyClosePopups = false) {
2541
- Tooltip.hide();
2542
- WidgetDiv.hideIfOwnerIsInWorkspace(this);
2543
- dropDownDiv.hideWithoutAnimation();
2544
-
2545
- this.hideComponents(onlyClosePopups);
2546
- }
2547
-
2548
- /**
2549
- * Hide any autohideable components (like flyout, trashcan, and any
2550
- * user-registered components).
2551
- *
2552
- * @param onlyClosePopups Whether only popups should be closed. Defaults to
2553
- * false.
2554
- */
2555
- hideComponents(onlyClosePopups = false) {
2556
- const autoHideables = this.getComponentManager().getComponents(
2557
- ComponentManager.Capability.AUTOHIDEABLE,
2558
- true,
2559
- );
2560
- autoHideables.forEach((autoHideable) =>
2561
- autoHideable.autoHide(onlyClosePopups),
2562
- );
2563
- }
2564
-
2565
- /**
2566
- * Sets the X/Y translations of a top level workspace.
2567
- *
2568
- * @param xyRatio Contains an x and/or y property which is a float between 0
2569
- * and 1 specifying the degree of scrolling.
2570
- */
2571
- private static setTopLevelWorkspaceMetrics(
2572
- this: WorkspaceSvg,
2573
- xyRatio: {x?: number; y?: number},
2574
- ) {
2575
- const metrics = this.getMetrics();
2576
-
2577
- if (typeof xyRatio.x === 'number') {
2578
- this.scrollX = -(
2579
- metrics.scrollLeft +
2580
- (metrics.scrollWidth - metrics.viewWidth) * xyRatio.x
2581
- );
2582
- }
2583
- if (typeof xyRatio.y === 'number') {
2584
- this.scrollY = -(
2585
- metrics.scrollTop +
2586
- (metrics.scrollHeight - metrics.viewHeight) * xyRatio.y
2587
- );
2588
- }
2589
- // We have to shift the translation so that when the canvas is at 0, 0 the
2590
- // workspace origin is not underneath the toolbox.
2591
- const x = this.scrollX + metrics.absoluteLeft;
2592
- const y = this.scrollY + metrics.absoluteTop;
2593
- // We could call scroll here, but that has extra checks we don't need to do.
2594
- this.translate(x, y);
2595
- }
2596
-
2597
- /**
2598
- * Adds a CSS class to the workspace.
2599
- *
2600
- * @param className Name of class to add.
2601
- */
2602
- addClass(className: string) {
2603
- if (this.injectionDiv) {
2604
- dom.addClass(this.injectionDiv, className);
2605
- }
2606
- }
2607
-
2608
- /**
2609
- * Removes a CSS class from the workspace.
2610
- *
2611
- * @param className Name of class to remove.
2612
- */
2613
- removeClass(className: string) {
2614
- if (this.injectionDiv) {
2615
- dom.removeClass(this.injectionDiv, className);
2616
- }
2617
- }
2618
-
2619
- override setIsReadOnly(readOnly: boolean) {
2620
- super.setIsReadOnly(readOnly);
2621
- if (readOnly) {
2622
- this.addClass('blocklyReadOnly');
2623
- } else {
2624
- this.removeClass('blocklyReadOnly');
2625
- }
2626
- }
2627
-
2628
- /**
2629
- * Scrolls the provided bounds into view.
2630
- *
2631
- * In the case of small workspaces/large bounds, this function prioritizes
2632
- * getting the top left corner of the bounds into view. It also adds some
2633
- * padding around the bounds to allow the element to be comfortably in view.
2634
- *
2635
- * @internal
2636
- * @param bounds A rectangle to scroll into view, as best as possible.
2637
- * @param padding Amount of spacing to put between the bounds and the edge of
2638
- * the workspace's viewport.
2639
- */
2640
- scrollBoundsIntoView(bounds: Rect, padding = 10) {
2641
- if (Gesture.inProgress()) {
2642
- // This can cause jumps during a drag and is only suited for keyboard nav.
2643
- return;
2644
- }
2645
- const scale = this.getScale();
2646
-
2647
- const rawViewport = this.getMetricsManager().getViewMetrics(true);
2648
- const viewport = new Rect(
2649
- rawViewport.top,
2650
- rawViewport.top + rawViewport.height,
2651
- rawViewport.left,
2652
- rawViewport.left + rawViewport.width,
2653
- );
2654
-
2655
- if (
2656
- bounds.left >= viewport.left &&
2657
- bounds.top >= viewport.top &&
2658
- bounds.right <= viewport.right &&
2659
- bounds.bottom <= viewport.bottom
2660
- ) {
2661
- // Do nothing if the block is fully inside the viewport.
2662
- return;
2663
- }
2664
-
2665
- // Add some padding to the bounds so the element is scrolled comfortably
2666
- // into view.
2667
- bounds = bounds.clone();
2668
- bounds.top -= padding;
2669
- bounds.bottom += padding;
2670
- bounds.left -= padding;
2671
- bounds.right += padding;
2672
-
2673
- let deltaX = 0;
2674
- let deltaY = 0;
2675
-
2676
- if (bounds.left < viewport.left) {
2677
- deltaX = this.RTL
2678
- ? Math.min(
2679
- viewport.left - bounds.left,
2680
- viewport.right - bounds.right, // Don't move the right side out of view
2681
- )
2682
- : viewport.left - bounds.left;
2683
- } else if (bounds.right > viewport.right) {
2684
- deltaX = this.RTL
2685
- ? viewport.right - bounds.right
2686
- : Math.max(
2687
- viewport.right - bounds.right,
2688
- viewport.left - bounds.left, // Don't move the left side out of view
2689
- );
2690
- }
2691
-
2692
- if (bounds.top < viewport.top) {
2693
- deltaY = viewport.top - bounds.top;
2694
- } else if (bounds.bottom > viewport.bottom) {
2695
- deltaY = Math.max(
2696
- viewport.bottom - bounds.bottom,
2697
- viewport.top - bounds.top, // Don't move the top out of view
2698
- );
2699
- }
2700
-
2701
- deltaX *= scale;
2702
- deltaY *= scale;
2703
- this.scroll(this.scrollX + deltaX, this.scrollY + deltaY);
2704
- }
2705
-
2706
- /** See IFocusableNode.getFocusableElement. */
2707
- getFocusableElement(): HTMLElement | SVGElement {
2708
- return this.svgGroup_;
2709
- }
2710
-
2711
- /** See IFocusableNode.getFocusableTree. */
2712
- getFocusableTree(): IFocusableTree {
2713
- return (this.isMutator && this.options.parentWorkspace) || this;
2714
- }
2715
-
2716
- /** See IFocusableNode.onNodeFocus. */
2717
- onNodeFocus(): void {}
2718
-
2719
- /** See IFocusableNode.onNodeBlur. */
2720
- onNodeBlur(): void {}
2721
-
2722
- /** See IFocusableNode.canBeFocused. */
2723
- canBeFocused(): boolean {
2724
- return true;
2725
- }
2726
-
2727
- /** See IFocusableTree.getRootFocusableNode. */
2728
- getRootFocusableNode(): IFocusableNode {
2729
- return this;
2730
- }
2731
-
2732
- /** See IFocusableTree.getRestoredFocusableNode. */
2733
- getRestoredFocusableNode(
2734
- previousNode: IFocusableNode | null,
2735
- ): IFocusableNode | null {
2736
- if (!previousNode) {
2737
- const flyout = this.targetWorkspace?.getFlyout();
2738
- if (this.isFlyout && flyout) {
2739
- // Return the first focusable item of the flyout.
2740
- return (
2741
- flyout
2742
- .getContents()
2743
- .find((flyoutItem) => {
2744
- const element = flyoutItem.getElement();
2745
- return isFocusableNode(element) && element.canBeFocused();
2746
- })
2747
- ?.getElement() ?? null
2748
- );
2749
- }
2750
- return this.getTopBlocks(true)[0] ?? null;
2751
- } else return null;
2752
- }
2753
-
2754
- /** See IFocusableTree.getNestedTrees. */
2755
- getNestedTrees(): Array<IFocusableTree> {
2756
- const nestedWorkspaces = this.getAllBlocks()
2757
- .map((block) => block.getIcons())
2758
- .flat()
2759
- .filter(
2760
- (icon): icon is MutatorIcon =>
2761
- icon instanceof MutatorIcon && icon.bubbleIsVisible(),
2762
- )
2763
- .map((icon) => icon.getBubble()?.getWorkspace())
2764
- .filter((workspace) => !!workspace);
2765
-
2766
- const ownFlyout = this.getFlyout(true);
2767
- if (ownFlyout) {
2768
- nestedWorkspaces.push(ownFlyout.getWorkspace());
2769
- }
2770
-
2771
- return nestedWorkspaces;
2772
- }
2773
-
2774
- /**
2775
- * Used for searching for a specific workspace comment.
2776
- * We can't use this.getWorkspaceCommentById because the workspace
2777
- * comment ids might not be globally unique, but the id assigned to
2778
- * the focusable element for the comment should be.
2779
- */
2780
- private searchForWorkspaceComment(
2781
- id: string,
2782
- ): RenderedWorkspaceComment | undefined {
2783
- for (const comment of this.getTopComments()) {
2784
- if (
2785
- comment instanceof RenderedWorkspaceComment &&
2786
- comment.canBeFocused() &&
2787
- comment.getFocusableElement().id === id
2788
- ) {
2789
- return comment;
2790
- }
2791
- }
2792
- }
2793
-
2794
- /** See IFocusableTree.lookUpFocusableNode. */
2795
- lookUpFocusableNode(id: string): IFocusableNode | null {
2796
- // Check against flyout items if this workspace is part of a flyout. Note
2797
- // that blocks may match against this pass before reaching getBlockById()
2798
- // below (but only for a flyout workspace).
2799
- const flyout = this.targetWorkspace?.getFlyout();
2800
- if (this.isFlyout && flyout) {
2801
- for (const flyoutItem of flyout.getContents()) {
2802
- const elem = flyoutItem.getElement();
2803
- if (
2804
- isFocusableNode(elem) &&
2805
- elem.canBeFocused() &&
2806
- elem.getFocusableElement().id === id
2807
- ) {
2808
- return elem;
2809
- }
2810
- }
2811
- }
2812
-
2813
- // Search for fields and connections (based on ID indicators).
2814
- const fieldIndicatorIndex = id.indexOf('_field_');
2815
- const connectionIndicatorIndex = id.indexOf('_connection_');
2816
- if (fieldIndicatorIndex !== -1) {
2817
- const blockId = id.substring(0, fieldIndicatorIndex);
2818
- const block = this.getBlockById(blockId);
2819
- if (block) {
2820
- for (const field of block.getFields()) {
2821
- if (field.canBeFocused() && field.getFocusableElement().id === id) {
2822
- return field;
2823
- }
2824
- }
2825
- }
2826
- return null;
2827
- } else if (connectionIndicatorIndex !== -1) {
2828
- const blockId = id.substring(0, connectionIndicatorIndex);
2829
- const block = this.getBlockById(blockId);
2830
- if (block) {
2831
- for (const connection of block.getConnections_(true)) {
2832
- if (connection.id === id) return connection;
2833
- }
2834
- }
2835
- return null;
2836
- }
2837
-
2838
- // Search for a specific workspace comment or comment icon if the ID
2839
- // indicates the presence of one.
2840
- const commentIdSeparatorIndex = Math.max(
2841
- id.indexOf(COMMENT_EDITOR_FOCUS_IDENTIFIER),
2842
- id.indexOf(COMMENT_COLLAPSE_BAR_BUTTON_FOCUS_IDENTIFIER),
2843
- id.indexOf(COMMENT_DELETE_BAR_BUTTON_FOCUS_IDENTIFIER),
2844
- );
2845
- if (commentIdSeparatorIndex !== -1) {
2846
- const commentId = id.substring(0, commentIdSeparatorIndex);
2847
- const comment = this.searchForWorkspaceComment(commentId);
2848
- if (comment) {
2849
- if (id.indexOf(COMMENT_EDITOR_FOCUS_IDENTIFIER) > -1) {
2850
- return comment.getEditorFocusableNode();
2851
- } else {
2852
- return (
2853
- comment.view
2854
- .getCommentBarButtons()
2855
- .find((button) => button.getFocusableElement().id.includes(id)) ??
2856
- null
2857
- );
2858
- }
2859
- }
2860
- }
2861
-
2862
- // Search for a specific block.
2863
- // Don't use `getBlockById` because the block ID is not guaranteed
2864
- // to be globally unique, but the ID on the focusable element is.
2865
- const block = this.getAllBlocks(false).find(
2866
- (block) => block.getFocusableElement().id === id,
2867
- );
2868
- if (block) return block;
2869
-
2870
- // Search for a workspace comment (semi-expensive).
2871
- const comment = this.searchForWorkspaceComment(id);
2872
- if (comment) {
2873
- return comment;
2874
- }
2875
-
2876
- // Search for icons and bubbles (which requires an expensive getAllBlocks).
2877
- const icons = this.getAllBlocks()
2878
- .map((block) => block.getIcons())
2879
- .flat();
2880
- for (const icon of icons) {
2881
- if (icon.canBeFocused() && icon.getFocusableElement().id === id) {
2882
- return icon;
2883
- }
2884
- if (hasBubble(icon)) {
2885
- const bubble = icon.getBubble();
2886
- if (
2887
- bubble &&
2888
- bubble.canBeFocused() &&
2889
- bubble.getFocusableElement().id === id
2890
- ) {
2891
- return bubble;
2892
- } else if (
2893
- bubble instanceof TextInputBubble &&
2894
- bubble.getEditor().getFocusableElement().id === id
2895
- ) {
2896
- return bubble.getEditor();
2897
- }
2898
- }
2899
- }
2900
-
2901
- return null;
2902
- }
2903
-
2904
- /** See IFocusableTree.onTreeFocus. */
2905
- onTreeFocus(
2906
- _node: IFocusableNode,
2907
- _previousTree: IFocusableTree | null,
2908
- ): void {}
2909
-
2910
- /** See IFocusableTree.onTreeBlur. */
2911
- onTreeBlur(nextTree: IFocusableTree | null): void {
2912
- // If the flyout loses focus, make sure to close it unless focus is being
2913
- // lost to the toolbox or ephemeral focus.
2914
- if (this.isFlyout && this.targetWorkspace) {
2915
- // Only hide the flyout if the flyout's workspace is losing focus and that
2916
- // focus isn't returning to the flyout itself, the toolbox, or ephemeral.
2917
- if (getFocusManager().ephemeralFocusTaken()) return;
2918
- const toolbox = this.targetWorkspace.getToolbox();
2919
- if (toolbox && nextTree === toolbox) return;
2920
- if (isAutoHideable(toolbox)) toolbox.autoHide(false);
2921
- }
2922
- }
2923
-
2924
- /**
2925
- * Returns an object responsible for coordinating movement of focus between
2926
- * items on this workspace in response to keyboard navigation commands.
2927
- *
2928
- * @returns This workspace's Navigator instance.
2929
- */
2930
- getNavigator(): Navigator {
2931
- return this.navigator;
2932
- }
2933
-
2934
- /**
2935
- * Sets the Navigator instance used by this workspace.
2936
- *
2937
- * @param newNavigator A Navigator object to coordinate movement between
2938
- * elements on the workspace.
2939
- */
2940
- setNavigator(newNavigator: Navigator) {
2941
- this.navigator = newNavigator;
2942
- }
2943
- }
2944
-
2945
- /**
2946
- * Size the workspace when the contents change. This also updates
2947
- * scrollbars accordingly.
2948
- *
2949
- * @param workspace The workspace to resize.
2950
- * @internal
2951
- */
2952
- export function resizeSvgContents(workspace: WorkspaceSvg) {
2953
- workspace.resizeContents();
2954
- }