blockly 12.0.0-beta.3 → 12.0.0-beta.5

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 (319) hide show
  1. package/blockly.min.js +565 -503
  2. package/blockly.mjs +10 -0
  3. package/blockly_compressed.js +530 -501
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +2 -2
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block_svg.d.ts +53 -23
  8. package/core/blockly.d.ts +13 -1
  9. package/core/comments/rendered_workspace_comment.d.ts +1 -1
  10. package/core/connection.d.ts +2 -0
  11. package/core/contextmenu.d.ts +6 -2
  12. package/core/contextmenu_registry.d.ts +21 -16
  13. package/core/dialog.d.ts +36 -16
  14. package/core/field.d.ts +29 -31
  15. package/core/field_checkbox.d.ts +9 -0
  16. package/core/field_dropdown.d.ts +19 -2
  17. package/core/field_image.d.ts +9 -0
  18. package/core/field_label.d.ts +9 -0
  19. package/core/field_number.d.ts +9 -0
  20. package/core/field_textinput.d.ts +9 -0
  21. package/core/flyout_base.d.ts +23 -1
  22. package/core/flyout_button.d.ts +30 -7
  23. package/core/flyout_item.d.ts +3 -9
  24. package/core/flyout_separator.d.ts +18 -1
  25. package/core/focus_manager.d.ts +82 -14
  26. package/core/interfaces/i_ast_node_location_svg.d.ts +0 -12
  27. package/core/interfaces/i_autohideable.d.ts +2 -0
  28. package/core/interfaces/i_flyout.d.ts +2 -1
  29. package/core/interfaces/i_focusable_node.d.ts +31 -2
  30. package/core/interfaces/i_focusable_tree.d.ts +67 -0
  31. package/core/interfaces/i_navigable.d.ts +30 -0
  32. package/core/interfaces/i_navigation_policy.d.ts +42 -0
  33. package/core/interfaces/i_toolbox.d.ts +2 -1
  34. package/core/interfaces/i_toolbox_item.d.ts +2 -1
  35. package/core/keyboard_nav/ast_node.d.ts +1 -113
  36. package/core/keyboard_nav/block_navigation_policy.d.ts +56 -0
  37. package/core/keyboard_nav/connection_navigation_policy.d.ts +53 -0
  38. package/core/keyboard_nav/field_navigation_policy.d.ts +42 -0
  39. package/core/keyboard_nav/flyout_button_navigation_policy.d.ts +42 -0
  40. package/core/keyboard_nav/flyout_navigation_policy.d.ts +51 -0
  41. package/core/keyboard_nav/flyout_separator_navigation_policy.d.ts +19 -0
  42. package/core/keyboard_nav/line_cursor.d.ts +60 -96
  43. package/core/keyboard_nav/marker.d.ts +20 -29
  44. package/core/keyboard_nav/workspace_navigation_policy.d.ts +42 -0
  45. package/core/marker_manager.d.ts +0 -26
  46. package/core/menuitem.d.ts +5 -2
  47. package/core/navigator.d.ts +65 -0
  48. package/core/rendered_connection.d.ts +35 -1
  49. package/core/renderers/common/block_rendering.d.ts +1 -2
  50. package/core/renderers/common/drawer.d.ts +1 -1
  51. package/core/renderers/common/i_path_object.d.ts +1 -25
  52. package/core/renderers/common/path_object.d.ts +1 -26
  53. package/core/renderers/common/renderer.d.ts +0 -11
  54. package/core/renderers/zelos/drawer.d.ts +1 -1
  55. package/core/renderers/zelos/renderer.d.ts +0 -11
  56. package/core/renderers/zelos/zelos.d.ts +1 -2
  57. package/core/shortcut_registry.d.ts +7 -2
  58. package/core/toast.d.ts +74 -0
  59. package/core/toolbox/toolbox.d.ts +23 -1
  60. package/core/toolbox/toolbox_item.d.ts +9 -0
  61. package/core/utils/aria.d.ts +5 -2
  62. package/core/variable_map.d.ts +4 -4
  63. package/core/variables.d.ts +3 -1
  64. package/core/workspace.d.ts +10 -9
  65. package/core/workspace_svg.d.ts +105 -48
  66. package/index.mjs +10 -0
  67. package/msg/ab.js +33 -0
  68. package/msg/ab.mjs +33 -0
  69. package/msg/ace.js +33 -0
  70. package/msg/ace.mjs +33 -0
  71. package/msg/af.js +33 -0
  72. package/msg/af.mjs +33 -0
  73. package/msg/am.js +33 -0
  74. package/msg/am.mjs +33 -0
  75. package/msg/ar.js +33 -0
  76. package/msg/ar.mjs +33 -0
  77. package/msg/ast.js +33 -0
  78. package/msg/ast.mjs +33 -0
  79. package/msg/az.js +33 -0
  80. package/msg/az.mjs +33 -0
  81. package/msg/ba.js +33 -0
  82. package/msg/ba.mjs +33 -0
  83. package/msg/bcc.js +33 -0
  84. package/msg/bcc.mjs +33 -0
  85. package/msg/be-tarask.js +33 -0
  86. package/msg/be-tarask.mjs +33 -0
  87. package/msg/be.js +33 -0
  88. package/msg/be.mjs +33 -0
  89. package/msg/bg.js +33 -0
  90. package/msg/bg.mjs +33 -0
  91. package/msg/bn.js +33 -0
  92. package/msg/bn.mjs +33 -0
  93. package/msg/br.js +33 -0
  94. package/msg/br.mjs +33 -0
  95. package/msg/bs.js +33 -0
  96. package/msg/bs.mjs +33 -0
  97. package/msg/ca.js +33 -0
  98. package/msg/ca.mjs +33 -0
  99. package/msg/cdo.js +33 -0
  100. package/msg/cdo.mjs +33 -0
  101. package/msg/ce.js +33 -0
  102. package/msg/ce.mjs +33 -0
  103. package/msg/cs.js +33 -0
  104. package/msg/cs.mjs +33 -0
  105. package/msg/da.js +33 -0
  106. package/msg/da.mjs +33 -0
  107. package/msg/de.js +33 -0
  108. package/msg/de.mjs +33 -0
  109. package/msg/diq.js +33 -0
  110. package/msg/diq.mjs +33 -0
  111. package/msg/dtp.js +33 -0
  112. package/msg/dtp.mjs +33 -0
  113. package/msg/dty.js +33 -0
  114. package/msg/dty.mjs +33 -0
  115. package/msg/ee.js +33 -0
  116. package/msg/ee.mjs +33 -0
  117. package/msg/el.js +33 -0
  118. package/msg/el.mjs +33 -0
  119. package/msg/en-gb.js +33 -0
  120. package/msg/en-gb.mjs +33 -0
  121. package/msg/en.js +33 -0
  122. package/msg/en.mjs +33 -0
  123. package/msg/eo.js +33 -0
  124. package/msg/eo.mjs +33 -0
  125. package/msg/es.js +33 -0
  126. package/msg/es.mjs +33 -0
  127. package/msg/et.js +33 -0
  128. package/msg/et.mjs +33 -0
  129. package/msg/eu.js +33 -0
  130. package/msg/eu.mjs +33 -0
  131. package/msg/fa.js +33 -0
  132. package/msg/fa.mjs +33 -0
  133. package/msg/fi.js +33 -0
  134. package/msg/fi.mjs +33 -0
  135. package/msg/fo.js +33 -0
  136. package/msg/fo.mjs +33 -0
  137. package/msg/fr.js +33 -0
  138. package/msg/fr.mjs +33 -0
  139. package/msg/frr.js +33 -0
  140. package/msg/frr.mjs +33 -0
  141. package/msg/gl.js +33 -0
  142. package/msg/gl.mjs +33 -0
  143. package/msg/gn.js +33 -0
  144. package/msg/gn.mjs +33 -0
  145. package/msg/gor.js +33 -0
  146. package/msg/gor.mjs +33 -0
  147. package/msg/ha.js +33 -0
  148. package/msg/ha.mjs +33 -0
  149. package/msg/hak.js +33 -0
  150. package/msg/hak.mjs +33 -0
  151. package/msg/he.js +33 -0
  152. package/msg/he.mjs +33 -0
  153. package/msg/hi.js +33 -0
  154. package/msg/hi.mjs +33 -0
  155. package/msg/hr.js +33 -0
  156. package/msg/hr.mjs +33 -0
  157. package/msg/hrx.js +33 -0
  158. package/msg/hrx.mjs +33 -0
  159. package/msg/hsb.js +33 -0
  160. package/msg/hsb.mjs +33 -0
  161. package/msg/hu.js +33 -0
  162. package/msg/hu.mjs +33 -0
  163. package/msg/hy.js +33 -0
  164. package/msg/hy.mjs +33 -0
  165. package/msg/ia.js +33 -0
  166. package/msg/ia.mjs +33 -0
  167. package/msg/id.js +33 -0
  168. package/msg/id.mjs +33 -0
  169. package/msg/ig.js +33 -0
  170. package/msg/ig.mjs +33 -0
  171. package/msg/inh.js +33 -0
  172. package/msg/inh.mjs +33 -0
  173. package/msg/is.js +33 -0
  174. package/msg/is.mjs +33 -0
  175. package/msg/it.js +33 -0
  176. package/msg/it.mjs +33 -0
  177. package/msg/ja.js +33 -0
  178. package/msg/ja.mjs +33 -0
  179. package/msg/ka.js +33 -0
  180. package/msg/ka.mjs +33 -0
  181. package/msg/kab.js +33 -0
  182. package/msg/kab.mjs +33 -0
  183. package/msg/kbd-cyrl.js +33 -0
  184. package/msg/kbd-cyrl.mjs +33 -0
  185. package/msg/km.js +33 -0
  186. package/msg/km.mjs +33 -0
  187. package/msg/kn.js +33 -0
  188. package/msg/kn.mjs +33 -0
  189. package/msg/ko.js +33 -0
  190. package/msg/ko.mjs +33 -0
  191. package/msg/ksh.js +33 -0
  192. package/msg/ksh.mjs +33 -0
  193. package/msg/ku-latn.js +33 -0
  194. package/msg/ku-latn.mjs +33 -0
  195. package/msg/ky.js +33 -0
  196. package/msg/ky.mjs +33 -0
  197. package/msg/la.js +33 -0
  198. package/msg/la.mjs +33 -0
  199. package/msg/lb.js +33 -0
  200. package/msg/lb.mjs +33 -0
  201. package/msg/lki.js +33 -0
  202. package/msg/lki.mjs +33 -0
  203. package/msg/lo.js +33 -0
  204. package/msg/lo.mjs +33 -0
  205. package/msg/lrc.js +33 -0
  206. package/msg/lrc.mjs +33 -0
  207. package/msg/lt.js +33 -0
  208. package/msg/lt.mjs +33 -0
  209. package/msg/lv.js +33 -0
  210. package/msg/lv.mjs +33 -0
  211. package/msg/mg.js +33 -0
  212. package/msg/mg.mjs +33 -0
  213. package/msg/mk.js +33 -0
  214. package/msg/mk.mjs +33 -0
  215. package/msg/ml.js +33 -0
  216. package/msg/ml.mjs +33 -0
  217. package/msg/mnw.js +33 -0
  218. package/msg/mnw.mjs +33 -0
  219. package/msg/ms.js +33 -0
  220. package/msg/ms.mjs +33 -0
  221. package/msg/my.js +33 -0
  222. package/msg/my.mjs +33 -0
  223. package/msg/mzn.js +33 -0
  224. package/msg/mzn.mjs +33 -0
  225. package/msg/nb.js +33 -0
  226. package/msg/nb.mjs +33 -0
  227. package/msg/ne.js +33 -0
  228. package/msg/ne.mjs +33 -0
  229. package/msg/nl.js +33 -0
  230. package/msg/nl.mjs +33 -0
  231. package/msg/oc.js +33 -0
  232. package/msg/oc.mjs +33 -0
  233. package/msg/olo.js +33 -0
  234. package/msg/olo.mjs +33 -0
  235. package/msg/pa.js +33 -0
  236. package/msg/pa.mjs +33 -0
  237. package/msg/pl.js +33 -0
  238. package/msg/pl.mjs +33 -0
  239. package/msg/pms.js +33 -0
  240. package/msg/pms.mjs +33 -0
  241. package/msg/ps.js +33 -0
  242. package/msg/ps.mjs +33 -0
  243. package/msg/pt-br.js +33 -0
  244. package/msg/pt-br.mjs +33 -0
  245. package/msg/pt.js +33 -0
  246. package/msg/pt.mjs +33 -0
  247. package/msg/ro.js +33 -0
  248. package/msg/ro.mjs +33 -0
  249. package/msg/ru.js +33 -0
  250. package/msg/ru.mjs +33 -0
  251. package/msg/sc.js +33 -0
  252. package/msg/sc.mjs +33 -0
  253. package/msg/sco.js +33 -0
  254. package/msg/sco.mjs +33 -0
  255. package/msg/sd.js +33 -0
  256. package/msg/sd.mjs +33 -0
  257. package/msg/shn.js +33 -0
  258. package/msg/shn.mjs +33 -0
  259. package/msg/si.js +33 -0
  260. package/msg/si.mjs +33 -0
  261. package/msg/sk.js +33 -0
  262. package/msg/sk.mjs +33 -0
  263. package/msg/skr-arab.js +33 -0
  264. package/msg/skr-arab.mjs +33 -0
  265. package/msg/sl.js +33 -0
  266. package/msg/sl.mjs +33 -0
  267. package/msg/smn.js +33 -0
  268. package/msg/smn.mjs +33 -0
  269. package/msg/sq.js +33 -0
  270. package/msg/sq.mjs +33 -0
  271. package/msg/sr-latn.js +33 -0
  272. package/msg/sr-latn.mjs +33 -0
  273. package/msg/sr.js +33 -0
  274. package/msg/sr.mjs +33 -0
  275. package/msg/sv.js +33 -0
  276. package/msg/sv.mjs +33 -0
  277. package/msg/sw.js +33 -0
  278. package/msg/sw.mjs +33 -0
  279. package/msg/ta.js +33 -0
  280. package/msg/ta.mjs +33 -0
  281. package/msg/tcy.js +33 -0
  282. package/msg/tcy.mjs +33 -0
  283. package/msg/tdd.js +33 -0
  284. package/msg/tdd.mjs +33 -0
  285. package/msg/te.js +33 -0
  286. package/msg/te.mjs +33 -0
  287. package/msg/th.js +33 -0
  288. package/msg/th.mjs +33 -0
  289. package/msg/ti.js +33 -0
  290. package/msg/ti.mjs +33 -0
  291. package/msg/tl.js +33 -0
  292. package/msg/tl.mjs +33 -0
  293. package/msg/tlh.js +33 -0
  294. package/msg/tlh.mjs +33 -0
  295. package/msg/tr.js +33 -0
  296. package/msg/tr.mjs +33 -0
  297. package/msg/ug-arab.js +33 -0
  298. package/msg/ug-arab.mjs +33 -0
  299. package/msg/uk.js +33 -0
  300. package/msg/uk.mjs +33 -0
  301. package/msg/ur.js +33 -0
  302. package/msg/ur.mjs +33 -0
  303. package/msg/uz.js +33 -0
  304. package/msg/uz.mjs +33 -0
  305. package/msg/vi.js +33 -0
  306. package/msg/vi.mjs +33 -0
  307. package/msg/xmf.js +33 -0
  308. package/msg/xmf.mjs +33 -0
  309. package/msg/yo.js +33 -0
  310. package/msg/yo.mjs +33 -0
  311. package/msg/zgh.js +33 -0
  312. package/msg/zgh.mjs +33 -0
  313. package/msg/zh-hans.js +33 -0
  314. package/msg/zh-hans.mjs +33 -0
  315. package/msg/zh-hant.js +33 -0
  316. package/msg/zh-hant.mjs +33 -0
  317. package/package.json +4 -4
  318. package/core/renderers/common/marker_svg.d.ts +0 -256
  319. package/core/renderers/zelos/marker_svg.d.ts +0 -49
