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
@@ -11,40 +11,22 @@
11
11
  * connections and fields.
12
12
  * @author aschmiedt@google.com (Abby Schmiedt)
13
13
  */
14
- import type { Block } from '../block.js';
15
- import type { MarkerSvg } from '../renderers/common/marker_svg.js';
16
- import type { WorkspaceSvg } from '../workspace_svg.js';
17
- import { ASTNode } from './ast_node.js';
14
+ import { BlockSvg } from '../block_svg.js';
15
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
16
+ import { WorkspaceSvg } from '../workspace_svg.js';
18
17
  import { Marker } from './marker.js';
19
- /** Options object for LineCursor instances. */
20
- export interface CursorOptions {
21
- /**
22
- * Can the cursor visit all stack connections (next/previous), or
23
- * (if false) only unconnected next connections?
24
- */
25
- stackConnections: boolean;
26
- }
27
18
  /**
28
19
  * Class for a line cursor.
29
20
  */
30
21
  export declare class LineCursor extends Marker {
31
- private readonly workspace;
22
+ protected readonly workspace: WorkspaceSvg;
32
23
  type: string;
33
- /** Options for this line cursor. */
34
- private readonly options;
35
24
  /** Locations to try moving the cursor to after a deletion. */
36
25
  private potentialNodes;
37
- /** Whether the renderer is zelos-style. */
38
- private isZelos;
39
26
  /**
40
27
  * @param workspace The workspace this cursor belongs to.
41
- * @param options Cursor options.
42
28
  */
43
- constructor(workspace: WorkspaceSvg, options?: Partial<CursorOptions>);
44
- /**
45
- * Clean up this cursor.
46
- */
47
- dispose(): void;
29
+ constructor(workspace: WorkspaceSvg);
48
30
  /**
49
31
  * Moves the cursor to the next previous connection, next connection or block
50
32
  * in the pre order traversal. Finds the next node in the pre order traversal.
@@ -52,7 +34,7 @@ export declare class LineCursor extends Marker {
52
34
  * @returns The next node, or null if the current node is
53
35
  * not set or there is no next value.
54
36
  */
55
- next(): ASTNode | null;
37
+ next(): IFocusableNode | null;
56
38
  /**
57
39
  * Moves the cursor to the next input connection or field
58
40
  * in the pre order traversal.
@@ -60,7 +42,7 @@ export declare class LineCursor extends Marker {
60
42
  * @returns The next node, or null if the current node is
61
43
  * not set or there is no next value.
62
44
  */
63
- in(): ASTNode | null;
45
+ in(): IFocusableNode | null;
64
46
  /**
65
47
  * Moves the cursor to the previous next connection or previous connection in
66
48
  * the pre order traversal.
@@ -68,7 +50,7 @@ export declare class LineCursor extends Marker {
68
50
  * @returns The previous node, or null if the current node
69
51
  * is not set or there is no previous value.
70
52
  */
71
- prev(): ASTNode | null;
53
+ prev(): IFocusableNode | null;
72
54
  /**
73
55
  * Moves the cursor to the previous input connection or field in the pre order
74
56
  * traversal.
@@ -76,61 +58,14 @@ export declare class LineCursor extends Marker {
76
58
  * @returns The previous node, or null if the current node
77
59
  * is not set or there is no previous value.
78
60
  */
79
- out(): ASTNode | null;
61
+ out(): IFocusableNode | null;
80
62
  /**
81
63
  * Returns true iff the node to which we would navigate if in() were
82
- * called, which will be a validInLineNode, is also a validLineNode
83
- * - in effect, if the LineCursor is at the end of the 'current
64
+ * called is the same as the node to which we would navigate if next() were
65
+ * called - in effect, if the LineCursor is at the end of the 'current
84
66
  * line' of the program.
85
67
  */
86
68
  atEndOfLine(): boolean;
87
- /**
88
- * Returns true iff the given node represents the "beginning of a
89
- * new line of code" (and thus can be visited by pressing the
90
- * up/down arrow keys). Specifically, if the node is for:
91
- *
92
- * - Any block that is not a value block.
93
- * - A top-level value block (one that is unconnected).
94
- * - An unconnected next statement input.
95
- * - An unconnected 'next' connection - the "blank line at the end".
96
- * This is to facilitate connecting additional blocks to a
97
- * stack/substack.
98
- *
99
- * If options.stackConnections is true (the default) then allow the
100
- * cursor to visit all (useful) stack connection by additionally
101
- * returning true for:
102
- *
103
- * - Any next statement input
104
- * - Any 'next' connection.
105
- * - An unconnected previous statement input.
106
- *
107
- * @param node The AST node to check.
108
- * @returns True if the node should be visited, false otherwise.
109
- */
110
- protected validLineNode(node: ASTNode | null): boolean;
111
- /**
112
- * Returns true iff the given node can be visited by the cursor when
113
- * using the left/right arrow keys. Specifically, if the node is
114
- * any node for which valideLineNode would return true, plus:
115
- *
116
- * - Any block.
117
- * - Any field that is not a full block field.
118
- * - Any unconnected next or input connection. This is to
119
- * facilitate connecting additional blocks.
120
- *
121
- * @param node The AST node to check whether it is valid.
122
- * @returns True if the node should be visited, false otherwise.
123
- */
124
- protected validInLineNode(node: ASTNode | null): boolean;
125
- /**
126
- * Returns true iff the given node can be visited by the cursor.
127
- * Specifically, if the node is any for which validInLineNode would
128
- * return true, or if it is a workspace node.
129
- *
130
- * @param node The AST node to check whether it is valid.
131
- * @returns True if the node should be visited, false otherwise.
132
- */
133
- protected validNode(node: ASTNode | null): boolean;
134
69
  /**
135
70
  * Uses pre order traversal to navigate the Blockly AST. This will allow
136
71
  * a user to easily navigate the entire Blockly AST without having to go in
@@ -139,6 +74,7 @@ export declare class LineCursor extends Marker {
139
74
  * @param node The current position in the AST.
140
75
  * @param isValid A function true/false depending on whether the given node
141
76
  * should be traversed.
77
+ * @param visitedNodes A set of previously visited nodes used to avoid cycles.
142
78
  * @returns The next node in the traversal.
143
79
  */
144
80
  private getNextNodeImpl;
@@ -148,11 +84,11 @@ export declare class LineCursor extends Marker {
148
84
  * @param node The current position in the AST.
149
85
  * @param isValid A function true/false depending on whether the given node
150
86
  * should be traversed.
151
- * @param loop Whether to loop around to the beginning of the workspace if
152
- * novalid node was found.
87
+ * @param loop Whether to loop around to the beginning of the workspace if no
88
+ * valid node was found.
153
89
  * @returns The next node in the traversal.
154
90
  */
155
- getNextNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean, loop: boolean): ASTNode | null;
91
+ getNextNode(node: IFocusableNode | null, isValid: (p1: IFocusableNode | null) => boolean, loop: boolean): IFocusableNode | null;
156
92
  /**
157
93
  * Reverses the pre order traversal in order to find the previous node. This
158
94
  * will allow a user to easily navigate the entire Blockly AST without having
@@ -161,6 +97,7 @@ export declare class LineCursor extends Marker {
161
97
  * @param node The current position in the AST.
162
98
  * @param isValid A function true/false depending on whether the given node
163
99
  * should be traversed.
100
+ * @param visitedNodes A set of previously visited nodes used to avoid cycles.
164
101
  * @returns The previous node in the traversal or null if no previous node
165
102
  * exists.
166
103
  */
@@ -171,20 +108,12 @@ export declare class LineCursor extends Marker {
171
108
  * @param node The current position in the AST.
172
109
  * @param isValid A function true/false depending on whether the given node
173
110
  * should be traversed.
174
- * @param loop Whether to loop around to the end of the workspace if no
175
- * valid node was found.
111
+ * @param loop Whether to loop around to the end of the workspace if no valid
112
+ * node was found.
176
113
  * @returns The previous node in the traversal or null if no previous node
177
114
  * exists.
178
115
  */
179
- getPreviousNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean, loop: boolean): ASTNode | null;
180
- /**
181
- * From the given node find either the next valid sibling or the parent's
182
- * next sibling.
183
- *
184
- * @param node The current position in the AST.
185
- * @returns The next sibling node, the parent's next sibling, or null.
186
- */
187
- private findSiblingOrParentSibling;
116
+ getPreviousNode(node: IFocusableNode | null, isValid: (p1: IFocusableNode | null) => boolean, loop: boolean): IFocusableNode | null;
188
117
  /**
189
118
  * Get the right most child of a node.
190
119
  *
@@ -215,7 +144,7 @@ export declare class LineCursor extends Marker {
215
144
  *
216
145
  * @param deletedBlock The block that is being deleted.
217
146
  */
218
- preDelete(deletedBlock: Block): void;
147
+ preDelete(deletedBlock: BlockSvg): void;
219
148
  /**
220
149
  * Move the cursor to the first valid location in
221
150
  * this.potentialNodes, following a block deletion.
@@ -232,18 +161,7 @@ export declare class LineCursor extends Marker {
232
161
  *
233
162
  * @returns The current field, connection, or block the cursor is on.
234
163
  */
235
- getCurNode(): ASTNode | null;
236
- /**
237
- * Sets the object in charge of drawing the marker.
238
- *
239
- * We want to customize drawing, so rather than directly setting the given
240
- * object, we instead set a wrapper proxy object that passes through all
241
- * method calls and property accesses except for draw(), which it delegates
242
- * to the drawMarker() method in this class.
243
- *
244
- * @param drawer The object ~in charge of drawing the marker.
245
- */
246
- setDrawer(drawer: MarkerSvg): void;
164
+ getCurNode(): IFocusableNode | null;
247
165
  /**
248
166
  * Set the location of the cursor and draw it.
249
167
  *
@@ -251,98 +169,19 @@ export declare class LineCursor extends Marker {
251
169
  * this.drawMarker() instead of this.drawer.draw() directly.
252
170
  *
253
171
  * @param newNode The new location of the cursor.
254
- * @param updateSelection If true (the default) we'll update the selection
255
- * too.
256
- */
257
- setCurNode(newNode: ASTNode | null, updateSelection?: boolean): void;
258
- /**
259
- * Draw this cursor's marker.
260
- *
261
- * This is a wrapper around this.drawer.draw (usually implemented by
262
- * MarkerSvg.prototype.draw) that will, if newNode is a BLOCK node,
263
- * instead call `setSelected` to select it (if it's a regular block)
264
- * or `addSelect` (if it's a shadow block, since shadow blocks can't
265
- * be selected) instead of using the normal drawer logic.
266
- *
267
- * TODO(#142): The selection and fake-selection code was originally
268
- * a hack added for testing on October 28 2024, because the default
269
- * drawer (MarkerSvg) behaviour in Zelos was to draw a box around
270
- * the block and all attached child blocks, which was confusing when
271
- * navigating stacks.
272
- *
273
- * Since then we have decided that we probably _do_ in most cases
274
- * want navigating to a block to select the block, but more
275
- * particularly that we want navigation to move _focus_. Replace
276
- * this selection hack with non-hacky changing of focus once that's
277
- * possible.
278
- *
279
- * @param oldNode The previous node.
280
- * @param curNode The current node.
281
- * @param realDrawer The object ~in charge of drawing the marker.
282
- */
283
- private drawMarker;
284
- /**
285
- * Check whether the node represents a value input connection.
286
- *
287
- * @param node The node to check
288
- * @returns True if the node represents a value input connection.
289
- */
290
- private isValueInputConnection;
291
- /**
292
- * Hide the cursor rendering at the given input node.
293
- *
294
- * @param node The input node to hide.
295
- */
296
- private hideAtInput;
297
- /**
298
- * Show the cursor rendering at the given input node.
299
- *
300
- * @param node The input node to show.
301
- */
302
- private showAtInput;
303
- /**
304
- * Event listener that syncs the cursor location to the selected block on
305
- * SELECTED events.
306
- *
307
- * This does not run early enough in all cases so `getCurNode()` also updates
308
- * the node from the selection.
309
- *
310
- * @param event The `Selected` event.
311
- */
312
- private changeListener;
313
- /**
314
- * Updates the current node to match the selection.
315
- *
316
- * Clears the current node if it's on a block but the selection is null.
317
- * Sets the node to a block if selected for our workspace.
318
- * For shadow blocks selections the parent is used by default (unless we're
319
- * already on the shadow block via keyboard) as that's where the visual
320
- * selection is.
321
- */
322
- private updateCurNodeFromSelection;
323
- /**
324
- * Updates the selection from the node.
325
- *
326
- * Clears the selection for non-block nodes.
327
- * Clears the selection for shadow blocks as the selection is drawn on
328
- * the parent but the cursor will be drawn on the shadow block itself.
329
- * We need to take care not to later clear the current node due to that null
330
- * selection, so we track the latest selection we're in sync with.
331
- *
332
- * @param newNode The new node.
333
172
  */
334
- private updateSelectionFromNode;
173
+ setCurNode(newNode: IFocusableNode | null): void;
335
174
  /**
336
175
  * Get the first navigable node on the workspace, or null if none exist.
337
176
  *
338
177
  * @returns The first navigable node on the workspace, or null.
339
178
  */
340
- getFirstNode(): ASTNode | null;
179
+ getFirstNode(): IFocusableNode | null;
341
180
  /**
342
181
  * Get the last navigable node on the workspace, or null if none exist.
343
182
  *
344
183
  * @returns The last navigable node on the workspace, or null.
345
184
  */
346
- getLastNode(): ASTNode | null;
185
+ getLastNode(): IFocusableNode | null;
347
186
  }
