scratch-blocks 2.0.2 → 2.0.3

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 (274) hide show
  1. package/commitlint.config.js +2 -2
  2. package/dist/main.mjs +1 -2
  3. package/dist/types/msg/scratch_msgs.d.ts.map +1 -1
  4. package/dist/types/src/block_reporting.d.ts.map +1 -1
  5. package/dist/types/src/blocks/colour.d.ts +0 -19
  6. package/dist/types/src/blocks/colour.d.ts.map +1 -1
  7. package/dist/types/src/blocks/control.d.ts +0 -19
  8. package/dist/types/src/blocks/control.d.ts.map +1 -1
  9. package/dist/types/src/blocks/data.d.ts +0 -19
  10. package/dist/types/src/blocks/data.d.ts.map +1 -1
  11. package/dist/types/src/blocks/event.d.ts +0 -19
  12. package/dist/types/src/blocks/event.d.ts.map +1 -1
  13. package/dist/types/src/blocks/looks.d.ts +0 -19
  14. package/dist/types/src/blocks/looks.d.ts.map +1 -1
  15. package/dist/types/src/blocks/math.d.ts +0 -19
  16. package/dist/types/src/blocks/math.d.ts.map +1 -1
  17. package/dist/types/src/blocks/matrix.d.ts +0 -19
  18. package/dist/types/src/blocks/matrix.d.ts.map +1 -1
  19. package/dist/types/src/blocks/motion.d.ts +0 -19
  20. package/dist/types/src/blocks/motion.d.ts.map +1 -1
  21. package/dist/types/src/blocks/note.d.ts +0 -19
  22. package/dist/types/src/blocks/note.d.ts.map +1 -1
  23. package/dist/types/src/blocks/operators.d.ts +0 -19
  24. package/dist/types/src/blocks/operators.d.ts.map +1 -1
  25. package/dist/types/src/blocks/procedures.d.ts +6 -9
  26. package/dist/types/src/blocks/procedures.d.ts.map +1 -1
  27. package/dist/types/src/blocks/sensing.d.ts +0 -19
  28. package/dist/types/src/blocks/sensing.d.ts.map +1 -1
  29. package/dist/types/src/blocks/sound.d.ts +0 -19
  30. package/dist/types/src/blocks/sound.d.ts.map +1 -1
  31. package/dist/types/src/blocks/text.d.ts +0 -19
  32. package/dist/types/src/blocks/text.d.ts.map +1 -1
  33. package/dist/types/src/blocks/vertical_extensions.d.ts +0 -19
  34. package/dist/types/src/blocks/vertical_extensions.d.ts.map +1 -1
  35. package/dist/types/src/checkable_continuous_flyout.d.ts +2 -7
  36. package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
  37. package/dist/types/src/checkbox_bubble.d.ts +13 -12
  38. package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
  39. package/dist/types/src/colours.d.ts.map +1 -1
  40. package/dist/types/src/constants.d.ts +0 -7
  41. package/dist/types/src/constants.d.ts.map +1 -1
  42. package/dist/types/src/context_menu_items.d.ts +0 -5
  43. package/dist/types/src/context_menu_items.d.ts.map +1 -1
  44. package/dist/types/src/data_category.d.ts +2 -4
  45. package/dist/types/src/data_category.d.ts.map +1 -1
  46. package/dist/types/src/events/events_block_comment_base.d.ts +2 -3
  47. package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
  48. package/dist/types/src/events/events_block_comment_change.d.ts +0 -5
  49. package/dist/types/src/events/events_block_comment_change.d.ts.map +1 -1
  50. package/dist/types/src/events/events_block_comment_collapse.d.ts +0 -5
  51. package/dist/types/src/events/events_block_comment_collapse.d.ts.map +1 -1
  52. package/dist/types/src/events/events_block_comment_create.d.ts +0 -5
  53. package/dist/types/src/events/events_block_comment_create.d.ts.map +1 -1
  54. package/dist/types/src/events/events_block_comment_delete.d.ts +0 -5
  55. package/dist/types/src/events/events_block_comment_delete.d.ts.map +1 -1
  56. package/dist/types/src/events/events_block_comment_move.d.ts +0 -5
  57. package/dist/types/src/events/events_block_comment_move.d.ts.map +1 -1
  58. package/dist/types/src/events/events_block_comment_resize.d.ts +0 -5
  59. package/dist/types/src/events/events_block_comment_resize.d.ts.map +1 -1
  60. package/dist/types/src/events/events_block_drag_end.d.ts +1 -2
  61. package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
  62. package/dist/types/src/events/events_block_drag_outside.d.ts +1 -2
  63. package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
  64. package/dist/types/src/events/events_scratch_variable_create.d.ts +0 -5
  65. package/dist/types/src/events/events_scratch_variable_create.d.ts.map +1 -1
  66. package/dist/types/src/fields/field_colour_slider.d.ts +3 -27
  67. package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
  68. package/dist/types/src/fields/field_matrix.d.ts +0 -19
  69. package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
  70. package/dist/types/src/fields/field_note.d.ts +8 -23
  71. package/dist/types/src/fields/field_note.d.ts.map +1 -1
  72. package/dist/types/src/fields/field_textinput_removable.d.ts +2 -4
  73. package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
  74. package/dist/types/src/fields/field_variable_getter.d.ts +0 -19
  75. package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
  76. package/dist/types/src/fields/field_vertical_separator.d.ts +0 -19
  77. package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
  78. package/dist/types/src/fields/scratch_field_angle.d.ts +0 -19
  79. package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
  80. package/dist/types/src/fields/scratch_field_dropdown.d.ts +0 -5
  81. package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
  82. package/dist/types/src/fields/scratch_field_number.d.ts +0 -19
  83. package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
  84. package/dist/types/src/fields/scratch_field_variable.d.ts +4 -7
  85. package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
  86. package/dist/types/src/flyout_checkbox_icon.d.ts +2 -3
  87. package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
  88. package/dist/types/src/glows.d.ts +1 -3
  89. package/dist/types/src/glows.d.ts.map +1 -1
  90. package/dist/types/src/index.d.ts +50 -51
  91. package/dist/types/src/index.d.ts.map +1 -1
  92. package/dist/types/src/procedures.d.ts +6 -8
  93. package/dist/types/src/procedures.d.ts.map +1 -1
  94. package/dist/types/src/recyclable_block_flyout_inflater.d.ts +3 -5
  95. package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
  96. package/dist/types/src/renderer/bowler_hat.d.ts +2 -3
  97. package/dist/types/src/renderer/bowler_hat.d.ts.map +1 -1
  98. package/dist/types/src/renderer/cat/cat_face.d.ts +6 -5
  99. package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
  100. package/dist/types/src/renderer/cat/constants.d.ts +2 -2
  101. package/dist/types/src/renderer/cat/constants.d.ts.map +1 -1
  102. package/dist/types/src/renderer/cat/drawer.d.ts +3 -4
  103. package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
  104. package/dist/types/src/renderer/cat/path_object.d.ts +2 -3
  105. package/dist/types/src/renderer/cat/path_object.d.ts.map +1 -1
  106. package/dist/types/src/renderer/cat/render_info.d.ts +3 -4
  107. package/dist/types/src/renderer/cat/render_info.d.ts.map +1 -1
  108. package/dist/types/src/renderer/cat/renderer.d.ts +6 -7
  109. package/dist/types/src/renderer/cat/renderer.d.ts.map +1 -1
  110. package/dist/types/src/renderer/constants.d.ts +4 -4
  111. package/dist/types/src/renderer/constants.d.ts.map +1 -1
  112. package/dist/types/src/renderer/drawer.d.ts +5 -4
  113. package/dist/types/src/renderer/drawer.d.ts.map +1 -1
  114. package/dist/types/src/renderer/path_object.d.ts +1 -3
  115. package/dist/types/src/renderer/path_object.d.ts.map +1 -1
  116. package/dist/types/src/renderer/render_info.d.ts +3 -4
  117. package/dist/types/src/renderer/render_info.d.ts.map +1 -1
  118. package/dist/types/src/renderer/renderer.d.ts +8 -15
  119. package/dist/types/src/renderer/renderer.d.ts.map +1 -1
  120. package/dist/types/src/scratch_block_paster.d.ts +0 -5
  121. package/dist/types/src/scratch_block_paster.d.ts.map +1 -1
  122. package/dist/types/src/scratch_blocks_utils.d.ts +0 -20
  123. package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
  124. package/dist/types/src/scratch_comment_bubble.d.ts +1 -4
  125. package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
  126. package/dist/types/src/scratch_comment_icon.d.ts +2 -3
  127. package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
  128. package/dist/types/src/scratch_connection_checker.d.ts +0 -5
  129. package/dist/types/src/scratch_connection_checker.d.ts.map +1 -1
  130. package/dist/types/src/scratch_continuous_category.d.ts +5 -5
  131. package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
  132. package/dist/types/src/scratch_continuous_toolbox.d.ts +3 -6
  133. package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
  134. package/dist/types/src/scratch_dragger.d.ts +1 -10
  135. package/dist/types/src/scratch_dragger.d.ts.map +1 -1
  136. package/dist/types/src/scratch_insertion_marker_previewer.d.ts +0 -5
  137. package/dist/types/src/scratch_insertion_marker_previewer.d.ts.map +1 -1
  138. package/dist/types/src/scratch_variable_map.d.ts +0 -5
  139. package/dist/types/src/scratch_variable_map.d.ts.map +1 -1
  140. package/dist/types/src/scratch_variable_model.d.ts +1 -2
  141. package/dist/types/src/scratch_variable_model.d.ts.map +1 -1
  142. package/dist/types/src/scratch_zoom_controls.d.ts +4 -6
  143. package/dist/types/src/scratch_zoom_controls.d.ts.map +1 -1
  144. package/dist/types/src/shadows.d.ts +2 -2
  145. package/dist/types/src/shadows.d.ts.map +1 -1
  146. package/dist/types/src/status_indicator_label.d.ts +4 -6
  147. package/dist/types/src/status_indicator_label.d.ts.map +1 -1
  148. package/dist/types/src/status_indicator_label_flyout_inflater.d.ts +1 -6
  149. package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
  150. package/dist/types/src/variables.d.ts +4 -8
  151. package/dist/types/src/variables.d.ts.map +1 -1
  152. package/dist/types/src/xml.d.ts +2 -3
  153. package/dist/types/src/xml.d.ts.map +1 -1
  154. package/dist/types/tests/jsunit/block_test.d.ts.map +1 -1
  155. package/dist/types/tests/jsunit/connection_db_test.d.ts.map +1 -1
  156. package/dist/types/tests/jsunit/connection_test.d.ts.map +1 -1
  157. package/dist/types/tests/jsunit/event_test.d.ts.map +1 -1
  158. package/dist/types/tests/jsunit/extensions_test.d.ts.map +1 -1
  159. package/dist/types/tests/jsunit/field_number_test.d.ts.map +1 -1
  160. package/dist/types/tests/jsunit/field_test.d.ts.map +1 -1
  161. package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +1 -1
  162. package/dist/types/tests/jsunit/field_variable_test.d.ts.map +1 -1
  163. package/dist/types/tests/jsunit/gesture_test.d.ts.map +1 -1
  164. package/dist/types/tests/jsunit/input_test.d.ts +1 -0
  165. package/dist/types/tests/jsunit/input_test.d.ts.map +1 -1
  166. package/dist/types/tests/jsunit/json_test.d.ts.map +1 -1
  167. package/dist/types/tests/jsunit/names_test.d.ts.map +1 -1
  168. package/dist/types/tests/jsunit/procedure_test.d.ts.map +1 -1
  169. package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +1 -1
  170. package/dist/types/tests/jsunit/svg_test.d.ts.map +1 -1
  171. package/dist/types/tests/jsunit/test_utilities.d.ts.map +1 -1
  172. package/dist/types/tests/jsunit/utils_test.d.ts.map +1 -1
  173. package/dist/types/tests/jsunit/variable_map_test.d.ts.map +1 -1
  174. package/dist/types/tests/jsunit/variable_model_test.d.ts.map +1 -1
  175. package/dist/types/tests/jsunit/widget_div_test.d.ts.map +1 -1
  176. package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +1 -1
  177. package/dist/types/tests/jsunit/workspace_test.d.ts.map +1 -1
  178. package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +1 -1
  179. package/dist/types/tests/jsunit/xml_test.d.ts.map +1 -1
  180. package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +1 -1
  181. package/eslint.config.mjs +69 -0
  182. package/i18n/create_scratch_msgs.js +44 -45
  183. package/i18n/js_to_json.js +40 -32
  184. package/i18n/json_to_js.js +37 -37
  185. package/i18n/sync_tx_translations.js +64 -65
  186. package/i18n/test_scratch_msgs.js +66 -63
  187. package/msg/js/en.js +289 -287
  188. package/msg/json/en.json +284 -284
  189. package/msg/messages.js +289 -287
  190. package/msg/scratch_msgs.js +22959 -22970
  191. package/package.json +6 -3
  192. package/prettier.config.mjs +3 -0
  193. package/release.config.js +7 -7
  194. package/renovate.json5 +7 -9
  195. package/src/block_reporting.ts +15 -18
  196. package/src/blocks/colour.ts +12 -15
  197. package/src/blocks/control.ts +167 -177
  198. package/src/blocks/data.ts +225 -292
  199. package/src/blocks/event.ts +121 -123
  200. package/src/blocks/looks.ts +165 -167
  201. package/src/blocks/math.ts +44 -46
  202. package/src/blocks/matrix.ts +11 -13
  203. package/src/blocks/motion.ts +151 -153
  204. package/src/blocks/note.ts +11 -13
  205. package/src/blocks/operators.ts +158 -160
  206. package/src/blocks/procedures.ts +415 -523
  207. package/src/blocks/sensing.ts +163 -165
  208. package/src/blocks/sound.ts +58 -60
  209. package/src/blocks/text.ts +10 -12
  210. package/src/blocks/vertical_extensions.ts +86 -102
  211. package/src/checkable_continuous_flyout.ts +25 -42
  212. package/src/checkbox_bubble.ts +83 -100
  213. package/src/colours.ts +35 -37
  214. package/src/constants.ts +22 -29
  215. package/src/context_menu_items.ts +56 -81
  216. package/src/css.ts +3 -4
  217. package/src/data_category.ts +137 -251
  218. package/src/events/events_block_comment_base.ts +21 -31
  219. package/src/events/events_block_comment_change.ts +21 -42
  220. package/src/events/events_block_comment_collapse.ts +22 -43
  221. package/src/events/events_block_comment_create.ts +29 -46
  222. package/src/events/events_block_comment_delete.ts +10 -19
  223. package/src/events/events_block_comment_move.ts +27 -52
  224. package/src/events/events_block_comment_resize.ts +28 -55
  225. package/src/events/events_block_drag_end.ts +16 -26
  226. package/src/events/events_block_drag_outside.ts +12 -22
  227. package/src/events/events_scratch_variable_create.ts +33 -56
  228. package/src/fields/field_colour_slider.ts +173 -228
  229. package/src/fields/field_matrix.ts +200 -269
  230. package/src/fields/field_note.ts +272 -377
  231. package/src/fields/field_textinput_removable.ts +25 -40
  232. package/src/fields/field_variable_getter.ts +26 -31
  233. package/src/fields/field_vertical_separator.ts +19 -24
  234. package/src/fields/scratch_field_angle.ts +150 -186
  235. package/src/fields/scratch_field_dropdown.ts +15 -19
  236. package/src/fields/scratch_field_number.ts +123 -180
  237. package/src/fields/scratch_field_variable.ts +54 -75
  238. package/src/flyout_checkbox_icon.ts +18 -28
  239. package/src/glows.ts +51 -58
  240. package/src/index.ts +119 -133
  241. package/src/procedures.ts +146 -213
  242. package/src/recyclable_block_flyout_inflater.ts +14 -25
  243. package/src/renderer/bowler_hat.ts +6 -8
  244. package/src/renderer/cat/cat_face.ts +98 -99
  245. package/src/renderer/cat/constants.ts +67 -87
  246. package/src/renderer/cat/drawer.ts +21 -27
  247. package/src/renderer/cat/path_object.ts +3 -5
  248. package/src/renderer/cat/render_info.ts +5 -8
  249. package/src/renderer/cat/renderer.ts +11 -15
  250. package/src/renderer/constants.ts +34 -49
  251. package/src/renderer/drawer.ts +35 -51
  252. package/src/renderer/path_object.ts +4 -10
  253. package/src/renderer/render_info.ts +36 -56
  254. package/src/renderer/renderer.ts +16 -29
  255. package/src/scratch_block_paster.ts +12 -20
  256. package/src/scratch_blocks_utils.ts +4 -7
  257. package/src/scratch_comment_bubble.ts +70 -101
  258. package/src/scratch_comment_icon.ts +74 -123
  259. package/src/scratch_connection_checker.ts +7 -17
  260. package/src/scratch_continuous_category.ts +24 -28
  261. package/src/scratch_continuous_toolbox.ts +20 -27
  262. package/src/scratch_dragger.ts +42 -81
  263. package/src/scratch_insertion_marker_previewer.ts +6 -11
  264. package/src/scratch_variable_map.ts +5 -12
  265. package/src/scratch_variable_model.ts +4 -11
  266. package/src/scratch_zoom_controls.ts +101 -156
  267. package/src/shadows.ts +32 -37
  268. package/src/status_indicator_label.ts +54 -67
  269. package/src/status_indicator_label_flyout_inflater.ts +11 -21
  270. package/src/variables.ts +89 -138
  271. package/src/xml.ts +21 -35
  272. package/tsconfig.json +2 -6
  273. package/types/continuous-toolbox.d.ts +1 -1
  274. package/dist/main.mjs.LICENSE.txt +0 -163