@@ -9,8 +9,9 @@
9
9
  *
10
10
  * @class
11
11
  */
12
- import type { MarkerSvg } from '../renderers/common/marker_svg.js';
13
- import type { ASTNode } from './ast_node.js';
12
+ import { BlockSvg } from '../block_svg.js';
13
+ import type { INavigable } from '../interfaces/i_navigable.js';
14
+ import { ASTNode } from './ast_node.js';
14
15
  /**
15
16
  * Class for a marker.
16
17
  * This is used in keyboard navigation to save a location in the Blockly AST.
@@ -19,47 +20,37 @@ export declare class Marker {
19
20
  /** The colour of the marker. */
20
21
  colour: string | null;
21
22
  /** The current location of the marker. */
22
- private curNode;
23
- /**
24
- * The object in charge of drawing the visual representation of the current
25
- * node.
26
- */
27
- private drawer;
23
+ protected curNode: INavigable<any> | null;
28
24
  /** The type of the marker. */
29
25
  type: string;
30
- /**
31
- * Sets the object in charge of drawing the marker.
32
- *
33
- * @param drawer The object in charge of drawing the marker.
34
- */
35
- setDrawer(drawer: MarkerSvg): void;
36
- /**
37
- * Get the current drawer for the marker.
38
- *
39
- * @returns The object in charge of drawing the marker.
40
- */
41
- getDrawer(): MarkerSvg | null;
42
26
  /**
43
27
  * Gets the current location of the marker.
44
28
  *
45
29
  * @returns The current field, connection, or block the marker is on.
46
30
  */
