blockly 13.0.0-beta.3 → 13.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 (282) hide show
  1. package/blockly.min.js +645 -530
  2. package/blockly_compressed.js +553 -493
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +28 -25
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +19 -1
  7. package/core/block_aria_composer.d.ts +23 -4
  8. package/core/block_svg.d.ts +11 -2
  9. package/core/comments/collapse_comment_bar_button.d.ts +7 -0
  10. package/core/comments/comment_bar_button.d.ts +14 -0
  11. package/core/comments/comment_editor.d.ts +15 -0
  12. package/core/comments/comment_view.d.ts +2 -2
  13. package/core/comments/delete_comment_bar_button.d.ts +7 -0
  14. package/core/contextmenu_registry.d.ts +10 -0
  15. package/core/dragging/block_drag_strategy.d.ts +9 -1
  16. package/core/field.d.ts +31 -9
  17. package/core/field_checkbox.d.ts +2 -2
  18. package/core/field_dropdown.d.ts +11 -2
  19. package/core/field_image.d.ts +29 -2
  20. package/core/field_input.d.ts +3 -3
  21. package/core/field_label.d.ts +27 -0
  22. package/core/flyout_button.d.ts +3 -1
  23. package/core/hints.d.ts +34 -0
  24. package/core/inputs/input.d.ts +6 -2
  25. package/core/keyboard_navigation_controller.d.ts +12 -0
  26. package/core/rendered_connection.d.ts +6 -5
  27. package/core/shortcut_items.d.ts +28 -4
  28. package/core/workspace_audio.d.ts +13 -7
  29. package/core/workspace_svg.d.ts +16 -0
  30. package/msg/ab.js +64 -12
  31. package/msg/ab.mjs +52 -0
  32. package/msg/ace.js +64 -12
  33. package/msg/ace.mjs +52 -0
  34. package/msg/af.js +64 -12
  35. package/msg/af.mjs +52 -0
  36. package/msg/am.js +64 -12
  37. package/msg/am.mjs +52 -0
  38. package/msg/ar.js +61 -9
  39. package/msg/ar.mjs +52 -0
  40. package/msg/ast.js +64 -12
  41. package/msg/ast.mjs +52 -0
  42. package/msg/az.js +64 -12
  43. package/msg/az.mjs +52 -0
  44. package/msg/ba.js +64 -12
  45. package/msg/ba.mjs +52 -0
  46. package/msg/bcc.js +64 -12
  47. package/msg/bcc.mjs +52 -0
  48. package/msg/be-tarask.js +61 -9
  49. package/msg/be-tarask.mjs +52 -0
  50. package/msg/be.js +64 -12
  51. package/msg/be.mjs +52 -0
  52. package/msg/bg.js +64 -12
  53. package/msg/bg.mjs +52 -0
  54. package/msg/bn.js +64 -12
  55. package/msg/bn.mjs +52 -0
  56. package/msg/br.js +64 -12
  57. package/msg/br.mjs +52 -0
  58. package/msg/bs.js +64 -12
  59. package/msg/bs.mjs +52 -0
  60. package/msg/ca.js +64 -12
  61. package/msg/ca.mjs +52 -0
  62. package/msg/ce.js +64 -12
  63. package/msg/ce.mjs +52 -0
  64. package/msg/cs.js +64 -12
  65. package/msg/cs.mjs +52 -0
  66. package/msg/da.js +61 -9
  67. package/msg/da.mjs +52 -0
  68. package/msg/de.js +64 -12
  69. package/msg/de.mjs +52 -0
  70. package/msg/diq.js +64 -12
  71. package/msg/diq.mjs +52 -0
  72. package/msg/dtp.js +64 -12
  73. package/msg/dtp.mjs +52 -0
  74. package/msg/dty.js +64 -12
  75. package/msg/dty.mjs +52 -0
  76. package/msg/ee.js +64 -12
  77. package/msg/ee.mjs +52 -0
  78. package/msg/el.js +61 -9
  79. package/msg/el.mjs +52 -0
  80. package/msg/en-gb.js +64 -12
  81. package/msg/en-gb.mjs +52 -0
  82. package/msg/en.js +64 -12
  83. package/msg/en.mjs +52 -0
  84. package/msg/eo.js +64 -12
  85. package/msg/eo.mjs +52 -0
  86. package/msg/es.js +64 -12
  87. package/msg/es.mjs +52 -0
  88. package/msg/et.js +64 -12
  89. package/msg/et.mjs +52 -0
  90. package/msg/eu.js +64 -12
  91. package/msg/eu.mjs +52 -0
  92. package/msg/fa.js +64 -12
  93. package/msg/fa.mjs +52 -0
  94. package/msg/fi.js +64 -12
  95. package/msg/fi.mjs +52 -0
  96. package/msg/fo.js +64 -12
  97. package/msg/fo.mjs +52 -0
  98. package/msg/fr.js +61 -9
  99. package/msg/fr.mjs +52 -0
  100. package/msg/frr.js +64 -12
  101. package/msg/frr.mjs +52 -0
  102. package/msg/ga.js +61 -9
  103. package/msg/ga.mjs +52 -0
  104. package/msg/gl.js +61 -9
  105. package/msg/gl.mjs +52 -0
  106. package/msg/gn.js +64 -12
  107. package/msg/gn.mjs +52 -0
  108. package/msg/gor.js +64 -12
  109. package/msg/gor.mjs +52 -0
  110. package/msg/ha.js +64 -12
  111. package/msg/ha.mjs +52 -0
  112. package/msg/hak.js +64 -12
  113. package/msg/hak.mjs +52 -0
  114. package/msg/he.js +61 -9
  115. package/msg/he.mjs +52 -0
  116. package/msg/hi.js +64 -12
  117. package/msg/hi.mjs +52 -0
  118. package/msg/hr.js +64 -12
  119. package/msg/hr.mjs +52 -0
  120. package/msg/hrx.js +64 -12
  121. package/msg/hrx.mjs +52 -0
  122. package/msg/hsb.js +64 -12
  123. package/msg/hsb.mjs +52 -0
  124. package/msg/hu.js +64 -12
  125. package/msg/hu.mjs +52 -0
  126. package/msg/hy.js +64 -12
  127. package/msg/hy.mjs +52 -0
  128. package/msg/ia.js +61 -9
  129. package/msg/ia.mjs +52 -0
  130. package/msg/id.js +61 -9
  131. package/msg/id.mjs +52 -0
  132. package/msg/ig.js +64 -12
  133. package/msg/ig.mjs +52 -0
  134. package/msg/inh.js +64 -12
  135. package/msg/inh.mjs +52 -0
  136. package/msg/is.js +64 -12
  137. package/msg/is.mjs +52 -0
  138. package/msg/it.js +64 -12
  139. package/msg/it.mjs +52 -0
  140. package/msg/ja.js +61 -9
  141. package/msg/ja.mjs +52 -0
  142. package/msg/ka.js +64 -12
  143. package/msg/ka.mjs +52 -0
  144. package/msg/kab.js +64 -12
  145. package/msg/kab.mjs +52 -0
  146. package/msg/kbd-cyrl.js +64 -12
  147. package/msg/kbd-cyrl.mjs +52 -0
  148. package/msg/km.js +64 -12
  149. package/msg/km.mjs +52 -0
  150. package/msg/kn.js +64 -12
  151. package/msg/kn.mjs +52 -0
  152. package/msg/ko.js +64 -12
  153. package/msg/ko.mjs +52 -0
  154. package/msg/krc.js +61 -9
  155. package/msg/krc.mjs +52 -0
  156. package/msg/ksh.js +64 -12
  157. package/msg/ksh.mjs +52 -0
  158. package/msg/ku-latn.js +64 -12
  159. package/msg/ku-latn.mjs +52 -0
  160. package/msg/ky.js +64 -12
  161. package/msg/ky.mjs +52 -0
  162. package/msg/la.js +64 -12
  163. package/msg/la.mjs +52 -0
  164. package/msg/lb.js +63 -11
  165. package/msg/lb.mjs +52 -0
  166. package/msg/lki.js +64 -12
  167. package/msg/lki.mjs +52 -0
  168. package/msg/lo.js +64 -12
  169. package/msg/lo.mjs +52 -0
  170. package/msg/lrc.js +64 -12
  171. package/msg/lrc.mjs +52 -0
  172. package/msg/lt.js +64 -12
  173. package/msg/lt.mjs +52 -0
  174. package/msg/lv.js +64 -12
  175. package/msg/lv.mjs +52 -0
  176. package/msg/mg.js +64 -12
  177. package/msg/mg.mjs +52 -0
  178. package/msg/mk.js +64 -12
  179. package/msg/mk.mjs +52 -0
  180. package/msg/ml.js +64 -12
  181. package/msg/ml.mjs +52 -0
  182. package/msg/mnw.js +64 -12
  183. package/msg/mnw.mjs +52 -0
  184. package/msg/ms.js +64 -12
  185. package/msg/ms.mjs +52 -0
  186. package/msg/my.js +64 -12
  187. package/msg/my.mjs +52 -0
  188. package/msg/mzn.js +64 -12
  189. package/msg/mzn.mjs +52 -0
  190. package/msg/nb.js +64 -12
  191. package/msg/nb.mjs +52 -0
  192. package/msg/ne.js +64 -12
  193. package/msg/ne.mjs +52 -0
  194. package/msg/nl.js +61 -9
  195. package/msg/nl.mjs +52 -0
  196. package/msg/oc.js +64 -12
  197. package/msg/oc.mjs +52 -0
  198. package/msg/olo.js +64 -12
  199. package/msg/olo.mjs +52 -0
  200. package/msg/pa.js +64 -12
  201. package/msg/pa.mjs +52 -0
  202. package/msg/pl.js +61 -9
  203. package/msg/pl.mjs +52 -0
  204. package/msg/pms.js +61 -9
  205. package/msg/pms.mjs +52 -0
  206. package/msg/ps.js +64 -12
  207. package/msg/ps.mjs +52 -0
  208. package/msg/pt-br.js +61 -9
  209. package/msg/pt-br.mjs +52 -0
  210. package/msg/pt.js +61 -9
  211. package/msg/pt.mjs +52 -0
  212. package/msg/ro.js +61 -9
  213. package/msg/ro.mjs +52 -0
  214. package/msg/ru.js +61 -9
  215. package/msg/ru.mjs +52 -0
  216. package/msg/sc.js +64 -12
  217. package/msg/sc.mjs +52 -0
  218. package/msg/sco.js +64 -12
  219. package/msg/sco.mjs +52 -0
  220. package/msg/sd.js +64 -12
  221. package/msg/sd.mjs +52 -0
  222. package/msg/shn.js +64 -12
  223. package/msg/shn.mjs +52 -0
  224. package/msg/si.js +64 -12
  225. package/msg/si.mjs +52 -0
  226. package/msg/sk.js +64 -12
  227. package/msg/sk.mjs +52 -0
  228. package/msg/skr-arab.js +64 -12
  229. package/msg/skr-arab.mjs +52 -0
  230. package/msg/sl.js +61 -9
  231. package/msg/sl.mjs +52 -0
  232. package/msg/smn.js +64 -12
  233. package/msg/smn.mjs +52 -0
  234. package/msg/sq.js +63 -11
  235. package/msg/sq.mjs +52 -0
  236. package/msg/sr-latn.js +64 -12
  237. package/msg/sr-latn.mjs +52 -0
  238. package/msg/sr.js +64 -12
  239. package/msg/sr.mjs +52 -0
  240. package/msg/sv.js +61 -9
  241. package/msg/sv.mjs +52 -0
  242. package/msg/sw.js +64 -12
  243. package/msg/sw.mjs +52 -0
  244. package/msg/ta.js +64 -12
  245. package/msg/ta.mjs +52 -0
  246. package/msg/tcy.js +61 -9
  247. package/msg/tcy.mjs +52 -0
  248. package/msg/tdd.js +64 -12
  249. package/msg/tdd.mjs +52 -0
  250. package/msg/te.js +64 -12
  251. package/msg/te.mjs +52 -0
  252. package/msg/th.js +64 -12
  253. package/msg/th.mjs +52 -0
  254. package/msg/ti.js +64 -12
  255. package/msg/ti.mjs +52 -0
  256. package/msg/tl.js +64 -12
  257. package/msg/tl.mjs +52 -0
  258. package/msg/tlh.js +64 -12
  259. package/msg/tlh.mjs +52 -0
  260. package/msg/tr.js +61 -9
  261. package/msg/tr.mjs +52 -0
  262. package/msg/ug-arab.js +64 -12
  263. package/msg/ug-arab.mjs +52 -0
  264. package/msg/uk.js +64 -12
  265. package/msg/uk.mjs +52 -0
  266. package/msg/ur.js +64 -12
  267. package/msg/ur.mjs +52 -0
  268. package/msg/uz.js +64 -12
  269. package/msg/uz.mjs +52 -0
  270. package/msg/vi.js +61 -9
  271. package/msg/vi.mjs +52 -0
  272. package/msg/xmf.js +64 -12
  273. package/msg/xmf.mjs +52 -0
  274. package/msg/yo.js +64 -12
  275. package/msg/yo.mjs +52 -0
  276. package/msg/zgh.js +64 -12
  277. package/msg/zgh.mjs +52 -0
  278. package/msg/zh-hans.js +61 -9
  279. package/msg/zh-hans.mjs +52 -0
  280. package/msg/zh-hant.js +61 -9
  281. package/msg/zh-hant.mjs +52 -0
  282. package/package.json +39 -38
