scratch-blocks 2.0.2 → 2.0.4
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.
- package/.nvmrc +1 -1
- package/commitlint.config.js +2 -2
- package/dist/main.mjs +1 -2
- package/dist/types/msg/scratch_msgs.d.ts.map +1 -1
- package/dist/types/src/block_reporting.d.ts.map +1 -1
- package/dist/types/src/blocks/colour.d.ts +0 -19
- package/dist/types/src/blocks/colour.d.ts.map +1 -1
- package/dist/types/src/blocks/control.d.ts +0 -19
- package/dist/types/src/blocks/control.d.ts.map +1 -1
- package/dist/types/src/blocks/data.d.ts +0 -19
- package/dist/types/src/blocks/data.d.ts.map +1 -1
- package/dist/types/src/blocks/event.d.ts +0 -19
- package/dist/types/src/blocks/event.d.ts.map +1 -1
- package/dist/types/src/blocks/looks.d.ts +0 -19
- package/dist/types/src/blocks/looks.d.ts.map +1 -1
- package/dist/types/src/blocks/math.d.ts +0 -19
- package/dist/types/src/blocks/math.d.ts.map +1 -1
- package/dist/types/src/blocks/matrix.d.ts +0 -19
- package/dist/types/src/blocks/matrix.d.ts.map +1 -1
- package/dist/types/src/blocks/motion.d.ts +0 -19
- package/dist/types/src/blocks/motion.d.ts.map +1 -1
- package/dist/types/src/blocks/note.d.ts +0 -19
- package/dist/types/src/blocks/note.d.ts.map +1 -1
- package/dist/types/src/blocks/operators.d.ts +0 -19
- package/dist/types/src/blocks/operators.d.ts.map +1 -1
- package/dist/types/src/blocks/procedures.d.ts +7 -10
- package/dist/types/src/blocks/procedures.d.ts.map +1 -1
- package/dist/types/src/blocks/sensing.d.ts +0 -19
- package/dist/types/src/blocks/sensing.d.ts.map +1 -1
- package/dist/types/src/blocks/sound.d.ts +0 -19
- package/dist/types/src/blocks/sound.d.ts.map +1 -1
- package/dist/types/src/blocks/text.d.ts +0 -19
- package/dist/types/src/blocks/text.d.ts.map +1 -1
- package/dist/types/src/blocks/vertical_extensions.d.ts +0 -19
- package/dist/types/src/blocks/vertical_extensions.d.ts.map +1 -1
- package/dist/types/src/checkable_continuous_flyout.d.ts +2 -7
- package/dist/types/src/checkable_continuous_flyout.d.ts.map +1 -1
- package/dist/types/src/checkbox_bubble.d.ts +13 -12
- package/dist/types/src/checkbox_bubble.d.ts.map +1 -1
- package/dist/types/src/colours.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +0 -7
- package/dist/types/src/constants.d.ts.map +1 -1
- package/dist/types/src/context_menu_items.d.ts +0 -5
- package/dist/types/src/context_menu_items.d.ts.map +1 -1
- package/dist/types/src/data_category.d.ts +2 -4
- package/dist/types/src/data_category.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_base.d.ts +2 -3
- package/dist/types/src/events/events_block_comment_base.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_change.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_change.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_collapse.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_collapse.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_create.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_create.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_delete.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_delete.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_move.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_move.d.ts.map +1 -1
- package/dist/types/src/events/events_block_comment_resize.d.ts +0 -5
- package/dist/types/src/events/events_block_comment_resize.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_end.d.ts +1 -2
- package/dist/types/src/events/events_block_drag_end.d.ts.map +1 -1
- package/dist/types/src/events/events_block_drag_outside.d.ts +1 -2
- package/dist/types/src/events/events_block_drag_outside.d.ts.map +1 -1
- package/dist/types/src/events/events_scratch_variable_create.d.ts +0 -5
- package/dist/types/src/events/events_scratch_variable_create.d.ts.map +1 -1
- package/dist/types/src/fields/field_colour_slider.d.ts +7 -9
- package/dist/types/src/fields/field_colour_slider.d.ts.map +1 -1
- package/dist/types/src/fields/field_matrix.d.ts +0 -19
- package/dist/types/src/fields/field_matrix.d.ts.map +1 -1
- package/dist/types/src/fields/field_note.d.ts +8 -23
- package/dist/types/src/fields/field_note.d.ts.map +1 -1
- package/dist/types/src/fields/field_textinput_removable.d.ts +2 -4
- package/dist/types/src/fields/field_textinput_removable.d.ts.map +1 -1
- package/dist/types/src/fields/field_variable_getter.d.ts +0 -19
- package/dist/types/src/fields/field_variable_getter.d.ts.map +1 -1
- package/dist/types/src/fields/field_vertical_separator.d.ts +0 -19
- package/dist/types/src/fields/field_vertical_separator.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_angle.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_angle.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_dropdown.d.ts +0 -5
- package/dist/types/src/fields/scratch_field_dropdown.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_number.d.ts +0 -19
- package/dist/types/src/fields/scratch_field_number.d.ts.map +1 -1
- package/dist/types/src/fields/scratch_field_variable.d.ts +4 -7
- package/dist/types/src/fields/scratch_field_variable.d.ts.map +1 -1
- package/dist/types/src/flyout_checkbox_icon.d.ts +2 -3
- package/dist/types/src/flyout_checkbox_icon.d.ts.map +1 -1
- package/dist/types/src/glows.d.ts +1 -3
- package/dist/types/src/glows.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +50 -55
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/procedures.d.ts +6 -8
- package/dist/types/src/procedures.d.ts.map +1 -1
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts +3 -5
- package/dist/types/src/recyclable_block_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/renderer/bowler_hat.d.ts +2 -3
- package/dist/types/src/renderer/bowler_hat.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/cat_face.d.ts +6 -5
- package/dist/types/src/renderer/cat/cat_face.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/constants.d.ts +2 -2
- package/dist/types/src/renderer/cat/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/drawer.d.ts +3 -4
- package/dist/types/src/renderer/cat/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/path_object.d.ts +2 -3
- package/dist/types/src/renderer/cat/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/render_info.d.ts +3 -4
- package/dist/types/src/renderer/cat/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/cat/renderer.d.ts +6 -7
- package/dist/types/src/renderer/cat/renderer.d.ts.map +1 -1
- package/dist/types/src/renderer/constants.d.ts +4 -4
- package/dist/types/src/renderer/constants.d.ts.map +1 -1
- package/dist/types/src/renderer/drawer.d.ts +5 -4
- package/dist/types/src/renderer/drawer.d.ts.map +1 -1
- package/dist/types/src/renderer/path_object.d.ts +1 -3
- package/dist/types/src/renderer/path_object.d.ts.map +1 -1
- package/dist/types/src/renderer/render_info.d.ts +3 -4
- package/dist/types/src/renderer/render_info.d.ts.map +1 -1
- package/dist/types/src/renderer/renderer.d.ts +8 -15
- package/dist/types/src/renderer/renderer.d.ts.map +1 -1
- package/dist/types/src/scratch_block_paster.d.ts +0 -5
- package/dist/types/src/scratch_block_paster.d.ts.map +1 -1
- package/dist/types/src/scratch_blocks_utils.d.ts +0 -20
- package/dist/types/src/scratch_blocks_utils.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_bubble.d.ts +1 -4
- package/dist/types/src/scratch_comment_bubble.d.ts.map +1 -1
- package/dist/types/src/scratch_comment_icon.d.ts +2 -3
- package/dist/types/src/scratch_comment_icon.d.ts.map +1 -1
- package/dist/types/src/scratch_connection_checker.d.ts +0 -5
- package/dist/types/src/scratch_connection_checker.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_category.d.ts +5 -5
- package/dist/types/src/scratch_continuous_category.d.ts.map +1 -1
- package/dist/types/src/scratch_continuous_toolbox.d.ts +3 -6
- package/dist/types/src/scratch_continuous_toolbox.d.ts.map +1 -1
- package/dist/types/src/scratch_dragger.d.ts +3 -12
- package/dist/types/src/scratch_dragger.d.ts.map +1 -1
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts +0 -5
- package/dist/types/src/scratch_insertion_marker_previewer.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_map.d.ts +0 -5
- package/dist/types/src/scratch_variable_map.d.ts.map +1 -1
- package/dist/types/src/scratch_variable_model.d.ts +1 -2
- package/dist/types/src/scratch_variable_model.d.ts.map +1 -1
- package/dist/types/src/scratch_zoom_controls.d.ts +4 -6
- package/dist/types/src/scratch_zoom_controls.d.ts.map +1 -1
- package/dist/types/src/shadows.d.ts +2 -2
- package/dist/types/src/shadows.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label.d.ts +4 -6
- package/dist/types/src/status_indicator_label.d.ts.map +1 -1
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts +1 -6
- package/dist/types/src/status_indicator_label_flyout_inflater.d.ts.map +1 -1
- package/dist/types/src/variables.d.ts +4 -8
- package/dist/types/src/variables.d.ts.map +1 -1
- package/dist/types/src/xml.d.ts +2 -3
- package/dist/types/src/xml.d.ts.map +1 -1
- package/dist/types/tests/jsunit/block_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_db_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/connection_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/event_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/extensions_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_number_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_getter_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/field_variable_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/gesture_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/input_test.d.ts +1 -0
- package/dist/types/tests/jsunit/input_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/json_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/names_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/procedure_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/scratch_block_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/svg_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/test_utilities.d.ts.map +1 -1
- package/dist/types/tests/jsunit/utils_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_map_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/variable_model_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/widget_div_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_comment_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/workspace_undo_redo_test.d.ts.map +1 -1
- package/dist/types/tests/jsunit/xml_test.d.ts.map +1 -1
- package/dist/types/tests/workspace_svg/workspace_svg_test.d.ts.map +1 -1
- package/eslint.config.mjs +69 -0
- package/i18n/create_scratch_msgs.js +44 -45
- package/i18n/js_to_json.js +40 -32
- package/i18n/json_to_js.js +37 -37
- package/i18n/sync_tx_translations.js +64 -65
- package/i18n/test_scratch_msgs.js +66 -63
- package/msg/js/en.js +289 -287
- package/msg/json/en.json +284 -284
- package/msg/messages.js +289 -287
- package/msg/scratch_msgs.js +22959 -22970
- package/package.json +13 -10
- package/prettier.config.mjs +3 -0
- package/release.config.js +7 -7
- package/renovate.json5 +7 -9
- package/src/block_reporting.ts +15 -18
- package/src/blocks/colour.ts +12 -15
- package/src/blocks/control.ts +167 -177
- package/src/blocks/data.ts +225 -292
- package/src/blocks/event.ts +121 -123
- package/src/blocks/looks.ts +165 -167
- package/src/blocks/math.ts +44 -46
- package/src/blocks/matrix.ts +11 -13
- package/src/blocks/motion.ts +151 -153
- package/src/blocks/note.ts +11 -13
- package/src/blocks/operators.ts +158 -160
- package/src/blocks/procedures.ts +488 -536
- package/src/blocks/sensing.ts +163 -165
- package/src/blocks/sound.ts +58 -60
- package/src/blocks/text.ts +10 -12
- package/src/blocks/vertical_extensions.ts +86 -102
- package/src/checkable_continuous_flyout.ts +25 -42
- package/src/checkbox_bubble.ts +83 -100
- package/src/colours.ts +35 -37
- package/src/constants.ts +22 -29
- package/src/context_menu_items.ts +56 -81
- package/src/css.ts +3 -4
- package/src/data_category.ts +136 -250
- package/src/events/events_block_comment_base.ts +21 -31
- package/src/events/events_block_comment_change.ts +21 -42
- package/src/events/events_block_comment_collapse.ts +22 -43
- package/src/events/events_block_comment_create.ts +29 -46
- package/src/events/events_block_comment_delete.ts +10 -19
- package/src/events/events_block_comment_move.ts +27 -52
- package/src/events/events_block_comment_resize.ts +28 -55
- package/src/events/events_block_drag_end.ts +16 -26
- package/src/events/events_block_drag_outside.ts +12 -22
- package/src/events/events_scratch_variable_create.ts +33 -56
- package/src/fields/field_colour_slider.ts +173 -228
- package/src/fields/field_matrix.ts +200 -269
- package/src/fields/field_note.ts +272 -377
- package/src/fields/field_textinput_removable.ts +25 -40
- package/src/fields/field_variable_getter.ts +26 -31
- package/src/fields/field_vertical_separator.ts +19 -24
- package/src/fields/scratch_field_angle.ts +150 -186
- package/src/fields/scratch_field_dropdown.ts +15 -19
- package/src/fields/scratch_field_number.ts +123 -180
- package/src/fields/scratch_field_variable.ts +52 -73
- package/src/flyout_checkbox_icon.ts +18 -28
- package/src/glows.ts +51 -58
- package/src/index.ts +119 -133
- package/src/procedures.ts +144 -211
- package/src/recyclable_block_flyout_inflater.ts +14 -25
- package/src/renderer/bowler_hat.ts +6 -8
- package/src/renderer/cat/cat_face.ts +98 -99
- package/src/renderer/cat/constants.ts +67 -87
- package/src/renderer/cat/drawer.ts +21 -27
- package/src/renderer/cat/path_object.ts +3 -5
- package/src/renderer/cat/render_info.ts +5 -8
- package/src/renderer/cat/renderer.ts +11 -15
- package/src/renderer/constants.ts +34 -49
- package/src/renderer/drawer.ts +35 -51
- package/src/renderer/path_object.ts +13 -15
- package/src/renderer/render_info.ts +36 -56
- package/src/renderer/renderer.ts +16 -29
- package/src/scratch_block_paster.ts +12 -20
- package/src/scratch_blocks_utils.ts +4 -7
- package/src/scratch_comment_bubble.ts +70 -101
- package/src/scratch_comment_icon.ts +74 -123
- package/src/scratch_connection_checker.ts +22 -17
- package/src/scratch_continuous_category.ts +24 -28
- package/src/scratch_continuous_toolbox.ts +20 -27
- package/src/scratch_dragger.ts +54 -86
- package/src/scratch_insertion_marker_previewer.ts +6 -11
- package/src/scratch_variable_map.ts +5 -12
- package/src/scratch_variable_model.ts +4 -11
- package/src/scratch_zoom_controls.ts +101 -156
- package/src/shadows.ts +32 -37
- package/src/status_indicator_label.ts +54 -67
- package/src/status_indicator_label_flyout_inflater.ts +11 -21
- package/src/variables.ts +89 -138
- package/src/xml.ts +21 -35
- package/tsconfig.json +2 -6
- package/types/continuous-toolbox.d.ts +1 -1
- 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
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
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 =
|
|
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
|
|
32
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
61
|
-
y: json
|
|
62
|
-
width: json
|
|
63
|
-
height: json
|
|
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
|
|
8
|
-
import { BlockCommentBase } from
|
|
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
|
|
14
|
-
|
|
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
|
|
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 =
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
45
|
-
|
|
46
|
-
|
|
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)
|