47
- getCurNode(): ASTNode | null;
31
+ getCurNode(): INavigable<any> | null;
48
32
  /**
49
33
  * Set the location of the marker and call the update method.
50
34
  *
51
35
  * @param newNode The new location of the marker, or null to remove it.
52
36
  */
53
- setCurNode(newNode: ASTNode | null): void;
37
+ setCurNode(newNode: INavigable<any> | null): void;
38
+ /** Dispose of this marker. */
39
+ dispose(): void;
54
40
  /**
55
- * Redraw the current marker.
41
+ * Converts an INavigable to a legacy ASTNode.
56
42
  *
57
- * @internal
43
+ * @param node The INavigable instance to convert.
44
+ * @returns An ASTNode representation of the given object if possible,
45
+ * otherwise null.
58
46
  */
59
- draw(): void;
60
- /** Hide the marker SVG. */
61
- hide(): void;
62
- /** Dispose of this marker. */
63
- dispose(): void;
47
+ toASTNode(node: INavigable<any> | null): ASTNode | null;
48
+ /**
49
+ * Returns the block that this marker's current node is a child of.
50
+ *
51
+ * @returns The parent block of the marker's current node if any, otherwise
52
+ * null.
53
+ */
54
+ getSourceBlock(): BlockSvg | null;
64
55
  }