package/core/block.d.ts CHANGED
@@ -457,7 +457,25 @@ export declare class Block {
457
457
  */
458
458
  isDisposed(): boolean;
459
459
  /**
460
- * @returns True if this block is a value block with a single editable field.
460
+ * Determines and returns the full-block field for this block, or null if there isn't one
461
+ * and this block can't be considered a singleton field block.
462
+ *
463
+ * Note that this method is unreliable if a block contains a single field that
464
+ * hasn't been initialized/rendered yet.
465
+ *
466
+ * @returns The full-block field this block contains, or null if it doesn't contain one.
467
+ * @internal
468
+ */
469
+ getFullBlockField(): Field<any> | null;
470
+ /**
471
+ * A block is a simple reporter if it has an output connection and exactly one field.
472
+ * In some renderers, simple reporters are rendered differently from other blocks.
473
+ * Being a simple reporter block is a prerequisite to the single field rendering itself
474
+ * as a "full-block field", but it is not sufficient, as not all fields or renderers use
475
+ * this special rendering. Use `getFullBlockField` to determine if the block is rendered
476
+ * as a "full-block field block".
477
+ *
478
+ * @returns True if this block is a value block with a single field.
461
479
  * @internal
462
480
  */
463
481
  isSimpleReporter(): boolean;
@@ -16,7 +16,8 @@ export declare enum ConnectionPreposition {
16
16
  BEFORE = 1,
17
17
  AFTER = 2,
18
18
  AROUND = 3,
19
- INSIDE = 4
19
+ INSIDE = 4,
20
+ TO = 5
20
21
  }
21
22
  /**
22
23
  * Returns an ARIA representation of the specified block.
@@ -41,9 +42,12 @@ export declare enum ConnectionPreposition {
41
42
  * @internal
42
43
  * @param block The block for which an ARIA representation should be created.
43
44
  * @param verbosity How much detail to include in the description.
45
+ * @param useCustomInputLabels Whether to use custom labels for inputs, if they
46
+ * exist. We don't want to do this when just reading a block's label, but do
47
+ * want to in other scenarios such as move mode.
44
48
  * @returns The ARIA representation for the specified block.
45
49
  */
46
- export declare function computeAriaLabel(block: BlockSvg, verbosity?: Verbosity): string;
50
+ export declare function computeAriaLabel(block: BlockSvg, verbosity?: Verbosity, useCustomInputLabels?: boolean): string;
47
51
  /**
48
52
  * Sets the ARIA role and role description for the specified block, accounting
49
53
  * for whether the block is part of a flyout.
@@ -62,6 +66,14 @@ export declare function configureAriaRole(block: BlockSvg): void;
62
66
  * `lookback` attribute is specified, all of the fields on the row immediately
63
67
  * above the Input will be used instead.
64
68
  *
69
+ * If the input contains multiple adjacent FieldLabel fields, they will be
70
+ * combined together into a singular label string so that screenreaders can
71
+ * know to read them together as one piece of text.
72
+ *
73
+ * Empty field labels are excluded because they don't provide useful context.
74
+ * Fields should generally have a helpful label, but there are exceptions, such
75
+ * as when empty label fields are used to control the layout of a block.
76
+ *
65
77
  * @internal
66
78
  * @param input The Input to compute a description/context label for.
67
79
  * @param lookback If true, will use labels for fields on the previous row if
@@ -78,11 +90,18 @@ export declare function computeFieldRowLabel(input: Input, lookback: boolean, ve
78
90
  * their contents are returned as a single item in the array per top-level
79
91
  * input.
80
92
  *
93
+ * Generally, if a custom label for an input is provided, that is preferred.
94
+ * However, we do not surface the custom labels when simply reading the text of
95
+ * the block. They are used as supplementary information for situations like
96
+ * move mode or when an input itself is focused.
97
+ *
81
98
  * @internal
82
99
  * @param block The block to retrieve a list of field/input labels for.
100
+ * @param verbosity
101
+ * @param useCustomLabels whether to use the custom label for an input, if it's present.
83
102
  * @returns A list of field/input labels for the given block.
84
103
  */
85
- export declare function getInputLabels(block: BlockSvg, verbosity?: Verbosity): string[];
104
+ export declare function getInputLabels(block: BlockSvg, verbosity?: Verbosity, useCustomLabels?: boolean): string[];
86
105
  /**
87
106
  * Returns a subset of labels for inputs on the given block, ending at the
88
107
  * specified input.
@@ -99,7 +118,7 @@ export declare function getInputLabels(block: BlockSvg, verbosity?: Verbosity):
99
118
  * @param input The input that defines the end of the subset.
100
119
  * @returns A list of field/input labels for the given block.
101
120
  */
102
- export declare function getInputLabelsSubset(block: BlockSvg, input: Input, verbosity?: Verbosity): string[];
121
+ export declare function getInputLabelsSubset(block: BlockSvg, input: Input): string[];
103
122
  /**
104
123
  * Returns a translated string describing an in-progress move of a block to a new
105
124
  * connection, suitable for announcement on the ARIA live region. The returned string
@@ -719,6 +719,12 @@ export declare class BlockSvg extends Block implements IBoundedElement, IContext
719
719
  */
720
720
  toFlyoutInfo(): FlyoutItemInfo[];
721
721
  jsonInit(json: any): void;
722
+ /**
723
+ * Returns the number of blocks that this block is nested inside of.
724
+ *
725
+ * @internal
726
+ */
727
+ getNestingLevel(): number;
722
728
  /** See IFocusableNode.getFocusableElement. */
723
729
  getFocusableElement(): HTMLElement | SVGElement;
724
730
  /** See IFocusableNode.getFocusableTree. */
@@ -752,7 +758,10 @@ export declare class BlockSvg extends Block implements IBoundedElement, IContext
752
758
  */
753
759
  getOutputParents(): Set<BlockSvg>;
754
760
  /**
755
- * Returns an ID for the visual "row" this block is part of.
761
+ * Returns an ID for the logical "row" this block is part of. A "row" is
762
+ * bounded by a previous/next connection, a statement input, or a block stack
763
+ * boundary; all blocks/inputs nested inside of one of those are conceptually
764
+ * part of its same row.
756
765
  *
757
766
  * @internal
758
767
  */
@@ -760,7 +769,7 @@ export declare class BlockSvg extends Block implements IBoundedElement, IContext
760
769
  /**
761
770
  * Updates the ARIA label, role and roledescription for this block.
762
771
  */
763
- private recomputeAriaAttributes;
772
+ private recomputeAriaContext;
764
773
  /**
765
774
  * Returns a description of this block suitable for screenreaders or use in
766
775
  * ARIA attributes.
@@ -48,5 +48,12 @@ export declare class CollapseCommentBarButton extends CommentBarButton {
48
48
  * @param e The event that triggered this action.
49
49
  */
50
50
  performAction(e?: Event): void;
51
+ /**
52
+ * Returns the ARIA label to use for this button (defaults to null). Note that this
53
+ * method will only be called and apply when recomputeAriaContext is called.
54
+ *
55
+ * @returns The ARIA label to use for this button, or null to use a default.
56
+ */
57
+ protected getAriaLabel(): string;
51
58
  }
