blockly 12.0.0-beta.4 → 12.0.0-beta.6

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 (336) hide show
  1. package/blockly.min.js +715 -664
  2. package/blockly.mjs +11 -1
  3. package/blockly_compressed.js +679 -661
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +3 -3
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +1 -16
  8. package/core/block_svg.d.ts +19 -31
  9. package/core/blockly.d.ts +15 -7
  10. package/core/bubbles/bubble.d.ts +22 -3
  11. package/core/bubbles/textinput_bubble.d.ts +3 -5
  12. package/core/comments/rendered_workspace_comment.d.ts +11 -0
  13. package/core/common.d.ts +19 -7
  14. package/core/connection.d.ts +3 -2
  15. package/core/contextmenu_registry.d.ts +11 -9
  16. package/core/dialog.d.ts +36 -16
  17. package/core/events/events.d.ts +0 -2
  18. package/core/events/predicates.d.ts +0 -3
  19. package/core/events/utils.d.ts +1 -5
  20. package/core/field.d.ts +28 -30
  21. package/core/field_dropdown.d.ts +17 -3
  22. package/core/field_image.d.ts +0 -2
  23. package/core/field_input.d.ts +9 -0
  24. package/core/field_variable.d.ts +0 -2
  25. package/core/flyout_base.d.ts +25 -1
  26. package/core/flyout_button.d.ts +15 -13
  27. package/core/flyout_item.d.ts +3 -9
  28. package/core/flyout_navigator.d.ts +11 -0
  29. package/core/flyout_separator.d.ts +20 -1
  30. package/core/focus_manager.d.ts +86 -14
  31. package/core/icons/comment_icon.d.ts +3 -0
  32. package/core/icons/icon.d.ts +13 -0
  33. package/core/icons/mutator_icon.d.ts +3 -0
  34. package/core/icons/warning_icon.d.ts +3 -0
  35. package/core/interfaces/i_autohideable.d.ts +2 -0
  36. package/core/interfaces/i_bubble.d.ts +2 -1
  37. package/core/interfaces/i_flyout.d.ts +2 -1
  38. package/core/interfaces/i_focusable_node.d.ts +71 -8
  39. package/core/interfaces/i_focusable_tree.d.ts +67 -0
  40. package/core/interfaces/i_has_bubble.d.ts +13 -0
  41. package/core/interfaces/i_icon.d.ts +2 -1
  42. package/core/interfaces/i_navigation_policy.d.ts +63 -0
  43. package/core/interfaces/i_selectable.d.ts +7 -1
  44. package/core/interfaces/i_toolbox.d.ts +2 -1
  45. package/core/interfaces/i_toolbox_item.d.ts +2 -1
  46. package/core/keyboard_nav/block_navigation_policy.d.ts +59 -0
  47. package/core/keyboard_nav/connection_navigation_policy.d.ts +67 -0
  48. package/core/keyboard_nav/field_navigation_policy.d.ts +56 -0
  49. package/core/keyboard_nav/flyout_button_navigation_policy.d.ts +56 -0
  50. package/core/keyboard_nav/flyout_navigation_policy.d.ts +65 -0
  51. package/core/keyboard_nav/flyout_separator_navigation_policy.d.ts +33 -0
  52. package/core/keyboard_nav/line_cursor.d.ts +24 -185
  53. package/core/keyboard_nav/marker.d.ts +17 -29
  54. package/core/keyboard_nav/workspace_navigation_policy.d.ts +56 -0
  55. package/core/layer_manager.d.ts +3 -2
  56. package/core/marker_manager.d.ts +0 -26
  57. package/core/navigator.d.ts +65 -0
  58. package/core/rendered_connection.d.ts +24 -1
  59. package/core/renderers/common/block_rendering.d.ts +1 -2
  60. package/core/renderers/common/drawer.d.ts +1 -1
  61. package/core/renderers/common/i_path_object.d.ts +1 -25
  62. package/core/renderers/common/path_object.d.ts +1 -26
  63. package/core/renderers/common/renderer.d.ts +0 -11
  64. package/core/renderers/zelos/drawer.d.ts +1 -1
  65. package/core/renderers/zelos/renderer.d.ts +0 -11
  66. package/core/renderers/zelos/zelos.d.ts +1 -2
  67. package/core/shortcut_registry.d.ts +7 -2
  68. package/core/toast.d.ts +74 -0
  69. package/core/toolbox/toolbox.d.ts +25 -1
  70. package/core/toolbox/toolbox_item.d.ts +11 -0
  71. package/core/utils/aria.d.ts +5 -2
  72. package/core/utils/object.d.ts +3 -0
  73. package/core/variable_map.d.ts +11 -6
  74. package/core/variables.d.ts +3 -1
  75. package/core/workspace.d.ts +11 -11
  76. package/core/workspace_dragger.d.ts +5 -0
  77. package/core/workspace_svg.d.ts +99 -48
  78. package/index.mjs +11 -1
  79. package/msg/ab.js +33 -0
  80. package/msg/ab.mjs +33 -0
  81. package/msg/ace.js +33 -0
  82. package/msg/ace.mjs +33 -0
  83. package/msg/af.js +33 -0
  84. package/msg/af.mjs +33 -0
  85. package/msg/am.js +33 -0
  86. package/msg/am.mjs +33 -0
  87. package/msg/ar.js +33 -0
  88. package/msg/ar.mjs +33 -0
  89. package/msg/ast.js +33 -0
  90. package/msg/ast.mjs +33 -0
  91. package/msg/az.js +33 -0
  92. package/msg/az.mjs +33 -0
  93. package/msg/ba.js +33 -0
  94. package/msg/ba.mjs +33 -0
  95. package/msg/bcc.js +33 -0
  96. package/msg/bcc.mjs +33 -0
  97. package/msg/be-tarask.js +33 -0
  98. package/msg/be-tarask.mjs +33 -0
  99. package/msg/be.js +33 -0
  100. package/msg/be.mjs +33 -0
  101. package/msg/bg.js +33 -0
  102. package/msg/bg.mjs +33 -0
  103. package/msg/bn.js +33 -0
  104. package/msg/bn.mjs +33 -0
  105. package/msg/br.js +33 -0
  106. package/msg/br.mjs +33 -0
  107. package/msg/bs.js +33 -0
  108. package/msg/bs.mjs +33 -0
  109. package/msg/ca.js +33 -0
  110. package/msg/ca.mjs +33 -0
  111. package/msg/cdo.js +33 -0
  112. package/msg/cdo.mjs +33 -0
  113. package/msg/ce.js +33 -0
  114. package/msg/ce.mjs +33 -0
  115. package/msg/cs.js +33 -0
  116. package/msg/cs.mjs +33 -0
  117. package/msg/da.js +33 -0
  118. package/msg/da.mjs +33 -0
  119. package/msg/de.js +33 -0
  120. package/msg/de.mjs +33 -0
  121. package/msg/diq.js +33 -0
  122. package/msg/diq.mjs +33 -0
  123. package/msg/dtp.js +33 -0
  124. package/msg/dtp.mjs +33 -0
  125. package/msg/dty.js +33 -0
  126. package/msg/dty.mjs +33 -0
  127. package/msg/ee.js +33 -0
  128. package/msg/ee.mjs +33 -0
  129. package/msg/el.js +33 -0
  130. package/msg/el.mjs +33 -0
  131. package/msg/en-gb.js +33 -0
  132. package/msg/en-gb.mjs +33 -0
  133. package/msg/en.js +33 -0
  134. package/msg/en.mjs +33 -0
  135. package/msg/eo.js +33 -0
  136. package/msg/eo.mjs +33 -0
  137. package/msg/es.js +33 -0
  138. package/msg/es.mjs +33 -0
  139. package/msg/et.js +33 -0
  140. package/msg/et.mjs +33 -0
  141. package/msg/eu.js +33 -0
  142. package/msg/eu.mjs +33 -0
  143. package/msg/fa.js +33 -0
  144. package/msg/fa.mjs +33 -0
  145. package/msg/fi.js +33 -0
  146. package/msg/fi.mjs +33 -0
  147. package/msg/fo.js +33 -0
  148. package/msg/fo.mjs +33 -0
  149. package/msg/fr.js +33 -0
  150. package/msg/fr.mjs +33 -0
  151. package/msg/frr.js +33 -0
  152. package/msg/frr.mjs +33 -0
  153. package/msg/gl.js +33 -0
  154. package/msg/gl.mjs +33 -0
  155. package/msg/gn.js +33 -0
  156. package/msg/gn.mjs +33 -0
  157. package/msg/gor.js +33 -0
  158. package/msg/gor.mjs +33 -0
  159. package/msg/ha.js +33 -0
  160. package/msg/ha.mjs +33 -0
  161. package/msg/hak.js +33 -0
  162. package/msg/hak.mjs +33 -0
  163. package/msg/he.js +33 -0
  164. package/msg/he.mjs +33 -0
  165. package/msg/hi.js +33 -0
  166. package/msg/hi.mjs +33 -0
  167. package/msg/hr.js +33 -0
  168. package/msg/hr.mjs +33 -0
  169. package/msg/hrx.js +33 -0
  170. package/msg/hrx.mjs +33 -0
  171. package/msg/hsb.js +33 -0
  172. package/msg/hsb.mjs +33 -0
  173. package/msg/hu.js +33 -0
  174. package/msg/hu.mjs +33 -0
  175. package/msg/hy.js +33 -0
  176. package/msg/hy.mjs +33 -0
  177. package/msg/ia.js +33 -0
  178. package/msg/ia.mjs +33 -0
  179. package/msg/id.js +33 -0
  180. package/msg/id.mjs +33 -0
  181. package/msg/ig.js +33 -0
  182. package/msg/ig.mjs +33 -0
  183. package/msg/inh.js +33 -0
  184. package/msg/inh.mjs +33 -0
  185. package/msg/is.js +33 -0
  186. package/msg/is.mjs +33 -0
  187. package/msg/it.js +33 -0
  188. package/msg/it.mjs +33 -0
  189. package/msg/ja.js +33 -0
  190. package/msg/ja.mjs +33 -0
  191. package/msg/ka.js +33 -0
  192. package/msg/ka.mjs +33 -0
  193. package/msg/kab.js +33 -0
  194. package/msg/kab.mjs +33 -0
  195. package/msg/kbd-cyrl.js +33 -0
  196. package/msg/kbd-cyrl.mjs +33 -0
  197. package/msg/km.js +33 -0
  198. package/msg/km.mjs +33 -0
  199. package/msg/kn.js +33 -0
  200. package/msg/kn.mjs +33 -0
  201. package/msg/ko.js +33 -0
  202. package/msg/ko.mjs +33 -0
  203. package/msg/ksh.js +33 -0
  204. package/msg/ksh.mjs +33 -0
  205. package/msg/ku-latn.js +33 -0
  206. package/msg/ku-latn.mjs +33 -0
  207. package/msg/ky.js +33 -0
  208. package/msg/ky.mjs +33 -0
  209. package/msg/la.js +33 -0
  210. package/msg/la.mjs +33 -0
  211. package/msg/lb.js +33 -0
  212. package/msg/lb.mjs +33 -0
  213. package/msg/lki.js +33 -0
  214. package/msg/lki.mjs +33 -0
  215. package/msg/lo.js +33 -0
  216. package/msg/lo.mjs +33 -0
  217. package/msg/lrc.js +33 -0
  218. package/msg/lrc.mjs +33 -0
  219. package/msg/lt.js +33 -0
  220. package/msg/lt.mjs +33 -0
  221. package/msg/lv.js +33 -0
  222. package/msg/lv.mjs +33 -0
  223. package/msg/mg.js +33 -0
  224. package/msg/mg.mjs +33 -0
  225. package/msg/mk.js +33 -0
  226. package/msg/mk.mjs +33 -0
  227. package/msg/ml.js +33 -0
  228. package/msg/ml.mjs +33 -0
  229. package/msg/mnw.js +33 -0
  230. package/msg/mnw.mjs +33 -0
  231. package/msg/ms.js +33 -0
  232. package/msg/ms.mjs +33 -0
  233. package/msg/my.js +33 -0
  234. package/msg/my.mjs +33 -0
  235. package/msg/mzn.js +33 -0
  236. package/msg/mzn.mjs +33 -0
  237. package/msg/nb.js +33 -0
  238. package/msg/nb.mjs +33 -0
  239. package/msg/ne.js +33 -0
  240. package/msg/ne.mjs +33 -0
  241. package/msg/nl.js +33 -0
  242. package/msg/nl.mjs +33 -0
  243. package/msg/oc.js +33 -0
  244. package/msg/oc.mjs +33 -0
  245. package/msg/olo.js +33 -0
  246. package/msg/olo.mjs +33 -0
  247. package/msg/pa.js +33 -0
  248. package/msg/pa.mjs +33 -0
  249. package/msg/pl.js +33 -0
  250. package/msg/pl.mjs +33 -0
  251. package/msg/pms.js +33 -0
  252. package/msg/pms.mjs +33 -0
  253. package/msg/ps.js +33 -0
  254. package/msg/ps.mjs +33 -0
  255. package/msg/pt-br.js +33 -0
  256. package/msg/pt-br.mjs +33 -0
  257. package/msg/pt.js +33 -0
  258. package/msg/pt.mjs +33 -0
  259. package/msg/ro.js +33 -0
  260. package/msg/ro.mjs +33 -0
  261. package/msg/ru.js +33 -0
  262. package/msg/ru.mjs +33 -0
  263. package/msg/sc.js +33 -0
  264. package/msg/sc.mjs +33 -0
  265. package/msg/sco.js +33 -0
  266. package/msg/sco.mjs +33 -0
  267. package/msg/sd.js +33 -0
  268. package/msg/sd.mjs +33 -0
  269. package/msg/shn.js +33 -0
  270. package/msg/shn.mjs +33 -0
  271. package/msg/si.js +33 -0
  272. package/msg/si.mjs +33 -0
  273. package/msg/sk.js +33 -0
  274. package/msg/sk.mjs +33 -0
  275. package/msg/skr-arab.js +33 -0
  276. package/msg/skr-arab.mjs +33 -0
  277. package/msg/sl.js +33 -0
  278. package/msg/sl.mjs +33 -0
  279. package/msg/smn.js +33 -0
  280. package/msg/smn.mjs +33 -0
  281. package/msg/sq.js +33 -0
  282. package/msg/sq.mjs +33 -0
  283. package/msg/sr-latn.js +33 -0
  284. package/msg/sr-latn.mjs +33 -0
  285. package/msg/sr.js +33 -0
  286. package/msg/sr.mjs +33 -0
  287. package/msg/sv.js +33 -0
  288. package/msg/sv.mjs +33 -0
  289. package/msg/sw.js +33 -0
  290. package/msg/sw.mjs +33 -0
  291. package/msg/ta.js +33 -0
  292. package/msg/ta.mjs +33 -0
  293. package/msg/tcy.js +33 -0
  294. package/msg/tcy.mjs +33 -0
  295. package/msg/tdd.js +33 -0
  296. package/msg/tdd.mjs +33 -0
  297. package/msg/te.js +33 -0
  298. package/msg/te.mjs +33 -0
  299. package/msg/th.js +33 -0
  300. package/msg/th.mjs +33 -0
  301. package/msg/ti.js +33 -0
  302. package/msg/ti.mjs +33 -0
  303. package/msg/tl.js +33 -0
  304. package/msg/tl.mjs +33 -0
  305. package/msg/tlh.js +33 -0
  306. package/msg/tlh.mjs +33 -0
  307. package/msg/tr.js +33 -0
  308. package/msg/tr.mjs +33 -0
  309. package/msg/ug-arab.js +33 -0
  310. package/msg/ug-arab.mjs +33 -0
  311. package/msg/uk.js +33 -0
  312. package/msg/uk.mjs +33 -0
  313. package/msg/ur.js +33 -0
  314. package/msg/ur.mjs +33 -0
  315. package/msg/uz.js +33 -0
  316. package/msg/uz.mjs +33 -0
  317. package/msg/vi.js +33 -0
  318. package/msg/vi.mjs +33 -0
  319. package/msg/xmf.js +33 -0
  320. package/msg/xmf.mjs +33 -0
  321. package/msg/yo.js +33 -0
  322. package/msg/yo.mjs +33 -0
  323. package/msg/zgh.js +33 -0
  324. package/msg/zgh.mjs +33 -0
  325. package/msg/zh-hans.js +33 -0
  326. package/msg/zh-hans.mjs +33 -0
  327. package/msg/zh-hant.js +33 -0
  328. package/msg/zh-hant.mjs +33 -0
  329. package/package.json +4 -4
  330. package/core/events/events_marker_move.d.ts +0 -69
  331. package/core/interfaces/i_ast_node_location.d.ts +0 -11
  332. package/core/interfaces/i_ast_node_location_svg.d.ts +0 -24
  333. package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -19
  334. package/core/keyboard_nav/ast_node.d.ts +0 -297
  335. package/core/renderers/common/marker_svg.d.ts +0 -256
  336. package/core/renderers/zelos/marker_svg.d.ts +0 -49