@@ -1,29 +1,27 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import type { ScratchCommentBubble } from "../scratch_comment_bubble";
5
+ import * as Blockly from 'blockly/core'
6
+ import type { ScratchCommentBubble } from '../scratch_comment_bubble'
9
7
 
10
8
  export class BlockCommentBase extends Blockly.Events.Abstract {
11
- isBlank = true;
12
- commentId!: string;
13
- blockId!: string;
14
- workspaceId!: string;
9
+ isBlank = true
10
+ commentId!: string
11
+ blockId!: string
12
+ workspaceId!: string
15
13
 
16
14
  constructor(opt_blockComment?: ScratchCommentBubble) {
17
- super();
18
- this.isBlank = !opt_blockComment;
15
+ super()
16
+ this.isBlank = !opt_blockComment
19
17
 
20
- if (!opt_blockComment) return;
18
+ if (!opt_blockComment) return
21
19
 
22
- this.commentId = opt_blockComment.getId();
23
- const sourceBlock = opt_blockComment.getSourceBlock();
20
+ this.commentId = opt_blockComment.getId()
21
+ const sourceBlock = opt_blockComment.getSourceBlock()
24
22
  if (sourceBlock) {
25
- this.blockId = sourceBlock.id;
26
- this.workspaceId = sourceBlock.workspace.id;
23
+ this.blockId = sourceBlock.id
24
+ this.workspaceId = sourceBlock.workspace.id
27
25
  }
28
26
  }
29
27
 
@@ -32,26 +30,18 @@ export class BlockCommentBase extends Blockly.Events.Abstract {
32
30
  ...super.toJson(),
33
31
  commentId: this.commentId,
34
32
  blockId: this.blockId,
35
- };
33
+ }
36
34
  }