65
56
  //# sourceMappingURL=marker.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { INavigable } from '../interfaces/i_navigable.js';
7
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
8
+ import type { WorkspaceSvg } from '../workspace_svg.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a workspace.
11
+ */
12
+ export declare class WorkspaceNavigationPolicy implements INavigationPolicy<WorkspaceSvg> {
13
+ /**
14
+ * Returns the first child of the given workspace.
15
+ *
16
+ * @param current The workspace to return the first child of.
17
+ * @returns The top block of the first block stack, if any.
18
+ */
19
+ getFirstChild(current: WorkspaceSvg): INavigable<unknown> | null;
20
+ /**
21
+ * Returns the parent of the given workspace.
22
+ *
23
+ * @param _current The workspace to return the parent of.
24
+ * @returns Null.
25
+ */
26
+ getParent(_current: WorkspaceSvg): INavigable<unknown> | null;
27
+ /**
28
+ * Returns the next sibling of the given workspace.
29
+ *
30
+ * @param _current The workspace to return the next sibling of.
31
+ * @returns Null.
32
+ */
33
+ getNextSibling(_current: WorkspaceSvg): INavigable<unknown> | null;
34
+ /**
35
+ * Returns the previous sibling of the given workspace.
36
+ *
37
+ * @param _current The workspace to return the previous sibling of.
38
+ * @returns Null.
39
+ */
40
+ getPreviousSibling(_current: WorkspaceSvg): INavigable<unknown> | null;
41
+ }
42
+ //# sourceMappingURL=workspace_navigation_policy.d.ts.map
@@ -20,12 +20,8 @@ export declare class MarkerManager {
20
20
  static readonly LOCAL_MARKER = "local_marker_1";
21
21
  /** The cursor. */
22
22
  private cursor;
23
- /** The cursor's SVG element. */
24
- private cursorSvg;
25
23
  /** The map of markers for the workspace. */
26
24
  private markers;
27
- /** The marker's SVG element. */
28
- private markerSvg;
29
25
  /**
30
26
  * @param workspace The workspace for the marker manager.
31
27
  * @internal
@@ -65,28 +61,6 @@ export declare class MarkerManager {
65
61
  * @param cursor The cursor used to move around this workspace.
66
62
  */
67
63
  setCursor(cursor: LineCursor): void;
68
- /**
69
- * Add the cursor SVG to this workspace SVG group.
70
- *
71
- * @param cursorSvg The SVG root of the cursor to be added to the workspace
72
- * SVG group.
73
- * @internal
74
- */
75
- setCursorSvg(cursorSvg: SVGElement | null): void;
76
- /**
77
- * Add the marker SVG to this workspaces SVG group.
78
- *
79
- * @param markerSvg The SVG root of the marker to be added to the workspace
80
- * SVG group.
81
- * @internal
82
- */
83
- setMarkerSvg(markerSvg: SVGElement | null): void;
84
- /**
85
- * Redraw the attached cursor SVG if needed.
86
- *
87
- * @internal
88
- */
89
- updateMarkers(): void;
90
64
  /**
91
65
  * Dispose of the marker manager.
92
66
  * Go through and delete all markers associated with this marker manager.
@@ -120,9 +120,12 @@ export declare class MenuItem {
120
120
  * Performs the appropriate action when the menu item is activated
121
121
  * by the user.
122
122
  *
123
+ * @param menuSelectEvent the event that triggered the selection
124
+ * of the menu item.
125
+ *
123
126
  * @internal
124
127
  */
125
- performAction(): void;
128
+ performAction(menuSelectEvent: Event): void;
126
129
  /**
127
130
  * Set the handler that's called when the menu item is activated by the user.
128
131
  * `obj` will be used as the 'this' object in the function when called.
@@ -131,6 +134,6 @@ export declare class MenuItem {
131
134
  * @param obj Used as the 'this' object in fn when called.
132
135
  * @internal
133
136
  */
134
- onAction(fn: (p1: MenuItem) => void, obj: object): void;
137
+ onAction(fn: (p1: MenuItem, menuSelectEvent: Event) => void, obj: object): void;
135
138
  }
