blockly 11.0.0-beta.8 → 11.0.0-beta.9

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 (151) hide show
  1. package/blockly.min.js +319 -342
  2. package/blockly_compressed.js +296 -319
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +22 -23
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +46 -4
  7. package/core/block_svg.d.ts +22 -2
  8. package/core/blockly.d.ts +0 -4
  9. package/core/clipboard/workspace_comment_paster.d.ts +5 -4
  10. package/core/comments/comment_view.d.ts +2 -0
  11. package/core/comments/rendered_workspace_comment.d.ts +11 -3
  12. package/core/constants.d.ts +5 -0
  13. package/core/contextmenu.d.ts +1 -34
  14. package/core/contextmenu_items.d.ts +8 -0
  15. package/core/contextmenu_registry.d.ts +18 -3
  16. package/core/dragging/comment_drag_strategy.d.ts +1 -0
  17. package/core/events/events_block_change.d.ts +15 -0
  18. package/core/events/utils.d.ts +1 -3
  19. package/core/serialization/blocks.d.ts +1 -0
  20. package/core/serialization/workspace_comments.d.ts +1 -1
  21. package/core/utils/toolbox.d.ts +1 -0
  22. package/core/workspace.d.ts +9 -1
  23. package/core/workspace_svg.d.ts +10 -2
  24. package/msg/ab.js +1 -0
  25. package/msg/ace.js +1 -0
  26. package/msg/af.js +1 -0
  27. package/msg/am.js +1 -0
  28. package/msg/ar.js +1 -0
  29. package/msg/ast.js +1 -0
  30. package/msg/az.js +1 -0
  31. package/msg/ba.js +1 -0
  32. package/msg/bcc.js +1 -0
  33. package/msg/be-tarask.js +1 -0
  34. package/msg/be.js +1 -0
  35. package/msg/bg.js +1 -0
  36. package/msg/bn.js +1 -0
  37. package/msg/br.js +1 -0
  38. package/msg/bs.js +1 -0
  39. package/msg/ca.js +1 -0
  40. package/msg/cdo.js +1 -0
  41. package/msg/ce.js +1 -0
  42. package/msg/cs.js +1 -0
  43. package/msg/da.js +1 -0
  44. package/msg/de.js +1 -0
  45. package/msg/diq.js +1 -0
  46. package/msg/dtp.js +1 -0
  47. package/msg/dty.js +1 -0
  48. package/msg/ee.js +1 -0
  49. package/msg/el.js +1 -0
  50. package/msg/en-gb.js +1 -0
  51. package/msg/en.js +1 -0
  52. package/msg/eo.js +1 -0
  53. package/msg/es.js +1 -0
  54. package/msg/et.js +1 -0
  55. package/msg/eu.js +1 -0
  56. package/msg/fa.js +1 -0
  57. package/msg/fi.js +1 -0
  58. package/msg/fo.js +1 -0
  59. package/msg/fr.js +1 -0
  60. package/msg/frr.js +1 -0
  61. package/msg/gl.js +1 -0
  62. package/msg/gn.js +1 -0
  63. package/msg/gor.js +1 -0
  64. package/msg/ha.js +1 -0
  65. package/msg/hak.js +1 -0
  66. package/msg/he.js +1 -0
  67. package/msg/hi.js +1 -0
  68. package/msg/hr.js +1 -0
  69. package/msg/hrx.js +1 -0
  70. package/msg/hsb.js +1 -0
  71. package/msg/hu.js +1 -0
  72. package/msg/hy.js +1 -0
  73. package/msg/ia.js +1 -0
  74. package/msg/id.js +1 -0
  75. package/msg/ig.js +1 -0
  76. package/msg/inh.js +1 -0
  77. package/msg/is.js +1 -0
  78. package/msg/it.js +1 -0
  79. package/msg/ja.js +1 -0
  80. package/msg/ka.js +1 -0
  81. package/msg/kab.js +1 -0
  82. package/msg/kbd-cyrl.js +1 -0
  83. package/msg/km.js +1 -0
  84. package/msg/kn.js +1 -0
  85. package/msg/ko.js +1 -0
  86. package/msg/ksh.js +1 -0
  87. package/msg/ku-latn.js +1 -0
  88. package/msg/ky.js +1 -0
  89. package/msg/la.js +1 -0
  90. package/msg/lb.js +1 -0
  91. package/msg/lki.js +1 -0
  92. package/msg/lo.js +1 -0
  93. package/msg/lrc.js +1 -0
  94. package/msg/lt.js +1 -0
  95. package/msg/lv.js +1 -0
  96. package/msg/mg.js +1 -0
  97. package/msg/mk.js +1 -0
  98. package/msg/ml.js +1 -0
  99. package/msg/mnw.js +1 -0
  100. package/msg/ms.js +1 -0
  101. package/msg/my.js +1 -0
  102. package/msg/mzn.js +1 -0
  103. package/msg/nb.js +1 -0
  104. package/msg/ne.js +1 -0
  105. package/msg/nl.js +1 -0
  106. package/msg/oc.js +1 -0
  107. package/msg/olo.js +1 -0
  108. package/msg/pa.js +1 -0
  109. package/msg/pl.js +1 -0
  110. package/msg/pms.js +1 -0
  111. package/msg/ps.js +1 -0
  112. package/msg/pt-br.js +1 -0
  113. package/msg/pt.js +1 -0
  114. package/msg/ro.js +1 -0
  115. package/msg/ru.js +1 -0
  116. package/msg/sc.js +1 -0
  117. package/msg/sco.js +1 -0
  118. package/msg/sd.js +1 -0
  119. package/msg/shn.js +1 -0
  120. package/msg/si.js +1 -0
  121. package/msg/sk.js +1 -0
  122. package/msg/skr-arab.js +1 -0
  123. package/msg/sl.js +1 -0
  124. package/msg/smn.js +1 -0
  125. package/msg/sq.js +1 -0
  126. package/msg/sr-latn.js +1 -0
  127. package/msg/sr.js +1 -0
  128. package/msg/sv.js +1 -0
  129. package/msg/sw.js +1 -0
  130. package/msg/ta.js +1 -0
  131. package/msg/tcy.js +1 -0
  132. package/msg/tdd.js +1 -0
  133. package/msg/te.js +1 -0
  134. package/msg/th.js +1 -0
  135. package/msg/ti.js +1 -0
  136. package/msg/tl.js +1 -0
  137. package/msg/tlh.js +1 -0
  138. package/msg/tr.js +1 -0
  139. package/msg/ug-arab.js +1 -0
  140. package/msg/uk.js +1 -0
  141. package/msg/ur.js +1 -0
  142. package/msg/uz.js +1 -0
  143. package/msg/vi.js +1 -0
  144. package/msg/xmf.js +1 -0
  145. package/msg/yo.js +1 -0
  146. package/msg/zgh.js +1 -0
  147. package/msg/zh-hans.js +1 -0
  148. package/msg/zh-hant.js +1 -0
  149. package/package.json +1 -1
  150. package/core/workspace_comment.d.ts +0 -190
  151. package/core/workspace_comment_svg.d.ts +0 -360