37
35
 
38
- static fromJson(
39
- json: BlockCommentBaseJson,
40
- workspace: Blockly.Workspace,
41
- event?: any
42
- ): BlockCommentBase {
43
- const newEvent = super.fromJson(
44
- json,
45
- workspace,
46
- event ?? new BlockCommentBase()
47
- ) as BlockCommentBase;
48
- newEvent.commentId = json["commentId"];
49
- newEvent.blockId = json["blockId"];
50
- return newEvent;
36
+ static fromJson(json: BlockCommentBaseJson, workspace: Blockly.Workspace, event?: any): BlockCommentBase {
37
+ const newEvent = super.fromJson(json, workspace, event ?? new BlockCommentBase()) as BlockCommentBase
38
+ newEvent.commentId = json.commentId
39
+ newEvent.blockId = json.blockId
40
+ return newEvent
51
41
  }
52
42
  }
53
43
 
54
44
  export interface BlockCommentBaseJson extends Blockly.Events.AbstractEventJson {
55
- commentId: string;
56
- blockId: string;
45
+ commentId: string
46
+ blockId: string
57
47
  }
@@ -1,33 +1,24 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import {
9
- BlockCommentBase,
10
- BlockCommentBaseJson,
11
- } from "./events_block_comment_base";
12
- import type { ScratchCommentBubble } from "../scratch_comment_bubble";
5
+ import * as Blockly from 'blockly/core'
6
+ import type { ScratchCommentBubble } from '../scratch_comment_bubble'
7
+ import { BlockCommentBase, BlockCommentBaseJson } from './events_block_comment_base'
13
8
 
