x-block-lib 0.2.1 → 0.2.2
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/dist/core/blocks/index.d.ts +1 -0
- package/dist/core/blocks/logic/if/v1/index.d.ts +1 -0
- package/dist/core/blocks/logic/if/v1/mutator.d.ts +1 -0
- package/dist/core/blocks/logic/index.d.ts +1 -0
- package/dist/core/blocks/loop/extensions/v1/index.d.ts +1 -0
- package/dist/core/blocks/loop/flowControl/v1/extensions.d.ts +1 -0
- package/dist/core/blocks/loop/flowControl/v1/index.d.ts +1 -0
- package/dist/core/blocks/loop/for/v1/index.d.ts +1 -0
- package/dist/core/blocks/loop/forEach/v1/index.d.ts +1 -0
- package/dist/core/blocks/loop/index.d.ts +5 -0
- package/dist/core/blocks/loop/whileUntil/v1/index.d.ts +1 -0
- package/dist/core/locale/msg/en.d.ts +14 -0
- package/dist/core/locale/msg/zhHans.d.ts +14 -0
- package/dist/core/toolbox/app/v1/index.d.ts +10 -2
- package/dist/core/toolbox/common/loop/v1/index.d.ts +10 -0
- package/dist/en-Djut8W3R.js +27 -0
- package/dist/index.js +592 -176
- package/dist/zhHans-D_qcn_1f.js +27 -0
- package/package.json +3 -3
- package/dist/en-CCqtrcN-.js +0 -11
- package/dist/zhHans---jf3OTZ.js +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './mutator';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './extensions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
LOOP_DO: string;
|
|
3
|
+
LOOP_V1_FOR_TITLE: string;
|
|
4
|
+
LOOP_V1_FOR_EACH_TITLE: string;
|
|
5
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE: string;
|
|
6
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL: string;
|
|
7
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE: string;
|
|
8
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL: string;
|
|
9
|
+
LOOP_V1_WHILE_UNTIL_HELPURL: string;
|
|
2
10
|
LOGIC_BOOLEAN_FALSE: string;
|
|
3
11
|
LOGIC_BOOLEAN_TRUE: string;
|
|
12
|
+
LOGIC_DO: string;
|
|
13
|
+
LOGIC_ELSE: string;
|
|
14
|
+
LOGIC_ELSE_IF: string;
|
|
15
|
+
LOGIC_IF: string;
|
|
4
16
|
LOGIC_V1_BOOLEAN_TOOPTIP: string;
|
|
5
17
|
LOGIC_V1_BOOLEAN_HELPURL: string;
|
|
18
|
+
LOGIC_V1_IF_TOOLTIP: string;
|
|
19
|
+
LOGIC_V1_IF_HELPURL: string;
|
|
6
20
|
};
|
|
7
21
|
export default _default;
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
LOOP_DO: string;
|
|
3
|
+
LOOP_V1_FOR_TITLE: string;
|
|
4
|
+
LOOP_V1_FOR_EACH_TITLE: string;
|
|
5
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE: string;
|
|
6
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL: string;
|
|
7
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE: string;
|
|
8
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL: string;
|
|
9
|
+
LOOP_V1_WHILE_UNTIL_HELPURL: string;
|
|
2
10
|
LOGIC_BOOLEAN_FALSE: string;
|
|
3
11
|
LOGIC_BOOLEAN_TRUE: string;
|
|
12
|
+
LOGIC_DO: string;
|
|
13
|
+
LOGIC_ELSE: string;
|
|
14
|
+
LOGIC_ELSE_IF: string;
|
|
15
|
+
LOGIC_IF: string;
|
|
4
16
|
LOGIC_V1_BOOLEAN_TOOPTIP: string;
|
|
5
17
|
LOGIC_V1_BOOLEAN_HELPURL: string;
|
|
18
|
+
LOGIC_V1_IF_TOOLTIP: string;
|
|
19
|
+
LOGIC_V1_IF_HELPURL: string;
|
|
6
20
|
};
|
|
7
21
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const toolbox: {
|
|
2
2
|
kind: string;
|
|
3
|
-
contents: {
|
|
3
|
+
contents: ({
|
|
4
4
|
kind: string;
|
|
5
5
|
name: string;
|
|
6
6
|
categorystyle: string;
|
|
@@ -13,6 +13,14 @@ declare const toolbox: {
|
|
|
13
13
|
type: string;
|
|
14
14
|
text?: undefined;
|
|
15
15
|
})[];
|
|
16
|
-
}
|
|
16
|
+
} | {
|
|
17
|
+
kind: string;
|
|
18
|
+
name: string;
|
|
19
|
+
categorystyle: string;
|
|
20
|
+
contents: {
|
|
21
|
+
kind: string;
|
|
22
|
+
type: string;
|
|
23
|
+
}[];
|
|
24
|
+
})[];
|
|
17
25
|
};
|
|
18
26
|
export default toolbox;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const _ = {
|
|
2
|
+
LOGIC_BOOLEAN_FALSE: "false",
|
|
3
|
+
LOGIC_BOOLEAN_TRUE: "true",
|
|
4
|
+
LOGIC_DO: "do",
|
|
5
|
+
LOGIC_ELSE: "else",
|
|
6
|
+
LOGIC_ELSE_IF: "else if",
|
|
7
|
+
LOGIC_IF: "if",
|
|
8
|
+
LOGIC_V1_BOOLEAN_TOOPTIP: "LOGIC_V1_BOOLEAN_TOOPTIP",
|
|
9
|
+
LOGIC_V1_BOOLEAN_HELPURL: "LOGIC_V1_BOOLEAN_HELPURL",
|
|
10
|
+
LOGIC_V1_IF_TOOLTIP: "LOGIC_V1_IF_TOOLTIP",
|
|
11
|
+
LOGIC_V1_IF_HELPURL: "LOGIC_V1_IF_HELPURL"
|
|
12
|
+
}, L = {
|
|
13
|
+
LOOP_DO: "do",
|
|
14
|
+
LOOP_V1_FOR_TITLE: "count with %1 from %2 to %3 by %4",
|
|
15
|
+
LOOP_V1_FOR_EACH_TITLE: "for each item %1 in list %2",
|
|
16
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE: "repeat while",
|
|
17
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL: "repeat until",
|
|
18
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE: "LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE",
|
|
19
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL: "LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL",
|
|
20
|
+
LOOP_V1_WHILE_UNTIL_HELPURL: "LOOP_V1_WHILE_UNTIL_HELPURL"
|
|
21
|
+
}, O = {
|
|
22
|
+
..._,
|
|
23
|
+
...L
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
O as default
|
|
27
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".blocklyToolboxDiv{overflow-x:hidden;width:56px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
|
|
2
|
-
import { getCurrentInstance as
|
|
3
|
-
import { openConfirmDlg as
|
|
2
|
+
import { getCurrentInstance as b, inject as d, defineComponent as m, ref as C, onMounted as k, nextTick as S, onBeforeUnmount as T, watch as y, openBlock as L, createElementBlock as E, withDirectives as I, createElementVNode as v } from "vue";
|
|
3
|
+
import { openConfirmDlg as B, openPromptDlg as R, useViewStack as x } from "x-essential-lib";
|
|
4
4
|
import * as e from "blockly/core";
|
|
5
|
-
import { javascriptGenerator as
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
9
|
-
throw new Error(`[Vuetify] ${
|
|
10
|
-
return
|
|
5
|
+
import { javascriptGenerator as P, Order as w } from "blockly/javascript";
|
|
6
|
+
function F(o, t) {
|
|
7
|
+
const n = b();
|
|
8
|
+
if (!n)
|
|
9
|
+
throw new Error(`[Vuetify] ${o} must be called from inside a setup function`);
|
|
10
|
+
return n;
|
|
11
11
|
}
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
12
|
+
const M = Symbol.for("vuetify:locale");
|
|
13
|
+
function K() {
|
|
14
|
+
const o = d(M);
|
|
15
|
+
if (!o)
|
|
16
16
|
throw new Error("[Vuetify] Could not find injected locale instance");
|
|
17
|
-
return
|
|
17
|
+
return o;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
19
|
+
const A = Symbol.for("vuetify:theme");
|
|
20
|
+
function D() {
|
|
21
|
+
F("useTheme");
|
|
22
|
+
const o = d(A, null);
|
|
23
|
+
if (!o)
|
|
24
24
|
throw new Error("Could not find Vuetify theme injection");
|
|
25
|
-
return
|
|
25
|
+
return o;
|
|
26
26
|
}
|
|
27
27
|
e.defineBlocksWithJsonArray([
|
|
28
28
|
{
|
|
@@ -44,39 +44,429 @@ e.defineBlocksWithJsonArray([
|
|
|
44
44
|
helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
|
|
45
45
|
}
|
|
46
46
|
]);
|
|
47
|
-
|
|
48
|
-
return [
|
|
47
|
+
P.forBlock.boolean_v1 = function(o) {
|
|
48
|
+
return [o.getFieldValue("BOOL") === "TRUE" ? "true" : "false", w.ATOMIC];
|
|
49
|
+
};
|
|
50
|
+
const N = {
|
|
51
|
+
elseIfCount_: 0,
|
|
52
|
+
hasElse_: !1,
|
|
53
|
+
mutationToDom: function() {
|
|
54
|
+
if (this.elseIfCount_ <= 0 && !this.hasElse_)
|
|
55
|
+
return null;
|
|
56
|
+
const o = e.utils.xml.createElement("mutation");
|
|
57
|
+
return this.elseIfCount_ > 0 && o.setAttribute("elseIf", String(this.elseIfCount_)), this.hasElse_ && o.setAttribute("else", "TRUE"), o;
|
|
58
|
+
},
|
|
59
|
+
domToMutation: function(o) {
|
|
60
|
+
this.elseIfCount_ = parseInt(o.getAttribute("elseif"), 10) || 0, this.hasElse_ = o.getAttribute("else") === "TRUE", this.rebuildShape_();
|
|
61
|
+
},
|
|
62
|
+
saveExtraState: function() {
|
|
63
|
+
if (this.elseIfCount_ <= 0 && !this.hasElse_)
|
|
64
|
+
return null;
|
|
65
|
+
const o = /* @__PURE__ */ Object.create(null);
|
|
66
|
+
return this.elseIfCount_ > 0 && (o.elseIfCount = this.elseIfCount_), this.hasElse_ && (o.hasElse = !0), o;
|
|
67
|
+
},
|
|
68
|
+
loadExtraState: function(o) {
|
|
69
|
+
this.elseIfCount_ = o.elseIfCount || 0, this.hasElse_ = !!o.hasElse, this.updateShape_();
|
|
70
|
+
},
|
|
71
|
+
decompose: function(o) {
|
|
72
|
+
const t = o.newBlock("if_if_v1");
|
|
73
|
+
t.initSvg();
|
|
74
|
+
let n = t.nextConnection;
|
|
75
|
+
for (let r = 0; r < this.elseIfCount_; r++) {
|
|
76
|
+
const s = o.newBlock(
|
|
77
|
+
"if_else_if_v1"
|
|
78
|
+
);
|
|
79
|
+
s.initSvg(), n.connect(s.previousConnection), n = s.nextConnection;
|
|
80
|
+
}
|
|
81
|
+
if (this.hasElse_) {
|
|
82
|
+
const r = o.newBlock("if_else_v1");
|
|
83
|
+
r.initSvg(), n.connect(r.previousConnection);
|
|
84
|
+
}
|
|
85
|
+
return t;
|
|
86
|
+
},
|
|
87
|
+
compose: function(o) {
|
|
88
|
+
let t = o.nextConnection.targetBlock();
|
|
89
|
+
this.elseIfCount_ = 0, this.hasElse_ = !1;
|
|
90
|
+
const n = [null], r = [null];
|
|
91
|
+
let s = null;
|
|
92
|
+
for (; t; ) {
|
|
93
|
+
if (t.isInsertionMarker()) {
|
|
94
|
+
t = t.getNextBlock();
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
switch (t.type) {
|
|
98
|
+
case "if_else_if_v1":
|
|
99
|
+
this.elseIfCount_++, n.push(
|
|
100
|
+
t.valueConnection_
|
|
101
|
+
), r.push(
|
|
102
|
+
t.statementConnection_
|
|
103
|
+
);
|
|
104
|
+
break;
|
|
105
|
+
case "if_else_v1":
|
|
106
|
+
this.hasElse_ = !0, s = t.statementConnection_;
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
throw TypeError("Unknown block type: " + t.type);
|
|
110
|
+
}
|
|
111
|
+
t = t.getNextBlock();
|
|
112
|
+
}
|
|
113
|
+
this.updateShape_(), this.reconnectChildBlocks_(
|
|
114
|
+
n,
|
|
115
|
+
r,
|
|
116
|
+
s
|
|
117
|
+
);
|
|
118
|
+
},
|
|
119
|
+
saveConnections: function(o) {
|
|
120
|
+
let t = o.nextConnection.targetBlock(), n = 1;
|
|
121
|
+
for (; t; ) {
|
|
122
|
+
if (t.isInsertionMarker()) {
|
|
123
|
+
t = t.getNextBlock();
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
switch (t.type) {
|
|
127
|
+
case "if_else_if_v1": {
|
|
128
|
+
const r = this.getInput("IF" + n), s = this.getInput("DO" + n);
|
|
129
|
+
t.valueConnection_ = r && r.connection.targetConnection, t.statementConnection_ = s && s.connection.targetConnection, n++;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "if_else_v1": {
|
|
133
|
+
const r = this.getInput("ELSE");
|
|
134
|
+
t.statementConnection_ = r && r.connection.targetConnection;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
default:
|
|
138
|
+
throw TypeError("Unknown block type: " + t.type);
|
|
139
|
+
}
|
|
140
|
+
t = t.getNextBlock();
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
rebuildShape_: function() {
|
|
144
|
+
const o = [null], t = [null];
|
|
145
|
+
let n = null;
|
|
146
|
+
this.getInput("ELSE") && (n = this.getInput("ELSE").connection.targetConnection);
|
|
147
|
+
for (let r = 1; this.getInput("IF" + r); r++) {
|
|
148
|
+
const s = this.getInput("IF" + r), i = this.getInput("DO" + r);
|
|
149
|
+
o.push(s.connection.targetConnection), t.push(i.connection.targetConnection);
|
|
150
|
+
}
|
|
151
|
+
this.updateShape_(), this.reconnectChildBlocks_(
|
|
152
|
+
o,
|
|
153
|
+
t,
|
|
154
|
+
n
|
|
155
|
+
);
|
|
156
|
+
},
|
|
157
|
+
updateShape_: function() {
|
|
158
|
+
this.getInput("ELSE") && this.removeInput("ELSE");
|
|
159
|
+
for (let o = 1; this.getInput("IF" + o); o++)
|
|
160
|
+
this.removeInput("IF" + o), this.removeInput("DO" + o);
|
|
161
|
+
for (let o = 1; o <= this.elseIfCount_; o++)
|
|
162
|
+
this.appendValueInput("IF" + o).setCheck("Boolean").appendField(e.Msg.LOGIC_ELSE_IF), this.appendStatementInput("DO" + o).appendField(e.Msg.LOGIC_DO);
|
|
163
|
+
this.hasElse_ && this.appendStatementInput("ELSE").appendField(e.Msg.LOGIC_ELSE);
|
|
164
|
+
},
|
|
165
|
+
reconnectChildBlocks_: function(o, t, n) {
|
|
166
|
+
var r, s;
|
|
167
|
+
for (let i = 1; i <= this.elseIfCount_; i++)
|
|
168
|
+
(r = o[i]) == null || r.reconnect(this, "IF" + i), (s = t[i]) == null || s.reconnect(this, "DO" + i);
|
|
169
|
+
n == null || n.reconnect(this, "ELSE");
|
|
170
|
+
}
|
|
49
171
|
};
|
|
50
|
-
e.
|
|
51
|
-
|
|
172
|
+
e.Extensions.registerMutator(
|
|
173
|
+
"if_v1_mutator",
|
|
174
|
+
N,
|
|
175
|
+
void 0,
|
|
176
|
+
["if_else_if_v1", "if_else_v1"]
|
|
177
|
+
);
|
|
178
|
+
e.defineBlocksWithJsonArray([
|
|
179
|
+
{
|
|
180
|
+
type: "if_v1",
|
|
181
|
+
message0: "%{BKY_LOGIC_IF} %1",
|
|
182
|
+
args0: [
|
|
183
|
+
{
|
|
184
|
+
type: "input_value",
|
|
185
|
+
name: "IF0",
|
|
186
|
+
check: "Boolean"
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
message1: "%{BKY_LOGIC_DO} %1",
|
|
190
|
+
args1: [
|
|
191
|
+
{
|
|
192
|
+
type: "input_statement",
|
|
193
|
+
name: "DO0"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
previousStatement: null,
|
|
197
|
+
nextStatement: null,
|
|
198
|
+
style: "logic_blocks",
|
|
199
|
+
helpUrl: "%{BKY_LOGIC_V1_IF_HELPURL",
|
|
200
|
+
suppressPrefixSuffix: !0,
|
|
201
|
+
mutator: "if_v1_mutator"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
type: "if_if_v1",
|
|
205
|
+
message0: "%{BKY_LOGIC_IF}",
|
|
206
|
+
nextStatement: null,
|
|
207
|
+
enableContextMenu: !1,
|
|
208
|
+
style: "logic_blocks"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
type: "if_else_if_v1",
|
|
212
|
+
message0: "%{BKY_LOGIC_ELSE_IF}",
|
|
213
|
+
previousStatement: null,
|
|
214
|
+
nextStatement: null,
|
|
215
|
+
enableContextMenu: !1,
|
|
216
|
+
style: "logic_blocks"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
type: "if_else_v1",
|
|
220
|
+
message0: "%{BKY_LOGIC_ELSE}",
|
|
221
|
+
previousStatement: null,
|
|
222
|
+
enableContextMenu: !1,
|
|
223
|
+
style: "logic_blocks"
|
|
224
|
+
}
|
|
225
|
+
]);
|
|
226
|
+
const V = {
|
|
227
|
+
customContextMenu: function(o) {
|
|
228
|
+
if (this.isInFlyout)
|
|
229
|
+
return;
|
|
230
|
+
const t = this.getField("VAR"), n = t.getVariable(), r = n == null ? void 0 : n.name;
|
|
231
|
+
if (!this.isCollapsed() && r) {
|
|
232
|
+
const s = {
|
|
233
|
+
type: "variables_get",
|
|
234
|
+
fields: {
|
|
235
|
+
VAR: t.saveState(!0)
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
o.push({
|
|
239
|
+
enabled: !0,
|
|
240
|
+
text: e.Msg.VARIABLES_SET_CREATE_GET.replace("%1", r),
|
|
241
|
+
callback: e.ContextMenu.callbackFactory(this, s)
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
e.Extensions.registerMixin(
|
|
247
|
+
"contextMenu_newGetVariableBlock_v1",
|
|
248
|
+
V
|
|
249
|
+
);
|
|
250
|
+
e.Extensions.register(
|
|
251
|
+
"flow_control_tooltip_v1",
|
|
252
|
+
e.Extensions.buildTooltipForDropdown("MODE", {
|
|
253
|
+
BREAK: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_BREAK}",
|
|
254
|
+
CONTINUE: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}"
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
const U = /* @__PURE__ */ new Set([
|
|
258
|
+
"repeat_v1",
|
|
259
|
+
"for_each_v1",
|
|
260
|
+
"for_v1",
|
|
261
|
+
"while_until_v1"
|
|
262
|
+
]), Y = {
|
|
263
|
+
getSurroundLoop: function() {
|
|
264
|
+
let o = this;
|
|
265
|
+
do {
|
|
266
|
+
if (U.has(o.type))
|
|
267
|
+
return !0;
|
|
268
|
+
o = o == null ? void 0 : o.getSurroundParent();
|
|
269
|
+
} while (o);
|
|
270
|
+
return !1;
|
|
271
|
+
},
|
|
272
|
+
onchange: function(o) {
|
|
273
|
+
const t = this.workspace;
|
|
274
|
+
if (!t.isDragging || t.isDragging() || o.type !== e.Events.BLOCK_MOVE && o.type !== e.Events.BLOCK_CREATE)
|
|
275
|
+
return;
|
|
276
|
+
const n = this.getSurroundLoop();
|
|
277
|
+
if (console.log(o.type, n), this.setWarningText(
|
|
278
|
+
n ? null : e.Msg.LOOP_FLOW_CONTROL_WARNING
|
|
279
|
+
), !this.isInFlyout)
|
|
280
|
+
try {
|
|
281
|
+
e.Events.setRecordUndo(!1), this.setDisabledReason(!n, "FLOW_CONTROL_NOT_IN_LOOP");
|
|
282
|
+
} finally {
|
|
283
|
+
e.Events.setRecordUndo(!0);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
e.Extensions.registerMixin(
|
|
288
|
+
"flow_control_in_loop_check_v1",
|
|
289
|
+
Y
|
|
290
|
+
);
|
|
291
|
+
e.defineBlocksWithJsonArray([
|
|
292
|
+
{
|
|
293
|
+
type: "flow_control_v1",
|
|
294
|
+
message0: "%1",
|
|
295
|
+
args0: [
|
|
296
|
+
{
|
|
297
|
+
type: "field_dropdown",
|
|
298
|
+
name: "MODE",
|
|
299
|
+
options: [
|
|
300
|
+
["%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_BREAK}", "BREAK"],
|
|
301
|
+
["%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_CONTINUE}", "CONTINUE"]
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
],
|
|
305
|
+
previousStatement: null,
|
|
306
|
+
style: "loop_blocks",
|
|
307
|
+
helpurl: "%{BKY_LOOP_V1_FLOW_CONTROL_HELPURL}",
|
|
308
|
+
suppressPrefixSuffix: !0,
|
|
309
|
+
extensions: ["flow_control_tooltip_v1", "flow_control_in_loop_check_v1"]
|
|
310
|
+
}
|
|
311
|
+
]);
|
|
312
|
+
e.Extensions.register(
|
|
313
|
+
"for_tooltip_v1",
|
|
314
|
+
e.Extensions.buildTooltipWithFieldText(
|
|
315
|
+
"%{BKY_LOOP_V1_FOR_TOOLTIP}",
|
|
316
|
+
"VAR"
|
|
317
|
+
)
|
|
318
|
+
);
|
|
319
|
+
e.defineBlocksWithJsonArray([
|
|
320
|
+
{
|
|
321
|
+
type: "for_v1",
|
|
322
|
+
message0: "%{BKY_LOOP_V1_FOR_TITLE}",
|
|
323
|
+
args0: [
|
|
324
|
+
{
|
|
325
|
+
type: "field_variable",
|
|
326
|
+
name: "VAR",
|
|
327
|
+
variable: null
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
type: "input_value",
|
|
331
|
+
name: "FROM",
|
|
332
|
+
check: "Number",
|
|
333
|
+
align: "RIGHT"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
type: "input_value",
|
|
337
|
+
name: "TO",
|
|
338
|
+
check: "Number",
|
|
339
|
+
align: "RIGHT"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
type: "input_value",
|
|
343
|
+
name: "BY",
|
|
344
|
+
check: "Number",
|
|
345
|
+
align: "RIGHT"
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
message1: "%{BKY_LOOP_DO} %1",
|
|
349
|
+
args1: [
|
|
350
|
+
{
|
|
351
|
+
type: "input_statement",
|
|
352
|
+
name: "DO"
|
|
353
|
+
}
|
|
354
|
+
],
|
|
355
|
+
inputsInline: !0,
|
|
356
|
+
previousStatement: null,
|
|
357
|
+
nextStatement: null,
|
|
358
|
+
style: "loop_blocks",
|
|
359
|
+
helpUrl: "%{BKY_LOOP_V1_FOR_HELPURL}",
|
|
360
|
+
extensions: ["contextMenu_newGetVariableBlock_v1", "for_tooltip_v1"]
|
|
361
|
+
}
|
|
362
|
+
]);
|
|
363
|
+
e.Extensions.register(
|
|
364
|
+
"for_each_tooltip_v1",
|
|
365
|
+
e.Extensions.buildTooltipWithFieldText(
|
|
366
|
+
"%{BKY_LOOP_V1_FOR_EACH_TOOLTIP}",
|
|
367
|
+
"VAR"
|
|
368
|
+
)
|
|
369
|
+
);
|
|
370
|
+
e.defineBlocksWithJsonArray([
|
|
371
|
+
{
|
|
372
|
+
type: "for_each_v1",
|
|
373
|
+
message0: "%{BKY_LOOP_V1_FOR_EACH_TITLE}",
|
|
374
|
+
args0: [
|
|
375
|
+
{
|
|
376
|
+
type: "field_variable",
|
|
377
|
+
name: "VAR",
|
|
378
|
+
variable: null
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
type: "input_value",
|
|
382
|
+
name: "LIST",
|
|
383
|
+
check: "Array"
|
|
384
|
+
}
|
|
385
|
+
],
|
|
386
|
+
message1: "%{BKY_LOOP_DO} %1",
|
|
387
|
+
args1: [
|
|
388
|
+
{
|
|
389
|
+
type: "input_statement",
|
|
390
|
+
name: "DO"
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
previousStatement: null,
|
|
394
|
+
nextStatement: null,
|
|
395
|
+
style: "loop_blocks",
|
|
396
|
+
helpUrl: "%{BKY_LOOP_V1_FOR_EACH_HELPURL}",
|
|
397
|
+
extensions: ["contextMenu_newGetVariableBlock_v1", "for_each_tooltip_v1"]
|
|
398
|
+
}
|
|
399
|
+
]);
|
|
400
|
+
e.Extensions.register(
|
|
401
|
+
"while_until_tooltip_v1",
|
|
402
|
+
e.Extensions.buildTooltipForDropdown("MODE", {
|
|
403
|
+
WHILE: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE}",
|
|
404
|
+
UNTIL: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}"
|
|
405
|
+
})
|
|
406
|
+
);
|
|
407
|
+
e.defineBlocksWithJsonArray([
|
|
408
|
+
{
|
|
409
|
+
type: "while_until_v1",
|
|
410
|
+
message0: "%1 %2",
|
|
411
|
+
args0: [
|
|
412
|
+
{
|
|
413
|
+
type: "field_dropdown",
|
|
414
|
+
name: "MODE",
|
|
415
|
+
options: [
|
|
416
|
+
["%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE}", "WHILE"],
|
|
417
|
+
["%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL}", "UNTIL"]
|
|
418
|
+
]
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
type: "input_value",
|
|
422
|
+
name: "BOOL",
|
|
423
|
+
check: "Boolean"
|
|
424
|
+
}
|
|
425
|
+
],
|
|
426
|
+
message1: "%{BKY_LOOP_DO} %1",
|
|
427
|
+
args1: [
|
|
428
|
+
{
|
|
429
|
+
type: "input_statement",
|
|
430
|
+
name: "DO"
|
|
431
|
+
}
|
|
432
|
+
],
|
|
433
|
+
previousStatement: null,
|
|
434
|
+
nextStatement: null,
|
|
435
|
+
style: "loop_blocks",
|
|
436
|
+
helpUrl: "%{BKY_LOOP_V1_WHILE_UNTIL_HELPURL}",
|
|
437
|
+
extensions: ["while_until_tooltip_v1"]
|
|
438
|
+
}
|
|
439
|
+
]);
|
|
440
|
+
e.dialog.setConfirm(async (o, t) => {
|
|
441
|
+
const n = await B({
|
|
52
442
|
title: "",
|
|
53
|
-
text:
|
|
443
|
+
text: o
|
|
54
444
|
});
|
|
55
|
-
t(!!
|
|
445
|
+
t(!!n);
|
|
56
446
|
});
|
|
57
|
-
e.dialog.setPrompt(async (
|
|
58
|
-
const r = await
|
|
447
|
+
e.dialog.setPrompt(async (o, t, n) => {
|
|
448
|
+
const r = await R({
|
|
59
449
|
title: "",
|
|
60
450
|
value: t
|
|
61
451
|
});
|
|
62
|
-
|
|
452
|
+
n(r);
|
|
63
453
|
});
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
454
|
+
const W = (o, t) => {
|
|
455
|
+
const n = o[t];
|
|
456
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((r, s) => {
|
|
457
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(s.bind(null, new Error("Unknown variable dynamic import: " + t)));
|
|
68
458
|
});
|
|
69
459
|
};
|
|
70
|
-
async function
|
|
71
|
-
const t = await
|
|
460
|
+
async function f(o) {
|
|
461
|
+
const t = await W(/* @__PURE__ */ Object.assign({ "./msg/en.ts": () => import("./en-Djut8W3R.js"), "./msg/zhHans.ts": () => import("./zhHans-D_qcn_1f.js") }), `./msg/${o}.ts`);
|
|
72
462
|
e.setLocale(t.default);
|
|
73
463
|
}
|
|
74
|
-
class
|
|
75
|
-
init({ contextMenu: t = !0, shortcut:
|
|
464
|
+
class G {
|
|
465
|
+
init({ contextMenu: t = !0, shortcut: n = !0 } = {
|
|
76
466
|
contextMenu: !0,
|
|
77
467
|
shortcut: !0
|
|
78
468
|
}) {
|
|
79
|
-
t && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()),
|
|
469
|
+
t && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), n && (e.ShortcutRegistry.registry.unregister(
|
|
80
470
|
e.ShortcutItems.names.COPY
|
|
81
471
|
), e.ShortcutRegistry.registry.unregister(
|
|
82
472
|
e.ShortcutItems.names.CUT
|
|
@@ -90,14 +480,14 @@ class V {
|
|
|
90
480
|
return e.Msg.CROSS_TAB_COPY ? e.Msg.CROSS_TAB_COPY : "Copy";
|
|
91
481
|
},
|
|
92
482
|
preconditionFn: function() {
|
|
93
|
-
const
|
|
94
|
-
return !
|
|
483
|
+
const n = e.getSelected();
|
|
484
|
+
return !n || !e.isDeletable(n) || !n.isDeletable() || !e.isDraggable(n) || !n.isMovable() || !e.isCopyable(n) ? "disabled" : "enabled";
|
|
95
485
|
},
|
|
96
|
-
callback: function(
|
|
486
|
+
callback: function(n) {
|
|
97
487
|
var r;
|
|
98
488
|
localStorage.setItem(
|
|
99
489
|
"blocklyStash",
|
|
100
|
-
JSON.stringify((r =
|
|
490
|
+
JSON.stringify((r = n.block) == null ? void 0 : r.toCopyData())
|
|
101
491
|
);
|
|
102
492
|
},
|
|
103
493
|
scopeType: e.ContextMenuRegistry.ScopeType.BLOCK,
|
|
@@ -111,20 +501,20 @@ class V {
|
|
|
111
501
|
displayText: function() {
|
|
112
502
|
return e.Msg.CROSS_TAB_PASTE ? e.Msg.CROSS_TAB_PASTE : "Paste";
|
|
113
503
|
},
|
|
114
|
-
preconditionFn: function(
|
|
115
|
-
var
|
|
504
|
+
preconditionFn: function(n) {
|
|
505
|
+
var i;
|
|
116
506
|
const r = localStorage.getItem("blocklyStash");
|
|
117
507
|
if (!r)
|
|
118
508
|
return "disabled";
|
|
119
|
-
const
|
|
120
|
-
return !
|
|
509
|
+
const s = JSON.parse(r);
|
|
510
|
+
return !s || !((i = n.workspace) != null && i.isCapacityAvailable(s.typeCounts)) ? "disabled" : "enabled";
|
|
121
511
|
},
|
|
122
|
-
callback: function(
|
|
512
|
+
callback: function(n) {
|
|
123
513
|
const r = localStorage.getItem("blocklyStash");
|
|
124
514
|
if (!r)
|
|
125
515
|
return;
|
|
126
|
-
const
|
|
127
|
-
|
|
516
|
+
const s = JSON.parse(r);
|
|
517
|
+
s && n.workspace && e.clipboard.paste(s, n.workspace);
|
|
128
518
|
},
|
|
129
519
|
scopeType: e.ContextMenuRegistry.ScopeType.WORKSPACE,
|
|
130
520
|
id: "blockPasteFromStorage",
|
|
@@ -136,161 +526,161 @@ class V {
|
|
|
136
526
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
137
527
|
e.utils.KeyCodes.C,
|
|
138
528
|
[e.utils.KeyCodes.CTRL]
|
|
139
|
-
),
|
|
529
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
140
530
|
e.utils.KeyCodes.C,
|
|
141
531
|
[e.utils.KeyCodes.ALT]
|
|
142
532
|
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
143
533
|
e.utils.KeyCodes.C,
|
|
144
534
|
[e.utils.KeyCodes.META]
|
|
145
|
-
),
|
|
535
|
+
), s = {
|
|
146
536
|
name: "copy",
|
|
147
|
-
preconditionFn: function(
|
|
148
|
-
if (
|
|
537
|
+
preconditionFn: function(i) {
|
|
538
|
+
if (i.options.readOnly || e.Gesture.inProgress())
|
|
149
539
|
return !1;
|
|
150
|
-
const n = e.getSelected();
|
|
151
|
-
return !(!n || !e.isDeletable(n) || !n.isDeletable() || !e.isDraggable(n) || !n.isMovable() || !e.isCopyable(n));
|
|
152
|
-
},
|
|
153
|
-
callback: function(l, n) {
|
|
154
|
-
n.preventDefault();
|
|
155
540
|
const a = e.getSelected();
|
|
156
|
-
|
|
541
|
+
return !(!a || !e.isDeletable(a) || !a.isDeletable() || !e.isDraggable(a) || !a.isMovable() || !e.isCopyable(a));
|
|
542
|
+
},
|
|
543
|
+
callback: function(i, a) {
|
|
544
|
+
a.preventDefault();
|
|
545
|
+
const l = e.getSelected();
|
|
546
|
+
if (!l || !e.isCopyable(l))
|
|
157
547
|
return !1;
|
|
158
|
-
const c =
|
|
159
|
-
return c ? (
|
|
548
|
+
const c = l.toCopyData();
|
|
549
|
+
return c ? (i.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
|
|
160
550
|
},
|
|
161
|
-
keyCodes: [t,
|
|
551
|
+
keyCodes: [t, n, r]
|
|
162
552
|
};
|
|
163
|
-
e.ShortcutRegistry.registry.register(
|
|
553
|
+
e.ShortcutRegistry.registry.register(s);
|
|
164
554
|
}
|
|
165
555
|
blockCutToStorageShortcut() {
|
|
166
556
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
167
557
|
e.utils.KeyCodes.X,
|
|
168
558
|
[e.utils.KeyCodes.CTRL]
|
|
169
|
-
),
|
|
559
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
170
560
|
e.utils.KeyCodes.X,
|
|
171
561
|
[e.utils.KeyCodes.ALT]
|
|
172
562
|
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
173
563
|
e.utils.KeyCodes.X,
|
|
174
564
|
[e.utils.KeyCodes.META]
|
|
175
|
-
),
|
|
565
|
+
), s = {
|
|
176
566
|
name: "cut",
|
|
177
|
-
preconditionFn: function(
|
|
178
|
-
if (
|
|
567
|
+
preconditionFn: function(i) {
|
|
568
|
+
if (i.options.readOnly || e.Gesture.inProgress())
|
|
179
569
|
return !1;
|
|
180
|
-
const n = e.getSelected();
|
|
181
|
-
return !(!n || !e.isDeletable(n) || !n.isDeletable() || !e.isDraggable(n) || !n.isMovable() || !e.isCopyable(n) || n.workspace.isFlyout);
|
|
182
|
-
},
|
|
183
|
-
callback: function(l, n) {
|
|
184
|
-
n.preventDefault();
|
|
185
570
|
const a = e.getSelected();
|
|
186
|
-
|
|
571
|
+
return !(!a || !e.isDeletable(a) || !a.isDeletable() || !e.isDraggable(a) || !a.isMovable() || !e.isCopyable(a) || a.workspace.isFlyout);
|
|
572
|
+
},
|
|
573
|
+
callback: function(i, a) {
|
|
574
|
+
a.preventDefault();
|
|
575
|
+
const l = e.getSelected();
|
|
576
|
+
if (!l || !e.isDeletable(l) || !l.isDeletable() || !e.isCopyable(l))
|
|
187
577
|
return !1;
|
|
188
|
-
const c =
|
|
189
|
-
return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)),
|
|
578
|
+
const c = l.toCopyData();
|
|
579
|
+
return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), l instanceof e.BlockSvg ? l.checkAndDelete() : l.dispose(), !0) : !1;
|
|
190
580
|
},
|
|
191
|
-
keyCodes: [t,
|
|
581
|
+
keyCodes: [t, n, r]
|
|
192
582
|
};
|
|
193
|
-
e.ShortcutRegistry.registry.register(
|
|
583
|
+
e.ShortcutRegistry.registry.register(s);
|
|
194
584
|
}
|
|
195
585
|
blockPasteFromStorageShortcut() {
|
|
196
586
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
197
587
|
e.utils.KeyCodes.V,
|
|
198
588
|
[e.utils.KeyCodes.CTRL]
|
|
199
|
-
),
|
|
589
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
200
590
|
e.utils.KeyCodes.V,
|
|
201
591
|
[e.utils.KeyCodes.ALT]
|
|
202
592
|
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
203
593
|
e.utils.KeyCodes.V,
|
|
204
594
|
[e.utils.KeyCodes.META]
|
|
205
|
-
),
|
|
595
|
+
), s = {
|
|
206
596
|
name: "paste",
|
|
207
|
-
preconditionFn: function(
|
|
208
|
-
if (
|
|
209
|
-
return !1;
|
|
210
|
-
const n = localStorage.getItem("blocklyStash");
|
|
211
|
-
if (!n)
|
|
597
|
+
preconditionFn: function(i) {
|
|
598
|
+
if (i.options.readOnly || e.Gesture.inProgress())
|
|
212
599
|
return !1;
|
|
213
|
-
const a = JSON.parse(n);
|
|
214
|
-
return !(!a || !l.isCapacityAvailable(a.typeCounts));
|
|
215
|
-
},
|
|
216
|
-
callback: function(l, n) {
|
|
217
|
-
n.preventDefault();
|
|
218
600
|
const a = localStorage.getItem("blocklyStash");
|
|
219
601
|
if (!a)
|
|
220
602
|
return !1;
|
|
221
|
-
const
|
|
222
|
-
return
|
|
603
|
+
const l = JSON.parse(a);
|
|
604
|
+
return !(!l || !i.isCapacityAvailable(l.typeCounts));
|
|
223
605
|
},
|
|
224
|
-
|
|
606
|
+
callback: function(i, a) {
|
|
607
|
+
a.preventDefault();
|
|
608
|
+
const l = localStorage.getItem("blocklyStash");
|
|
609
|
+
if (!l)
|
|
610
|
+
return !1;
|
|
611
|
+
const c = JSON.parse(l);
|
|
612
|
+
return c ? (e.clipboard.paste(c, i), !0) : !1;
|
|
613
|
+
},
|
|
614
|
+
keyCodes: [t, n, r]
|
|
225
615
|
};
|
|
226
|
-
e.ShortcutRegistry.registry.register(
|
|
616
|
+
e.ShortcutRegistry.registry.register(s);
|
|
227
617
|
}
|
|
228
618
|
}
|
|
229
|
-
class
|
|
619
|
+
class H {
|
|
230
620
|
init() {
|
|
231
621
|
const t = e.ContextMenuRegistry.registry.getItem("cleanWorkspace");
|
|
232
|
-
t && (t.callback = function(
|
|
233
|
-
const r =
|
|
622
|
+
t && (t.callback = function(n) {
|
|
623
|
+
const r = n.workspace;
|
|
234
624
|
if (!r)
|
|
235
625
|
return;
|
|
236
626
|
r.setResizesEnabled(!1), e.Events.setGroup(!0);
|
|
237
|
-
const
|
|
238
|
-
let
|
|
239
|
-
for (let
|
|
240
|
-
if (!
|
|
627
|
+
const s = r.getTopBlocks(!0);
|
|
628
|
+
let i = 0;
|
|
629
|
+
for (let a = 0, l; l = s[a]; a++) {
|
|
630
|
+
if (!l.isMovable())
|
|
241
631
|
continue;
|
|
242
|
-
const c =
|
|
243
|
-
|
|
632
|
+
const c = l.getRelativeToSurfaceXY();
|
|
633
|
+
l.moveBy(-c.x, i - c.y, ["cleanup"]), l.snapToGrid(), i = l.getRelativeToSurfaceXY().y + l.getHeightWidth().height + 100;
|
|
244
634
|
}
|
|
245
635
|
e.Events.setGroup(!1), r.setResizesEnabled(!0);
|
|
246
636
|
});
|
|
247
637
|
}
|
|
248
638
|
}
|
|
249
|
-
function
|
|
250
|
-
const t =
|
|
251
|
-
return t &&
|
|
639
|
+
function g(o) {
|
|
640
|
+
const t = o.getParent();
|
|
641
|
+
return t && g(t) ? !0 : !t && !!(o.outputConnection || o.previousConnection);
|
|
252
642
|
}
|
|
253
|
-
class
|
|
643
|
+
class z {
|
|
254
644
|
init() {
|
|
255
645
|
const t = e.ContextMenuRegistry.registry.getItem("blockDisable");
|
|
256
|
-
t && (t.preconditionFn = function(
|
|
257
|
-
const r =
|
|
258
|
-
return r && !r.isInFlyout && r.workspace.options.disable && r.isEditable() ? r.getInheritedDisabled() ||
|
|
646
|
+
t && (t.preconditionFn = function(n) {
|
|
647
|
+
const r = n.block;
|
|
648
|
+
return r && !r.isInFlyout && r.workspace.options.disable && r.isEditable() ? r.getInheritedDisabled() || g(r) ? "disabled" : "enabled" : "hidden";
|
|
259
649
|
});
|
|
260
650
|
}
|
|
261
651
|
}
|
|
262
|
-
class
|
|
263
|
-
addBlockListeners_(t,
|
|
264
|
-
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t,
|
|
652
|
+
class X extends e.HorizontalFlyout {
|
|
653
|
+
addBlockListeners_(t, n, r) {
|
|
654
|
+
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, n, r);
|
|
265
655
|
}
|
|
266
656
|
isBlockCreatable(t) {
|
|
267
657
|
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
268
658
|
}
|
|
269
659
|
}
|
|
270
|
-
class
|
|
271
|
-
addBlockListeners_(t,
|
|
272
|
-
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t,
|
|
660
|
+
class J extends e.VerticalFlyout {
|
|
661
|
+
addBlockListeners_(t, n, r) {
|
|
662
|
+
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, n, r);
|
|
273
663
|
}
|
|
274
664
|
isBlockCreatable(t) {
|
|
275
665
|
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
276
666
|
}
|
|
277
667
|
}
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
668
|
+
const j = new G();
|
|
669
|
+
j.init({ contextMenu: !0, shortcut: !0 });
|
|
670
|
+
const $ = new H();
|
|
671
|
+
$.init();
|
|
672
|
+
const q = new z();
|
|
673
|
+
q.init();
|
|
284
674
|
e.registry.register(
|
|
285
675
|
e.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
|
|
286
676
|
e.registry.DEFAULT,
|
|
287
|
-
|
|
677
|
+
X,
|
|
288
678
|
!0
|
|
289
679
|
);
|
|
290
680
|
e.registry.register(
|
|
291
681
|
e.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
|
|
292
682
|
e.registry.DEFAULT,
|
|
293
|
-
|
|
683
|
+
J,
|
|
294
684
|
!0
|
|
295
685
|
);
|
|
296
686
|
e.Themes.Classic.blockStyles = {
|
|
@@ -417,7 +807,7 @@ e.Themes.Classic.categoryStyles = {
|
|
|
417
807
|
colour: "#a55b80"
|
|
418
808
|
}
|
|
419
809
|
};
|
|
420
|
-
const
|
|
810
|
+
const Z = e.Theme.defineTheme("light", {
|
|
421
811
|
name: "light",
|
|
422
812
|
base: e.Themes.Classic,
|
|
423
813
|
componentStyles: {
|
|
@@ -433,7 +823,7 @@ const $ = e.Theme.defineTheme("light", {
|
|
|
433
823
|
scrollbarOpacity: 0.4,
|
|
434
824
|
cursorColour: ""
|
|
435
825
|
}
|
|
436
|
-
}),
|
|
826
|
+
}), Q = e.Theme.defineTheme("dark", {
|
|
437
827
|
name: "dark",
|
|
438
828
|
base: e.Themes.Classic,
|
|
439
829
|
componentStyles: {
|
|
@@ -450,18 +840,18 @@ const $ = e.Theme.defineTheme("light", {
|
|
|
450
840
|
cursorColour: ""
|
|
451
841
|
}
|
|
452
842
|
});
|
|
453
|
-
function
|
|
843
|
+
function ee(o) {
|
|
454
844
|
const t = e.getMainWorkspace();
|
|
455
|
-
switch (console.log(t),
|
|
845
|
+
switch (console.log(t), o) {
|
|
456
846
|
case "light":
|
|
457
|
-
t.setTheme(
|
|
847
|
+
t.setTheme(Z);
|
|
458
848
|
break;
|
|
459
849
|
case "dark":
|
|
460
|
-
t.setTheme(
|
|
850
|
+
t.setTheme(Q);
|
|
461
851
|
break;
|
|
462
852
|
}
|
|
463
853
|
}
|
|
464
|
-
const
|
|
854
|
+
const te = {
|
|
465
855
|
kind: "category",
|
|
466
856
|
name: "%{BKY_CATEGORY_LOGIC}",
|
|
467
857
|
categorystyle: "logic_category",
|
|
@@ -473,46 +863,72 @@ const q = {
|
|
|
473
863
|
{
|
|
474
864
|
kind: "block",
|
|
475
865
|
type: "boolean_v1"
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
kind: "block",
|
|
869
|
+
type: "if_v1"
|
|
870
|
+
}
|
|
871
|
+
]
|
|
872
|
+
}, oe = {
|
|
873
|
+
kind: "category",
|
|
874
|
+
name: "%{BKY_CATEGORY_LOOP}",
|
|
875
|
+
categorystyle: "loop_category",
|
|
876
|
+
contents: [
|
|
877
|
+
{
|
|
878
|
+
kind: "block",
|
|
879
|
+
type: "while_until_v1"
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
kind: "block",
|
|
883
|
+
type: "flow_control_v1"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
kind: "block",
|
|
887
|
+
type: "for_v1"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
kind: "block",
|
|
891
|
+
type: "for_each_v1"
|
|
476
892
|
}
|
|
477
893
|
]
|
|
478
|
-
},
|
|
894
|
+
}, ne = {
|
|
479
895
|
kind: "categoryToolbox",
|
|
480
|
-
contents: [
|
|
896
|
+
contents: [te, oe]
|
|
481
897
|
};
|
|
482
|
-
function
|
|
483
|
-
var
|
|
484
|
-
const
|
|
485
|
-
passive: !((
|
|
898
|
+
function re(o, t) {
|
|
899
|
+
var s, i;
|
|
900
|
+
const n = t.value, r = {
|
|
901
|
+
passive: !((s = t.modifiers) != null && s.active)
|
|
486
902
|
};
|
|
487
|
-
window.addEventListener("resize",
|
|
488
|
-
handler:
|
|
903
|
+
window.addEventListener("resize", n, r), o._onResize = Object(o._onResize), o._onResize[t.instance.$.uid] = {
|
|
904
|
+
handler: n,
|
|
489
905
|
options: r
|
|
490
|
-
}, (
|
|
906
|
+
}, (i = t.modifiers) != null && i.quiet || n();
|
|
491
907
|
}
|
|
492
|
-
function
|
|
493
|
-
var
|
|
494
|
-
if (!((
|
|
908
|
+
function se(o, t) {
|
|
909
|
+
var s;
|
|
910
|
+
if (!((s = o._onResize) != null && s[t.instance.$.uid]))
|
|
495
911
|
return;
|
|
496
912
|
const {
|
|
497
|
-
handler:
|
|
913
|
+
handler: n,
|
|
498
914
|
options: r
|
|
499
|
-
} =
|
|
500
|
-
window.removeEventListener("resize",
|
|
915
|
+
} = o._onResize[t.instance.$.uid];
|
|
916
|
+
window.removeEventListener("resize", n, r), delete o._onResize[t.instance.$.uid];
|
|
501
917
|
}
|
|
502
|
-
const
|
|
503
|
-
mounted:
|
|
504
|
-
unmounted:
|
|
505
|
-
},
|
|
918
|
+
const ie = {
|
|
919
|
+
mounted: re,
|
|
920
|
+
unmounted: se
|
|
921
|
+
}, le = { class: "position-relative w-100 h-100" }, ae = /* @__PURE__ */ m({
|
|
506
922
|
__name: "index",
|
|
507
923
|
props: {
|
|
508
924
|
type: {},
|
|
509
925
|
version: {}
|
|
510
926
|
},
|
|
511
927
|
emits: ["ready", "change"],
|
|
512
|
-
setup(
|
|
513
|
-
const
|
|
928
|
+
setup(o, { emit: t }) {
|
|
929
|
+
const n = K(), r = D(), { open: s } = x("blocklyEditorFlyout"), i = o, a = t, l = C(null);
|
|
514
930
|
let c;
|
|
515
|
-
const
|
|
931
|
+
const p = {
|
|
516
932
|
grid: {
|
|
517
933
|
length: 2,
|
|
518
934
|
snap: !0,
|
|
@@ -535,48 +951,48 @@ const te = {
|
|
|
535
951
|
wheel: !0
|
|
536
952
|
}
|
|
537
953
|
};
|
|
538
|
-
|
|
539
|
-
if (!
|
|
954
|
+
k(async () => {
|
|
955
|
+
if (!l.value)
|
|
540
956
|
return;
|
|
541
|
-
await
|
|
957
|
+
await f(n.current.value);
|
|
542
958
|
let u;
|
|
543
|
-
|
|
959
|
+
i.type === "app" && i.version === "v1" && (u = ne), p.toolbox = u, c = e.inject(l.value, p), c.addChangeListener(e.Events.disableOrphans), c.addChangeListener(O), await S(), a("ready", c);
|
|
544
960
|
});
|
|
545
|
-
function
|
|
961
|
+
function h() {
|
|
546
962
|
c && e.svgResize(c);
|
|
547
963
|
}
|
|
548
|
-
function
|
|
549
|
-
|
|
964
|
+
function O(u) {
|
|
965
|
+
a("change", u);
|
|
550
966
|
}
|
|
551
|
-
return
|
|
552
|
-
|
|
553
|
-
}),
|
|
554
|
-
var
|
|
555
|
-
u || (
|
|
556
|
-
}),
|
|
557
|
-
() =>
|
|
967
|
+
return T(() => {
|
|
968
|
+
s.value = !1;
|
|
969
|
+
}), y(s, (u) => {
|
|
970
|
+
var _;
|
|
971
|
+
u || (_ = c.getToolbox()) == null || _.clearSelection();
|
|
972
|
+
}), y(
|
|
973
|
+
() => n.current.value,
|
|
558
974
|
(u) => {
|
|
559
|
-
|
|
975
|
+
f(u);
|
|
560
976
|
}
|
|
561
|
-
),
|
|
977
|
+
), y(
|
|
562
978
|
() => r.current.value.dark,
|
|
563
979
|
(u) => {
|
|
564
|
-
|
|
980
|
+
ee(u ? "dark" : "light");
|
|
565
981
|
}
|
|
566
|
-
), (u,
|
|
567
|
-
|
|
982
|
+
), (u, _) => (L(), E("div", le, [
|
|
983
|
+
I(v("div", {
|
|
568
984
|
class: "w-100 h-100",
|
|
569
985
|
ref_key: "blocklyDiv",
|
|
570
|
-
ref:
|
|
986
|
+
ref: l,
|
|
571
987
|
id: "blocklyEditor"
|
|
572
988
|
}, null, 512), [
|
|
573
|
-
[
|
|
989
|
+
[ie, h]
|
|
574
990
|
])
|
|
575
991
|
]));
|
|
576
992
|
}
|
|
577
|
-
}),
|
|
578
|
-
|
|
579
|
-
},
|
|
993
|
+
}), ce = (o) => {
|
|
994
|
+
o.component("x-blockly", ae);
|
|
995
|
+
}, pe = { install: ce };
|
|
580
996
|
export {
|
|
581
|
-
|
|
997
|
+
pe as default
|
|
582
998
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const _ = {
|
|
2
|
+
LOGIC_BOOLEAN_FALSE: "假",
|
|
3
|
+
LOGIC_BOOLEAN_TRUE: "真",
|
|
4
|
+
LOGIC_DO: "执行",
|
|
5
|
+
LOGIC_ELSE: "否则",
|
|
6
|
+
LOGIC_ELSE_IF: "否则如果",
|
|
7
|
+
LOGIC_IF: "如果",
|
|
8
|
+
LOGIC_V1_BOOLEAN_TOOPTIP: "LOGIC_V1_BOOLEAN_TOOPTIP",
|
|
9
|
+
LOGIC_V1_BOOLEAN_HELPURL: "LOGIC_V1_BOOLEAN_HELPURL",
|
|
10
|
+
LOGIC_V1_IF_TOOLTIP: "LOGIC_V1_IF_TOOLTIP",
|
|
11
|
+
LOGIC_V1_IF_HELPURL: "LOGIC_V1_IF_HELPURL"
|
|
12
|
+
}, L = {
|
|
13
|
+
LOOP_DO: "执行",
|
|
14
|
+
LOOP_V1_FOR_TITLE: "变量%1从%2数到%3每次增加%4",
|
|
15
|
+
LOOP_V1_FOR_EACH_TITLE: "遍历列表%2中的每一项%1",
|
|
16
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE: "当条件满足时重复",
|
|
17
|
+
LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL: "重复直到条件满足",
|
|
18
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE: "LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE",
|
|
19
|
+
LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL: "LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL",
|
|
20
|
+
LOOP_V1_WHILE_UNTIL_HELPURL: "LOOP_V1_WHILE_UNTIL_HELPURL"
|
|
21
|
+
}, O = {
|
|
22
|
+
..._,
|
|
23
|
+
...L
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
O as default
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-block-lib",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"*": "prettier --write ."
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"blockly": "^11.0.0
|
|
25
|
+
"blockly": "^11.0.0",
|
|
26
26
|
"vue": "^3.4.26",
|
|
27
27
|
"vuetify": "^3.6.5",
|
|
28
|
-
"x-essential-lib": "^0.3.
|
|
28
|
+
"x-essential-lib": "^0.3.17"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@rushstack/eslint-patch": "^1.8.0",
|
package/dist/en-CCqtrcN-.js
DELETED
package/dist/zhHans---jf3OTZ.js
DELETED