348
187
  //# sourceMappingURL=line_cursor.d.ts.map
@@ -9,8 +9,8 @@
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 { IFocusableNode } from '../interfaces/i_focusable_node.js';
14
14
  /**
15
15
  * Class for a marker.
16
16
  * This is used in keyboard navigation to save a location in the Blockly AST.
@@ -19,47 +19,35 @@ export declare class Marker {
19
19
  /** The colour of the marker. */
20
20
  colour: string | null;
21
21
  /** 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;
22
+ protected curNode: IFocusableNode | null;
28
23
  /** The type of the marker. */
29
24
  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
25
  /**
43
26
  * Gets the current location of the marker.
44
27
  *
45
28
  * @returns The current field, connection, or block the marker is on.
46
29
  */
47
- getCurNode(): ASTNode | null;
30
+ getCurNode(): IFocusableNode | null;
48
31
  /**
49
32
  * Set the location of the marker and call the update method.
50
33
  *
51
34
  * @param newNode The new location of the marker, or null to remove it.
52
35
  */
53
- setCurNode(newNode: ASTNode | null): void;
36
+ setCurNode(newNode: IFocusableNode | null): void;
37
+ /** Dispose of this marker. */
38
+ dispose(): void;
54
39
  /**
55
- * Redraw the current marker.
40
+ * Returns the block that the given node is a child of.
56
41
  *
57
- * @internal
42
+ * @returns The parent block of the node if any, otherwise null.
58
43
  */