14
9
  class BlockCommentChange extends BlockCommentBase {
15
- oldContents_!: string;
16
- newContents_!: string;
17
-
18
- constructor(
19
- opt_blockComment?: ScratchCommentBubble,
20
- oldContents?: string,
21
- newContents?: string
22
- ) {
23
- super(opt_blockComment);
24
- this.type = "block_comment_change";
25
- if (oldContents !== undefined) this.oldContents_ = oldContents;
26
- if (newContents !== undefined) this.newContents_ = newContents;
10
+ oldContents_!: string
11
+ newContents_!: string
12
+
13
+ constructor(opt_blockComment?: ScratchCommentBubble, oldContents?: string, newContents?: string) {
14
+ super(opt_blockComment)
15
+ this.type = 'block_comment_change'
16
+ if (oldContents !== undefined) this.oldContents_ = oldContents
17
+ if (newContents !== undefined) this.newContents_ = newContents
27
18
  // Disable undo because Blockly already tracks changes to comment text for
28
19
  // undo purposes; this event exists solely to keep the Scratch VM apprised
29
20
  // of the state of things.
30
- this.recordUndo = false;
21
+ this.recordUndo = false
31
22
  }
32
23
 
33
24
  toJson(): BlockCommentChangeJson {
@@ -35,33 +26,21 @@ class BlockCommentChange extends BlockCommentBase {
35
26
  ...super.toJson(),
36
27
  newContents: this.newContents_,
37
28
  oldContents: this.oldContents_,
38
- };
29
+ }
39
30
  }
40
31
 
41
- static fromJson(
42
- json: BlockCommentChangeJson,
43
- workspace: Blockly.Workspace,
44
- event?: any
45
- ): BlockCommentChange {
46
- const newEvent = super.fromJson(
47
- json,
48
- workspace,
49
- event ?? new BlockCommentChange()
50
- ) as BlockCommentChange;
51
- newEvent.newContents_ = json["newContents"];
52
- newEvent.oldContents_ = json["oldContents"];
32
+ static fromJson(json: BlockCommentChangeJson, workspace: Blockly.Workspace, event?: any): BlockCommentChange {
33
+ const newEvent = super.fromJson(json, workspace, event ?? new BlockCommentChange()) as BlockCommentChange
34
+ newEvent.newContents_ = json.newContents
35
+ newEvent.oldContents_ = json.oldContents
53
36
 
54
- return newEvent;
37
+ return newEvent
55
38
  }
56
39
  }
57
40
 
58
41
  interface BlockCommentChangeJson extends BlockCommentBaseJson {
59
- newContents: string;
60
- oldContents: string;
42
+ newContents: string
43
+ oldContents: string
61
44
  }
62
45
 
63
- Blockly.registry.register(
64
- Blockly.registry.Type.EVENT,
65
- "block_comment_change",
66
- BlockCommentChange
67
- );
46
+ Blockly.registry.register(Blockly.registry.Type.EVENT, 'block_comment_change', BlockCommentChange)
@@ -1,73 +1,52 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import {
9
- BlockCommentBase,
10
- BlockCommentBaseJson,
11
- } from "./events_block_comment_base";
12
- import type { ScratchCommentBubble } from "../scratch_comment_bubble";
5
+ import * as Blockly from 'blockly/core'
6
+ import type { ScratchCommentBubble } from '../scratch_comment_bubble'
7
+ import { BlockCommentBase, BlockCommentBaseJson } from './events_block_comment_base'
13
8
 
14
9
  class BlockCommentCollapse extends BlockCommentBase {
15
- newCollapsed!: boolean;
10
+ newCollapsed!: boolean
16
11
 
17
12
  constructor(opt_blockComment?: ScratchCommentBubble, collapsed?: boolean) {
18
- super(opt_blockComment);
19
- this.type = "block_comment_collapse";
20
- if (collapsed !== undefined) this.newCollapsed = collapsed;
13
+ super(opt_blockComment)
14
+ this.type = 'block_comment_collapse'
15
+ if (collapsed !== undefined) this.newCollapsed = collapsed
21
16
  }
22
17
 
23
18
  toJson(): BlockCommentCollapseJson {
24
19
  return {
25
20
  ...super.toJson(),
26
21
  collapsed: this.newCollapsed,
27
- };
22
+ }
28
23
  }
29
24
 
30
- static fromJson(
31
- json: BlockCommentCollapseJson,
32
- workspace: Blockly.Workspace,
33
- event?: any
34
- ): BlockCommentCollapse {
35
- const newEvent = super.fromJson(
36
- json,
37
- workspace,
38
- event ?? new BlockCommentCollapse()
39
- ) as BlockCommentCollapse;
40
- newEvent.newCollapsed = json["collapsed"];
25
+ static fromJson(json: BlockCommentCollapseJson, workspace: Blockly.Workspace, event?: any): BlockCommentCollapse {
26
+ const newEvent = super.fromJson(json, workspace, event ?? new BlockCommentCollapse()) as BlockCommentCollapse
27
+ newEvent.newCollapsed = json.collapsed
41
28
 
42
- return newEvent;
29
+ return newEvent
43
30
  }
44
31
 
45
32
  run(forward: boolean) {
46
- const workspace = this.getEventWorkspace_();
47
- const block = workspace.getBlockById(this.blockId);
33
+ const workspace = this.getEventWorkspace_()
34
+ const block = workspace.getBlockById(this.blockId)
48
35
  if (!block) {
49
- console.warn(
50
- "BlockCommentCollapse.run: block not found",
51
- this.blockId,
52
- this.workspaceId
53
- );
54
- return;
36
+ console.warn('BlockCommentCollapse.run: block not found', this.blockId, this.workspaceId)
37
+ return
55
38
  }
56
- const comment = block.getIcon(Blockly.icons.IconType.COMMENT);
39
+ const comment = block.getIcon(Blockly.icons.IconType.COMMENT)
57
40
  if (!comment) {
58
- console.warn("BlockCommentCollapse.run: comment icon not found", block.id);
59
- return;
41
+ console.warn('BlockCommentCollapse.run: comment icon not found', block.id)
42
+ return
60
43
  }
61
- comment.setBubbleVisible(forward ? !this.newCollapsed : this.newCollapsed);
44
+ comment.setBubbleVisible(forward ? !this.newCollapsed : this.newCollapsed)
62
45
  }
63
46
  }
64
47
 
65
48
  interface BlockCommentCollapseJson extends BlockCommentBaseJson {
66
- collapsed: boolean;
49
+ collapsed: boolean
67
50
  }
68
51
 
69
- Blockly.registry.register(
70
- Blockly.registry.Type.EVENT,
71
- "block_comment_collapse",
72
- BlockCommentCollapse
73
- );
52
+ Blockly.registry.register(Blockly.registry.Type.EVENT, 'block_comment_collapse', BlockCommentCollapse)
@@ -1,81 +1,64 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import {
9
- BlockCommentBase,
10
- BlockCommentBaseJson,
11
- } from "./events_block_comment_base";
12
- import type { ScratchCommentBubble } from "../scratch_comment_bubble";
5
+ import * as Blockly from 'blockly/core'
6
+ import type { ScratchCommentBubble } from '../scratch_comment_bubble'
7
+ import { BlockCommentBase, BlockCommentBaseJson } from './events_block_comment_base'
13
8
 
14
9
  class BlockCommentCreate extends BlockCommentBase {
15
10
  json!: {
16
- x: number;
17
- y: number;
18
- width: number;
19
- height: number;
20
- };
11
+ x: number
12
+ y: number
13
+ width: number
14
+ height: number
15
+ }
21
16
 
22
17
  constructor(opt_blockComment?: ScratchCommentBubble) {
23
- super(opt_blockComment);
24
- this.type = "block_comment_create";
18
+ super(opt_blockComment)
19
+ this.type = 'block_comment_create'
25
20
  // opt_blockComment is absent when this class is instantiated by fromJson.
26
21
  // In that case fromJson sets this.json directly, so return early here.
27
- if (!opt_blockComment) return;
28
- const size = opt_blockComment.getSize();
29
- const location = opt_blockComment.getRelativeToSurfaceXY();
22
+ if (!opt_blockComment) return
23
+ const size = opt_blockComment.getSize()
24
+ const location = opt_blockComment.getRelativeToSurfaceXY()
30
25
  this.json = {
31
26
  x: location.x,
32
27
  y: location.y,
33
28
  width: size.width,
34
29
  height: size.height,
35
- };
30
+ }
36
31
  // Disable undo because Blockly already tracks comment creation for
37
32
  // undo purposes; this event exists solely to keep the Scratch VM apprised
38
33
  // of the state of things.
39
- this.recordUndo = false;
34
+ this.recordUndo = false
40
35
  }