52
59
  //# sourceMappingURL=collapse_comment_bar_button.d.ts.map
@@ -58,5 +58,19 @@ export declare abstract class CommentBarButton implements IFocusableNode {
58
58
  onNodeBlur(): void;
59
59
  /** Returns whether this button can be focused. True if it is visible. */
60
60
  canBeFocused(): boolean;
61
+ /**
62
+ * Recomputes the ARIA label and role for this button. Note that this is not
63
+ * automatically called during initialization and must be called once a button's
64
+ * focusable element (icon) is initialized. Implementations may also find it useful
65
+ * to call this if the button's label should be changed.
66
+ */
67
+ protected recomputeAriaContext(): void;
68
+ /**
69
+ * Returns the ARIA label to use for this button (defaults to null). Note that this
70
+ * method will only be called and apply when recomputeAriaContext is called.
71
+ *
72
+ * @returns The ARIA label to use for this button, or null to use a default.
73
+ */
74
+ protected getAriaLabel(): string | null;
61
75
  }
62
76
  //# sourceMappingURL=comment_bar_button.d.ts.map
@@ -3,10 +3,12 @@
3
3
  * Copyright 2024 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { BlockSvg } from '../block_svg.js';
6
7
  import { IFocusableNode } from '../interfaces/i_focusable_node.js';