package/core/field.d.ts CHANGED
@@ -13,8 +13,8 @@
13
13
  import './events/events_block_change.js';
14
14
  import type { Block } from './block.js';
15
15
  import type { Input } from './inputs/input.js';
16
- import type { IASTNodeLocationSvg } from './interfaces/i_ast_node_location_svg.js';
17
- import type { IASTNodeLocationWithBlock } from './interfaces/i_ast_node_location_with_block.js';
16
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
17
+ import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
18
18
  import type { IKeyboardAccessible } from './interfaces/i_keyboard_accessible.js';
19
19
  import type { IRegistrable } from './interfaces/i_registrable.js';
20
20
  import { ISerializable } from './interfaces/i_serializable.js';
@@ -45,7 +45,7 @@ export type FieldValidator<T = any> = (newValue: T) => T | null | undefined;
45
45
  *
46
46
  * @typeParam T - The value stored on the field.
47
47
  */
48
- export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IASTNodeLocationWithBlock, IKeyboardAccessible, IRegistrable, ISerializable {
48
+ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRegistrable, ISerializable, IFocusableNode {
49
49
  /**
50
50
  * To overwrite the default value which is set in **Field**, directly update
51
51
  * the prototype.
@@ -54,6 +54,8 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
54
54
  * `FieldImage.prototype.DEFAULT_VALUE = null;`
55
55
  */
56
56
  DEFAULT_VALUE: T | null;
57
+ /** Non-breaking space. */
58
+ static readonly NBSP = "\u00A0";
57
59
  /**
58
60
  * A value used to signal when a field's constructor should *not* set the
59
61
  * field's value or run configure_, and should allow a subclass to do that
@@ -73,17 +75,21 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
73
75
  * field is not yet initialized. Is *not* guaranteed to be accurate.
74
76
  */
75
77
  private tooltip;
76
- protected size_: Size;
78
+ /** This field's dimensions. */
79
+ private size;
77
80
  /**
78
- * Holds the cursors svg element when the cursor is attached to the field.
79
- * This is null if there is no cursor on the field.
81
+ * Gets the size of this field. Because getSize() and updateSize() have side
82
+ * effects, this acts as a shim for subclasses which wish to adjust field
83
+ * bounds when setting/getting the size without triggering unwanted rendering
84
+ * or other side effects. Note that subclasses must override *both* get and
85
+ * set if either is overridden; the implementation may just call directly
86
+ * through to super, but it must exist per the JS spec.
80
87
  */
81
- private cursorSvg;
88
+ protected get size_(): Size;
82
89
  /**
83
- * Holds the markers svg element when the marker is attached to the field.
84
- * This is null if there is no marker on the field.
90
+ * Sets the size of this field.
85
91
  */
86
- private markerSvg;
92
+ protected set size_(newValue: Size);
87
93
  /** The rendered field's SVG group element. */
88
94
  protected fieldGroup_: SVGGElement | null;
89
95
  /** The rendered field's SVG border element. */
@@ -139,6 +145,8 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
139
145
  * case by default so that SERIALIZABLE is backwards compatible.
140
146
  */
141
147
  SERIALIZABLE: boolean;
148
+ /** The unique ID of this field. */
149
+ private id_;
142
150
  /**
143
151
  * @param value The initial value of the field.
144
152
  * Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by
@@ -669,26 +677,16 @@ export declare abstract class Field<T = any> implements IASTNodeLocationSvg, IAS
669
677
  * @returns True if the shortcut has been handled, false otherwise.
670
678
  */
671
679
  onShortcut(_shortcut: KeyboardShortcut): boolean;
672
- /**
673
- * Add the cursor SVG to this fields SVG group.
674
- *
675
- * @param cursorSvg The SVG root of the cursor to be added to the field group.
676
- * @internal
677
- */
678
- setCursorSvg(cursorSvg: SVGElement): void;
679
- /**
680
- * Add the marker SVG to this fields SVG group.
681
- *
682
- * @param markerSvg The SVG root of the marker to be added to the field group.
683
- * @internal
684
- */
685
- setMarkerSvg(markerSvg: SVGElement): void;
686
- /**
687
- * Redraw any attached marker or cursor svgs if needed.
688
- *
689
- * @internal
690
- */
691
- updateMarkers_(): void;
680
+ /** See IFocusableNode.getFocusableElement. */
681
+ getFocusableElement(): HTMLElement | SVGElement;
682
+ /** See IFocusableNode.getFocusableTree. */
683
+ getFocusableTree(): IFocusableTree;
684
+ /** See IFocusableNode.onNodeFocus. */
685
+ onNodeFocus(): void;
686
+ /** See IFocusableNode.onNodeBlur. */
687
+ onNodeBlur(): void;
688
+ /** See IFocusableNode.canBeFocused. */
689
+ canBeFocused(): boolean;
692
690
  /**
693
691
  * Subclasses should reimplement this method to construct their Field
694
692
  * subclass from a JSON arg object.
@@ -144,6 +144,13 @@ export declare class FieldDropdown extends Field<string> {
144
144
  * @throws {TypeError} If generated options are incorrectly structured.
145
145
  */
146
146
  getOptions(useCache?: boolean): MenuOption[];
147
+ /**
148
+ * Update the options on this dropdown. This will reset the selected item to
149
+ * the first item in the list.
150
+ *
151
+ * @param menuGenerator The array of options or a generator function.
152
+ */
153
+ setOptions(menuGenerator: MenuGenerator): void;
147
154
  /**
148
155
  * Ensure that the input value is a valid language-neutral option.
149
156
  *
@@ -184,7 +191,13 @@ export declare class FieldDropdown extends Field<string> {
184
191
  /**
185
192
  * Use the `getText_` developer hook to override the field's text
186
193
  * representation. Get the selected option text. If the selected option is
187
- * an image we return the image alt text.
194
+ * an image we return the image alt text. If the selected option is
195
+ * an HTMLElement, return the title, ariaLabel, or innerText of the
196
+ * element.
197
+ *
198
+ * If you use HTMLElement options in Node.js and call this function,
199
+ * ensure that you are supplying an implementation of HTMLElement,
200
+ * such as through jsdom-global.
188
201
  *
189
202
  * @returns Selected option text.
190
203
  */
@@ -239,9 +252,10 @@ export interface ImageProperties {
239
252
  * An individual option in the dropdown menu. Can be either the string literal
240
253
  * `separator` for a menu separator item, or an array for normal action menu
241
254
  * items. In the latter case, the first element is the human-readable value
242
- * (text or image), and the second element is the language-neutral value.
255
+ * (text, ImageProperties object, or HTML element), and the second element is
256
+ * the language-neutral value.
243
257
  */
244
- export type MenuOption = [string | ImageProperties, string] | 'separator';
258
+ export type MenuOption = [string | ImageProperties | HTMLElement, string] | 'separator';
245
259
  /**
246
260
  * A function that generates an array of menu options for FieldDropdown
247
261
  * or its descendants.
@@ -9,7 +9,6 @@
9
9
  * @class
10
10
  */
11
11
  import { Field, FieldConfig } from './field.js';
12
- import { Size } from './utils/size.js';
13
12
  /**
14
13
  * Class for an image on a block.
15
14
  */
@@ -19,7 +18,6 @@ export declare class FieldImage extends Field<string> {
19
18
  * of the field.
20
19
  */
21
20
  private static readonly Y_PADDING;
22
- protected size_: Size;
23
21
  protected readonly imageHeight: number;
24
22
  /** The function to be called when this field is clicked. */
25
23
  private clickHandler;
@@ -62,6 +62,15 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
62
62
  * are not. Editable fields should also be serializable.
63
63
  */
64
64
  SERIALIZABLE: boolean;
65
+ /**
66
+ * Sets the size of this field. Although this appears to be a no-op, it must
67
+ * exist since the getter is overridden below.
68
+ */
69
+ protected set size_(newValue: Size);
70
+ /**
71
+ * Returns the size of this field, with a minimum width of 14.
72
+ */
73
+ protected get size_(): Size;
65
74
  /**
66
75
  * @param value The initial value of the field. Should cast to a string.
67
76
  * Defaults to an empty string if null or undefined. Also accepts
@@ -15,7 +15,6 @@ import { FieldDropdown, FieldDropdownValidator, MenuGenerator, MenuOption } from
15
15
  import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
16
16
  import type { Menu } from './menu.js';
17
17
  import type { MenuItem } from './menuitem.js';
18
- import { Size } from './utils/size.js';
19
18
  /**
20
19
  * Class for a variable's dropdown field.
21
20
  */
@@ -29,7 +28,6 @@ export declare class FieldVariable extends FieldDropdown {
29
28
  * dropdown.
30
29
  */
31
30
  variableTypes: string[] | null;
32
- protected size_: Size;
33
31
  /** The variable model associated with this field. */
34
32
  private variable;
35
33
  /**
@@ -14,6 +14,8 @@ import { FlyoutItem } from './flyout_item.js';
14
14
  import { IAutoHideable } from './interfaces/i_autohideable.js';
15
15
  import type { IFlyout } from './interfaces/i_flyout.js';
16
16
  import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
17
+ import { IFocusableNode } from './interfaces/i_focusable_node.js';
18
+ import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
17
19
  import type { Options } from './options.js';
18
20
  import * as blocks from './serialization/blocks.js';
19
21
  import { Coordinate } from './utils/coordinate.js';
@@ -23,7 +25,7 @@ import { WorkspaceSvg } from './workspace_svg.js';
23
25
  /**
24
26
  * Class for a flyout.
25
27
  */
26
- export declare abstract class Flyout extends DeleteArea implements IAutoHideable, IFlyout {
28
+ export declare abstract class Flyout extends DeleteArea implements IAutoHideable, IFlyout, IFocusableNode {
27
29
  /**
28
30
  * Position the flyout.
29
31
  */
@@ -399,5 +401,27 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
399
401
  * is registered for that type.
400
402
  */
401
403
  protected getInflaterForType(type: string): IFlyoutInflater | null;
404
+ /** See IFocusableNode.getFocusableElement. */
405
+ getFocusableElement(): HTMLElement | SVGElement;
406
+ /** See IFocusableNode.getFocusableTree. */
407
+ getFocusableTree(): IFocusableTree;
408
+ /** See IFocusableNode.onNodeFocus. */
409
+ onNodeFocus(): void;
410
+ /** See IFocusableNode.onNodeBlur. */
411
+ onNodeBlur(): void;
412
+ /** See IFocusableNode.canBeFocused. */
413
+ canBeFocused(): boolean;
414
+ /** See IFocusableTree.getRootFocusableNode. */
415
+ getRootFocusableNode(): IFocusableNode;
416
+ /** See IFocusableTree.getRestoredFocusableNode. */
417
+ getRestoredFocusableNode(_previousNode: IFocusableNode | null): IFocusableNode | null;
418
+ /** See IFocusableTree.getNestedTrees. */
419
+ getNestedTrees(): Array<IFocusableTree>;
420
+ /** See IFocusableTree.lookUpFocusableNode. */
421
+ lookUpFocusableNode(_id: string): IFocusableNode | null;
422
+ /** See IFocusableTree.onTreeFocus. */
423
+ onTreeFocus(_node: IFocusableNode, _previousTree: IFocusableTree | null): void;
424
+ /** See IFocusableTree.onTreeBlur. */
425
+ onTreeBlur(nextTree: IFocusableTree | null): void;
402
426
  }
403
427
  //# sourceMappingURL=flyout_base.d.ts.map
@@ -3,13 +3,9 @@
3
3
  * Copyright 2016 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- /**
7
- * Class for a button in the flyout.
8
- *
9
- * @class
10
- */
11
- import type { IASTNodeLocationSvg } from './blockly.js';
12
6
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
7
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
8
+ import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
13
9
  import type { IRenderedElement } from './interfaces/i_rendered_element.js';
14
10
  import { Coordinate } from './utils/coordinate.js';
15
11
  import { Rect } from './utils/rect.js';
@@ -18,7 +14,7 @@ import type { WorkspaceSvg } from './workspace_svg.js';
18
14
  /**
19
15
  * Class for a button or label in the flyout.
20
16
  */
21
- export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElement, IRenderedElement {
17
+ export declare class FlyoutButton implements IBoundedElement, IRenderedElement, IFocusableNode {
22
18
  private readonly workspace;
23
19
  private readonly targetWorkspace;
24
20
  private readonly isFlyoutLabel;
@@ -49,6 +45,8 @@ export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElemen
49
45
  * This is null if there is no cursor on the button.
50
46
  */
51
47
  cursorSvg: SVGElement | null;
48
+ /** The unique ID for this FlyoutButton. */
49
+ private id;
52
50
  /**
53
51
  * @param workspace The workspace in which to place this button.
54
52
  * @param targetWorkspace The flyout's target workspace.
@@ -116,12 +114,6 @@ export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElemen
116
114
  * group.
117
115
  */
118
116
  setCursorSvg(cursorSvg: SVGElement): void;
119
- /**
120
- * Required by IASTNodeLocationSvg, but not used. A marker cannot be set on a
121
- * button. If the 'mark' shortcut is used on a button, its associated callback
122
- * function is triggered.
123
- */
124
- setMarkerSvg(): void;
125
117
  /**
126
118
  * Do something when the button is clicked.
127
119
  *
@@ -133,5 +125,15 @@ export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElemen
133
125
  * @returns The root SVG element of this rendered element.
134
126
  */
135
127
  getSvgRoot(): SVGGElement;
128
+ /** See IFocusableNode.getFocusableElement. */
129
+ getFocusableElement(): HTMLElement | SVGElement;
130
+ /** See IFocusableNode.getFocusableTree. */
131
+ getFocusableTree(): IFocusableTree;
132
+ /** See IFocusableNode.onNodeFocus. */
133
+ onNodeFocus(): void;
134
+ /** See IFocusableNode.onNodeBlur. */
135
+ onNodeBlur(): void;
136
+ /** See IFocusableNode.canBeFocused. */
137
+ canBeFocused(): boolean;
136
138
  }
137
139
  //# sourceMappingURL=flyout_button.d.ts.map
@@ -1,32 +1,26 @@
1
1
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
2
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
2
3
  /**
3
4
  * Representation of an item displayed in a flyout.
4
5
  */
5
6
  export declare class FlyoutItem {
6
7
  private element;
7
8
  private type;
8
- private focusable;
9
9
  /**
10
10
  * Creates a new FlyoutItem.
11
11
  *
12
12
  * @param element The element that will be displayed in the flyout.
13
13
  * @param type The type of element. Should correspond to the type of the
14
14
  * flyout inflater that created this object.
15
- * @param focusable True if the element should be allowed to be focused by
16
- * e.g. keyboard navigation in the flyout.
17
15
  */
18
- constructor(element: IBoundedElement, type: string, focusable: boolean);
16
+ constructor(element: IBoundedElement & IFocusableNode, type: string);
19
17
  /**
20
18
  * Returns the element displayed in the flyout.
21
19
  */
22
- getElement(): IBoundedElement;
20
+ getElement(): IBoundedElement & IFocusableNode;
23
21
  /**
24
22
  * Returns the type of flyout element this item represents.
25
23
  */
26
24
  getType(): string;
27
- /**
28
- * Returns whether or not the flyout element can receive focus.
29
- */
30
- isFocusable(): boolean;
31
25
  }
32
26
  //# sourceMappingURL=flyout_item.d.ts.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFlyout } from './interfaces/i_flyout.js';
7
+ import { Navigator } from './navigator.js';
8
+ export declare class FlyoutNavigator extends Navigator {
9
+ constructor(flyout: IFlyout);
10
+ }
11
+ //# sourceMappingURL=flyout_navigator.d.ts.map
@@ -4,11 +4,13 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
7
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
8
+ import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
7
9
  import { Rect } from './utils/rect.js';
8
10
  /**
9
11
  * Representation of a gap between elements in a flyout.
10
12
  */
11
- export declare class FlyoutSeparator implements IBoundedElement {
13
+ export declare class FlyoutSeparator implements IBoundedElement, IFocusableNode {
12
14
  private gap;
13
15
  private axis;
14
16
  private x;
@@ -34,6 +36,23 @@ export declare class FlyoutSeparator implements IBoundedElement {
34
36
  * @param _reason The reason this move was initiated.
35
37
  */
36
38
  moveBy(dx: number, dy: number, _reason?: string[]): void;
39
+ /**
40
+ * Returns false to prevent this separator from being navigated to by the
41
+ * keyboard.
42
+ *
43
+ * @returns False.
44
+ */
45
+ isNavigable(): boolean;
46
+ /** See IFocusableNode.getFocusableElement. */
47
+ getFocusableElement(): HTMLElement | SVGElement;
48
+ /** See IFocusableNode.getFocusableTree. */
49
+ getFocusableTree(): IFocusableTree;
50
+ /** See IFocusableNode.onNodeFocus. */
51
+ onNodeFocus(): void;
52
+ /** See IFocusableNode.onNodeBlur. */
53
+ onNodeBlur(): void;
54
+ /** See IFocusableNode.canBeFocused. */
55
+ canBeFocused(): boolean;
37
56
  }
38
57
  /**
39
58
  * Representation of an axis along which a separator occupies space.
@@ -49,9 +49,12 @@ export declare class FocusManager {
49
49
  * using this constant directly (generally it never should need to be used).
50
50
  */
51
51
  static readonly PASSIVE_FOCUS_NODE_CSS_CLASS_NAME = "blocklyPassiveFocus";
52
- focusedNode: IFocusableNode | null;
53
- registeredTrees: Array<IFocusableTree>;
52
+ private focusedNode;
53
+ private previouslyFocusedNode;
54
+ private registeredTrees;
54
55
  private currentlyHoldsEphemeralFocus;
56
+ private lockFocusStateChanges;
57
+ private recentlyLostAllFocus;
55
58
  constructor(addGlobalEventListener: (type: string, listener: EventListener) => void);
56
59
  /**
57
60
  * Registers a new IFocusableTree for automatic focus management.
@@ -120,17 +123,20 @@ export declare class FocusManager {
120
123
  */
121
124
  focusTree(focusableTree: IFocusableTree): void;
122
125
  /**
123
- * Focuses DOM input on the selected node, and marks it as actively focused.
126
+ * Focuses DOM input on the specified node, and marks it as actively focused.
124
127
  *
125
128
  * Any previously focused node will be updated to be passively highlighted (if
126
129
  * it's in a different focusable tree) or blurred (if it's in the same one).
127
130
  *
128
- * @param focusableNode The node that should receive active
129
- * focus.
131
+ * **Important**: If the provided node is not able to be focused (e.g. its
132
+ * canBeFocused() method returns false), it will be ignored and any existing
133
+ * focus state will remain unchanged.
134
+ *
135
+ * @param focusableNode The node that should receive active focus.
130
136
  */
131
137
  focusNode(focusableNode: IFocusableNode): void;
132
138
  /**
133
- * Ephemerally captures focus for a selected element until the returned lambda
139
+ * Ephemerally captures focus for a specific element until the returned lambda
134
140
  * is called. This is expected to be especially useful for ephemeral UI flows
135
141
  * like dialogs.
136
142
  *
@@ -148,16 +154,82 @@ export declare class FocusManager {
148
154
  * simultaneously will result in an error being thrown).
149
155
  */
150
156
  takeEphemeralFocus(focusableElement: HTMLElement | SVGElement): ReturnEphemeralFocus;
157
+ /**
158
+ * Ensures that the manager is currently allowing operations that change its
159
+ * internal focus state (such as via focusNode()).
160
+ *
161
+ * If the manager is currently not allowing state changes, an exception is
162
+ * thrown.
163
+ */
164
+ private ensureManagerIsUnlocked;
165
+ /**
166
+ * Updates the internally tracked focused node to the specified node, or null
167
+ * if focus is being lost. This also updates previous focus tracking.
168
+ *
169
+ * @param newFocusedNode The new node to set as focused.
170
+ */
171
+ private updateFocusedNode;
172
+ /**
173
+ * Defocuses the current actively focused node tracked by the manager, iff
174
+ * there's a node being tracked and the manager doesn't have ephemeral focus.
175
+ */
151
176
  private defocusCurrentFocusedNode;
152
- private setNodeToActive;
153
- private setNodeToPassive;
177
+ /**
178
+ * Marks the specified node as actively focused, also calling related
179
+ * lifecycle callback methods for both the node and its parent tree. This
180
+ * ensures that the node is properly styled to indicate its active focus.
181
+ *
182
+ * This does not change the manager's currently tracked node, nor does it
183
+ * change any other nodes.
184
+ *
185
+ * @param node The node to be actively focused.
186
+ * @param prevTree The tree of the previously actively focused node, or null
187
+ * if there wasn't a previously actively focused node.
188
+ */
189
+ private activelyFocusNode;
190
+ /**
191
+ * Marks the specified node as passively focused, also calling related
192
+ * lifecycle callback methods for both the node and its parent tree. This
193
+ * ensures that the node is properly styled to indicate its passive focus.
194
+ *
195
+ * This does not change the manager's currently tracked node, nor does it
196
+ * change any other nodes.
197
+ *
198
+ * @param node The node to be passively focused.
199
+ * @param nextTree The tree of the node receiving active focus, or null if no
200
+ * node will be actively focused.
201
+ */
202
+ private passivelyFocusNode;
203
+ /**
204
+ * Updates the node's styling to indicate that it should have an active focus
205
+ * indicator.
206
+ *
207
+ * @param node The node to be styled for active focus.
208
+ */
209
+ private setNodeToVisualActiveFocus;
210
+ /**
211
+ * Updates the node's styling to indicate that it should have a passive focus
212
+ * indicator.
213
+ *
214
+ * @param node The node to be styled for passive focus.
215
+ */
216
+ private setNodeToVisualPassiveFocus;
217
+ /**
218
+ * Removes any active/passive indicators for the specified node.
219
+ *
220
+ * @param node The node which should have neither passive nor active focus
221
+ * indication.
222
+ */
154
223
  private removeHighlight;
224
+ private static focusManager;
225
+ /**
226
+ * Returns the page-global FocusManager.
227
+ *
228
+ * The returned instance is guaranteed to not change across function calls,
229
+ * but may change across page loads.
230
+ */
231
+ static getFocusManager(): FocusManager;
155
232
  }
156
- /**
157
- * Returns the page-global FocusManager.
158
- *
159
- * The returned instance is guaranteed to not change across function calls, but
160
- * may change across page loads.
161
- */
233
+ /** Convenience function for FocusManager.getFocusManager. */
162
234
  export declare function getFocusManager(): FocusManager;
163
235
  //# sourceMappingURL=focus_manager.d.ts.map
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { Block } from '../block.js';
7
+ import type { IBubble } from '../interfaces/i_bubble.js';
7
8
  import type { IHasBubble } from '../interfaces/i_has_bubble.js';
8
9
  import type { ISerializable } from '../interfaces/i_serializable.js';
9
10
  import { Coordinate } from '../utils.js';
@@ -92,6 +93,8 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
92
93
  onBubbleLocationChange(): void;
93
94
  bubbleIsVisible(): boolean;
94
95
  setBubbleVisible(visible: boolean): Promise<void>;
96
+ /** See IHasBubble.getBubble. */
97
+ getBubble(): IBubble | null;
95
98
  /**
96
99
  * Shows the editable text bubble for this comment, and adds change listeners
97
100
  * to update the state of this icon in response to changes in the bubble.
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { Block } from '../block.js';
7
+ import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
7
8
  import type { IIcon } from '../interfaces/i_icon.js';
8
9
  import * as tooltip from '../tooltip.js';
9
10
  import { Coordinate } from '../utils/coordinate.js';
@@ -28,6 +29,8 @@ export declare abstract class Icon implements IIcon {
28
29
  protected svgRoot: SVGGElement | null;
29
30
  /** The tooltip for this icon. */
30
31
  protected tooltip: tooltip.TipInfo;
32
+ /** The unique ID of this icon. */
33
+ private id;
31
34
  constructor(sourceBlock: Block);
32
35
  getType(): IconType<IIcon>;
33
36
  initView(pointerdownListener: (e: PointerEvent) => void): void;
@@ -59,5 +62,15 @@ export declare abstract class Icon implements IIcon {
59
62
  * @returns Whether the icon should be clickable while the block is in a flyout.
60
63
  */
61
64
  isClickableInFlyout(autoClosingFlyout: boolean): boolean;
65
+ /** See IFocusableNode.getFocusableElement. */
66
+ getFocusableElement(): HTMLElement | SVGElement;
67
+ /** See IFocusableNode.getFocusableTree. */
68
+ getFocusableTree(): IFocusableTree;
69
+ /** See IFocusableNode.onNodeFocus. */
70
+ onNodeFocus(): void;
71
+ /** See IFocusableNode.onNodeBlur. */
72
+ onNodeBlur(): void;
73
+ /** See IFocusableNode.canBeFocused. */
74
+ canBeFocused(): boolean;
62
75
  }
63
76
  //# sourceMappingURL=icon.d.ts.map
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { BlockSvg } from '../block_svg.js';
7
7
  import type { Abstract } from '../events/events_abstract.js';
8
+ import type { IBubble } from '../interfaces/i_bubble.js';
8
9
  import type { IHasBubble } from '../interfaces/i_has_bubble.js';
9
10
  import { Coordinate } from '../utils/coordinate.js';
10
11
  import { Size } from '../utils/size.js';
@@ -54,6 +55,8 @@ export declare class MutatorIcon extends Icon implements IHasBubble {
54
55
  isClickableInFlyout(): boolean;
55
56
  bubbleIsVisible(): boolean;
56
57
  setBubbleVisible(visible: boolean): Promise<void>;
58
+ /** See IHasBubble.getBubble. */
59
+ getBubble(): IBubble | null;
57
60
  /** @returns the configuration the mini workspace should have. */
58
61
  private getMiniWorkspaceConfig;
59
62
  /**
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { BlockSvg } from '../block_svg.js';
7
+ import type { IBubble } from '../interfaces/i_bubble.js';
7
8
  import type { IHasBubble } from '../interfaces/i_has_bubble.js';
8
9
  import { Size } from '../utils.js';
9
10
  import { Coordinate } from '../utils/coordinate.js';
@@ -60,6 +61,8 @@ export declare class WarningIcon extends Icon implements IHasBubble {
60
61
  isClickableInFlyout(): boolean;
61
62
  bubbleIsVisible(): boolean;
62
63
  setBubbleVisible(visible: boolean): Promise<void>;
64
+ /** See IHasBubble.getBubble. */
65
+ getBubble(): IBubble | null;
63
66
  /**
64
67
  * @returns the location the bubble should be anchored to.
65
68
  * I.E. the middle of this icon.
@@ -16,4 +16,6 @@ export interface IAutoHideable extends IComponent {
16
16
  */
17
17
  autoHide(onlyClosePopups: boolean): void;
18
18
  }
19
+ /** Returns true if the given object is autohideable. */
20
+ export declare function isAutoHideable(obj: any): obj is IAutoHideable;
19
21
  //# sourceMappingURL=i_autohideable.d.ts.map
@@ -6,10 +6,11 @@
6
6
  import type { Coordinate } from '../utils/coordinate.js';
7
7
  import type { IContextMenu } from './i_contextmenu.js';
8
8
  import type { IDraggable } from './i_draggable.js';
9
+ import { IFocusableNode } from './i_focusable_node.js';
9
10
  /**
10
11
  * A bubble interface.
11
12
  */
12
- export interface IBubble extends IDraggable, IContextMenu {
13
+ export interface IBubble extends IDraggable, IContextMenu, IFocusableNode {
13
14
  /**
14
15
  * Return the coordinates of the top-left corner of this bubble's body
15
16
  * relative to the drawing surface's origin (0,0), in workspace units.
@@ -9,11 +9,12 @@ import type { Coordinate } from '../utils/coordinate.js';
9
9
  import type { Svg } from '../utils/svg.js';
10
10
  import type { FlyoutDefinition } from '../utils/toolbox.js';
11
11
  import type { WorkspaceSvg } from '../workspace_svg.js';
12
+ import { IFocusableTree } from './i_focusable_tree.js';
12
13
  import type { IRegistrable } from './i_registrable.js';
13
14
  /**
14
15
  * Interface for a flyout.
15
16
  */
16
- export interface IFlyout extends IRegistrable {
17
+ export interface IFlyout extends IRegistrable, IFocusableTree {
17
18
  /** Whether the flyout is laid out horizontally or not. */
18
19
  horizontalLayout: boolean;
19
20
  /** Is RTL vs LTR. */