41
36
 
42
37
  toJson(): BlockCommentCreateJson {
43
38
  return {
44
39
  ...super.toJson(),
45
40
  ...this.json,
46
- };
41
+ }
47
42
  }
48
43
 
49
- static fromJson(
50
- json: BlockCommentCreateJson,
51
- workspace: Blockly.Workspace,
52
- event?: any
53
- ): BlockCommentCreate {
54
- const newEvent = super.fromJson(
55
- json,
56
- workspace,
57
- event ?? new BlockCommentCreate()
58
- ) as BlockCommentCreate;
44
+ static fromJson(json: BlockCommentCreateJson, workspace: Blockly.Workspace, event?: any): BlockCommentCreate {
45
+ const newEvent = super.fromJson(json, workspace, event ?? new BlockCommentCreate()) as BlockCommentCreate
59
46
  newEvent.json = {
60
- x: json["x"],
61
- y: json["y"],
62
- width: json["width"],
63
- height: json["height"],
64
- };
47
+ x: json.x,
48
+ y: json.y,
49
+ width: json.width,
50
+ height: json.height,
51
+ }
65
52
 
66
- return newEvent;
53
+ return newEvent
67
54
  }
68
55
  }
69
56
 
70
57
  interface BlockCommentCreateJson extends BlockCommentBaseJson {
71
- x: number;
72
- y: number;
73
- width: number;
74
- height: number;
58
+ x: number
59
+ y: number
60
+ width: number
61
+ height: number
75
62
  }