7
8
  import { IFocusableTree } from '../interfaces/i_focusable_tree.js';
8
9
  import { Size } from '../utils/size.js';
9
10
  import { WorkspaceSvg } from '../workspace_svg.js';
11
+ import { RenderedWorkspaceComment } from './rendered_workspace_comment.js';
10
12
  /**
11
13
  * String added to the ID of a workspace comment to identify
12
14
  * the focusable node for the comment editor.
@@ -25,6 +27,8 @@ export declare class CommentEditor implements IFocusableNode {
25
27
  private textChangeListeners;
26
28
  /** The current text of the comment. Updates on text area change. */
27
29
  private text;
30
+ /** The parent object that owns this comment editor. */
31
+ private parent?;
28
32
  constructor(workspace: WorkspaceSvg, commentId: string, onFinishEditing?: (() => void) | undefined);
29
33
  /** Gets the dom structure for this comment editor. */
30
34
  getDom(): SVGForeignObjectElement;
@@ -32,6 +36,17 @@ export declare class CommentEditor implements IFocusableNode {
32
36
  getText(): string;
33
37
  /** Sets the current text of the comment and fires change listeners. */
34
38
  setText(text: string): void;
39
+ /**
40
+ * Sets the parent object that owns this comment editor.
41
+ *
42
+ * @param newParent The parent of this comment editor.
43
+ * @internal
44
+ */
45
+ setParent(newParent: BlockSvg | RenderedWorkspaceComment): void;
46
+ /**
47
+ * Returns the parent object that owns this comment editor, if any.
48
+ */
49
+ getParent(): BlockSvg | RenderedWorkspaceComment | undefined;
35
50
  /**
36
51
  * Triggers listeners when the text of the comment changes, either
37
52
  * programmatically or manually by the user.
@@ -3,12 +3,12 @@
3
3
  * Copyright 2024 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { IFocusableNode } from '../interfaces/i_focusable_node';
7
6
  import { IRenderedElement } from '../interfaces/i_rendered_element.js';
8
7
  import { Coordinate } from '../utils/coordinate.js';
9
8
  import { Size } from '../utils/size.js';
10
9
  import { WorkspaceSvg } from '../workspace_svg.js';
11
10
  import { CommentBarButton } from './comment_bar_button.js';
11
+ import { CommentEditor } from './comment_editor.js';
12
12
  export declare class CommentView implements IRenderedElement {
13
13
  readonly workspace: WorkspaceSvg;
14
14
  readonly commentId: string;
@@ -84,7 +84,7 @@ export declare class CommentView implements IRenderedElement {
84
84
  *
85
85
  * @returns The FocusableNode representing the editor portion of this comment.
86
86
  */
87
- getEditorFocusableNode(): IFocusableNode;
87
+ getEditorFocusableNode(): CommentEditor;
88
88
  /** Creates the DOM elements for the comment resize handle. */
89
89
  private createResizeHandle;
90
90
  /** Returns the root SVG group element of the comment view. */
@@ -48,5 +48,12 @@ export declare class DeleteCommentBarButton extends CommentBarButton {
48
48
  * @param e The event that triggered this action.
49
49
  */
50
50
  performAction(e?: Event): void;
51
+ /**
52
+ * Returns the ARIA label to use for this button (defaults to null). Note that this
53
+ * method will only be called and apply when recomputeAriaContext is called.
54
+ *
55
+ * @returns The ARIA label to use for this button, or null to use a default.
56
+ */
57
+ protected getAriaLabel(): string;
51
58
  }
52
59
  //# sourceMappingURL=delete_comment_bar_button.d.ts.map
@@ -103,6 +103,13 @@ export declare namespace ContextMenuRegistry {
103
103
  displayText: ((p1: Scope) => string | HTMLElement) | string | HTMLElement;
104
104
  separator?: never;
105
105
  preconditionFn: (p1: Scope, menuOpenEvent: Event) => string;
106
+ /**
107
+ * Identifier used to associate this context menu item with a keyboard
108
+ * shortcut which will be displayed in the menu as a hint. Should
109
+ * correspond to the name under which a keyboard shortcut that performs the
110
+ * same action as this menu item is registered.
111
+ */
112
+ associatedKeyboardShortcut?: string;
106
113
  }
107
114
  /**
108
115
  * A representation of a menu separator item in the registry.
@@ -120,8 +127,10 @@ export declare namespace ContextMenuRegistry {
120
127
  * Fields common to all context menu items as used by contextmenu.ts.
121
128
  */
122
129
  export interface CoreContextMenuOption {
130
+ id: string;
123
131
  scope: Scope;
124
132
  weight: number;
133
+ associatedKeyboardShortcut?: string;
125
134
  }
126
135
  /**
127
136
  * A representation of a normal, clickable menu item in contextmenu.ts.
@@ -170,4 +179,5 @@ export type Scope = ContextMenuRegistry.Scope;
170
179
  export type RegistryItem = ContextMenuRegistry.RegistryItem;
171
180
  export type ContextMenuOption = ContextMenuRegistry.ContextMenuOption;
172
181
  export type LegacyContextMenuOption = ContextMenuRegistry.LegacyContextMenuOption;
182
+ export type ActionContextMenuOption = ContextMenuRegistry.ActionContextMenuOption;
173
183
  //# sourceMappingURL=contextmenu_registry.d.ts.map
@@ -75,7 +75,7 @@ export declare class BlockDragStrategy implements IDragStrategy {
75
75
  * Handles any setup for starting the drag, including disconnecting the block
76
76
  * from any parent blocks.
77
77
  */
78
- startDrag(e?: PointerEvent | KeyboardEvent): import("../interfaces/i_draggable.js").IDraggable;
78
+ startDrag(e?: PointerEvent | KeyboardEvent): import("../blockly.js").IDraggable;
79
79
  /**
80
80
  * Handles any setup for starting the drag, including disconnecting the block
81
81
  * from any parent blocks.
@@ -237,6 +237,14 @@ export declare class BlockDragStrategy implements IDragStrategy {
237
237
  * @returns All connections on the block and its children.
238
238
  */
239
239
  private getAllConnections;
240
+ /**
241
+ * Returns a connection candidate to move the dragged block to at the start of
242
+ * a drag. If the passively focused node is a connection and the dragged block
243
+ * can connect to it, the connection will be returned. Otherwise, the first
244
+ * compatible connection on the passively focused node's block, if any, will
245
+ * be returned. Returns null if the workspace does not have passive focus.
246
+ */
247
+ private getInitialCandidate;
240
248
  }