59
- draw(): void;
60
- /** Hide the marker SVG. */
61
- hide(): void;
62
- /** Dispose of this marker. */
63
- dispose(): void;
44
+ getSourceBlockFromNode(node: IFocusableNode | null): BlockSvg | null;
45
+ /**
46
+ * Returns the block that this marker's current node is a child of.
47
+ *
48
+ * @returns The parent block of the marker's current node if any, otherwise
49
+ * null.
50
+ */
51
+ getSourceBlock(): BlockSvg | null;
64
52
  }
65
53
  //# sourceMappingURL=marker.d.ts.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
7
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
8
+ import { 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): IFocusableNode | 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): IFocusableNode | 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): IFocusableNode | 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): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given workspace can be navigated to.
43
+ *
44
+ * @param current The instance to check for navigability.
45
+ * @returns True if the given workspace can be focused.
46
+ */
47
+ isNavigable(current: WorkspaceSvg): boolean;
48
+ /**
49
+ * Returns whether the given object can be navigated from by this policy.
50
+ *
51
+ * @param current The object to check if this policy applies to.
52
+ * @returns True if the object is a WorkspaceSvg.
53
+ */
54
+ isApplicable(current: any): current is WorkspaceSvg;
55
+ }
56
+ //# sourceMappingURL=workspace_navigation_policy.d.ts.map
@@ -3,6 +3,7 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
6
7
  import { IRenderedElement } from './interfaces/i_rendered_element.js';