76
63
 
77
- Blockly.registry.register(
78
- Blockly.registry.Type.EVENT,
79
- "block_comment_create",
80
- BlockCommentCreate
81
- );
64
+ Blockly.registry.register(Blockly.registry.Type.EVENT, 'block_comment_create', BlockCommentCreate)
@@ -1,33 +1,24 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import { BlockCommentBase } from "./events_block_comment_base";
9
- import type { ScratchCommentBubble } from "../scratch_comment_bubble";
5
+ import * as Blockly from 'blockly/core'
6
+ import type { ScratchCommentBubble } from '../scratch_comment_bubble'
7
+ import { BlockCommentBase } from './events_block_comment_base'
10
8
 
11
9
  class BlockCommentDelete extends BlockCommentBase {
12
- constructor(
13
- opt_blockComment?: ScratchCommentBubble,
14
- sourceBlock?: Blockly.Block
15
- ) {
16
- super(opt_blockComment);
17
- this.type = "block_comment_delete";
10
+ constructor(opt_blockComment?: ScratchCommentBubble, sourceBlock?: Blockly.Block) {
11
+ super(opt_blockComment)
12
+ this.type = 'block_comment_delete'
18
13
  if (sourceBlock) {
19
- this.blockId = sourceBlock.id;
20
- this.workspaceId = sourceBlock.workspace.id;
14
+ this.blockId = sourceBlock.id
15
+ this.workspaceId = sourceBlock.workspace.id
21
16
  }
22
17
  // Disable undo because Blockly already tracks comment deletion for
23
18
  // undo purposes; this event exists solely to keep the Scratch VM apprised
24
19
  // of the state of things.
25
- this.recordUndo = false;
20
+ this.recordUndo = false
26
21
  }
27
22
  }
28
23
 
29
- Blockly.registry.register(
30
- Blockly.registry.Type.EVENT,
31
- "block_comment_delete",
32
- BlockCommentDelete
33
- );
24
+ Blockly.registry.register(Blockly.registry.Type.EVENT, 'block_comment_delete', BlockCommentDelete)
@@ -1,29 +1,24 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import {
9
- BlockCommentBase,
10
- BlockCommentBaseJson,
11
- } from "./events_block_comment_base";
12
- import type { ScratchCommentBubble } from "../scratch_comment_bubble";
5
+ import * as Blockly from 'blockly/core'
6
+ import type { ScratchCommentBubble } from '../scratch_comment_bubble'
7
+ import { BlockCommentBase, BlockCommentBaseJson } from './events_block_comment_base'
13
8
 
14
9
  class BlockCommentMove extends BlockCommentBase {
15
- oldCoordinate_!: Blockly.utils.Coordinate;
16
- newCoordinate_!: Blockly.utils.Coordinate;
10
+ oldCoordinate_!: Blockly.utils.Coordinate
11
+ newCoordinate_!: Blockly.utils.Coordinate
17
12
 
18
13
  constructor(
19
14
  opt_blockComment?: ScratchCommentBubble,
20
15
  oldCoordinate?: Blockly.utils.Coordinate,
21
- newCoordinate?: Blockly.utils.Coordinate
16
+ newCoordinate?: Blockly.utils.Coordinate,
22
17
  ) {
23
- super(opt_blockComment);
24
- this.type = "block_comment_move";
25
- if (oldCoordinate !== undefined) this.oldCoordinate_ = oldCoordinate;
26
- if (newCoordinate !== undefined) this.newCoordinate_ = newCoordinate;
18
+ super(opt_blockComment)
19
+ this.type = 'block_comment_move'
20
+ if (oldCoordinate !== undefined) this.oldCoordinate_ = oldCoordinate
21
+ if (newCoordinate !== undefined) this.newCoordinate_ = newCoordinate
27
22
  }
28
23
 
29
24
  toJson(): BlockCommentMoveJson {
@@ -31,54 +26,34 @@ class BlockCommentMove extends BlockCommentBase {
31
26
  ...super.toJson(),
32
27
  newCoordinate: this.newCoordinate_,
33
28
  oldCoordinate: this.oldCoordinate_,
34
- };
29
+ }
35
30
  }
36
31
 
37
- static fromJson(
38
- json: BlockCommentMoveJson,
39
- workspace: Blockly.Workspace,
40
- event?: any
41
- ): BlockCommentMove {
42
- const newEvent = super.fromJson(
43
- json,
44
- workspace,
45
- event ?? new BlockCommentMove()
46
- ) as BlockCommentMove;
47
- newEvent.newCoordinate_ = new Blockly.utils.Coordinate(
48
- json["newCoordinate"]["x"],
49
- json["newCoordinate"]["y"]
50
- );
51
- newEvent.oldCoordinate_ = new Blockly.utils.Coordinate(
52
- json["oldCoordinate"]["x"],
53
- json["oldCoordinate"]["y"]
54
- );
32
+ static fromJson(json: BlockCommentMoveJson, workspace: Blockly.Workspace, event?: any): BlockCommentMove {
33
+ const newEvent = super.fromJson(json, workspace, event ?? new BlockCommentMove()) as BlockCommentMove
34
+ newEvent.newCoordinate_ = new Blockly.utils.Coordinate(json.newCoordinate.x, json.newCoordinate.y)
35
+ newEvent.oldCoordinate_ = new Blockly.utils.Coordinate(json.oldCoordinate.x, json.oldCoordinate.y)
55
36
 
56
- return newEvent;
37
+ return newEvent
57
38
  }
58
39
 
59
40
  run(forward: boolean) {
60
- const workspace = this.getEventWorkspace_();
61
- const block = workspace?.getBlockById(this.blockId);
62
- const comment = block?.getIcon(Blockly.icons.IconType.COMMENT);
63
- comment?.setBubbleLocation(
64
- forward ? this.newCoordinate_ : this.oldCoordinate_
65
- );
41
+ const workspace = this.getEventWorkspace_()
42
+ const block = workspace?.getBlockById(this.blockId)
43
+ const comment = block?.getIcon(Blockly.icons.IconType.COMMENT)
44
+ comment?.setBubbleLocation(forward ? this.newCoordinate_ : this.oldCoordinate_)
66
45
  }
67
46
  }
68
47
 
69
48
  interface BlockCommentMoveJson extends BlockCommentBaseJson {
70
49
  newCoordinate: {
71
- x: number;
72
- y: number;
73
- };
50
+ x: number
51
+ y: number
52
+ }
74
53
  oldCoordinate: {
75
- x: number;
76
- y: number;
77
- };
54
+ x: number
55
+ y: number
56
+ }
78
57
  }