136
139
  //# sourceMappingURL=menuitem.d.ts.map
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { INavigable } from './interfaces/i_navigable.js';
7
+ import type { INavigationPolicy } from './interfaces/i_navigation_policy.js';
8
+ /**
9
+ * Class responsible for determining where focus should move in response to
10
+ * keyboard navigation commands.
11
+ */
12
+ export declare class Navigator {
13
+ /**
14
+ * Map from classes to a corresponding ruleset to handle navigation from
15
+ * instances of that class.
16
+ */
17
+ private rules;
18
+ /**
19
+ * Associates a navigation ruleset with its corresponding class.
20
+ *
21
+ * @param key The class whose object instances should have their navigation
22
+ * controlled by the associated policy.
23
+ * @param policy A ruleset that determines where focus should move starting
24
+ * from an instance of the given class.
25
+ */
26
+ set<T extends INavigable<T>>(key: new (...args: any) => T, policy: INavigationPolicy<T>): void;
27
+ /**
28
+ * Returns the navigation ruleset associated with the given object instance's
29
+ * class.
30
+ *
31
+ * @param key An object to retrieve a navigation ruleset for.
32
+ * @returns The navigation ruleset of objects of the given object's class, or
33
+ * undefined if no ruleset has been registered for the object's class.
34
+ */
35
+ private get;
36
+ /**
37
+ * Returns the first child of the given object instance, if any.
38
+ *
39
+ * @param current The object to retrieve the first child of.
40
+ * @returns The first child node of the given object, if any.
41
+ */
42
+ getFirstChild<T extends INavigable<T>>(current: T): INavigable<any> | null;
43
+ /**
44
+ * Returns the parent of the given object instance, if any.
45
+ *
46
+ * @param current The object to retrieve the parent of.
47
+ * @returns The parent node of the given object, if any.
48
+ */
49
+ getParent<T extends INavigable<T>>(current: T): INavigable<any> | null;
50
+ /**
51
+ * Returns the next sibling of the given object instance, if any.
52
+ *
53
+ * @param current The object to retrieve the next sibling node of.
54
+ * @returns The next sibling node of the given object, if any.
55
+ */
56
+ getNextSibling<T extends INavigable<T>>(current: T): INavigable<any> | null;
57
+ /**
58
+ * Returns the previous sibling of the given object instance, if any.
59
+ *
60
+ * @param current The object to retrieve the previous sibling node of.
61
+ * @returns The previous sibling node of the given object, if any.
62
+ */
63
+ getPreviousSibling<T extends INavigable<T>>(current: T): INavigable<any> | null;
64
+ }
65
+ //# sourceMappingURL=navigator.d.ts.map
@@ -11,11 +11,15 @@
11
11
  import type { Block } from './block.js';
12
12
  import type { BlockSvg } from './block_svg.js';
13
13
  import { Connection } from './connection.js';
14
+ import { IContextMenu } from './interfaces/i_contextmenu.js';
15
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
16
+ import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
17
+ import type { INavigable } from './interfaces/i_navigable.js';
14
18
  import { Coordinate } from './utils/coordinate.js';
15
19
  /**
16
20
  * Class for a connection between blocks that may be rendered on screen.
17
21
  */