241
249
  export {};
242
250
  //# sourceMappingURL=block_drag_strategy.d.ts.map
package/core/field.d.ts CHANGED
@@ -43,7 +43,7 @@ export type FieldValidator<T = any> = (newValue: T) => T | null | undefined;
43
43
  /**
44
44
  * Abstract class for an editable field.
45
45
  *
46
- * @typeParam T - The value stored on the field.
46
+ * @template T - The value stored on the field.
47
47
  */
48
48
  export declare abstract class Field<T = any> implements IKeyboardAccessible, IRegistrable, ISerializable, IFocusableNode {
49
49
  /**
@@ -235,9 +235,11 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
235
235
  * checkboxes represent their checked/non-checked status (i.e. value) through
236
236
  * a separate ARIA property.
237
237
  *
238
- * It's not expected that this method, under normal operations, returns an empty
239
- * string. If the field's value is empty then it will return a localized
240
- * placeholder indicating that its value is empty.
238
+ * If the field's value is empty then it will return a localized placeholder
239
+ * indicating that its value is empty. If this method returns an empty string,
240
+ * the output will be ignored when composing the block-level ARIA label. Make
241
+ * sure you want your label hidden from screenreaders before returning an
242
+ * empty string.
241
243
  *
242
244
  * @param includeTypeInfo Whether to include the field's type information in
243
245
  * the returned label, if available.
@@ -263,12 +265,16 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
263
265
  /**
264
266
  * Defines whether this field should take up the full block or not.
265
267
  *
266
- * Be cautious when overriding this function. It may not work as you expect /
267
- * intend because the behavior was kind of hacked in. If you are thinking
268
- * about overriding this function, post on the forum with your intended
269
- * behavior to see if there's another approach.
268
+ * This is typically only done for certain kinds of fields and in certain
269
+ * renderers. You should only override this if you're sure your field will
270
+ * render correctly in zelos and other renderers that support full-block
271
+ * fields.
270
272
  *
271
- * @internal
273
+ * Blocks that contain only a single field that is a full-block-field
274
+ * have a special appearance in some renderers and their behavior is
275
+ * unique, because we pretend that the field is a whole block in some cases.
276
+ * This is hacky and you should use caution when attempting to do anything
277
+ * with this method.
272
278
  */
273
279
  isFullBlockField(): boolean;
274
280
  /**
@@ -750,6 +756,22 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
750
756
  * Shows and focuses the field editor.
751
757
  */
752
758
  performAction(): void;
759
+ /**
760
+ * Recomputes the aria state and label for this field. Fields are generally hidden
761
+ * when in blocks in the flyout (except for top-level full-block fields), and
762
+ * otherwise set to a role of button (indicating they can be clicked to edit)
763
+ * and given the label returned from their `computeAriaLabel` method.
764
+ *
765
+ * Subclasses can override this in order to change the role or label, but they must
766
+ * ensure they keep the correct behavior for fields in flyout blocks.
767
+ *
768
+ * This method will return a boolean indicating if the element is displayed in the
769
+ * aria tree or not. This can be used by subclasses to determine whether or not
770
+ * to continue customizing the role and label (hidden elements should not have labels).
771
+ *
772
+ * @returns true if the element is in the accessibility tree, false if the aria state is hidden
773
+ */
774
+ protected recomputeAriaContext(): boolean;
753
775
  /**
754
776
  * Subclasses should reimplement this method to construct their Field
755
777
  * subclass from a JSON arg object.
@@ -147,9 +147,9 @@ export declare class FieldCheckbox extends Field<CheckboxBool> {
147
147
  */
148
148
  static fromJson(options: FieldCheckboxFromJsonConfig): FieldCheckbox;
149
149
  /**
150
- * Recomputes the ARIA role and label for this field.
150
+ * Customizes the label and sets additional aria state.
151
151
  */
152
- protected recomputeAriaContext(): void;
152
+ recomputeAriaContext(): boolean;
153
153
  }