79
58
 
80
- Blockly.registry.register(
81
- Blockly.registry.Type.EVENT,
82
- "block_comment_move",
83
- BlockCommentMove
84
- );
59
+ Blockly.registry.register(Blockly.registry.Type.EVENT, 'block_comment_move', BlockCommentMove)
@@ -1,29 +1,20 @@
1
1
  /**
2
- * @license
3
2
  * Copyright 2024 Google LLC
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
-
7
- import * as Blockly from "blockly/core";
8
- import {
9
- BlockCommentBase,
10
- BlockCommentBaseJson,
11
- } from "./events_block_comment_base";
12
- import type { ScratchCommentBubble } from "../scratch_comment_bubble";
5
+ import * as Blockly from 'blockly/core'
6
+ import type { ScratchCommentBubble } from '../scratch_comment_bubble'
7
+ import { BlockCommentBase, BlockCommentBaseJson } from './events_block_comment_base'
13
8
 
14
9
  class BlockCommentResize extends BlockCommentBase {
15
- oldSize!: Blockly.utils.Size;
16
- newSize!: Blockly.utils.Size;
17
-
18
- constructor(
19
- opt_blockComment?: ScratchCommentBubble,
20
- oldSize?: Blockly.utils.Size,
21
- newSize?: Blockly.utils.Size
22
- ) {
23
- super(opt_blockComment);
24
- this.type = "block_comment_resize";
25
- if (oldSize !== undefined) this.oldSize = oldSize;
26
- if (newSize !== undefined) this.newSize = newSize;
10
+ oldSize!: Blockly.utils.Size
11
+ newSize!: Blockly.utils.Size
12
+
13
+ constructor(opt_blockComment?: ScratchCommentBubble, oldSize?: Blockly.utils.Size, newSize?: Blockly.utils.Size) {
14
+ super(opt_blockComment)
15
+ this.type = 'block_comment_resize'
16
+ if (oldSize !== undefined) this.oldSize = oldSize
17
+ if (newSize !== undefined) this.newSize = newSize
27
18
  }
28
19
 
29
20
  toJson(): BlockCommentResizeJson {
@@ -37,52 +28,34 @@ class BlockCommentResize extends BlockCommentBase {
37
28
  width: this.oldSize.width,
38
29
  height: this.oldSize.height,
39
30
  },
40
- };
31
+ }
41
32
  }
42
33
 
43
- static fromJson(
44
- json: BlockCommentResizeJson,
45
- workspace: Blockly.Workspace,
46
- event?: any
47
- ): BlockCommentResize {
48
- const newEvent = super.fromJson(
49
- json,
50
- workspace,
51
- event ?? new BlockCommentResize()
52
- ) as BlockCommentResize;
53
- newEvent.newSize = new Blockly.utils.Size(
54
- json["newSize"]["width"],
55
- json["newSize"]["height"]
56
- );
57
- newEvent.oldSize = new Blockly.utils.Size(
58
- json["oldSize"]["width"],
59
- json["oldSize"]["height"]
60
- );
34
+ static fromJson(json: BlockCommentResizeJson, workspace: Blockly.Workspace, event?: any): BlockCommentResize {
35
+ const newEvent = super.fromJson(json, workspace, event ?? new BlockCommentResize()) as BlockCommentResize
36
+ newEvent.newSize = new Blockly.utils.Size(json.newSize.width, json.newSize.height)
37
+ newEvent.oldSize = new Blockly.utils.Size(json.oldSize.width, json.oldSize.height)
61
38
 
62
- return newEvent;
39
+ return newEvent
63
40
  }
64
41
 
65
42
  run(forward: boolean) {
66
- const workspace = this.getEventWorkspace_();
67
- const block = workspace?.getBlockById(this.blockId);
68
- const comment = block?.getIcon(Blockly.icons.IconType.COMMENT);
69
- comment?.setBubbleSize(forward ? this.newSize : this.oldSize);
43
+ const workspace = this.getEventWorkspace_()
44
+ const block = workspace?.getBlockById(this.blockId)
45
+ const comment = block?.getIcon(Blockly.icons.IconType.COMMENT)
46
+ comment?.setBubbleSize(forward ? this.newSize : this.oldSize)
70
47
  }
71
48
  }
72
49
 
73
50
  interface BlockCommentResizeJson extends BlockCommentBaseJson {
74
51
  newSize: {
75
- width: number;
76
- height: number;
77
- };
52
+ width: number
53
+ height: number
54
+ }
78
55
  oldSize: {
79
- width: number;
80
- height: number;
81
- };
56
+ width: number
57
+ height: number
58
+ }
82
59
  }
83
60
 
84
- Blockly.registry.register(
85
- Blockly.registry.Type.EVENT,
86
- "block_comment_resize",
87
- BlockCommentResize
88
- );
61
+ Blockly.registry.register(Blockly.registry.Type.EVENT, 'block_comment_resize', BlockCommentResize)