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
@@ -80,89 +80,7 @@ export declare class ASTNode {
80
80
  * @internal
81
81
  */
82
82
  isConnection(): boolean;
83
- /**
84
- * Given an input find the next editable field or an input with a non null
85
- * connection in the same block. The current location must be an input
86
- * connection.
87
- *
88
- * @returns The AST node holding the next field or connection or null if there
89
- * is no editable field or input connection after the given input.
90
- */
91
- private findNextForInput;
92
- /**
93
- * Given a field find the next editable field or an input with a non null
94
- * connection in the same block. The current location must be a field.
95
- *
96
- * @returns The AST node pointing to the next field or connection or null if
97
- * there is no editable field or input connection after the given input.
98
- */
99
- private findNextForField;
100
- /**
101
- * Given an input find the previous editable field or an input with a non null
102
- * connection in the same block. The current location must be an input
103
- * connection.
104
- *
105
- * @returns The AST node holding the previous field or connection.
106
- */
107
- private findPrevForInput;
108
- /**
109
- * Given a field find the previous editable field or an input with a non null
110
- * connection in the same block. The current location must be a field.
111
- *
112
- * @returns The AST node holding the previous input or field.
113
- */
114
- private findPrevForField;
115
- /**
116
- * Navigate between stacks of blocks on the workspace.
117
- *
118
- * @param forward True to go forward. False to go backwards.
119
- * @returns The first block of the next stack or null if there are no blocks
120
- * on the workspace.
121
- */
122
- private navigateBetweenStacks;
123
- /**
124
- * Navigate between buttons and stacks of blocks on the flyout workspace.
125
- *
126
- * @param forward True to go forward. False to go backwards.
127
- * @returns The next button, or next stack's first block, or null
128
- */
129
- private navigateFlyoutContents;
130
- /**
131
- * Finds the next (or previous if navigating backward) item in the flyout that should be navigated to.
132
- *
133
- * @param flyoutContents Contents of the current flyout.
134
- * @param currentLocation Current ASTNode location.
135
- * @param forward True if we're navigating forward, else false.
136
- * @returns The next (or previous) FlyoutItem, or null if there is none.
137
- */
138
- private findNextLocationInFlyout;
139
- /**
140
- * Finds the top most AST node for a given block.
141
- * This is either the previous connection, output connection or block
142
- * depending on what kind of connections the block has.
143
- *
144
- * @param block The block that we want to find the top connection on.
145
- * @returns The AST node containing the top connection.
146
- */
147
- private findTopASTNodeForBlock;
148
- /**
149
- * Get the AST node pointing to the input that the block is nested under or if
150
- * the block is not nested then get the stack AST node.
151
- *
152
- * @param block The source block of the current location.
153
- * @returns The AST node pointing to the input connection or the top block of
154
- * the stack this block is in.
155
- */
156
- private getOutAstNodeForBlock;
157
- /**
158
- * Find the first editable field or input with a connection on a given block.
159
- *
160
- * @param block The source block of the current location.
161
- * @returns An AST node pointing to the first field or input.
162
- * Null if there are no editable fields or inputs with connections on the
163
- * block.
164
- */
165
- private findFirstFieldOrInput;
83
+ private getVisibleInputs;
166
84
  /**
167
85
  * Finds the source block of the location of this node.
168
86
  *
@@ -170,36 +88,6 @@ export declare class ASTNode {
170
88
  * workspace or button.
171
89
  */
172
90
  getSourceBlock(): Block | null;
173
- /**
174
- * Find the element to the right of the current element in the AST.
175
- *
176
- * @returns An AST node that wraps the next field, connection, block, or
177
- * workspace. Or null if there is no node to the right.
178
- */
179
- next(): ASTNode | null;
180
- /**
181
- * Find the element one level below and all the way to the left of the current
182
- * location.
183
- *
184
- * @returns An AST node that wraps the next field, connection, workspace, or
185
- * block. Or null if there is nothing below this node.
186
- */
187
- in(): ASTNode | null;
188
- /**
189
- * Find the element to the left of the current element in the AST.
190
- *
191
- * @returns An AST node that wraps the previous field, connection, workspace
192
- * or block. Or null if no node exists to the left. null.
193
- */
194
- prev(): ASTNode | null;
195
- /**
196
- * Find the next element that is one position above and all the way to the
197
- * left of the current location.
198
- *
199
- * @returns An AST node that wraps the next field, connection, workspace or
200
- * block. Or null if we are at the workspace level.
201
- */
202
- out(): ASTNode | null;
203
91
  /**
204
92
  * Whether an AST node of the given type points to a connection.
205
93
  *
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { BlockSvg } from '../block_svg.js';
7
+ import type { INavigable } from '../interfaces/i_navigable.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ import type { RenderedConnection } from '../rendered_connection.js';
10
+ /**
11
+ * Set of rules controlling keyboard navigation from a block.
12
+ */
13
+ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg> {
14
+ /**
15
+ * Returns the first child of the given block.
16
+ *
17
+ * @param current The block to return the first child of.
18
+ * @returns The first field or input of the given block, if any.
19
+ */
20
+ getFirstChild(current: BlockSvg): INavigable<unknown> | null;
21
+ /**
22
+ * Returns the parent of the given block.
23
+ *
24
+ * @param current The block to return the parent of.
25
+ * @returns The top block of the given block's stack, or the connection to
26
+ * which it is attached.
27
+ */
28
+ getParent(current: BlockSvg): INavigable<unknown> | null;
29
+ /**
30
+ * Returns the next peer node of the given block.
31
+ *
32
+ * @param current The block to find the following element of.
33
+ * @returns The first block of the next stack if the given block is a terminal
34
+ * block, or its next connection.
35
+ */
36
+ getNextSibling(current: BlockSvg): INavigable<unknown> | null;
37
+ /**
38
+ * Returns the previous peer node of the given block.
39
+ *
40
+ * @param current The block to find the preceding element of.
41
+ * @returns The block's previous/output connection, or the last
42
+ * connection/block of the previous block stack if it is a root block.
43
+ */
44
+ getPreviousSibling(current: BlockSvg): INavigable<unknown> | null;
45
+ /**
46
+ * Gets the parent connection on a block.
47
+ * This is either an output connection, previous connection or undefined.
48
+ * If both connections exist return the one that is actually connected
49
+ * to another block.
50
+ *
51
+ * @param block The block to find the parent connection on.
52
+ * @returns The connection connecting to the parent of the block.
53
+ */
54
+ protected getParentConnection(block: BlockSvg): RenderedConnection;
55
+ }
56
+ //# sourceMappingURL=block_navigation_policy.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { BlockSvg } from '../block_svg.js';
7
+ import type { INavigable } from '../interfaces/i_navigable.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ import type { RenderedConnection } from '../rendered_connection.js';
10
+ /**
11
+ * Set of rules controlling keyboard navigation from a connection.
12
+ */
13
+ export declare class ConnectionNavigationPolicy implements INavigationPolicy<RenderedConnection> {
14
+ /**
15
+ * Returns the first child of the given connection.
16
+ *
17
+ * @param current The connection to return the first child of.
18
+ * @returns The connection's first child element, or null if not none.
19
+ */
20
+ getFirstChild(current: RenderedConnection): INavigable<unknown> | null;
21
+ /**
22
+ * Returns the parent of the given connection.
23
+ *
24
+ * @param current The connection to return the parent of.
25
+ * @returns The given connection's parent connection or block.
26
+ */
27
+ getParent(current: RenderedConnection): INavigable<unknown> | null;
28
+ /**
29
+ * Returns the next element following the given connection.
30
+ *
31
+ * @param current The connection to navigate from.
32
+ * @returns The field, input connection or block following this connection.
33
+ */
34
+ getNextSibling(current: RenderedConnection): INavigable<unknown> | null;
35
+ /**
36
+ * Returns the element preceding the given connection.
37
+ *
38
+ * @param current The connection to navigate from.
39
+ * @returns The field, input connection or block preceding this connection.
40
+ */
41
+ getPreviousSibling(current: RenderedConnection): INavigable<unknown> | null;
42
+ /**
43
+ * Gets the parent connection on a block.
44
+ * This is either an output connection, previous connection or undefined.
45
+ * If both connections exist return the one that is actually connected
46
+ * to another block.
47
+ *
48
+ * @param block The block to find the parent connection on.
49
+ * @returns The connection connecting to the parent of the block.
50
+ */
51
+ protected getParentConnection(block: BlockSvg): RenderedConnection;
52
+ }
53
+ //# sourceMappingURL=connection_navigation_policy.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 { Field } from '../field.js';
7
+ import type { INavigable } from '../interfaces/i_navigable.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a field.
11
+ */
12
+ export declare class FieldNavigationPolicy implements INavigationPolicy<Field<any>> {
13
+ /**
14
+ * Returns null since fields do not have children.
15
+ *
16
+ * @param _current The field to navigate from.
17
+ * @returns Null.
18
+ */
19
+ getFirstChild(_current: Field<any>): INavigable<unknown> | null;
20
+ /**
21
+ * Returns the parent block of the given field.
22
+ *
23
+ * @param current The field to navigate from.
24
+ * @returns The given field's parent block.
25
+ */
26
+ getParent(current: Field<any>): INavigable<unknown> | null;
27
+ /**
28
+ * Returns the next field or input following the given field.
29
+ *
30
+ * @param current The field to navigate from.
31
+ * @returns The next field or input in the given field's block.
32
+ */
33
+ getNextSibling(current: Field<any>): INavigable<unknown> | null;
34
+ /**
35
+ * Returns the field or input preceding the given field.
36
+ *
37
+ * @param current The field to navigate from.
38
+ * @returns The preceding field or input in the given field's block.
39
+ */
40
+ getPreviousSibling(current: Field<any>): INavigable<unknown> | null;
41
+ }
42
+ //# sourceMappingURL=field_navigation_policy.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 { FlyoutButton } from '../flyout_button.js';
7
+ import type { INavigable } from '../interfaces/i_navigable.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a flyout button.
11
+ */
12
+ export declare class FlyoutButtonNavigationPolicy implements INavigationPolicy<FlyoutButton> {
13
+ /**
14
+ * Returns null since flyout buttons have no children.
15
+ *
16
+ * @param _current The FlyoutButton instance to navigate from.
17
+ * @returns Null.
18
+ */
19
+ getFirstChild(_current: FlyoutButton): INavigable<unknown> | null;
20
+ /**
21
+ * Returns the parent workspace of the given flyout button.
22
+ *
23
+ * @param current The FlyoutButton instance to navigate from.
24
+ * @returns The given flyout button's parent workspace.
25
+ */
26
+ getParent(current: FlyoutButton): INavigable<unknown> | null;
27
+ /**
28
+ * Returns null since inter-item navigation is done by FlyoutNavigationPolicy.
29
+ *
30
+ * @param _current The FlyoutButton instance to navigate from.
31
+ * @returns Null.
32
+ */
33
+ getNextSibling(_current: FlyoutButton): INavigable<unknown> | null;
34
+ /**
35
+ * Returns null since inter-item navigation is done by FlyoutNavigationPolicy.
36
+ *
37
+ * @param _current The FlyoutButton instance to navigate from.
38
+ * @returns Null.
39
+ */
40
+ getPreviousSibling(_current: FlyoutButton): INavigable<unknown> | null;
41
+ }
42
+ //# sourceMappingURL=flyout_button_navigation_policy.d.ts.map
@@ -0,0 +1,51 @@
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 type { INavigable } from '../interfaces/i_navigable.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Generic navigation policy that navigates between items in the flyout.
11
+ */
12
+ export declare class FlyoutNavigationPolicy<T> implements INavigationPolicy<T> {
13
+ private policy;
14
+ private flyout;
15
+ /**
16
+ * Creates a new FlyoutNavigationPolicy instance.
17
+ *
18
+ * @param policy The policy to defer to for parents/children.
19
+ * @param flyout The flyout this policy will control navigation in.
20
+ */
21
+ constructor(policy: INavigationPolicy<T>, flyout: IFlyout);
22
+ /**
23
+ * Returns null to prevent navigating into flyout items.
24
+ *
25
+ * @param _current The flyout item to navigate from.
26
+ * @returns Null to prevent navigating into flyout items.
27
+ */
28
+ getFirstChild(_current: T): INavigable<unknown> | null;
29
+ /**
30
+ * Returns the parent of the given flyout item.
31
+ *
32
+ * @param current The flyout item to navigate from.
33
+ * @returns The parent of the given flyout item.
34
+ */
35
+ getParent(current: T): INavigable<unknown> | null;
36
+ /**
37
+ * Returns the next item in the flyout relative to the given item.
38
+ *
39
+ * @param current The flyout item to navigate from.
40
+ * @returns The flyout item following the given one.
41
+ */
42
+ getNextSibling(current: T): INavigable<unknown> | null;
43
+ /**
44
+ * Returns the previous item in the flyout relative to the given item.
45
+ *
46
+ * @param current The flyout item to navigate from.
47
+ * @returns The flyout item preceding the given one.
48
+ */
49
+ getPreviousSibling(current: T): INavigable<unknown> | null;
50
+ }
51
+ //# sourceMappingURL=flyout_navigation_policy.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { FlyoutSeparator } from '../flyout_separator.js';
7
+ import type { INavigable } from '../interfaces/i_navigable.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a flyout separator.
11
+ * This is a no-op placeholder, since flyout separators can't be navigated to.
12
+ */
13
+ export declare class FlyoutSeparatorNavigationPolicy implements INavigationPolicy<FlyoutSeparator> {
14
+ getFirstChild(_current: FlyoutSeparator): INavigable<unknown> | null;
15
+ getParent(_current: FlyoutSeparator): INavigable<unknown> | null;
16
+ getNextSibling(_current: FlyoutSeparator): INavigable<unknown> | null;
17
+ getPreviousSibling(_current: FlyoutSeparator): INavigable<unknown> | null;
18
+ }
19
+ //# sourceMappingURL=flyout_separator_navigation_policy.d.ts.map
@@ -11,10 +11,9 @@
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 { INavigable } from '../interfaces/i_navigable.js';
16
+ import { WorkspaceSvg } from '../workspace_svg.js';
18
17
  import { Marker } from './marker.js';
19
18
  /** Options object for LineCursor instances. */
20
19
  export interface CursorOptions {
@@ -28,7 +27,7 @@ export interface CursorOptions {
28
27
  * Class for a line cursor.
29
28
  */
30
29
  export declare class LineCursor extends Marker {
31
- private readonly workspace;
30
+ protected readonly workspace: WorkspaceSvg;
32
31
  type: string;
33
32
  /** Options for this line cursor. */
34
33
  private readonly options;
@@ -42,9 +41,10 @@ export declare class LineCursor extends Marker {
42
41
  */
43
42
  constructor(workspace: WorkspaceSvg, options?: Partial<CursorOptions>);
44
43
  /**
45
- * Clean up this cursor.
44
+ * Registers default navigation policies for Blockly's built-in types with
45
+ * this cursor's workspace.
46
46
  */
47
- dispose(): void;
47
+ protected registerNavigationPolicies(): void;
48
48
  /**
49
49
  * Moves the cursor to the next previous connection, next connection or block
50
50
  * in the pre order traversal. Finds the next node in the pre order traversal.
@@ -52,7 +52,7 @@ export declare class LineCursor extends Marker {
52
52
  * @returns The next node, or null if the current node is
53
53
  * not set or there is no next value.
54
54
  */
55
- next(): ASTNode | null;
55
+ next(): INavigable<any> | null;
56
56
  /**
57
57
  * Moves the cursor to the next input connection or field
58
58
  * in the pre order traversal.
@@ -60,7 +60,7 @@ export declare class LineCursor extends Marker {
60
60
  * @returns The next node, or null if the current node is
61
61
  * not set or there is no next value.
62
62
  */
63
- in(): ASTNode | null;
63
+ in(): INavigable<any> | null;
64
64
  /**
65
65
  * Moves the cursor to the previous next connection or previous connection in
66
66
  * the pre order traversal.
@@ -68,7 +68,7 @@ export declare class LineCursor extends Marker {
68
68
  * @returns The previous node, or null if the current node
69
69
  * is not set or there is no previous value.
70
70
  */
71
- prev(): ASTNode | null;
71
+ prev(): INavigable<any> | null;
72
72
  /**
73
73
  * Moves the cursor to the previous input connection or field in the pre order
74
74
  * traversal.
@@ -76,7 +76,7 @@ export declare class LineCursor extends Marker {
76
76
  * @returns The previous node, or null if the current node
77
77
  * is not set or there is no previous value.
78
78
  */
79
- out(): ASTNode | null;
79
+ out(): INavigable<any> | null;
80
80
  /**
81
81
  * Returns true iff the node to which we would navigate if in() were
82
82
  * called, which will be a validInLineNode, is also a validLineNode
@@ -107,11 +107,11 @@ export declare class LineCursor extends Marker {
107
107
  * @param node The AST node to check.
108
108
  * @returns True if the node should be visited, false otherwise.
109
109
  */
110
- protected validLineNode(node: ASTNode | null): boolean;
110
+ protected validLineNode(node: INavigable<any> | null): boolean;
111
111
  /**
112
112
  * Returns true iff the given node can be visited by the cursor when
113
113
  * using the left/right arrow keys. Specifically, if the node is
114
- * any node for which valideLineNode would return true, plus:
114
+ * any node for which validLineNode would return true, plus:
115
115
  *
116
116
  * - Any block.
117
117
  * - Any field that is not a full block field.
@@ -121,7 +121,7 @@ export declare class LineCursor extends Marker {
121
121
  * @param node The AST node to check whether it is valid.
122
122
  * @returns True if the node should be visited, false otherwise.
123
123
  */
124
- protected validInLineNode(node: ASTNode | null): boolean;
124
+ protected validInLineNode(node: INavigable<any> | null): boolean;
125
125
  /**
126
126
  * Returns true iff the given node can be visited by the cursor.
127
127
  * Specifically, if the node is any for which validInLineNode would
@@ -130,7 +130,7 @@ export declare class LineCursor extends Marker {
130
130
  * @param node The AST node to check whether it is valid.
131
131
  * @returns True if the node should be visited, false otherwise.
132
132
  */
133
- protected validNode(node: ASTNode | null): boolean;
133
+ protected validNode(node: INavigable<any> | null): boolean;
134
134
  /**
135
135
  * Uses pre order traversal to navigate the Blockly AST. This will allow
136
136
  * a user to easily navigate the entire Blockly AST without having to go in
@@ -139,9 +139,21 @@ export declare class LineCursor extends Marker {
139
139
  * @param node The current position in the AST.
140
140
  * @param isValid A function true/false depending on whether the given node
141
141
  * should be traversed.
142
+ * @param visitedNodes A set of previously visited nodes used to avoid cycles.
142
143
  * @returns The next node in the traversal.
143
144
  */
144
- getNextNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
145
+ private getNextNodeImpl;
146
+ /**
147
+ * Get the next node in the AST, optionally allowing for loopback.
148
+ *
149
+ * @param node The current position in the AST.
150
+ * @param isValid A function true/false depending on whether the given node
151
+ * should be traversed.
152
+ * @param loop Whether to loop around to the beginning of the workspace if no
153
+ * valid node was found.
154
+ * @returns The next node in the traversal.
155
+ */
156
+ getNextNode(node: INavigable<any> | null, isValid: (p1: INavigable<any> | null) => boolean, loop: boolean): INavigable<any> | null;
145
157
  /**
146
158
  * Reverses the pre order traversal in order to find the previous node. This
147
159
  * will allow a user to easily navigate the entire Blockly AST without having
@@ -150,10 +162,23 @@ export declare class LineCursor extends Marker {
150
162
  * @param node The current position in the AST.
151
163
  * @param isValid A function true/false depending on whether the given node
152
164
  * should be traversed.
165
+ * @param visitedNodes A set of previously visited nodes used to avoid cycles.
166
+ * @returns The previous node in the traversal or null if no previous node
167
+ * exists.
168
+ */
169
+ private getPreviousNodeImpl;
170
+ /**
171
+ * Get the previous node in the AST, optionally allowing for loopback.
172
+ *
173
+ * @param node The current position in the AST.
174
+ * @param isValid A function true/false depending on whether the given node
175
+ * should be traversed.
176
+ * @param loop Whether to loop around to the end of the workspace if no valid
177
+ * node was found.
153
178
  * @returns The previous node in the traversal or null if no previous node
154
179
  * exists.
155
180
  */
156
- getPreviousNode(node: ASTNode | null, isValid: (p1: ASTNode | null) => boolean): ASTNode | null;
181
+ getPreviousNode(node: INavigable<any> | null, isValid: (p1: INavigable<any> | null) => boolean, loop: boolean): INavigable<any> | null;
157
182
  /**
158
183
  * From the given node find either the next valid sibling or the parent's
159
184
  * next sibling.
@@ -192,7 +217,7 @@ export declare class LineCursor extends Marker {
192
217
  *
193
218
  * @param deletedBlock The block that is being deleted.
194
219
  */
195
- preDelete(deletedBlock: Block): void;
220
+ preDelete(deletedBlock: BlockSvg): void;
196
221
  /**
197
222
  * Move the cursor to the first valid location in
198
223
  * this.potentialNodes, following a block deletion.
@@ -209,18 +234,7 @@ export declare class LineCursor extends Marker {
209
234
  *
210
235
  * @returns The current field, connection, or block the cursor is on.
211
236
  */
212
- getCurNode(): ASTNode | null;
213
- /**
214
- * Sets the object in charge of drawing the marker.
215
- *
216
- * We want to customize drawing, so rather than directly setting the given
217
- * object, we instead set a wrapper proxy object that passes through all
218
- * method calls and property accesses except for draw(), which it delegates
219
- * to the drawMarker() method in this class.
220
- *
221
- * @param drawer The object ~in charge of drawing the marker.
222
- */
223
- setDrawer(drawer: MarkerSvg): void;
237
+ getCurNode(): INavigable<any> | null;
224
238
  /**
225
239
  * Set the location of the cursor and draw it.
226
240
  *
@@ -228,65 +242,8 @@ export declare class LineCursor extends Marker {
228
242
  * this.drawMarker() instead of this.drawer.draw() directly.
229
243
  *
230
244
  * @param newNode The new location of the cursor.
231
- * @param updateSelection If true (the default) we'll update the selection
232
- * too.
233
245
  */
234
- setCurNode(newNode: ASTNode | null, updateSelection?: boolean): void;
235
- /**
236
- * Draw this cursor's marker.
237
- *
238
- * This is a wrapper around this.drawer.draw (usually implemented by
239
- * MarkerSvg.prototype.draw) that will, if newNode is a BLOCK node,
240
- * instead call `setSelected` to select it (if it's a regular block)
241
- * or `addSelect` (if it's a shadow block, since shadow blocks can't
242
- * be selected) instead of using the normal drawer logic.
243
- *
244
- * TODO(#142): The selection and fake-selection code was originally
245
- * a hack added for testing on October 28 2024, because the default
246
- * drawer (MarkerSvg) behaviour in Zelos was to draw a box around
247
- * the block and all attached child blocks, which was confusing when
248
- * navigating stacks.
249
- *
250
- * Since then we have decided that we probably _do_ in most cases
251
- * want navigating to a block to select the block, but more
252
- * particularly that we want navigation to move _focus_. Replace
253
- * this selection hack with non-hacky changing of focus once that's
254
- * possible.
255
- *
256
- * @param oldNode The previous node.
257
- * @param curNode The current node.
258
- * @param realDrawer The object ~in charge of drawing the marker.
259
- */
260
- private drawMarker;
261
- /**
262
- * Check whether the node represents a value input connection.
263
- *
264
- * @param node The node to check
265
- * @returns True if the node represents a value input connection.
266
- */
267
- private isValueInputConnection;
268
- /**
269
- * Hide the cursor rendering at the given input node.
270
- *
271
- * @param node The input node to hide.
272
- */
273
- private hideAtInput;
274
- /**
275
- * Show the cursor rendering at the given input node.
276
- *
277
- * @param node The input node to show.
278
- */
279
- private showAtInput;
280
- /**
281
- * Event listener that syncs the cursor location to the selected block on
282
- * SELECTED events.
283
- *
284
- * This does not run early enough in all cases so `getCurNode()` also updates
285
- * the node from the selection.
286
- *
287
- * @param event The `Selected` event.
288
- */
289
- private changeListener;
246
+ setCurNode(newNode: INavigable<any> | null): void;
290
247
  /**
291
248
  * Updates the current node to match the selection.
292
249
  *
@@ -298,16 +255,23 @@ export declare class LineCursor extends Marker {
298
255
  */
299
256
  private updateCurNodeFromSelection;
300
257
  /**
301
- * Updates the selection from the node.
258
+ * Updates the current node to match what's currently focused.
302
259
  *
303
- * Clears the selection for non-block nodes.
304
- * Clears the selection for shadow blocks as the selection is drawn on
305
- * the parent but the cursor will be drawn on the shadow block itself.
306
- * We need to take care not to later clear the current node due to that null
307
- * selection, so we track the latest selection we're in sync with.
260
+ * @returns Whether the current node has been set successfully from the
261
+ * current focused node.
262
+ */
263
+ private updateCurNodeFromFocus;
264
+ /**
265
+ * Get the first navigable node on the workspace, or null if none exist.
266
+ *
267
+ * @returns The first navigable node on the workspace, or null.
268
+ */
269
+ getFirstNode(): INavigable<any> | null;
270
+ /**
271
+ * Get the last navigable node on the workspace, or null if none exist.
308
272
  *
309
- * @param newNode The new node.
273
+ * @returns The last navigable node on the workspace, or null.
310
274
  */
311
- private updateSelectionFromNode;
275
+ getLastNode(): INavigable<any> | null;
312
276
  }
313
277
  //# sourceMappingURL=line_cursor.d.ts.map