154
154
  /**
155
155
  * Config options for the checkbox field.
@@ -98,6 +98,15 @@ export declare class FieldDropdown extends Field<string> {
98
98
  * Create the block UI for this dropdown.
99
99
  */
100
100
  initView(): void;
101
+ /**
102
+ * This is hacky way of determining if a dropdown field is a full-block field or not.
103
+ * The constants that control the border rect are the same ones that determine how we
104
+ * render full-block dropdown fields. It's a full-block field if it doesn't have the
105
+ * border rect (and it's a simple reporter block).
106
+ *
107
+ * @returns true if this field should be treated as a full-block field
108
+ */
109
+ isFullBlockField(): boolean;
101
110
  /**
102
111
  * Whether or not the dropdown should add a border rect.
103
112
  *
@@ -270,9 +279,9 @@ export declare class FieldDropdown extends Field<string> {
270
279
  */
271
280
  private getSelectedAriaLabel;
272
281
  /**
273
- * Recomputes the ARIA role and label for this field.
282
+ * Overrides the default label and sets additional aria state.
274
283
  */
275
- protected recomputeAriaContext(): void;
284
+ recomputeAriaContext(): boolean;
276
285
  /**
277
286
  * Computes an ARIA-friendly label for a dropdown option.
278
287
  *
@@ -150,9 +150,36 @@ export declare class FieldImage extends Field<string> {
150
150
  */
