scratch-blocks 2.0.0-spork.2 → 2.0.0-spork.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.
- package/CHANGELOG.md +7 -0
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/src/{block_reporting.js → block_reporting.ts} +7 -5
- package/src/blocks/{colour.js → colour.ts} +6 -6
- package/src/blocks/{control.js → control.ts} +21 -54
- package/src/blocks/{data.js → data.ts} +134 -142
- package/src/blocks/{event.js → event.ts} +12 -33
- package/src/blocks/{looks.js → looks.ts} +24 -73
- package/src/blocks/{math.js → math.ts} +6 -11
- package/src/blocks/{matrix.js → matrix.ts} +2 -3
- package/src/blocks/{motion.js → motion.ts} +23 -70
- package/src/blocks/{note.js → note.ts} +2 -3
- package/src/blocks/{operators.js → operators.ts} +18 -55
- package/src/blocks/{procedures.js → procedures.ts} +418 -269
- package/src/blocks/{sensing.js → sensing.ts} +21 -61
- package/src/blocks/{sound.js → sound.ts} +9 -28
- package/src/blocks/{text.js → text.ts} +1 -2
- package/src/blocks/{vertical_extensions.js → vertical_extensions.ts} +63 -100
- package/src/checkable_continuous_flyout.js +2 -2
- package/src/{checkbox_bubble.js → checkbox_bubble.ts} +36 -53
- package/src/{colours.js → colours.ts} +11 -4
- package/src/{constants.js → constants.ts} +13 -0
- package/src/{context_menu_items.js → context_menu_items.ts} +18 -12
- package/src/{data_category.js → data_category.ts} +216 -150
- package/src/events/{events_block_comment_base.js → events_block_comment_base.ts} +23 -4
- package/src/events/{events_block_comment_change.js → events_block_comment_change.ts} +29 -5
- package/src/events/{events_block_comment_collapse.js → events_block_comment_collapse.ts} +24 -6
- package/src/events/{events_block_comment_create.js → events_block_comment_create.ts} +36 -10
- package/src/events/{events_block_comment_delete.js → events_block_comment_delete.ts} +6 -2
- package/src/events/{events_block_comment_move.js → events_block_comment_move.ts} +36 -6
- package/src/events/events_block_comment_resize.ts +88 -0
- package/src/events/events_block_drag_end.ts +49 -0
- package/src/events/events_block_drag_outside.ts +44 -0
- package/src/events/{events_scratch_variable_create.js → events_scratch_variable_create.ts} +28 -15
- package/src/fields/{field_colour_slider.js → field_colour_slider.ts} +117 -106
- package/src/fields/{field_matrix.js → field_matrix.ts} +189 -215
- package/src/fields/{field_note.js → field_note.ts} +227 -286
- package/src/fields/{field_textinput_removable.js → field_textinput_removable.ts} +17 -20
- package/src/fields/{field_variable_getter.js → field_variable_getter.ts} +28 -17
- package/src/fields/{field_vertical_separator.js → field_vertical_separator.ts} +14 -30
- package/src/fields/{field_angle.js → scratch_field_angle.ts} +124 -80
- package/src/fields/{field_dropdown.js → scratch_field_dropdown.ts} +9 -7
- package/src/fields/{field_number.js → scratch_field_number.ts} +60 -55
- package/src/fields/{field_variable.js → scratch_field_variable.ts} +46 -27
- package/src/{flyout_checkbox_icon.js → flyout_checkbox_icon.ts} +15 -19
- package/src/{glows.js → glows.ts} +29 -18
- package/src/index.ts +59 -60
- package/src/procedures.ts +462 -0
- package/src/{recyclable_block_flyout_inflater.js → recyclable_block_flyout_inflater.ts} +35 -35
- package/src/renderer/{bowler_hat.js → bowler_hat.ts} +1 -1
- package/src/renderer/{constants.js → constants.ts} +26 -12
- package/src/renderer/{drawer.js → drawer.ts} +8 -3
- package/src/renderer/{path_object.js → path_object.ts} +2 -2
- package/src/renderer/{render_info.js → render_info.ts} +19 -7
- package/src/renderer/renderer.ts +76 -0
- package/src/{scratch_block_paster.js → scratch_block_paster.ts} +9 -7
- package/src/scratch_blocks_utils.ts +39 -0
- package/src/{scratch_comment_icon.js → scratch_comment_icon.ts} +43 -26
- package/src/scratch_connection_checker.ts +44 -0
- package/src/{scratch_continuous_category.js → scratch_continuous_category.ts} +20 -13
- package/src/{scratch_continuous_toolbox.js → scratch_continuous_toolbox.ts} +20 -18
- package/src/{scratch_dragger.js → scratch_dragger.ts} +97 -28
- package/src/{scratch_variable_map.js → scratch_variable_map.ts} +4 -1
- package/src/scratch_variable_model.ts +30 -0
- package/src/{shadows.js → shadows.ts} +8 -4
- package/src/{status_indicator_label.js → status_indicator_label.ts} +24 -36
- package/src/{status_indicator_label_flyout_inflater.js → status_indicator_label_flyout_inflater.ts} +9 -7
- package/src/{variables.js → variables.ts} +153 -123
- package/tsconfig.json +5 -0
- package/src/categories.js +0 -15
- package/src/events/events_block_comment_resize.js +0 -52
- package/src/events/events_block_drag_end.js +0 -33
- package/src/events/events_block_drag_outside.js +0 -30
- package/src/procedures.js +0 -425
- package/src/renderer/renderer.js +0 -74
- package/src/scratch_blocks_utils.js +0 -148
- package/src/scratch_connection_checker.js +0 -29
- package/src/scratch_variable_model.js +0 -24
- /package/src/{css.js → css.ts} +0 -0
- /package/{continuous-toolbox.d.ts → types/continuous-toolbox.d.ts} +0 -0
|
@@ -5,10 +5,21 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as Blockly from "blockly/core";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
BlockCommentBase,
|
|
10
|
+
BlockCommentBaseJson,
|
|
11
|
+
} from "./events_block_comment_base";
|
|
12
|
+
import type { ScratchCommentBubble } from "../scratch_comment_bubble";
|
|
9
13
|
|
|
10
14
|
class BlockCommentChange extends BlockCommentBase {
|
|
11
|
-
|
|
15
|
+
oldContents_: string;
|
|
16
|
+
newContents_: string;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
opt_blockComment?: ScratchCommentBubble,
|
|
20
|
+
oldContents?: string,
|
|
21
|
+
newContents?: string
|
|
22
|
+
) {
|
|
12
23
|
super(opt_blockComment);
|
|
13
24
|
this.type = "block_comment_change";
|
|
14
25
|
this.oldContents_ = oldContents;
|
|
@@ -19,7 +30,7 @@ class BlockCommentChange extends BlockCommentBase {
|
|
|
19
30
|
this.recordUndo = false;
|
|
20
31
|
}
|
|
21
32
|
|
|
22
|
-
toJson() {
|
|
33
|
+
toJson(): BlockCommentChangeJson {
|
|
23
34
|
return {
|
|
24
35
|
...super.toJson(),
|
|
25
36
|
newContents: this.newContents_,
|
|
@@ -27,8 +38,16 @@ class BlockCommentChange extends BlockCommentBase {
|
|
|
27
38
|
};
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
static fromJson(
|
|
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;
|
|
32
51
|
newEvent.newContents_ = json["newContents"];
|
|
33
52
|
newEvent.oldContents_ = json["oldContents"];
|
|
34
53
|
|
|
@@ -36,6 +55,11 @@ class BlockCommentChange extends BlockCommentBase {
|
|
|
36
55
|
}
|
|
37
56
|
}
|
|
38
57
|
|
|
58
|
+
interface BlockCommentChangeJson extends BlockCommentBaseJson {
|
|
59
|
+
newContents: string;
|
|
60
|
+
oldContents: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
Blockly.registry.register(
|
|
40
64
|
Blockly.registry.Type.EVENT,
|
|
41
65
|
"block_comment_change",
|
|
@@ -5,30 +5,44 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as Blockly from "blockly/core";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
BlockCommentBase,
|
|
10
|
+
BlockCommentBaseJson,
|
|
11
|
+
} from "./events_block_comment_base";
|
|
12
|
+
import type { ScratchCommentBubble } from "../scratch_comment_bubble";
|
|
9
13
|
|
|
10
14
|
class BlockCommentCollapse extends BlockCommentBase {
|
|
11
|
-
|
|
15
|
+
newCollapsed: boolean;
|
|
16
|
+
|
|
17
|
+
constructor(opt_blockComment?: ScratchCommentBubble, collapsed?: boolean) {
|
|
12
18
|
super(opt_blockComment);
|
|
13
19
|
this.type = "block_comment_collapse";
|
|
14
20
|
this.newCollapsed = collapsed;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
toJson() {
|
|
23
|
+
toJson(): BlockCommentCollapseJson {
|
|
18
24
|
return {
|
|
19
25
|
...super.toJson(),
|
|
20
26
|
collapsed: this.newCollapsed,
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
static fromJson(
|
|
25
|
-
|
|
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;
|
|
26
40
|
newEvent.newCollapsed = json["collapsed"];
|
|
27
41
|
|
|
28
42
|
return newEvent;
|
|
29
43
|
}
|
|
30
44
|
|
|
31
|
-
run(forward) {
|
|
45
|
+
run(forward: boolean) {
|
|
32
46
|
const workspace = this.getEventWorkspace_();
|
|
33
47
|
const block = workspace.getBlockById(this.blockId);
|
|
34
48
|
const comment = block.getIcon(Blockly.icons.IconType.COMMENT);
|
|
@@ -36,6 +50,10 @@ class BlockCommentCollapse extends BlockCommentBase {
|
|
|
36
50
|
}
|
|
37
51
|
}
|
|
38
52
|
|
|
53
|
+
interface BlockCommentCollapseJson extends BlockCommentBaseJson {
|
|
54
|
+
collapsed: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
39
57
|
Blockly.registry.register(
|
|
40
58
|
Blockly.registry.Type.EVENT,
|
|
41
59
|
"block_comment_collapse",
|
|
@@ -5,10 +5,21 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as Blockly from "blockly/core";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
BlockCommentBase,
|
|
10
|
+
BlockCommentBaseJson,
|
|
11
|
+
} from "./events_block_comment_base";
|
|
12
|
+
import type { ScratchCommentBubble } from "../scratch_comment_bubble";
|
|
9
13
|
|
|
10
14
|
class BlockCommentCreate extends BlockCommentBase {
|
|
11
|
-
|
|
15
|
+
json: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
constructor(opt_blockComment?: ScratchCommentBubble) {
|
|
12
23
|
super(opt_blockComment);
|
|
13
24
|
this.type = "block_comment_create";
|
|
14
25
|
const size = opt_blockComment.getSize();
|
|
@@ -25,26 +36,41 @@ class BlockCommentCreate extends BlockCommentBase {
|
|
|
25
36
|
this.recordUndo = false;
|
|
26
37
|
}
|
|
27
38
|
|
|
28
|
-
toJson() {
|
|
39
|
+
toJson(): BlockCommentCreateJson {
|
|
29
40
|
return {
|
|
30
41
|
...super.toJson(),
|
|
31
|
-
|
|
42
|
+
...this.json,
|
|
32
43
|
};
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
static fromJson(
|
|
36
|
-
|
|
46
|
+
static fromJson(
|
|
47
|
+
json: BlockCommentCreateJson,
|
|
48
|
+
workspace: Blockly.Workspace,
|
|
49
|
+
event?: any
|
|
50
|
+
): BlockCommentCreate {
|
|
51
|
+
const newEvent = super.fromJson(
|
|
52
|
+
json,
|
|
53
|
+
workspace,
|
|
54
|
+
event ?? new BlockCommentCreate()
|
|
55
|
+
) as BlockCommentCreate;
|
|
37
56
|
newEvent.json = {
|
|
38
|
-
x: json["
|
|
39
|
-
y: json["
|
|
40
|
-
width: json["
|
|
41
|
-
height: json["
|
|
57
|
+
x: json["x"],
|
|
58
|
+
y: json["y"],
|
|
59
|
+
width: json["width"],
|
|
60
|
+
height: json["height"],
|
|
42
61
|
};
|
|
43
62
|
|
|
44
63
|
return newEvent;
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
66
|
|
|
67
|
+
interface BlockCommentCreateJson extends BlockCommentBaseJson {
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
48
74
|
Blockly.registry.register(
|
|
49
75
|
Blockly.registry.Type.EVENT,
|
|
50
76
|
"block_comment_create",
|
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as Blockly from "blockly/core";
|
|
8
|
-
import { BlockCommentBase } from "./events_block_comment_base
|
|
8
|
+
import { BlockCommentBase } from "./events_block_comment_base";
|
|
9
|
+
import type { ScratchCommentBubble } from "../scratch_comment_bubble";
|
|
9
10
|
|
|
10
11
|
class BlockCommentDelete extends BlockCommentBase {
|
|
11
|
-
constructor(
|
|
12
|
+
constructor(
|
|
13
|
+
opt_blockComment?: ScratchCommentBubble,
|
|
14
|
+
sourceBlock?: Blockly.Block
|
|
15
|
+
) {
|
|
12
16
|
super(opt_blockComment);
|
|
13
17
|
this.type = "block_comment_delete";
|
|
14
18
|
this.blockId = sourceBlock.id;
|
|
@@ -5,17 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as Blockly from "blockly/core";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
BlockCommentBase,
|
|
10
|
+
BlockCommentBaseJson,
|
|
11
|
+
} from "./events_block_comment_base";
|
|
12
|
+
import type { ScratchCommentBubble } from "../scratch_comment_bubble";
|
|
9
13
|
|
|
10
14
|
class BlockCommentMove extends BlockCommentBase {
|
|
11
|
-
|
|
15
|
+
oldCoordinate_: Blockly.utils.Coordinate;
|
|
16
|
+
newCoordinate_: Blockly.utils.Coordinate;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
opt_blockComment?: ScratchCommentBubble,
|
|
20
|
+
oldCoordinate?: Blockly.utils.Coordinate,
|
|
21
|
+
newCoordinate?: Blockly.utils.Coordinate
|
|
22
|
+
) {
|
|
12
23
|
super(opt_blockComment);
|
|
13
24
|
this.type = "block_comment_move";
|
|
14
25
|
this.oldCoordinate_ = oldCoordinate;
|
|
15
26
|
this.newCoordinate_ = newCoordinate;
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
toJson() {
|
|
29
|
+
toJson(): BlockCommentMoveJson {
|
|
19
30
|
return {
|
|
20
31
|
...super.toJson(),
|
|
21
32
|
newCoordinate: this.newCoordinate_,
|
|
@@ -23,8 +34,16 @@ class BlockCommentMove extends BlockCommentBase {
|
|
|
23
34
|
};
|
|
24
35
|
}
|
|
25
36
|
|
|
26
|
-
static fromJson(
|
|
27
|
-
|
|
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;
|
|
28
47
|
newEvent.newCoordinate_ = new Blockly.utils.Coordinate(
|
|
29
48
|
json["newCoordinate"]["x"],
|
|
30
49
|
json["newCoordinate"]["y"]
|
|
@@ -37,7 +56,7 @@ class BlockCommentMove extends BlockCommentBase {
|
|
|
37
56
|
return newEvent;
|
|
38
57
|
}
|
|
39
58
|
|
|
40
|
-
run(forward) {
|
|
59
|
+
run(forward: boolean) {
|
|
41
60
|
const workspace = this.getEventWorkspace_();
|
|
42
61
|
const block = workspace?.getBlockById(this.blockId);
|
|
43
62
|
const comment = block?.getIcon(Blockly.icons.IconType.COMMENT);
|
|
@@ -47,6 +66,17 @@ class BlockCommentMove extends BlockCommentBase {
|
|
|
47
66
|
}
|
|
48
67
|
}
|
|
49
68
|
|
|
69
|
+
interface BlockCommentMoveJson extends BlockCommentBaseJson {
|
|
70
|
+
newCoordinate: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
};
|
|
74
|
+
oldCoordinate: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
50
80
|
Blockly.registry.register(
|
|
51
81
|
Blockly.registry.Type.EVENT,
|
|
52
82
|
"block_comment_move",
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
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";
|
|
13
|
+
|
|
14
|
+
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
|
+
this.oldSize = oldSize;
|
|
26
|
+
this.newSize = newSize;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
toJson(): BlockCommentResizeJson {
|
|
30
|
+
return {
|
|
31
|
+
...super.toJson(),
|
|
32
|
+
newSize: {
|
|
33
|
+
width: this.newSize.width,
|
|
34
|
+
height: this.newSize.height,
|
|
35
|
+
},
|
|
36
|
+
oldSize: {
|
|
37
|
+
width: this.oldSize.width,
|
|
38
|
+
height: this.oldSize.height,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
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
|
+
);
|
|
61
|
+
|
|
62
|
+
return newEvent;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
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);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface BlockCommentResizeJson extends BlockCommentBaseJson {
|
|
74
|
+
newSize: {
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
};
|
|
78
|
+
oldSize: {
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Blockly.registry.register(
|
|
85
|
+
Blockly.registry.Type.EVENT,
|
|
86
|
+
"block_comment_resize",
|
|
87
|
+
BlockCommentResize
|
|
88
|
+
);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as Blockly from "blockly/core";
|
|
8
|
+
|
|
9
|
+
export class BlockDragEnd extends Blockly.Events.BlockBase {
|
|
10
|
+
isOutside: boolean;
|
|
11
|
+
xml: Element | DocumentFragment;
|
|
12
|
+
|
|
13
|
+
constructor(block?: Blockly.Block, isOutside?: boolean) {
|
|
14
|
+
super(block);
|
|
15
|
+
this.type = "endDrag";
|
|
16
|
+
this.isOutside = isOutside;
|
|
17
|
+
this.recordUndo = false;
|
|
18
|
+
this.xml = Blockly.Xml.blockToDom(block, true);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toJson(): BlockDragEndJson {
|
|
22
|
+
return {
|
|
23
|
+
...super.toJson(),
|
|
24
|
+
isOutside: this.isOutside,
|
|
25
|
+
xml: Blockly.utils.xml.domToText(this.xml),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static fromJson(
|
|
30
|
+
json: BlockDragEndJson,
|
|
31
|
+
workspace: Blockly.Workspace,
|
|
32
|
+
event?: any
|
|
33
|
+
): BlockDragEnd {
|
|
34
|
+
const newEvent = super.fromJson(
|
|
35
|
+
json,
|
|
36
|
+
workspace,
|
|
37
|
+
event ?? new BlockDragEnd()
|
|
38
|
+
) as BlockDragEnd;
|
|
39
|
+
newEvent.isOutside = json["isOutside"];
|
|
40
|
+
newEvent.xml = Blockly.utils.xml.textToDom(json["xml"]);
|
|
41
|
+
|
|
42
|
+
return newEvent;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface BlockDragEndJson extends Blockly.Events.BlockBaseJson {
|
|
47
|
+
isOutside: boolean;
|
|
48
|
+
xml: string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as Blockly from "blockly/core";
|
|
8
|
+
|
|
9
|
+
export class BlockDragOutside extends Blockly.Events.BlockBase {
|
|
10
|
+
isOutside: boolean;
|
|
11
|
+
|
|
12
|
+
constructor(block?: Blockly.Block, isOutside?: boolean) {
|
|
13
|
+
super(block);
|
|
14
|
+
this.type = "dragOutside";
|
|
15
|
+
this.isOutside = isOutside;
|
|
16
|
+
this.recordUndo = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toJson(): BlockDragOutsideJson {
|
|
20
|
+
return {
|
|
21
|
+
...super.toJson(),
|
|
22
|
+
isOutside: this.isOutside,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static fromJson(
|
|
27
|
+
json: BlockDragOutsideJson,
|
|
28
|
+
workspace: Blockly.Workspace,
|
|
29
|
+
event?: any
|
|
30
|
+
): BlockDragOutside {
|
|
31
|
+
const newEvent = super.fromJson(
|
|
32
|
+
json,
|
|
33
|
+
workspace,
|
|
34
|
+
event ?? new BlockDragOutside()
|
|
35
|
+
) as BlockDragOutside;
|
|
36
|
+
newEvent.isOutside = json["isOutside"];
|
|
37
|
+
|
|
38
|
+
return newEvent;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface BlockDragOutsideJson extends Blockly.Events.BlockBaseJson {
|
|
43
|
+
isOutside: boolean;
|
|
44
|
+
}
|
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as Blockly from "blockly/core";
|
|
8
|
+
import { ScratchVariableModel } from "../scratch_variable_model";
|
|
8
9
|
|
|
9
10
|
class ScratchVariableCreate extends Blockly.Events.VarCreate {
|
|
10
|
-
|
|
11
|
+
isLocal: boolean;
|
|
12
|
+
isCloud: boolean;
|
|
13
|
+
|
|
14
|
+
constructor(variable?: ScratchVariableModel) {
|
|
11
15
|
super(variable);
|
|
12
16
|
if (!variable) return;
|
|
13
17
|
|
|
@@ -15,30 +19,34 @@ class ScratchVariableCreate extends Blockly.Events.VarCreate {
|
|
|
15
19
|
this.isCloud = variable.isCloud;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
toJson() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
toJson(): ScratchVariableCreateJson {
|
|
23
|
+
return {
|
|
24
|
+
...super.toJson(),
|
|
25
|
+
isLocal: this.isLocal,
|
|
26
|
+
isCloud: this.isCloud,
|
|
27
|
+
};
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
static fromJson(
|
|
26
|
-
|
|
30
|
+
static fromJson(
|
|
31
|
+
json: ScratchVariableCreateJson,
|
|
32
|
+
workspace: Blockly.Workspace,
|
|
33
|
+
event?: any
|
|
34
|
+
): ScratchVariableCreate {
|
|
35
|
+
const newEvent = super.fromJson(
|
|
36
|
+
json,
|
|
37
|
+
workspace,
|
|
38
|
+
event ?? new ScratchVariableCreate()
|
|
39
|
+
) as ScratchVariableCreate;
|
|
27
40
|
newEvent.isLocal = json["isLocal"];
|
|
28
41
|
newEvent.isCloud = json["isCloud"];
|
|
29
42
|
return newEvent;
|
|
30
43
|
}
|
|
31
44
|
|
|
32
|
-
run(forward) {
|
|
45
|
+
run(forward: boolean) {
|
|
33
46
|
const workspace = this.getEventWorkspace_();
|
|
34
47
|
const variableMap = workspace.getVariableMap();
|
|
35
48
|
if (forward) {
|
|
36
|
-
const
|
|
37
|
-
Blockly.registry.Type.VARIABLE_MODEL,
|
|
38
|
-
Blockly.registry.DEFAULT,
|
|
39
|
-
true
|
|
40
|
-
);
|
|
41
|
-
const variable = new VariableModel(
|
|
49
|
+
const variable = new ScratchVariableModel(
|
|
42
50
|
workspace,
|
|
43
51
|
this.varName,
|
|
44
52
|
this.varType,
|
|
@@ -59,6 +67,11 @@ class ScratchVariableCreate extends Blockly.Events.VarCreate {
|
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
interface ScratchVariableCreateJson extends Blockly.Events.VarCreateJson {
|
|
71
|
+
isCloud: boolean;
|
|
72
|
+
isLocal: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
Blockly.registry.register(
|
|
63
76
|
Blockly.registry.Type.EVENT,
|
|
64
77
|
Blockly.Events.VAR_CREATE,
|