7
8
  import { Coordinate } from './utils/coordinate.js';
8
9
  import { WorkspaceSvg } from './workspace_svg.js';
@@ -39,13 +40,13 @@ export declare class LayerManager {
39
40
  *
40
41
  * @internal
41
42
  */
42
- moveToDragLayer(elem: IRenderedElement): void;
43
+ moveToDragLayer(elem: IRenderedElement & IFocusableNode): void;
43
44
  /**
44
45
  * Moves the given element off of the drag layer.
45
46
  *
46
47
  * @internal
47
48
  */
48
- moveOffDragLayer(elem: IRenderedElement, layerNum: number): void;
49
+ moveOffDragLayer(elem: IRenderedElement & IFocusableNode, layerNum: number): void;
49
50
  /**
50
51
  * Appends the given element to a layer. If the layer does not exist, it is
51
52
  * created.
@@ -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.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
7
+ import type { INavigationPolicy } from './interfaces/i_navigation_policy.js';
8
+ type RuleList<T> = INavigationPolicy<T>[];
9
+ /**
10
+ * Class responsible for determining where focus should move in response to
11
+ * keyboard navigation commands.
12
+ */
13
+ export declare class Navigator {
14
+ /**
15
+ * Map from classes to a corresponding ruleset to handle navigation from
16
+ * instances of that class.
17
+ */
18
+ protected rules: RuleList<any>;
19
+ /**
20
+ * Adds a navigation ruleset to this Navigator.
21
+ *
22
+ * @param policy A ruleset that determines where focus should move starting
23
+ * from an instance of its managed class.
24
+ */
25
+ addNavigationPolicy(policy: INavigationPolicy<any>): void;
26
+ /**
27
+ * Returns the navigation ruleset associated with the given object instance's
28
+ * class.
29
+ *
30
+ * @param current An object to retrieve a navigation ruleset for.
31
+ * @returns The navigation ruleset of objects of the given object's class, or
32
+ * undefined if no ruleset has been registered for the object's class.
33
+ */
34
+ private get;
35
+ /**
36
+ * Returns the first child of the given object instance, if any.
37
+ *
38
+ * @param current The object to retrieve the first child of.
39
+ * @returns The first child node of the given object, if any.
40
+ */
41
+ getFirstChild(current: IFocusableNode): IFocusableNode | null;
42
+ /**
43
+ * Returns the parent of the given object instance, if any.
44
+ *
45
+ * @param current The object to retrieve the parent of.
46
+ * @returns The parent node of the given object, if any.
47
+ */
48
+ getParent(current: IFocusableNode): IFocusableNode | null;
49
+ /**
50
+ * Returns the next sibling of the given object instance, if any.
51
+ *
52
+ * @param current The object to retrieve the next sibling node of.
53
+ * @returns The next sibling node of the given object, if any.
54
+ */
55
+ getNextSibling(current: IFocusableNode): IFocusableNode | null;
56
+ /**
57
+ * Returns the previous sibling of the given object instance, if any.
58
+ *
59
+ * @param current The object to retrieve the previous sibling node of.
60
+ * @returns The previous sibling node of the given object, if any.
61
+ */
62
+ getPreviousSibling(current: IFocusableNode): IFocusableNode | null;
63
+ }
64
+ export {};
65
+ //# sourceMappingURL=navigator.d.ts.map
@@ -11,11 +11,14 @@
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';
14
17
  import { Coordinate } from './utils/coordinate.js';
15
18
  /**
16
19
  * Class for a connection between blocks that may be rendered on screen.
17
20
  */
18
- export declare class RenderedConnection extends Connection {
21
+ export declare class RenderedConnection extends Connection implements IContextMenu, IFocusableNode {
19
22
  sourceBlock_: BlockSvg;
20
23
  private readonly db;
21
24
  private readonly dbOpposite;
@@ -216,6 +219,26 @@ export declare class RenderedConnection extends Connection {
216
219
  * @returns The connection being modified (to allow chaining).
217
220
  */
218
221
  setCheck(check: string | string[] | null): RenderedConnection;
222
+ /**
223
+ * Handles showing the context menu when it is opened on a connection.
224
+ * Note that typically the context menu can't be opened with the mouse
225
+ * on a connection, because you can't select a connection. But keyboard
226
+ * users may open the context menu with a keyboard shortcut.
227
+ *
228
+ * @param e Event that triggered the opening of the context menu.
229
+ */
230
+ showContextMenu(e: Event): void;
231
+ /** See IFocusableNode.getFocusableElement. */
232
+ getFocusableElement(): HTMLElement | SVGElement;
233
+ /** See IFocusableNode.getFocusableTree. */
234
+ getFocusableTree(): IFocusableTree;
235
+ /** See IFocusableNode.onNodeFocus. */
236
+ onNodeFocus(): void;
237
+ /** See IFocusableNode.onNodeBlur. */
238
+ onNodeBlur(): void;
239
+ /** See IFocusableNode.canBeFocused. */
240
+ canBeFocused(): boolean;
241
+ private findHighlightSvg;
219
242
  }
220
243
  export declare namespace RenderedConnection {
221
244
  /**
@@ -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.