151
151
  getAriaValue(): string | null;
152
152
  /**
153
- * Recomputes the ARIA role and label for this field.
153
+ * Computes a descriptive ARIA label to represent this field with configurable
154
+ * verbosity.
155
+ *
156
+ * A 'verbose' label includes type information, if available, whereas a
157
+ * non-verbose label only contains the field's value.
158
+ *
159
+ * Note that this will always return the latest representation of the field's
160
+ * label which may differ from any previously set ARIA label for the field
161
+ * itself. Implementations are largely responsible for ensuring that the
162
+ * field's ARIA label is set correctly at relevant moments in the field's
163
+ * lifecycle (such as when its value changes).
164
+ *
165
+ * Finally, it is never guaranteed that implementations use the label returned
166
+ * by this method for their actual ARIA label. Some implementations may rely
167
+ * on other contexts to convey information like the field's value. Example:
168
+ * checkboxes represent their checked/non-checked status (i.e. value) through
169
+ * a separate ARIA property.
170
+ *
171
+ * Returns an empty string on clickable images (buttons), as we do not want to
172
+ * include image buttons on the block-level ARIA label. When the button is
173
+ * focused the label is set in recomputeAriaContext below.
174
+ *
175
+ * @param includeTypeInfo Whether to include the field's type information in
176
+ * the returned label, if available.
177
+ */
178
+ computeAriaLabel(includeTypeInfo: boolean): string;
179
+ /**
180
+ * Customizes label and sets additional aria state.
154
181
  */
155
- protected recomputeAriaContext(): void;
182
+ recomputeAriaContext(): boolean;
156
183
  }
157
184
  /**
158
185
  * Config options for the image field.
@@ -21,7 +21,7 @@ type InputTypes = string | number;
21
21
  /**
22
22
  * Abstract class for an editable input field.
23
23
  *
24
- * @typeParam T - The value stored on the field.
24
+ * @template T - The value stored on the field.
25
25
  * @internal
26
26
  */
27
27
  export declare abstract class FieldInput<T extends InputTypes> extends Field<string | T> {
@@ -283,9 +283,9 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
283
283
  */
284
284
  getAriaValue(): string | null;
285
285
  /**
286
- * Recomputes the ARIA role and label for this field.
286
+ * Customizes the label for this field to include "editable" if it applies.
287
287
  */
288
- protected recomputeAriaContext(): void;
288
+ recomputeAriaContext(): boolean;
289
289
  }
290
290
  /**
291
291
  * Config options for the input field.
@@ -41,6 +41,33 @@ export declare class FieldLabel extends Field<string> {
41
41
  * Create block UI for this label.
42
42
  */
43
43
  initView(): void;
44
+ /**
45
+ * Computes a descriptive ARIA label to represent this field with configurable
46
+ * verbosity.
47
+ *
48
+ * A 'verbose' label includes type information, if available, whereas a
49
+ * non-verbose label only contains the field's value.
50
+ *
51
+ * Note that this will always return the latest representation of the field's
52
+ * label which may differ from any previously set ARIA label for the field
53
+ * itself. Implementations are largely responsible for ensuring that the
54
+ * field's ARIA label is set correctly at relevant moments in the field's
55
+ * lifecycle (such as when its value changes).
56
+ *
57
+ * Finally, it is never guaranteed that implementations use the label returned
58
+ * by this method for their actual ARIA label. Some implementations may rely
59
+ * on other contexts to convey information like the field's value. Example:
60
+ * checkboxes represent their checked/non-checked status (i.e. value) through
61
+ * a separate ARIA property.
62
+ *
63
+ * Unlike other built-in fields, FieldLabel does return an empty string when its
64
+ * value is empty. This is because empty labels are sometimes used for layout
65
+ * purposes.
66
+ *
67
+ * @param includeTypeInfo Whether to include the field's type information in
68
+ * the returned label, if available.
69
+ */
70
+ computeAriaLabel(includeTypeInfo?: boolean): string;
44
71
  /**
45
72
  * Ensure that the input value casts to a valid string.
46
73
  *
@@ -142,7 +142,9 @@ export declare class FlyoutButton implements IBoundedElement, IRenderedElement,
142
142
  getId(): string;
143
143
  /**
144
144
  * Handles the user acting on this button via keyboard navigation.
145
- * Invokes the click handler callback.
145
+ * Invokes the click handler callback for buttons. For labels, which are not
146
+ * interactive, shows a toast directing the user to navigate using the arrow
147
+ * keys or the next-heading shortcut.
146
148
  */