18
- export declare class RenderedConnection extends Connection {
22
+ export declare class RenderedConnection extends Connection implements IContextMenu, IFocusableNode, INavigable<RenderedConnection> {
19
23
  sourceBlock_: BlockSvg;
20
24
  private readonly db;
21
25
  private readonly dbOpposite;
@@ -216,6 +220,36 @@ export declare class RenderedConnection extends Connection {
216
220
  * @returns The connection being modified (to allow chaining).
217
221
  */
218
222
  setCheck(check: string | string[] | null): RenderedConnection;
223
+ /**
224
+ * Handles showing the context menu when it is opened on a connection.
225
+ * Note that typically the context menu can't be opened with the mouse
226
+ * on a connection, because you can't select a connection. But keyboard
227
+ * users may open the context menu with a keyboard shortcut.
228
+ *
229
+ * @param e Event that triggered the opening of the context menu.
230
+ */
231
+ showContextMenu(e: Event): void;
232
+ /** See IFocusableNode.getFocusableElement. */
233
+ getFocusableElement(): HTMLElement | SVGElement;
234
+ /** See IFocusableNode.getFocusableTree. */
235
+ getFocusableTree(): IFocusableTree;
236
+ /** See IFocusableNode.onNodeFocus. */
237
+ onNodeFocus(): void;
238
+ /** See IFocusableNode.onNodeBlur. */
239
+ onNodeBlur(): void;
240
+ private findHighlightSvg;
241
+ /**
242
+ * Returns whether or not this connection is keyboard-navigable.
243
+ *
244
+ * @returns True.
245
+ */
246
+ isNavigable(): boolean;
247
+ /**
248
+ * Returns this connection's class for keyboard navigation.
249
+ *
250
+ * @returns RenderedConnection.
251
+ */
252
+ getClass(): typeof RenderedConnection;
219
253
  }
220
254
  export declare namespace RenderedConnection {
221
255
  /**
@@ -29,7 +29,6 @@ import { Types } from '../measurables/types.js';
29
29
  import { Drawer } from './drawer.js';
30
30
  import type { IPathObject } from './i_path_object.js';
31
31
  import { RenderInfo } from './info.js';
32
- import { MarkerSvg } from './marker_svg.js';
33
32
  import { PathObject } from './path_object.js';
34
33
  import { Renderer } from './renderer.js';
35
34
  /**
@@ -59,6 +58,6 @@ export declare function unregister(name: string): void;
59
58
  export declare function init(name: string, theme: Theme, opt_rendererOverrides?: {
60
59
  [rendererConstant: string]: any;
61
60
  }): Renderer;
62
- export { BottomRow, Connection, Drawer, ExternalValueInput, Field, Hat, Icon, InlineInput, InputConnection, InputRow, InRowSpacer, IPathObject, JaggedEdge, MarkerSvg, Measurable, NextConnection, OutputConnection, PathObject, PreviousConnection, Renderer, RenderInfo, RoundCorner, Row, SpacerRow, SquareCorner, StatementInput, TopRow, Types, };
61
+ export { BottomRow, Connection, Drawer, ExternalValueInput, Field, Hat, Icon, InlineInput, InputConnection, InputRow, InRowSpacer, IPathObject, JaggedEdge, Measurable, NextConnection, OutputConnection, PathObject, PreviousConnection, Renderer, RenderInfo, RoundCorner, Row, SpacerRow, SquareCorner, StatementInput, TopRow, Types, };
63
62
  export { BaseShape, ConstantProvider, DynamicShape, InsideCorners, JaggedTeeth, Notch, OutsideCorners, PuzzleTab, StartHat, } from './constants.js';
64
63
  //# sourceMappingURL=block_rendering.d.ts.map
@@ -141,7 +141,7 @@ export declare class Drawer {
141
141
  */
142
142
  protected updateConnectionHighlights(): void;
143
143
  /** Returns a path to highlight the given connection. */
144
- drawConnectionHighlightPath(measurable: Connection): void;
144
+ drawConnectionHighlightPath(measurable: Connection): SVGElement | undefined;
145
145
  /**
146
146
  * Returns a path to highlight the given conneciton, assuming it is an
147
147
  * input or output connection.
@@ -23,16 +23,6 @@ export interface IPathObject {
23
23
  constants: ConstantProvider;
24
24
  /** The primary path of the block. */
25
25
  style: BlockStyle;
26
- /**
27
- * Holds the cursors SVG element when the cursor is attached to the block.
28
- * This is null if there is no cursor on the block.
29
- */
30
- cursorSvg: SVGElement | null;
31
- /**
32
- * Holds the markers SVG element when the marker is attached to the block.
33
- * This is null if there is no marker on the block.
34
- */
35
- markerSvg: SVGElement | null;
36
26
  /**
37
27
  * Set the path generated by the renderer onto the respective SVG element.
38
28
  *
@@ -43,20 +33,6 @@ export interface IPathObject {
43
33
  * Flip the SVG paths in RTL.
44
34
  */
45
35
  flipRTL(): void;
46
- /**
47
- * Add the cursor SVG to this block's SVG group.
48
- *
49
- * @param cursorSvg The SVG root of the cursor to be added to the block SVG
50
- * group.
51
- */
52
- setCursorSvg(cursorSvg: SVGElement): void;
53
- /**
54
- * Add the marker SVG to this block's SVG group.
55
- *
56
- * @param markerSvg The SVG root of the marker to be added to the block SVG
57
- * group.
58
- */
59
- setMarkerSvg(markerSvg: SVGElement): void;
60
36
  /**
61
37
  * Set whether the block shows a highlight or not. Block highlighting is
62
38
  * often used to visually mark blocks currently being executed.
@@ -90,7 +66,7 @@ export interface IPathObject {
90
66
  */
91
67
  updateMovable(enabled: boolean): void;
92
68
  /** Adds the given path as a connection highlight for the given connection. */
93
- addConnectionHighlight?(connection: RenderedConnection, connectionPath: string, offset: Coordinate, rtl: boolean): void;
69
+ addConnectionHighlight?(connection: RenderedConnection, connectionPath: string, offset: Coordinate, rtl: boolean): SVGElement;
94
70
  /**
95
71
  * Apply the stored colours to the block's path, taking into account whether
96
72
  * the paths belong to a shadow block.
@@ -17,16 +17,6 @@ import type { IPathObject } from './i_path_object.js';
17
17
  export declare class PathObject implements IPathObject {
18
18
  svgRoot: SVGElement;
19
19
  svgPath: SVGElement;
20
- /**
21
- * Holds the cursors svg element when the cursor is attached to the block.
22
- * This is null if there is no cursor on the block.
23
- */
24
- cursorSvg: SVGElement | null;
25
- /**
26
- * Holds the markers svg element when the marker is attached to the block.
27
- * This is null if there is no marker on the block.
28
- */
29
- markerSvg: SVGElement | null;
30
20
  constants: ConstantProvider;
31
21
  style: BlockStyle;
32
22
  /** Highlight paths associated with connections. */
@@ -49,20 +39,6 @@ export declare class PathObject implements IPathObject {
49
39
  * Flip the SVG paths in RTL.
50
40
  */
51
41
  flipRTL(): void;
52
- /**
53
- * Add the cursor SVG to this block's SVG group.
54
- *
55
- * @param cursorSvg The SVG root of the cursor to be added to the block SVG
56
- * group.
57
- */
58
- setCursorSvg(cursorSvg: SVGElement): void;
59
- /**
60
- * Add the marker SVG to this block's SVG group.
61
- *
62
- * @param markerSvg The SVG root of the marker to be added to the block SVG
63
- * group.
64
- */
65
- setMarkerSvg(markerSvg: SVGElement): void;
66
42
  /**
67
43
  * Apply the stored colours to the block's path, taking into account whether
68
44
  * the paths belong to a shadow block.
@@ -145,8 +121,7 @@ export declare class PathObject implements IPathObject {
145
121
  */
146
122
  updateShapeForInputHighlight(_conn: Connection, _enable: boolean): void;
147
123
  /** Adds the given path as a connection highlight for the given connection. */
148
- addConnectionHighlight(connection: RenderedConnection, connectionPath: string, offset: Coordinate, rtl: boolean): void;
149
- private currentHighlightMatchesNew;
124
+ addConnectionHighlight(connection: RenderedConnection, connectionPath: string, offset: Coordinate, rtl: boolean): SVGElement;
150
125
  /**
151
126
  * Removes any highlight associated with the given connection, if it exists.
152
127
  */
@@ -6,14 +6,11 @@
6
6
  import type { BlockSvg } from '../../block_svg.js';
7
7
  import { Connection } from '../../connection.js';
8
8
  import type { IRegistrable } from '../../interfaces/i_registrable.js';
9
- import type { Marker } from '../../keyboard_nav/marker.js';
10
9
  import type { BlockStyle, Theme } from '../../theme.js';
11
- import type { WorkspaceSvg } from '../../workspace_svg.js';
12
10
  import { ConstantProvider } from './constants.js';
13
11
  import { Drawer } from './drawer.js';
14
12
  import type { IPathObject } from './i_path_object.js';
15
13
  import { RenderInfo } from './info.js';
16
- import { MarkerSvg } from './marker_svg.js';
17
14
  /**
18
15
  * The base class for a block renderer.
19
16
  */
@@ -98,14 +95,6 @@ export declare class Renderer implements IRegistrable {
98
95
  * @returns The drawer.
99
96
  */
100
97
  protected makeDrawer_(block: BlockSvg, info: RenderInfo): Drawer;
101
- /**
102
- * Create a new instance of the renderer's marker drawer.
103
- *
104
- * @param workspace The workspace the marker belongs to.
105
- * @param marker The marker.
106
- * @returns The object in charge of drawing the marker.
107
- */
108
- makeMarkerDrawer(workspace: WorkspaceSvg, marker: Marker): MarkerSvg;
109
98
  /**
110
99
  * Create a new instance of a renderer path object.
111
100
  *
@@ -46,6 +46,6 @@ export declare class Drawer extends BaseDrawer {
46
46
  private getInlineInputPath;
47
47
  drawStatementInput_(row: Row): void;
48
48
  /** Returns a path to highlight the given connection. */
49
- drawConnectionHighlightPath(measurable: Connection): void;
49
+ drawConnectionHighlightPath(measurable: Connection): SVGElement | undefined;
50
50
  }
51
51
  //# sourceMappingURL=drawer.d.ts.map
@@ -4,15 +4,12 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { BlockSvg } from '../../block_svg.js';
7
- import type { Marker } from '../../keyboard_nav/marker.js';
8
7
  import type { BlockStyle } from '../../theme.js';
9
- import type { WorkspaceSvg } from '../../workspace_svg.js';
10
8
  import type { RenderInfo as BaseRenderInfo } from '../common/info.js';
11
9
  import { Renderer as BaseRenderer } from '../common/renderer.js';
12
10
  import { ConstantProvider } from './constants.js';
13
11
  import { Drawer } from './drawer.js';
14
12
  import { RenderInfo } from './info.js';
15
- import { MarkerSvg } from './marker_svg.js';
16
13
  import { PathObject } from './path_object.js';
17
14
  /**
18
15
  * The zelos renderer. This renderer emulates Scratch-style and MakeCode-style
@@ -48,14 +45,6 @@ export declare class Renderer extends BaseRenderer {
48
45
  * @returns The drawer.
49
46
  */
50
47
  protected makeDrawer_(block: BlockSvg, info: BaseRenderInfo): Drawer;
51
- /**
52
- * Create a new instance of the renderer's cursor drawer.
53
- *
54
- * @param workspace The workspace the cursor belongs to.
55
- * @param marker The marker.
56
- * @returns The object in charge of drawing the marker.
57
- */
58
- makeMarkerDrawer(workspace: WorkspaceSvg, marker: Marker): MarkerSvg;
59
48
  /**
60
49
  * Create a new instance of a renderer path object.
61
50
  *
@@ -7,12 +7,11 @@
7
7
  import { ConstantProvider } from './constants.js';
8
8
  import { Drawer } from './drawer.js';
9
9
  import { RenderInfo } from './info.js';
10
- import { MarkerSvg } from './marker_svg.js';
11
10
  import { BottomRow } from './measurables/bottom_row.js';
12
11
  import { StatementInput } from './measurables/inputs.js';
13
12
  import { RightConnectionShape } from './measurables/row_elements.js';
14
13
  import { TopRow } from './measurables/top_row.js';
15
14
  import { PathObject } from './path_object.js';
16
15
  import { Renderer } from './renderer.js';
17
- export { BottomRow, ConstantProvider, Drawer, MarkerSvg, PathObject, Renderer, RenderInfo, RightConnectionShape, StatementInput, TopRow, };
16
+ export { BottomRow, ConstantProvider, Drawer, PathObject, Renderer, RenderInfo, RightConnectionShape, StatementInput, TopRow, };
18
17
  //# sourceMappingURL=zelos.d.ts.map
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * @class
11
11
  */
12
+ import { Scope } from './contextmenu_registry.js';
12
13
  import { KeyCodes } from './utils/keycodes.js';
13
14
  import { WorkspaceSvg } from './workspace_svg.js';
14
15
  /**
@@ -183,12 +184,14 @@ export declare namespace ShortcutRegistry {
183
184
  * @param e The event that caused the shortcut to be activated.
184
185
  * @param shortcut The `KeyboardShortcut` that was activated
185
186
  * (i.e., the one this callback is attached to).
187
+ * @param scope Information about the focused item when the
188
+ * shortcut was invoked.
186
189
  * @returns Returning true ends processing of the invoked keycode.
187
190
  * Returning false causes processing to continue with the
188
191
  * next-most-recently registered shortcut for the invoked
189
192
  * keycode.
190
193
  */
191
- callback?: (workspace: WorkspaceSvg, e: Event, shortcut: KeyboardShortcut) => boolean;
194
+ callback?: (workspace: WorkspaceSvg, e: Event, shortcut: KeyboardShortcut, scope: Scope) => boolean;
192
195
  /** The name of the shortcut. Should be unique. */
193
196
  name: string;
194
197
  /**
@@ -198,9 +201,11 @@ export declare namespace ShortcutRegistry {
198
201
  *
199
202
  * @param workspace The `WorkspaceSvg` where the shortcut was
200
203
  * invoked.
204
+ * @param scope Information about the focused item when the
205
+ * shortcut would be invoked.
201
206
  * @returns True iff `callback` function should be called.
202
207
  */
203
- preconditionFn?: (workspace: WorkspaceSvg) => boolean;
208
+ preconditionFn?: (workspace: WorkspaceSvg, scope: Scope) => boolean;
204
209
  /** Optional arbitray extra data attached to the shortcut. */
205
210
  metadata?: object;
206
211
  /**
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { WorkspaceSvg } from './workspace_svg.js';
7
+ /**
8
+ * Display/configuration options for a toast notification.
9
+ */
10
+ export interface ToastOptions {
11
+ /**
12
+ * Toast ID. If set along with `oncePerSession`, will cause subsequent toasts
13
+ * with this ID to not be shown.
14
+ */
15
+ id?: string;
16
+ /**
17
+ * Flag to show the toast once per session only.
18
+ * Subsequent calls are ignored.
19
+ */
20
+ oncePerSession?: boolean;
21
+ /**
22
+ * Text of the message to display on the toast.
23
+ */
24
+ message: string;
25
+ /**
26
+ * Duration in seconds before the toast is removed. Defaults to 5.
27
+ */
28
+ duration?: number;
29
+ /**
30
+ * How prominently/interrupting the readout of the toast should be for
31
+ * screenreaders. Corresponds to aria-live and defaults to polite.
32
+ */
33
+ assertiveness?: Toast.Assertiveness;
34
+ }
35
+ /**
36
+ * Class that allows for showing and dismissing temporary notifications.
37
+ */
38
+ export declare class Toast {
39
+ /** IDs of toasts that have previously been shown. */
40
+ private static shownIds;
41
+ /**
42
+ * Shows a toast notification.
43
+ *
44
+ * @param workspace The workspace to show the toast on.
45
+ * @param options Configuration options for the toast message, duration, etc.
46
+ */
47
+ static show(workspace: WorkspaceSvg, options: ToastOptions): void;
48
+ /**
49
+ * Creates the DOM representation of a toast.
50
+ *
51
+ * @param workspace The workspace to inject the toast notification onto.
52
+ * @param options Configuration options for the toast.
53
+ * @returns The root DOM element of the toast.
54
+ */
55
+ protected static createDom(workspace: WorkspaceSvg, options: ToastOptions): HTMLDivElement;
56
+ /**
57
+ * Dismiss a toast, e.g. in response to a user action.
58
+ *
59
+ * @param workspace The workspace to dismiss a toast in.
60
+ * @param id The toast ID, or undefined to clear any toast.
61
+ */
62
+ static hide(workspace: WorkspaceSvg, id?: string): void;
63
+ }
64
+ /**
65
+ * Options for how aggressively toasts should be read out by screenreaders.
66
+ * Values correspond to those for aria-live.
67
+ */
68
+ export declare namespace Toast {
69
+ enum Assertiveness {
70
+ ASSERTIVE = "assertive",
71
+ POLITE = "polite"
72
+ }
73
+ }
74
+ //# sourceMappingURL=toast.d.ts.map
@@ -9,6 +9,8 @@ import '../events/events_toolbox_item_select.js';
9
9
  import type { IAutoHideable } from '../interfaces/i_autohideable.js';
10
10
  import type { IDraggable } from '../interfaces/i_draggable.js';
11
11
  import type { IFlyout } from '../interfaces/i_flyout.js';
12
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
13
+ import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
12
14
  import type { IKeyboardAccessible } from '../interfaces/i_keyboard_accessible.js';
13
15
  import type { ISelectableToolboxItem } from '../interfaces/i_selectable_toolbox_item.js';
14
16
  import type { IStyleable } from '../interfaces/i_styleable.js';
@@ -22,7 +24,7 @@ import type { WorkspaceSvg } from '../workspace_svg.js';
22
24
  * Class for a Toolbox.
23
25
  * Creates the toolbox's DOM.
24
26
  */
25
- export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeyboardAccessible, IStyleable, IToolbox {
27
+ export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeyboardAccessible, IStyleable, IToolbox, IFocusableNode {
26
28
  /**
27
29
  * The unique ID for this component that is used to register with the
28
30
  * ComponentManager.
@@ -389,5 +391,25 @@ export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeybo
389
391
  private selectPrevious;
390
392
  /** Disposes of this toolbox. */
391
393
  dispose(): void;
394
+ /** See IFocusableNode.getFocusableElement. */
395
+ getFocusableElement(): HTMLElement | SVGElement;
396
+ /** See IFocusableNode.getFocusableTree. */
397
+ getFocusableTree(): IFocusableTree;
398
+ /** See IFocusableNode.onNodeFocus. */
399
+ onNodeFocus(): void;
400
+ /** See IFocusableNode.onNodeBlur. */
401
+ onNodeBlur(): void;
402
+ /** See IFocusableTree.getRootFocusableNode. */
403
+ getRootFocusableNode(): IFocusableNode;
404
+ /** See IFocusableTree.getRestoredFocusableNode. */
405
+ getRestoredFocusableNode(previousNode: IFocusableNode | null): IFocusableNode | null;
406
+ /** See IFocusableTree.getNestedTrees. */
407
+ getNestedTrees(): Array<IFocusableTree>;
408
+ /** See IFocusableTree.lookUpFocusableNode. */
409
+ lookUpFocusableNode(id: string): IFocusableNode | null;
410
+ /** See IFocusableTree.onTreeFocus. */
411
+ onTreeFocus(node: IFocusableNode, _previousTree: IFocusableTree | null): void;
412
+ /** See IFocusableTree.onTreeBlur. */
413
+ onTreeBlur(_nextTree: IFocusableTree | null): void;
392
414
  }
393
415
  //# sourceMappingURL=toolbox.d.ts.map