package/core/block.d.ts CHANGED
@@ -123,7 +123,7 @@ export declare class Block implements IASTNodeLocation {
123
123
  inputList: Input[];
124
124
  inputsInline?: boolean;
125
125
  icons: IIcon[];
126
- private disabled;
126
+ private disabledReasons;
127
127
  tooltip: Tooltip.TipInfo;
128
128
  contextMenu: boolean;
129
129
  protected parentBlock_: this | null;
@@ -627,17 +627,44 @@ export declare class Block implements IASTNodeLocation {
627
627
  */
628
628
  getOutputShape(): number | null;
629
629
  /**
630
- * Get whether this block is enabled or not.
630
+ * Get whether this block is enabled or not. A block is considered enabled
631
+ * if there aren't any reasons why it would be disabled. A block may still
632
+ * be disabled for other reasons even if the user attempts to manually
633
+ * enable it, such as when the block is in an invalid location.
631
634
  *
632
635
  * @returns True if enabled.
633
636
  */
634
637
  isEnabled(): boolean;
635
- /**
636
- * Set whether the block is enabled or not.
638
+ /** @deprecated v11 - Get whether the block is manually disabled. */
639
+ private get disabled();
640
+ /** @deprecated v11 - Set whether the block is manually disabled. */
641
+ private set disabled(value);
642
+ /**
643
+ * @deprecated v11 - Set whether the block is manually enabled or disabled.
644
+ * The user can toggle whether a block is disabled from a context menu
645
+ * option. A block may still be disabled for other reasons even if the user
646
+ * attempts to manually enable it, such as when the block is in an invalid
647
+ * location. This method is deprecated and setDisabledReason should be used
648
+ * instead.
637
649
  *
638
650
  * @param enabled True if enabled.
639
651
  */
640
652
  setEnabled(enabled: boolean): void;
653
+ /**
654
+ * Add or remove a reason why the block might be disabled. If a block has
655
+ * any reasons to be disabled, then the block itself will be considered
656
+ * disabled. A block could be disabled for multiple independent reasons
657
+ * simultaneously, such as when the user manually disables it, or the block
658
+ * is invalid.
659
+ *
660
+ * @param disabled If true, then the block should be considered disabled for
661
+ * at least the provided reason, otherwise the block is no longer disabled
662
+ * for that reason.
663
+ * @param reason A language-neutral identifier for a reason why the block
664
+ * could be disabled. Call this method again with the same identifier to
665
+ * update whether the block is currently disabled for this reason.
666
+ */
667
+ setDisabledReason(disabled: boolean, reason: string): void;
641
668
  /**
642
669
  * Get whether the block is disabled or not due to parents.
643
670
  * The block's own disabled property is not considered.
@@ -645,6 +672,21 @@ export declare class Block implements IASTNodeLocation {
645
672
  * @returns True if disabled.
646
673
  */
647
674
  getInheritedDisabled(): boolean;
675
+ /**
676
+ * Get whether the block is currently disabled for the provided reason.
677
+ *
678
+ * @param reason A language-neutral identifier for a reason why the block
679
+ * could be disabled.
680
+ * @returns Whether the block is disabled for the provided reason.
681
+ */
682
+ hasDisabledReason(reason: string): boolean;
683
+ /**
684
+ * Get a set of reasons why the block is currently disabled, if any. If the
685
+ * block is enabled, this set will be empty.
686
+ *
687
+ * @returns The set of reasons why the block is disabled, if any.
688
+ */
689
+ getDisabledReasons(): ReadonlySet<string>;
648
690
  /**
649
691
  * Get whether the block is collapsed or not.
650
692
  *
@@ -238,7 +238,7 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
238
238
  * @param e Mouse event.
239
239
  * @internal
240
240
  */
241
- showContextMenu(e: Event): void;
241
+ showContextMenu(e: PointerEvent): void;
242
242
  /**
243
243
  * Updates the locations of any parts of the block that need to know where
244
244
  * they are (e.g. connections, icons).
@@ -356,11 +356,31 @@ export declare class BlockSvg extends Block implements IASTNodeLocationSvg, IBou
356
356
  private createIconPointerDownListener;
357
357
  removeIcon(type: IconType<IIcon>): boolean;
358
358
  /**
359
- * Set whether the block is enabled or not.
359
+ * @deprecated v11 - Set whether the block is manually enabled or disabled.
360
+ * The user can toggle whether a block is disabled from a context menu
361
+ * option. A block may still be disabled for other reasons even if the user
362
+ * attempts to manually enable it, such as when the block is in an invalid
363
+ * location. This method is deprecated and setDisabledReason should be used
364
+ * instead.
360
365
  *
361
366
  * @param enabled True if enabled.
362
367
  */
363
368
  setEnabled(enabled: boolean): void;
369
+ /**
370
+ * Add or remove a reason why the block might be disabled. If a block has
371
+ * any reasons to be disabled, then the block itself will be considered
372
+ * disabled. A block could be disabled for multiple independent reasons
373
+ * simultaneously, such as when the user manually disables it, or the block
374
+ * is invalid.
375
+ *
376
+ * @param disabled If true, then the block should be considered disabled for
377
+ * at least the provided reason, otherwise the block is no longer disabled
378
+ * for that reason.
379
+ * @param reason A language-neutral identifier for a reason why the block
380
+ * could be disabled. Call this method again with the same identifier to
381
+ * update whether the block is currently disabled for this reason.
382
+ */
383
+ setDisabledReason(disabled: boolean, reason: string): void;
364
384
  /**
365
385
  * Set whether the block is highlighted or not. Block highlighting is
366
386
  * often used to visually mark blocks currently being executed.
package/core/blockly.d.ts CHANGED
@@ -141,8 +141,6 @@ import * as VariablesDynamic from './variables_dynamic.js';
141
141
  import * as WidgetDiv from './widgetdiv.js';
142
142
  import { Workspace } from './workspace.js';
143
143
  import { WorkspaceAudio } from './workspace_audio.js';
144
- import { WorkspaceComment } from './workspace_comment.js';
145
- import { WorkspaceCommentSvg } from './workspace_comment_svg.js';
146
144
  import { WorkspaceDragger } from './workspace_dragger.js';
147
145
  import { WorkspaceSvg } from './workspace_svg.js';
148
146
  import * as Xml from './xml.js';
@@ -397,8 +395,6 @@ export { VariableModel };
397
395
  export { VerticalFlyout };
398
396
  export { Workspace };
399
397
  export { WorkspaceAudio };
400
- export { WorkspaceComment };
401
- export { WorkspaceCommentSvg };
402
398
  export { WorkspaceDragger };
403
399
  export { WorkspaceSvg };
404
400
  export { ZoomControls };
@@ -7,12 +7,13 @@ import { IPaster } from '../interfaces/i_paster.js';
7
7
  import { ICopyData } from '../interfaces/i_copyable.js';
8
8
  import { Coordinate } from '../utils/coordinate.js';
9
9
  import { WorkspaceSvg } from '../workspace_svg.js';
10
- import { WorkspaceCommentSvg } from '../workspace_comment_svg.js';
11
- export declare class WorkspaceCommentPaster implements IPaster<WorkspaceCommentCopyData, WorkspaceCommentSvg> {
10
+ import * as commentSerialiation from '../serialization/workspace_comments.js';
11
+ import { RenderedWorkspaceComment } from '../comments/rendered_workspace_comment.js';
12
+ export declare class WorkspaceCommentPaster implements IPaster<WorkspaceCommentCopyData, RenderedWorkspaceComment> {
12
13
  static TYPE: string;
13
- paste(copyData: WorkspaceCommentCopyData, workspace: WorkspaceSvg, coordinate?: Coordinate): WorkspaceCommentSvg;
14
+ paste(copyData: WorkspaceCommentCopyData, workspace: WorkspaceSvg, coordinate?: Coordinate): RenderedWorkspaceComment | null;
14
15
  }
15
16
  export interface WorkspaceCommentCopyData extends ICopyData {
16
- commentState: Element;
17
+ commentState: commentSerialiation.State;
17
18
  }
18
19
  //# sourceMappingURL=workspace_comment_paster.d.ts.map
@@ -103,6 +103,8 @@ export declare class CommentView implements IRenderedElement {
103
103
  private calcDeleteMargin;
104
104
  /** Calculates the margin that should exist around the foldout icon. */
105
105
  private calcFoldoutMargin;
106
+ /** Updates the size of the highlight rect to reflect the new size. */
107
+ private updateHighlightRect;
106
108
  /** Updates the size of the top bar to reflect the new size. */
107
109
  private updateTopBarSize;
108
110
  /** Updates the size of the text area elements to reflect the new size. */
@@ -13,7 +13,10 @@ import { IRenderedElement } from '../interfaces/i_rendered_element.js';
13
13
  import { IDraggable } from '../interfaces/i_draggable.js';
14
14
  import { ISelectable } from '../interfaces/i_selectable.js';
15
15
  import { IDeletable } from '../interfaces/i_deletable.js';
16
- export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement, IDraggable, ISelectable, IDeletable {
16
+ import { ICopyable } from '../interfaces/i_copyable.js';
17
+ import { WorkspaceCommentCopyData } from '../clipboard/workspace_comment_paster.js';
18
+ import { IContextMenu } from '../interfaces/i_contextmenu.js';
19
+ export declare class RenderedWorkspaceComment extends WorkspaceComment implements IBoundedElement, IRenderedElement, IDraggable, ISelectable, IDeletable, ICopyable<WorkspaceCommentCopyData>, IContextMenu {
17
20
  /** The class encompassing the svg elements making up the workspace comment. */
18
21
  private view;
19
22
  readonly workspace: WorkspaceSvg;
@@ -60,8 +63,6 @@ export declare class RenderedWorkspaceComment extends WorkspaceComment implement
60
63
  * (that wasn't otherwise gobbled up, e.g. by resizing).
61
64
  */
62
65
  private startGesture;
63
- /** Returns whether this comment is deletable or not. */
64
- isDeletable(): boolean;
65
66
  /** Visually indicates that this comment would be deleted if dropped. */
66
67
  setDeleteStyle(wouldDelete: boolean): void;
67
68
  /** Returns whether this comment is movable or not. */
@@ -78,5 +79,12 @@ export declare class RenderedWorkspaceComment extends WorkspaceComment implement
78
79
  select(): void;
79
80
  /** Visually unhighlights the comment. */
80
81
  unselect(): void;
82
+ /**
83
+ * Returns a JSON serializable representation of this comment's state that
84
+ * can be used for pasting.
85
+ */
86
+ toCopyData(): WorkspaceCommentCopyData | null;
87
+ /** Show a context menu for this comment. */
88
+ showContextMenu(e: PointerEvent): void;
81
89
  }
82
90
  //# sourceMappingURL=rendered_workspace_comment.d.ts.map
@@ -11,4 +11,9 @@ export declare const COLLAPSED_INPUT_NAME = "_TEMP_COLLAPSED_INPUT";
11
11
  * The language-neutral ID given to the collapsed field.
12
12
  */
13
13
  export declare const COLLAPSED_FIELD_NAME = "_TEMP_COLLAPSED_FIELD";
14
+ /**
15
+ * The language-neutral ID for when the reason why a block is disabled is
16
+ * because the user manually disabled it, such as via the context menu.
17
+ */
18
+ export declare const MANUALLY_DISABLED = "MANUALLY_DISABLED";
14
19
  //# sourceMappingURL=constants.d.ts.map
@@ -7,8 +7,6 @@ import type { Block } from './block.js';
7
7
  import type { BlockSvg } from './block_svg.js';
8
8
  import type { ContextMenuOption, LegacyContextMenuOption } from './contextmenu_registry.js';
9
9
  import * as serializationBlocks from './serialization/blocks.js';
10
- import { WorkspaceCommentSvg } from './workspace_comment_svg.js';
11
- import type { WorkspaceSvg } from './workspace_svg.js';
12
10
  /**
13
11
  * Gets the block the context menu is currently attached to.
14
12
  *
@@ -28,7 +26,7 @@ export declare function setCurrentBlock(block: Block | null): void;
28
26
  * @param options Array of menu options.
29
27
  * @param rtl True if RTL, false if LTR.
30
28
  */
31
- export declare function show(e: Event, options: (ContextMenuOption | LegacyContextMenuOption)[], rtl: boolean): void;
29
+ export declare function show(e: PointerEvent, options: (ContextMenuOption | LegacyContextMenuOption)[], rtl: boolean): void;
32
30
  /**
33
31
  * Hide the context menu.
34
32
  */
@@ -46,35 +44,4 @@ export declare function dispose(): void;
46
44
  * @returns Function that creates a block.
47
45
  */
48
46
  export declare function callbackFactory(block: Block, state: Element | serializationBlocks.State): () => BlockSvg;
49
- /**
50
- * Make a context menu option for deleting the current workspace comment.
51
- *
52
- * @param comment The workspace comment where the
53
- * right-click originated.
54
- * @returns A menu option,
55
- * containing text, enabled, and a callback.
56
- * @internal
57
- */
58
- export declare function commentDeleteOption(comment: WorkspaceCommentSvg): LegacyContextMenuOption;
59
- /**
60
- * Make a context menu option for duplicating the current workspace comment.
61
- *
62
- * @param comment The workspace comment where the
63
- * right-click originated.
64
- * @returns A menu option,
65
- * containing text, enabled, and a callback.
66
- * @internal
67
- */
68
- export declare function commentDuplicateOption(comment: WorkspaceCommentSvg): LegacyContextMenuOption;
69
- /**
70
- * Make a context menu option for adding a comment on the workspace.
71
- *
72
- * @param ws The workspace where the right-click
73
- * originated.
74
- * @param e The right-click mouse event.
75
- * @returns A menu option, containing text, enabled, and a callback.
76
- * comments are not bundled in.
77
- * @internal
78
- */
79
- export declare function workspaceCommentOption(ws: WorkspaceSvg, e: Event): ContextMenuOption;
80
47
  //# sourceMappingURL=contextmenu.d.ts.map
@@ -55,6 +55,14 @@ export declare function registerDelete(): void;
55
55
  * Option to open help for a block.
56
56
  */
57
57
  export declare function registerHelp(): void;
58
+ /** Registers an option for deleting a workspace comment. */
59
+ export declare function registerCommentDelete(): void;
60
+ /** Registers an option for duplicating a workspace comment. */
61
+ export declare function registerCommentDuplicate(): void;
62
+ /** Registers an option for adding a workspace comment to the workspace. */
63
+ export declare function registerCommentCreate(): void;
64
+ /** Registers all workspace comment related menu items. */
65
+ export declare function registerCommentOptions(): void;
58
66
  /**
59
67
  * Registers all default context menu items. This should be called once per
60
68
  * instance of ContextMenuRegistry.
@@ -9,6 +9,7 @@
9
9
  * @class
10
10
  */
11
11
  import type { BlockSvg } from './block_svg.js';
12
+ import { RenderedWorkspaceComment } from './comments/rendered_workspace_comment.js';
12
13
  import type { WorkspaceSvg } from './workspace_svg.js';
13
14
  /**
14
15
  * Class for the registry of context menu items. This is intended to be a
@@ -63,7 +64,8 @@ export declare namespace ContextMenuRegistry {
63
64
  */
64
65
  enum ScopeType {
65
66
  BLOCK = "block",
66
- WORKSPACE = "workspace"
67
+ WORKSPACE = "workspace",
68
+ COMMENT = "comment"
67
69
  }
68
70
  /**
69
71
  * The actual workspace/block where the menu is being rendered. This is passed
@@ -72,12 +74,19 @@ export declare namespace ContextMenuRegistry {
72
74
  interface Scope {
73
75
  block?: BlockSvg;
74
76
  workspace?: WorkspaceSvg;
77
+ comment?: RenderedWorkspaceComment;
75
78
  }
76
79
  /**
77
80
  * A menu item as entered in the registry.
78
81
  */
79
82
  interface RegistryItem {
80
- callback: (p1: Scope) => void;
83
+ /**
84
+ * @param scope Object that provides a reference to the thing that had its
85
+ * context menu opened.
86
+ * @param e The original event that triggered the context menu to open. Not
87
+ * the event that triggered the click on the option.
88
+ */
89
+ callback: (scope: Scope, e: PointerEvent) => void;
81
90
  scopeType: ScopeType;
82
91
  displayText: ((p1: Scope) => string | HTMLElement) | string | HTMLElement;
83
92
  preconditionFn: (p1: Scope) => string;
@@ -90,7 +99,13 @@ export declare namespace ContextMenuRegistry {
90
99
  interface ContextMenuOption {
91
100
  text: string | HTMLElement;
92
101
  enabled: boolean;
93
- callback: (p1: Scope) => void;
102
+ /**
103
+ * @param scope Object that provides a reference to the thing that had its
104
+ * context menu opened.
105
+ * @param e The original event that triggered the context menu to open. Not
106
+ * the event that triggered the click on the option.
107
+ */
108
+ callback: (scope: Scope, e: PointerEvent) => void;
94
109
  scope: Scope;
95
110
  weight: number;
96
111
  }
@@ -15,6 +15,7 @@ export declare class CommentDragStrategy implements IDragStrategy {
15
15
  startDrag(): void;
16
16
  drag(newLoc: Coordinate): void;
17
17
  endDrag(): void;
18
+ private fireMoveEvent;
18
19
  revertDrag(): void;
19
20
  }
20
21
  //# sourceMappingURL=comment_drag_strategy.d.ts.map
@@ -29,6 +29,11 @@ export declare class BlockChange extends BlockBase {
29
29
  oldValue: unknown;
30
30
  /** The new value of the element. */
31
31
  newValue: unknown;
32
+ /**
33
+ * If element is 'disabled', this is the language-neutral identifier of the
34
+ * reason why the block was or was not disabled.
35
+ */
36
+ private disabledReason?;
32
37
  /**
33
38
  * @param opt_block The changed block. Undefined for a blank event.
34
39
  * @param opt_element One of 'field', 'comment', 'disabled', etc.
@@ -53,6 +58,15 @@ export declare class BlockChange extends BlockBase {
53
58
  * @internal
54
59
  */
55
60
  static fromJson(json: BlockChangeJson, workspace: Workspace, event?: any): BlockChange;
61
+ /**
62
+ * Set the language-neutral identifier for the reason why the block was or was
63
+ * not disabled. This is only valid for events where element is 'disabled'.
64
+ * Defaults to 'MANUALLY_DISABLED'.
65
+ *
66
+ * @param disabledReason The identifier of the reason why the block was or was
67
+ * not disabled.
68
+ */
69
+ setDisabledReason(disabledReason: string): void;
56
70
  /**
57
71
  * Does this event record any change of state?
58
72
  *
@@ -80,5 +94,6 @@ export interface BlockChangeJson extends BlockBaseJson {
80
94
  name?: string;
81
95
  newValue: unknown;
82
96
  oldValue: unknown;
97
+ disabledReason?: string;
83
98
  }
84
99
  //# sourceMappingURL=events_block_change.d.ts.map
@@ -231,10 +231,8 @@ export declare function fromJson(json: any, workspace: Workspace): Abstract;
231
231
  */
232
232
  export declare function get(eventType: string): new (...p1: any[]) => Abstract;
233
233
  /**
234
- * Enable/disable a block depending on whether it is properly connected.
234
+ * Set if a block is disabled depending on whether it is properly connected.
235
235
  * Use this on applications where all blocks should be connected to a top block.
236
- * Recommend setting the 'disable' option to 'false' in the config so that
237
- * users don't try to re-enable disabled orphan blocks.
238
236
  *
239
237
  * @param event Custom data for event.
240
238
  */
@@ -27,6 +27,7 @@ export interface State {
27
27
  movable?: boolean;
28
28
  editable?: boolean;
29
29
  enabled?: boolean;
30
+ disabledReasons?: string[];
30
31
  inline?: boolean;
31
32
  data?: string;
32
33
  extraState?: any;
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { ISerializer } from '../interfaces/i_serializer.js';
7
7
  import { Workspace } from '../workspace.js';
8
- import { WorkspaceComment } from '../comments/workspace_comment.js';
8
+ import type { WorkspaceComment } from '../comments/workspace_comment.js';
9
9
  export interface State {
10
10
  id?: string;
11
11
  text?: string;
@@ -16,6 +16,7 @@ export interface BlockInfo {
16
16
  type?: string;
17
17
  gap?: string | number;
18
18
  disabled?: string | boolean;
19
+ disabledReasons?: string[];
19
20
  enabled?: boolean;
20
21
  id?: string;
21
22
  x?: number;
@@ -18,7 +18,7 @@ import { Options } from './options.js';
18
18
  import type * as toolbox from './utils/toolbox.js';
19
19
  import { VariableMap } from './variable_map.js';
20
20
  import type { VariableModel } from './variable_model.js';
21
- import type { WorkspaceComment } from './workspace_comment.js';
21
+ import { WorkspaceComment } from './comments/workspace_comment.js';
22
22
  import { IProcedureMap } from './interfaces/i_procedure_map.js';
23
23
  /**
24
24
  * Class for a workspace. This is a data structure that contains blocks.
@@ -279,6 +279,14 @@ export declare class Workspace implements IASTNodeLocation {
279
279
  * @returns The created block.
280
280
  */
281
281
  newBlock(prototypeName: string, opt_id?: string): Block;
282
+ /**
283
+ * Obtain a newly created comment.
284
+ *
285
+ * @param id Optional ID. Use this ID if provided, otherwise create a new
286
+ * ID.
287
+ * @returns The created comment.
288
+ */
289
+ newComment(id?: string): WorkspaceComment;
282
290
  /**
283
291
  * The number of blocks that may be added to the workspace before reaching
284
292
  * the maxBlocks.
@@ -42,7 +42,7 @@ import * as toolbox from './utils/toolbox.js';
42
42
  import type { VariableModel } from './variable_model.js';
43
43
  import { Workspace } from './workspace.js';
44
44
  import { WorkspaceAudio } from './workspace_audio.js';
45
- import { WorkspaceComment } from './workspace_comment.js';
45
+ import { WorkspaceComment } from './comments/workspace_comment.js';
46
46
  import { ZoomControls } from './zoom_controls.js';
47
47
  import { ContextMenuOption } from './contextmenu_registry.js';
48
48
  import { LayerManager } from './layer_manager.js';
@@ -618,6 +618,14 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
618
618
  * @returns The created block.
619
619
  */
620
620
  newBlock(prototypeName: string, opt_id?: string): BlockSvg;
621
+ /**
622
+ * Obtain a newly created comment.
623
+ *
624
+ * @param id Optional ID. Use this ID if provided, otherwise create a new
625
+ * ID.
626
+ * @returns The created comment.
627
+ */
628
+ newComment(id?: string): WorkspaceComment;
621
629
  /**
622
630
  * Returns the drag target the pointer event is over.
623
631
  *
@@ -704,7 +712,7 @@ export declare class WorkspaceSvg extends Workspace implements IASTNodeLocationS
704
712
  * @param e Mouse event.
705
713
  * @internal
706
714
  */
707
- showContextMenu(e: Event): void;
715
+ showContextMenu(e: PointerEvent): void;
708
716
  /**
709
717
  * Modify the block tree on the existing toolbox.
710
718
  *
package/msg/ab.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://ru.wikipedia.org/wiki/Ацхыраагӡатә программа";
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "аҟынтәи:";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Иаԥҵатәуп ааԥхьара '%1'";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Абри афункциа ахҳәа азыҟашәҵа...";
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/ace.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "with:"; // untranslated
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Create '%1'"; // untranslated
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/af.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "with:"; // untranslated
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Create '%1'"; // untranslated
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/am.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "with:"; // untranslated
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Create '%1'"; // untranslated
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/ar.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "تشغيل الدالة الم
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://ar.wikipedia.org/wiki/دالة_(برمجة)";
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "تشغيل الدالة المعرفة من قبل المستخدم %1 واستخدام مخرجاتها.";
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "مع:";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "إنشئ '%1'";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "صف هذه الوظيفة...";
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/ast.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "with:"; // untranslated
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Create '%1'"; // untranslated
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/az.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Yaradılmış '%1' funksiyası
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Yaradılmış '%1' funksiyasını çalışdır və nəticəni istifadə et.";
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "ilə:";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "'%1' yarat";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Bu funksiyanı təsvir et";
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/ba.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "with:"; // untranslated
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "'%1' төҙөргә";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/bcc.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "اجرای تابع تعریف
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "اجرای تابع تعریف‌شده توسط کاربر «%1» و استفاده از خروجی آن.";
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "با:";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "ساختن «%1»";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/be-tarask.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Запусьціць функ
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Запусьціць функцыю вызначаную карыстальнікам '%1' і выкарыстаць яе вынік.";
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "з:";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Стварыць '%1'";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Апішыце гэтую функцыю…";
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/be.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Выконвае вызнач
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://be.wikipedia.org/wiki/Падпраграма";
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Выконвае вызначаную карыстальнікам функцыю '%1' і ўжыць яе значэнне.";
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "з:";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Стварыць выклік '%1'";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Апішыце гэтую функцыю...";
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/bg.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Изпълни дефинир
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://bg.wikipedia.org/wiki/Подпрограма";
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Изпълни дефинирана от потребителя функция „%1“ и използвай резултата.";
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "с:";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Създай '%1'";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Опишете тази функция...";
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/bn.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "with:"; // untranslated
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Create '%1'"; // untranslated
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/br.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Seveniñ an arc'hwel '%1' term
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Seveniñ an arc'hwel '%1' termenet gant an implijer hag implijout e zisoc'h.";
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "gant :";
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Krouiñ '%1'";
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Deskrivañ an arc'hwel-mañ...";
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated
package/msg/bs.js CHANGED
@@ -300,6 +300,7 @@ Blockly.Msg["PROCEDURES_CALLNORETURN_TOOLTIP"] = "Run the user-defined function
300
300
  Blockly.Msg["PROCEDURES_CALLRETURN_HELPURL"] = "https://en.wikipedia.org/wiki/Subroutine"; // untranslated
301
301
  Blockly.Msg["PROCEDURES_CALLRETURN_TOOLTIP"] = "Run the user-defined function '%1' and use its output."; // untranslated
302
302
  Blockly.Msg["PROCEDURES_CALL_BEFORE_PARAMS"] = "with:"; // untranslated
303
+ Blockly.Msg["PROCEDURES_CALL_DISABLED_DEF_WARNING"] = "Can't run the user-defined function '%1' because the definition block is disabled."; // untranslated
303
304
  Blockly.Msg["PROCEDURES_CREATE_DO"] = "Create '%1'"; // untranslated
304
305
  Blockly.Msg["PROCEDURES_DEFNORETURN_COMMENT"] = "Describe this function..."; // untranslated
305
306
  Blockly.Msg["PROCEDURES_DEFNORETURN_DO"] = ""; // untranslated