147
149
  performAction(): void;
148
150
  }
package/core/hints.d.ts CHANGED
@@ -41,4 +41,38 @@ export declare function showBlockNavigationHint(workspace: WorkspaceSvg): void;
41
41
  * @param workspace The workspace.
42
42
  */
43
43
  export declare function showWorkspaceNavigationHint(workspace: WorkspaceSvg): void;
44
+ /**
45
+ * Tell the user how to navigate away from a flyout label (heading) when they
46
+ * try to act on it. Labels are not interactive, so direct them to use the
47
+ * arrow keys to reach a block or the next-heading shortcut to skip ahead.
48
+ *
49
+ * @param workspace The workspace.
50
+ */
51
+ export declare function showFlyoutLabelActionHint(workspace: WorkspaceSvg): void;
52
+ /**
53
+ * Nudge the user to paste after a copy.
54
+ *
55
+ * @param workspace Workspace.
56
+ */
57
+ export declare function showCopiedHint(workspace: WorkspaceSvg): void;
58
+ /**
59
+ * Nudge the user to paste after a cut.
60
+ *
61
+ * @param workspace Workspace.
62
+ */
63
+ export declare function showCutHint(workspace: WorkspaceSvg): void;
64
+ /**
65
+ * Clear active paste-related hints, if any.
66
+ *
67
+ * @param workspace The workspace.
68
+ */
69
+ export declare function clearPasteHints(workspace: WorkspaceSvg): void;
70
+ /**
71
+ * Inform the user about screenreader optimization mode being toggled, and how
72
+ * to undo it.
73
+ *
74
+ * @param workspace The workspace where screenreader mode was toggled.
75
+ * @param enabled True if screenreader mode is now enabled, otherwise false.
76
+ */
77
+ export declare function showScreenreaderModeHint(workspace: WorkspaceSvg, enabled: boolean): void;
44
78
  //# sourceMappingURL=hints.d.ts.map
@@ -173,7 +173,10 @@ export declare class Input {
173
173
  */
174
174
  protected makeConnection(type: ConnectionType): Connection;
175
175
  /**
176
- * Returns an ID for the visual "row" this input is part of.
176
+ * Returns an ID for the logical "row" this input is part of. A "row" is
177
+ * bounded by a previous/next connection, a statement input, or a block stack
178
+ * boundary; all blocks/inputs nested inside of one of those are conceptually
179
+ * part of its same row.
177
180
  *
178
181
  * @internal
179
182
  */
@@ -187,7 +190,8 @@ export declare class Input {
187
190
  */
188
191
  getLabel(verbosity?: Verbosity): string;
189
192
  /**
190
- * Returns the index of this input on its source block.
193
+ * Returns the index of this input, excluding inputs without connections, on its
194
+ * source block.
191
195
  *
192
196
  * @internal
193
197
  */
@@ -11,6 +11,8 @@
11
11
  export declare class KeyboardNavigationController {
12
12
  /** Whether the user is actively using keyboard navigation. */
13
13
  private isActive;
14
+ /** Whether to play audio cues when navigating between scope levels. */
15
+ private scopeChangeAudioCuesEnabled;
14
16
  /** Css class name added to body if keyboard nav is active. */
15
17
  private activeClassName;
16
18
  /**
@@ -40,6 +42,16 @@ export declare class KeyboardNavigationController {
40
42
  * (e.g., has recently taken some action that is only relevant to keyboard users)
41
43
  */
42
44
  getIsActive(): boolean;
45
+ /**
46
+ * Sets whether or not audio cues should be played when keyboard navigation
47
+ * transitions between blocks of different nesting levels.
48
+ */
49
+ setScopeChangeAudioCuesEnabled(enabled: boolean): void;
50
+ /**
51
+ * Returns whether or not audio cues should be played when keyboard navigation
52
+ * transitions between blocks of different nesting levels.
53
+ */
54
+ getScopeChangeAudioCuesEnabled(): boolean;
43
55
  /** Adds or removes the css class that indicates keyboard navigation is active. */
44
56
  private updateActiveVisualization;
45
57
  }
@@ -3,11 +3,6 @@
3
3
  * Copyright 2016 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- /**
7
- * Components for creating connections between blocks.
8
- *
9
- * @class
10
- */
11
6
  import type { BlockSvg } from './block_svg.js';
12
7
  import { Connection } from './connection.js';
13
8
  import { IContextMenu } from './interfaces/i_contextmenu.js';
@@ -133,6 +128,12 @@ export declare class RenderedConnection extends Connection implements IContextMe
133
128
  connection: RenderedConnection | null;
134
129
  radius: number;
135
130
  };
131
+ /**
132
+ * Sets the aria role, label, and other state for this connection.
133
+ *
134
+ * @param highlightSvg The focusable element for this connection.
135
+ */
136
+ private recomputeAriaContext;
136
137
  /** Add highlighting around this connection. */
137
138
  highlight(): void;
138
139
  /** Remove the highlighting around this connection. */