x-block-lib 0.3.2 → 0.3.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/dist/blockly-kru4jhu1.js +15872 -0
- package/dist/components/blockly/index.vue.d.ts +1 -0
- package/dist/core/locale/msg/en/index.d.ts +21 -0
- package/dist/core/locale/msg/zhHans/index.d.ts +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +319 -341
- package/package.json +6 -9
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="x-block-lib",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 { defineComponent as
|
|
3
|
-
import { useLocale as
|
|
4
|
-
import { openConfirmDlg as
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
e.defineBlocksWithJsonArray([
|
|
2
|
+
import { defineComponent as F, ref as A, onMounted as N, nextTick as D, onBeforeUnmount as M, watch as k, resolveDirective as V, openBlock as U, createElementBlock as Y, withDirectives as G, createElementVNode as W } from "vue";
|
|
3
|
+
import { useLocale as H, useTheme as z } from "vuetify";
|
|
4
|
+
import { openConfirmDlg as X, openPromptDlg as J, useViewStack as j } from "x-essential-lib";
|
|
5
|
+
import { d as g, j as $, O as q, E as p, u as c, M as f, C as Q, a as y, b as B, s as Z, S as u, c as S, g as h, i as b, e as T, f as O, h as d, k as v, G as L, B as ee, T as C, l as P, m as te, n as oe, o as ne } from "./blockly-kru4jhu1.js";
|
|
6
|
+
g([
|
|
8
7
|
{
|
|
9
8
|
type: "boolean_v1",
|
|
10
9
|
message0: "%1",
|
|
@@ -24,138 +23,138 @@ e.defineBlocksWithJsonArray([
|
|
|
24
23
|
helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
|
|
25
24
|
}
|
|
26
25
|
]);
|
|
27
|
-
|
|
28
|
-
return [
|
|
26
|
+
$.forBlock.boolean_v1 = function(t) {
|
|
27
|
+
return [t.getFieldValue("BOOL") === "TRUE" ? "true" : "false", q.ATOMIC];
|
|
29
28
|
};
|
|
30
|
-
const
|
|
29
|
+
const re = {
|
|
31
30
|
elseIfCount_: 0,
|
|
32
31
|
hasElse_: !1,
|
|
33
32
|
mutationToDom: function() {
|
|
34
33
|
if (this.elseIfCount_ <= 0 && !this.hasElse_)
|
|
35
34
|
return null;
|
|
36
|
-
const
|
|
37
|
-
return this.elseIfCount_ > 0 &&
|
|
35
|
+
const t = c.xml.createElement("mutation");
|
|
36
|
+
return this.elseIfCount_ > 0 && t.setAttribute("elseIf", String(this.elseIfCount_)), this.hasElse_ && t.setAttribute("else", "TRUE"), t;
|
|
38
37
|
},
|
|
39
|
-
domToMutation: function(
|
|
40
|
-
this.elseIfCount_ = parseInt(
|
|
38
|
+
domToMutation: function(t) {
|
|
39
|
+
this.elseIfCount_ = parseInt(t.getAttribute("elseif"), 10) || 0, this.hasElse_ = t.getAttribute("else") === "TRUE", this.rebuildShape_();
|
|
41
40
|
},
|
|
42
41
|
saveExtraState: function() {
|
|
43
42
|
if (this.elseIfCount_ <= 0 && !this.hasElse_)
|
|
44
43
|
return null;
|
|
45
|
-
const
|
|
46
|
-
return this.elseIfCount_ > 0 && (
|
|
47
|
-
},
|
|
48
|
-
loadExtraState: function(
|
|
49
|
-
this.elseIfCount_ =
|
|
50
|
-
},
|
|
51
|
-
decompose: function(
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
for (let
|
|
56
|
-
const
|
|
44
|
+
const t = /* @__PURE__ */ Object.create(null);
|
|
45
|
+
return this.elseIfCount_ > 0 && (t.elseIfCount = this.elseIfCount_), this.hasElse_ && (t.hasElse = !0), t;
|
|
46
|
+
},
|
|
47
|
+
loadExtraState: function(t) {
|
|
48
|
+
this.elseIfCount_ = t.elseIfCount || 0, this.hasElse_ = !!t.hasElse, this.updateShape_();
|
|
49
|
+
},
|
|
50
|
+
decompose: function(t) {
|
|
51
|
+
const e = t.newBlock("if_if_v1");
|
|
52
|
+
e.initSvg();
|
|
53
|
+
let n = e.nextConnection;
|
|
54
|
+
for (let o = 0; o < this.elseIfCount_; o++) {
|
|
55
|
+
const r = t.newBlock(
|
|
57
56
|
"if_else_if_v1"
|
|
58
57
|
);
|
|
59
|
-
|
|
58
|
+
r.initSvg(), n.connect(r.previousConnection), n = r.nextConnection;
|
|
60
59
|
}
|
|
61
60
|
if (this.hasElse_) {
|
|
62
|
-
const
|
|
63
|
-
|
|
61
|
+
const o = t.newBlock("if_else_v1");
|
|
62
|
+
o.initSvg(), n.connect(o.previousConnection);
|
|
64
63
|
}
|
|
65
|
-
return
|
|
64
|
+
return e;
|
|
66
65
|
},
|
|
67
|
-
compose: function(
|
|
68
|
-
let
|
|
66
|
+
compose: function(t) {
|
|
67
|
+
let e = t.nextConnection.targetBlock();
|
|
69
68
|
this.elseIfCount_ = 0, this.hasElse_ = !1;
|
|
70
|
-
const
|
|
71
|
-
let
|
|
72
|
-
for (;
|
|
73
|
-
if (
|
|
74
|
-
|
|
69
|
+
const n = [null], o = [null];
|
|
70
|
+
let r = null;
|
|
71
|
+
for (; e; ) {
|
|
72
|
+
if (e.isInsertionMarker()) {
|
|
73
|
+
e = e.getNextBlock();
|
|
75
74
|
continue;
|
|
76
75
|
}
|
|
77
|
-
switch (
|
|
76
|
+
switch (e.type) {
|
|
78
77
|
case "if_else_if_v1":
|
|
79
|
-
this.elseIfCount_++,
|
|
80
|
-
|
|
81
|
-
),
|
|
82
|
-
|
|
78
|
+
this.elseIfCount_++, n.push(
|
|
79
|
+
e.valueConnection_
|
|
80
|
+
), o.push(
|
|
81
|
+
e.statementConnection_
|
|
83
82
|
);
|
|
84
83
|
break;
|
|
85
84
|
case "if_else_v1":
|
|
86
|
-
this.hasElse_ = !0,
|
|
85
|
+
this.hasElse_ = !0, r = e.statementConnection_;
|
|
87
86
|
break;
|
|
88
87
|
default:
|
|
89
|
-
throw TypeError("Unknown block type: " +
|
|
88
|
+
throw TypeError("Unknown block type: " + e.type);
|
|
90
89
|
}
|
|
91
|
-
|
|
90
|
+
e = e.getNextBlock();
|
|
92
91
|
}
|
|
93
92
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
94
|
-
r,
|
|
95
93
|
n,
|
|
96
|
-
|
|
94
|
+
o,
|
|
95
|
+
r
|
|
97
96
|
);
|
|
98
97
|
},
|
|
99
|
-
saveConnections: function(
|
|
100
|
-
let
|
|
101
|
-
for (;
|
|
102
|
-
if (
|
|
103
|
-
|
|
98
|
+
saveConnections: function(t) {
|
|
99
|
+
let e = t.nextConnection.targetBlock(), n = 1;
|
|
100
|
+
for (; e; ) {
|
|
101
|
+
if (e.isInsertionMarker()) {
|
|
102
|
+
e = e.getNextBlock();
|
|
104
103
|
continue;
|
|
105
104
|
}
|
|
106
|
-
switch (
|
|
105
|
+
switch (e.type) {
|
|
107
106
|
case "if_else_if_v1": {
|
|
108
|
-
const
|
|
109
|
-
|
|
107
|
+
const o = this.getInput("IF" + n), r = this.getInput("DO" + n);
|
|
108
|
+
e.valueConnection_ = o && o.connection.targetConnection, e.statementConnection_ = r && r.connection.targetConnection, n++;
|
|
110
109
|
break;
|
|
111
110
|
}
|
|
112
111
|
case "if_else_v1": {
|
|
113
|
-
const
|
|
114
|
-
|
|
112
|
+
const o = this.getInput("ELSE");
|
|
113
|
+
e.statementConnection_ = o && o.connection.targetConnection;
|
|
115
114
|
break;
|
|
116
115
|
}
|
|
117
116
|
default:
|
|
118
|
-
throw TypeError("Unknown block type: " +
|
|
117
|
+
throw TypeError("Unknown block type: " + e.type);
|
|
119
118
|
}
|
|
120
|
-
|
|
119
|
+
e = e.getNextBlock();
|
|
121
120
|
}
|
|
122
121
|
},
|
|
123
122
|
rebuildShape_: function() {
|
|
124
|
-
const
|
|
125
|
-
let
|
|
126
|
-
this.getInput("ELSE") && (
|
|
127
|
-
for (let
|
|
128
|
-
const
|
|
129
|
-
|
|
123
|
+
const t = [null], e = [null];
|
|
124
|
+
let n = null;
|
|
125
|
+
this.getInput("ELSE") && (n = this.getInput("ELSE").connection.targetConnection);
|
|
126
|
+
for (let o = 1; this.getInput("IF" + o); o++) {
|
|
127
|
+
const r = this.getInput("IF" + o), s = this.getInput("DO" + o);
|
|
128
|
+
t.push(r.connection.targetConnection), e.push(s.connection.targetConnection);
|
|
130
129
|
}
|
|
131
130
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
132
|
-
o,
|
|
133
131
|
t,
|
|
134
|
-
|
|
132
|
+
e,
|
|
133
|
+
n
|
|
135
134
|
);
|
|
136
135
|
},
|
|
137
136
|
updateShape_: function() {
|
|
138
137
|
this.getInput("ELSE") && this.removeInput("ELSE");
|
|
139
|
-
for (let
|
|
140
|
-
this.removeInput("IF" +
|
|
141
|
-
for (let
|
|
142
|
-
this.appendValueInput("IF" +
|
|
143
|
-
this.hasElse_ && this.appendStatementInput("ELSE").appendField(
|
|
144
|
-
},
|
|
145
|
-
reconnectChildBlocks_: function(
|
|
146
|
-
var
|
|
147
|
-
for (let
|
|
148
|
-
(
|
|
149
|
-
|
|
138
|
+
for (let t = 1; this.getInput("IF" + t); t++)
|
|
139
|
+
this.removeInput("IF" + t), this.removeInput("DO" + t);
|
|
140
|
+
for (let t = 1; t <= this.elseIfCount_; t++)
|
|
141
|
+
this.appendValueInput("IF" + t).setCheck("Boolean").appendField(f.LOGIC_ELSE_IF), this.appendStatementInput("DO" + t).appendField(f.LOGIC_DO);
|
|
142
|
+
this.hasElse_ && this.appendStatementInput("ELSE").appendField(f.LOGIC_ELSE);
|
|
143
|
+
},
|
|
144
|
+
reconnectChildBlocks_: function(t, e, n) {
|
|
145
|
+
var o, r;
|
|
146
|
+
for (let s = 1; s <= this.elseIfCount_; s++)
|
|
147
|
+
(o = t[s]) == null || o.reconnect(this, "IF" + s), (r = e[s]) == null || r.reconnect(this, "DO" + s);
|
|
148
|
+
n == null || n.reconnect(this, "ELSE");
|
|
150
149
|
}
|
|
151
150
|
};
|
|
152
|
-
|
|
151
|
+
p.registerMutator(
|
|
153
152
|
"if_v1_mutator",
|
|
154
|
-
|
|
153
|
+
re,
|
|
155
154
|
void 0,
|
|
156
155
|
["if_else_if_v1", "if_else_v1"]
|
|
157
156
|
);
|
|
158
|
-
|
|
157
|
+
g([
|
|
159
158
|
{
|
|
160
159
|
type: "if_v1",
|
|
161
160
|
message0: "%{BKY_LOGIC_IF} %1",
|
|
@@ -203,72 +202,72 @@ e.defineBlocksWithJsonArray([
|
|
|
203
202
|
style: "logic_blocks"
|
|
204
203
|
}
|
|
205
204
|
]);
|
|
206
|
-
const
|
|
207
|
-
customContextMenu: function(
|
|
205
|
+
const se = {
|
|
206
|
+
customContextMenu: function(t) {
|
|
208
207
|
if (this.isInFlyout)
|
|
209
208
|
return;
|
|
210
|
-
const
|
|
211
|
-
if (!this.isCollapsed() &&
|
|
212
|
-
const
|
|
209
|
+
const e = this.getField("VAR"), n = e.getVariable(), o = n == null ? void 0 : n.name;
|
|
210
|
+
if (!this.isCollapsed() && o) {
|
|
211
|
+
const r = {
|
|
213
212
|
type: "variables_get",
|
|
214
213
|
fields: {
|
|
215
|
-
VAR:
|
|
214
|
+
VAR: e.saveState(!0)
|
|
216
215
|
}
|
|
217
216
|
};
|
|
218
|
-
|
|
217
|
+
t.push({
|
|
219
218
|
enabled: !0,
|
|
220
|
-
text:
|
|
221
|
-
callback:
|
|
219
|
+
text: f.VARIABLES_SET_CREATE_GET.replace("%1", o),
|
|
220
|
+
callback: Q.callbackFactory(this, r)
|
|
222
221
|
});
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
224
|
};
|
|
226
|
-
|
|
225
|
+
p.registerMixin(
|
|
227
226
|
"contextMenu_newGetVariableBlock_v1",
|
|
228
|
-
|
|
227
|
+
se
|
|
229
228
|
);
|
|
230
|
-
|
|
229
|
+
p.register(
|
|
231
230
|
"flow_control_tooltip_v1",
|
|
232
|
-
|
|
231
|
+
p.buildTooltipForDropdown("MODE", {
|
|
233
232
|
BREAK: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_BREAK}",
|
|
234
233
|
CONTINUE: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}"
|
|
235
234
|
})
|
|
236
235
|
);
|
|
237
|
-
const
|
|
236
|
+
const ae = /* @__PURE__ */ new Set([
|
|
238
237
|
"repeat_v1",
|
|
239
238
|
"for_each_v1",
|
|
240
239
|
"for_v1",
|
|
241
240
|
"while_until_v1"
|
|
242
|
-
]),
|
|
241
|
+
]), le = {
|
|
243
242
|
getSurroundLoop: function() {
|
|
244
|
-
let
|
|
243
|
+
let t = this;
|
|
245
244
|
do {
|
|
246
|
-
if (
|
|
245
|
+
if (ae.has(t.type))
|
|
247
246
|
return !0;
|
|
248
|
-
|
|
249
|
-
} while (
|
|
247
|
+
t = t == null ? void 0 : t.getSurroundParent();
|
|
248
|
+
} while (t);
|
|
250
249
|
return !1;
|
|
251
250
|
},
|
|
252
|
-
onchange: function(
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
251
|
+
onchange: function(t) {
|
|
252
|
+
const e = this.workspace;
|
|
253
|
+
if (!e.isDragging || e.isDragging() || t.type !== y.BLOCK_MOVE && t.type !== y.BLOCK_CREATE)
|
|
255
254
|
return;
|
|
256
|
-
const
|
|
257
|
-
if (console.log(
|
|
258
|
-
|
|
255
|
+
const n = this.getSurroundLoop();
|
|
256
|
+
if (console.log(t.type, n), this.setWarningText(
|
|
257
|
+
n ? null : f.LOOP_FLOW_CONTROL_WARNING
|
|
259
258
|
), !this.isInFlyout)
|
|
260
259
|
try {
|
|
261
|
-
|
|
260
|
+
y.setRecordUndo(!1), this.setDisabledReason(!n, "FLOW_CONTROL_NOT_IN_LOOP");
|
|
262
261
|
} finally {
|
|
263
|
-
|
|
262
|
+
y.setRecordUndo(!0);
|
|
264
263
|
}
|
|
265
264
|
}
|
|
266
265
|
};
|
|
267
|
-
|
|
266
|
+
p.registerMixin(
|
|
268
267
|
"flow_control_in_loop_check_v1",
|
|
269
|
-
|
|
268
|
+
le
|
|
270
269
|
);
|
|
271
|
-
|
|
270
|
+
g([
|
|
272
271
|
{
|
|
273
272
|
type: "flow_control_v1",
|
|
274
273
|
message0: "%1",
|
|
@@ -289,14 +288,14 @@ e.defineBlocksWithJsonArray([
|
|
|
289
288
|
extensions: ["flow_control_tooltip_v1", "flow_control_in_loop_check_v1"]
|
|
290
289
|
}
|
|
291
290
|
]);
|
|
292
|
-
|
|
291
|
+
p.register(
|
|
293
292
|
"for_tooltip_v1",
|
|
294
|
-
|
|
293
|
+
p.buildTooltipWithFieldText(
|
|
295
294
|
"%{BKY_LOOP_V1_FOR_TOOLTIP}",
|
|
296
295
|
"VAR"
|
|
297
296
|
)
|
|
298
297
|
);
|
|
299
|
-
|
|
298
|
+
g([
|
|
300
299
|
{
|
|
301
300
|
type: "for_v1",
|
|
302
301
|
message0: "%{BKY_LOOP_V1_FOR_TITLE}",
|
|
@@ -340,14 +339,14 @@ e.defineBlocksWithJsonArray([
|
|
|
340
339
|
extensions: ["contextMenu_newGetVariableBlock_v1", "for_tooltip_v1"]
|
|
341
340
|
}
|
|
342
341
|
]);
|
|
343
|
-
|
|
342
|
+
p.register(
|
|
344
343
|
"for_each_tooltip_v1",
|
|
345
|
-
|
|
344
|
+
p.buildTooltipWithFieldText(
|
|
346
345
|
"%{BKY_LOOP_V1_FOR_EACH_TOOLTIP}",
|
|
347
346
|
"VAR"
|
|
348
347
|
)
|
|
349
348
|
);
|
|
350
|
-
|
|
349
|
+
g([
|
|
351
350
|
{
|
|
352
351
|
type: "for_each_v1",
|
|
353
352
|
message0: "%{BKY_LOOP_V1_FOR_EACH_TITLE}",
|
|
@@ -377,14 +376,14 @@ e.defineBlocksWithJsonArray([
|
|
|
377
376
|
extensions: ["contextMenu_newGetVariableBlock_v1", "for_each_tooltip_v1"]
|
|
378
377
|
}
|
|
379
378
|
]);
|
|
380
|
-
|
|
379
|
+
p.register(
|
|
381
380
|
"while_until_tooltip_v1",
|
|
382
|
-
|
|
381
|
+
p.buildTooltipForDropdown("MODE", {
|
|
383
382
|
WHILE: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE}",
|
|
384
383
|
UNTIL: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}"
|
|
385
384
|
})
|
|
386
385
|
);
|
|
387
|
-
|
|
386
|
+
g([
|
|
388
387
|
{
|
|
389
388
|
type: "while_until_v1",
|
|
390
389
|
message0: "%1 %2",
|
|
@@ -417,253 +416,232 @@ e.defineBlocksWithJsonArray([
|
|
|
417
416
|
extensions: ["while_until_tooltip_v1"]
|
|
418
417
|
}
|
|
419
418
|
]);
|
|
420
|
-
|
|
421
|
-
const
|
|
419
|
+
B.setConfirm(async (t, e) => {
|
|
420
|
+
const n = await X({
|
|
422
421
|
title: "",
|
|
423
|
-
text:
|
|
422
|
+
text: t
|
|
424
423
|
});
|
|
425
|
-
|
|
424
|
+
e(!!n);
|
|
426
425
|
});
|
|
427
|
-
|
|
428
|
-
const
|
|
426
|
+
B.setPrompt(async (t, e, n) => {
|
|
427
|
+
const o = await J({
|
|
429
428
|
title: "",
|
|
430
|
-
value:
|
|
429
|
+
value: e
|
|
431
430
|
});
|
|
432
|
-
|
|
431
|
+
n(o);
|
|
433
432
|
});
|
|
434
|
-
const
|
|
435
|
-
const
|
|
436
|
-
return
|
|
437
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
433
|
+
const ie = (t, e, n) => {
|
|
434
|
+
const o = t[e];
|
|
435
|
+
return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((r, s) => {
|
|
436
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
437
|
+
s.bind(
|
|
438
|
+
null,
|
|
439
|
+
new Error(
|
|
440
|
+
"Unknown variable dynamic import: " + e + (e.split("/").length !== n ? ". Note that variables only represent file names one level deep." : "")
|
|
441
|
+
)
|
|
442
|
+
)
|
|
443
|
+
);
|
|
438
444
|
});
|
|
439
445
|
};
|
|
440
|
-
async function
|
|
441
|
-
const
|
|
442
|
-
e.
|
|
446
|
+
async function E(t) {
|
|
447
|
+
const e = await ie(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-c75t6n0y.js"), "./msg/zhHans/index.ts": () => import("./zhHans-dmzotd2n.js") }), `./msg/${t}/index.ts`, 4);
|
|
448
|
+
Z(e.default);
|
|
443
449
|
}
|
|
444
|
-
class
|
|
445
|
-
init({ contextMenu:
|
|
450
|
+
class ce {
|
|
451
|
+
init({ contextMenu: e = !0, shortcut: n = !0 } = {
|
|
446
452
|
contextMenu: !0,
|
|
447
453
|
shortcut: !0
|
|
448
454
|
}) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
),
|
|
452
|
-
|
|
453
|
-
),
|
|
454
|
-
|
|
455
|
+
e && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), n && (u.registry.unregister(
|
|
456
|
+
S.names.COPY
|
|
457
|
+
), u.registry.unregister(
|
|
458
|
+
S.names.CUT
|
|
459
|
+
), u.registry.unregister(
|
|
460
|
+
S.names.PASTE
|
|
455
461
|
), this.blockCopyToStorageShortcut(), this.blockCutToStorageShortcut(), this.blockPasteFromStorageShortcut());
|
|
456
462
|
}
|
|
457
463
|
blockCopyToStorageContextMenu() {
|
|
458
|
-
const
|
|
464
|
+
const e = {
|
|
459
465
|
displayText: function() {
|
|
460
|
-
return
|
|
466
|
+
return f.CROSS_TAB_COPY ? f.CROSS_TAB_COPY : "Copy";
|
|
461
467
|
},
|
|
462
468
|
preconditionFn: function() {
|
|
463
|
-
const
|
|
464
|
-
return !
|
|
469
|
+
const n = h();
|
|
470
|
+
return !n || !b(n) || !n.isDeletable() || !T(n) || !n.isMovable() || !O(n) ? "disabled" : "enabled";
|
|
465
471
|
},
|
|
466
|
-
callback: function(
|
|
467
|
-
var
|
|
472
|
+
callback: function(n) {
|
|
473
|
+
var o;
|
|
468
474
|
localStorage.setItem(
|
|
469
475
|
"blocklyStash",
|
|
470
|
-
JSON.stringify((
|
|
476
|
+
JSON.stringify((o = n.block) == null ? void 0 : o.toCopyData())
|
|
471
477
|
);
|
|
472
478
|
},
|
|
473
|
-
scopeType:
|
|
479
|
+
scopeType: d.ScopeType.BLOCK,
|
|
474
480
|
id: "blockCopyToStorage",
|
|
475
481
|
weight: 0
|
|
476
482
|
};
|
|
477
|
-
|
|
483
|
+
d.registry.register(e);
|
|
478
484
|
}
|
|
479
485
|
blockPasteFromStorageContextMenu() {
|
|
480
|
-
const
|
|
486
|
+
const e = {
|
|
481
487
|
displayText: function() {
|
|
482
|
-
return
|
|
488
|
+
return f.CROSS_TAB_PASTE ? f.CROSS_TAB_PASTE : "Paste";
|
|
483
489
|
},
|
|
484
|
-
preconditionFn: function(
|
|
485
|
-
var
|
|
486
|
-
const
|
|
487
|
-
if (!
|
|
490
|
+
preconditionFn: function(n) {
|
|
491
|
+
var s;
|
|
492
|
+
const o = localStorage.getItem("blocklyStash");
|
|
493
|
+
if (!o)
|
|
488
494
|
return "disabled";
|
|
489
|
-
const
|
|
490
|
-
return !
|
|
495
|
+
const r = JSON.parse(o);
|
|
496
|
+
return !r || !((s = n.workspace) != null && s.isCapacityAvailable(r.typeCounts)) ? "disabled" : "enabled";
|
|
491
497
|
},
|
|
492
|
-
callback: function(
|
|
493
|
-
const
|
|
494
|
-
if (!
|
|
498
|
+
callback: function(n) {
|
|
499
|
+
const o = localStorage.getItem("blocklyStash");
|
|
500
|
+
if (!o)
|
|
495
501
|
return;
|
|
496
|
-
const
|
|
497
|
-
|
|
502
|
+
const r = JSON.parse(o);
|
|
503
|
+
r && n.workspace && v.paste(r, n.workspace);
|
|
498
504
|
},
|
|
499
|
-
scopeType:
|
|
505
|
+
scopeType: d.ScopeType.WORKSPACE,
|
|
500
506
|
id: "blockPasteFromStorage",
|
|
501
507
|
weight: 0
|
|
502
508
|
};
|
|
503
|
-
|
|
509
|
+
d.registry.register(e);
|
|
504
510
|
}
|
|
505
511
|
blockCopyToStorageShortcut() {
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
[
|
|
509
|
-
),
|
|
510
|
-
|
|
511
|
-
[
|
|
512
|
-
),
|
|
513
|
-
|
|
514
|
-
[
|
|
515
|
-
),
|
|
512
|
+
const e = u.registry.createSerializedKey(
|
|
513
|
+
c.KeyCodes.C,
|
|
514
|
+
[c.KeyCodes.CTRL]
|
|
515
|
+
), n = u.registry.createSerializedKey(
|
|
516
|
+
c.KeyCodes.C,
|
|
517
|
+
[c.KeyCodes.ALT]
|
|
518
|
+
), o = u.registry.createSerializedKey(
|
|
519
|
+
c.KeyCodes.C,
|
|
520
|
+
[c.KeyCodes.META]
|
|
521
|
+
), r = {
|
|
516
522
|
name: "copy",
|
|
517
|
-
preconditionFn: function(
|
|
518
|
-
if (
|
|
523
|
+
preconditionFn: function(s) {
|
|
524
|
+
if (s.options.readOnly || L.inProgress())
|
|
519
525
|
return !1;
|
|
520
|
-
const
|
|
521
|
-
return !(!
|
|
526
|
+
const l = h();
|
|
527
|
+
return !(!l || !b(l) || !l.isDeletable() || !T(l) || !l.isMovable() || !O(l));
|
|
522
528
|
},
|
|
523
|
-
callback: function(
|
|
524
|
-
|
|
525
|
-
const
|
|
526
|
-
if (!
|
|
529
|
+
callback: function(s, l) {
|
|
530
|
+
l.preventDefault();
|
|
531
|
+
const a = h();
|
|
532
|
+
if (!a || !O(a))
|
|
527
533
|
return !1;
|
|
528
|
-
const
|
|
529
|
-
return
|
|
534
|
+
const i = a.toCopyData();
|
|
535
|
+
return i ? (s.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(i)), !0) : !1;
|
|
530
536
|
},
|
|
531
|
-
keyCodes: [
|
|
537
|
+
keyCodes: [e, n, o]
|
|
532
538
|
};
|
|
533
|
-
|
|
539
|
+
u.registry.register(r);
|
|
534
540
|
}
|
|
535
541
|
blockCutToStorageShortcut() {
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
[
|
|
539
|
-
),
|
|
540
|
-
|
|
541
|
-
[
|
|
542
|
-
),
|
|
543
|
-
|
|
544
|
-
[
|
|
545
|
-
),
|
|
542
|
+
const e = u.registry.createSerializedKey(
|
|
543
|
+
c.KeyCodes.X,
|
|
544
|
+
[c.KeyCodes.CTRL]
|
|
545
|
+
), n = u.registry.createSerializedKey(
|
|
546
|
+
c.KeyCodes.X,
|
|
547
|
+
[c.KeyCodes.ALT]
|
|
548
|
+
), o = u.registry.createSerializedKey(
|
|
549
|
+
c.KeyCodes.X,
|
|
550
|
+
[c.KeyCodes.META]
|
|
551
|
+
), r = {
|
|
546
552
|
name: "cut",
|
|
547
|
-
preconditionFn: function(
|
|
548
|
-
if (
|
|
553
|
+
preconditionFn: function(s) {
|
|
554
|
+
if (s.options.readOnly || L.inProgress())
|
|
549
555
|
return !1;
|
|
550
|
-
const
|
|
551
|
-
return !(!
|
|
556
|
+
const l = h();
|
|
557
|
+
return !(!l || !b(l) || !l.isDeletable() || !T(l) || !l.isMovable() || !O(l) || l.workspace.isFlyout);
|
|
552
558
|
},
|
|
553
|
-
callback: function(
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
if (!
|
|
559
|
+
callback: function(s, l) {
|
|
560
|
+
l.preventDefault();
|
|
561
|
+
const a = h();
|
|
562
|
+
if (!a || !b(a) || !a.isDeletable() || !O(a))
|
|
557
563
|
return !1;
|
|
558
|
-
const
|
|
559
|
-
return
|
|
564
|
+
const i = a.toCopyData();
|
|
565
|
+
return i ? (localStorage.setItem("blocklyStash", JSON.stringify(i)), a instanceof ee ? a.checkAndDelete() : a.dispose(), !0) : !1;
|
|
560
566
|
},
|
|
561
|
-
keyCodes: [
|
|
567
|
+
keyCodes: [e, n, o]
|
|
562
568
|
};
|
|
563
|
-
|
|
569
|
+
u.registry.register(r);
|
|
564
570
|
}
|
|
565
571
|
blockPasteFromStorageShortcut() {
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
[
|
|
569
|
-
),
|
|
570
|
-
|
|
571
|
-
[
|
|
572
|
-
),
|
|
573
|
-
|
|
574
|
-
[
|
|
575
|
-
),
|
|
572
|
+
const e = u.registry.createSerializedKey(
|
|
573
|
+
c.KeyCodes.V,
|
|
574
|
+
[c.KeyCodes.CTRL]
|
|
575
|
+
), n = u.registry.createSerializedKey(
|
|
576
|
+
c.KeyCodes.V,
|
|
577
|
+
[c.KeyCodes.ALT]
|
|
578
|
+
), o = u.registry.createSerializedKey(
|
|
579
|
+
c.KeyCodes.V,
|
|
580
|
+
[c.KeyCodes.META]
|
|
581
|
+
), r = {
|
|
576
582
|
name: "paste",
|
|
577
|
-
preconditionFn: function(
|
|
578
|
-
if (
|
|
583
|
+
preconditionFn: function(s) {
|
|
584
|
+
if (s.options.readOnly || L.inProgress())
|
|
585
|
+
return !1;
|
|
586
|
+
const l = localStorage.getItem("blocklyStash");
|
|
587
|
+
if (!l)
|
|
579
588
|
return !1;
|
|
589
|
+
const a = JSON.parse(l);
|
|
590
|
+
return !(!a || !s.isCapacityAvailable(a.typeCounts));
|
|
591
|
+
},
|
|
592
|
+
callback: function(s, l) {
|
|
593
|
+
l.preventDefault();
|
|
580
594
|
const a = localStorage.getItem("blocklyStash");
|
|
581
595
|
if (!a)
|
|
582
596
|
return !1;
|
|
583
597
|
const i = JSON.parse(a);
|
|
584
|
-
return
|
|
598
|
+
return i ? (v.paste(i, s), !0) : !1;
|
|
585
599
|
},
|
|
586
|
-
|
|
587
|
-
a.preventDefault();
|
|
588
|
-
const i = localStorage.getItem("blocklyStash");
|
|
589
|
-
if (!i)
|
|
590
|
-
return !1;
|
|
591
|
-
const c = JSON.parse(i);
|
|
592
|
-
return c ? (e.clipboard.paste(c, l), !0) : !1;
|
|
593
|
-
},
|
|
594
|
-
keyCodes: [t, r, n]
|
|
600
|
+
keyCodes: [e, n, o]
|
|
595
601
|
};
|
|
596
|
-
|
|
602
|
+
u.registry.register(r);
|
|
597
603
|
}
|
|
598
604
|
}
|
|
599
|
-
class
|
|
605
|
+
class ue {
|
|
600
606
|
init() {
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
const
|
|
604
|
-
if (!
|
|
607
|
+
const e = d.registry.getItem("cleanWorkspace");
|
|
608
|
+
e && (e.callback = function(n) {
|
|
609
|
+
const o = n.workspace;
|
|
610
|
+
if (!o)
|
|
605
611
|
return;
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
let
|
|
609
|
-
for (let
|
|
610
|
-
if (!
|
|
612
|
+
o.setResizesEnabled(!1), y.setGroup(!0);
|
|
613
|
+
const r = o.getTopBlocks(!0);
|
|
614
|
+
let s = 0;
|
|
615
|
+
for (let l = 0, a; a = r[l]; l++) {
|
|
616
|
+
if (!a.isMovable())
|
|
611
617
|
continue;
|
|
612
|
-
const
|
|
613
|
-
|
|
618
|
+
const i = a.getRelativeToSurfaceXY();
|
|
619
|
+
a.moveBy(-i.x, s - i.y, ["cleanup"]), a.snapToGrid(), s = a.getRelativeToSurfaceXY().y + a.getHeightWidth().height + 100;
|
|
614
620
|
}
|
|
615
|
-
|
|
621
|
+
y.setGroup(!1), o.setResizesEnabled(!0);
|
|
616
622
|
});
|
|
617
623
|
}
|
|
618
624
|
}
|
|
619
|
-
function
|
|
620
|
-
const
|
|
621
|
-
return
|
|
625
|
+
function R(t) {
|
|
626
|
+
const e = t.getParent();
|
|
627
|
+
return e && R(e) ? !0 : !e && !!(t.outputConnection || t.previousConnection);
|
|
622
628
|
}
|
|
623
|
-
class
|
|
629
|
+
class _e {
|
|
624
630
|
init() {
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
const
|
|
628
|
-
return
|
|
631
|
+
const e = d.registry.getItem("blockDisable");
|
|
632
|
+
e && (e.preconditionFn = function(n) {
|
|
633
|
+
const o = n.block;
|
|
634
|
+
return o && !o.isInFlyout && o.workspace.options.disable && o.isEditable() ? o.getInheritedDisabled() || R(o) ? "disabled" : "enabled" : "hidden";
|
|
629
635
|
});
|
|
630
636
|
}
|
|
631
637
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
class H extends e.VerticalFlyout {
|
|
641
|
-
addBlockListeners_(t, r, n) {
|
|
642
|
-
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, r, n);
|
|
643
|
-
}
|
|
644
|
-
isBlockCreatable(t) {
|
|
645
|
-
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
const z = new V();
|
|
649
|
-
z.init({ contextMenu: !0, shortcut: !0 });
|
|
650
|
-
const X = new Y();
|
|
651
|
-
X.init();
|
|
652
|
-
const J = new W();
|
|
653
|
-
J.init();
|
|
654
|
-
e.registry.register(
|
|
655
|
-
e.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
|
|
656
|
-
e.registry.DEFAULT,
|
|
657
|
-
G,
|
|
658
|
-
!0
|
|
659
|
-
);
|
|
660
|
-
e.registry.register(
|
|
661
|
-
e.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
|
|
662
|
-
e.registry.DEFAULT,
|
|
663
|
-
H,
|
|
664
|
-
!0
|
|
665
|
-
);
|
|
666
|
-
e.Themes.Classic.blockStyles = {
|
|
638
|
+
const pe = new ce();
|
|
639
|
+
pe.init({ contextMenu: !0, shortcut: !0 });
|
|
640
|
+
const fe = new ue();
|
|
641
|
+
fe.init();
|
|
642
|
+
const ye = new _e();
|
|
643
|
+
ye.init();
|
|
644
|
+
C.Classic.blockStyles = {
|
|
667
645
|
color_blocks: {
|
|
668
646
|
colourPrimary: "#a5745b",
|
|
669
647
|
colourSecondary: "#ede3de",
|
|
@@ -737,7 +715,7 @@ e.Themes.Classic.blockStyles = {
|
|
|
737
715
|
hat: ""
|
|
738
716
|
}
|
|
739
717
|
};
|
|
740
|
-
|
|
718
|
+
C.Classic.categoryStyles = {
|
|
741
719
|
calc_category: {
|
|
742
720
|
colour: "#757575"
|
|
743
721
|
},
|
|
@@ -787,9 +765,9 @@ e.Themes.Classic.categoryStyles = {
|
|
|
787
765
|
colour: "#a55b80"
|
|
788
766
|
}
|
|
789
767
|
};
|
|
790
|
-
const
|
|
768
|
+
const de = P.defineTheme("light", {
|
|
791
769
|
name: "light",
|
|
792
|
-
base:
|
|
770
|
+
base: C.Classic,
|
|
793
771
|
componentStyles: {
|
|
794
772
|
workspaceBackgroundColour: "#ffffff",
|
|
795
773
|
toolboxBackgroundColour: "#eeeeee",
|
|
@@ -803,9 +781,9 @@ const j = e.Theme.defineTheme("light", {
|
|
|
803
781
|
scrollbarOpacity: 0.4,
|
|
804
782
|
cursorColour: ""
|
|
805
783
|
}
|
|
806
|
-
}),
|
|
784
|
+
}), ge = P.defineTheme("dark", {
|
|
807
785
|
name: "dark",
|
|
808
|
-
base:
|
|
786
|
+
base: C.Classic,
|
|
809
787
|
componentStyles: {
|
|
810
788
|
workspaceBackgroundColour: "#1e1e1e",
|
|
811
789
|
toolboxBackgroundColour: "#272727",
|
|
@@ -820,18 +798,18 @@ const j = e.Theme.defineTheme("light", {
|
|
|
820
798
|
cursorColour: ""
|
|
821
799
|
}
|
|
822
800
|
});
|
|
823
|
-
function
|
|
824
|
-
const
|
|
825
|
-
switch (console.log(
|
|
801
|
+
function he(t) {
|
|
802
|
+
const e = te();
|
|
803
|
+
switch (console.log(e), t) {
|
|
826
804
|
case "light":
|
|
827
|
-
|
|
805
|
+
e.setTheme(de);
|
|
828
806
|
break;
|
|
829
807
|
case "dark":
|
|
830
|
-
|
|
808
|
+
e.setTheme(ge);
|
|
831
809
|
break;
|
|
832
810
|
}
|
|
833
811
|
}
|
|
834
|
-
const
|
|
812
|
+
const Oe = {
|
|
835
813
|
kind: "category",
|
|
836
814
|
name: "%{BKY_CATEGORY_LOGIC}",
|
|
837
815
|
categorystyle: "logic_category",
|
|
@@ -849,7 +827,7 @@ const Z = {
|
|
|
849
827
|
type: "if_v1"
|
|
850
828
|
}
|
|
851
829
|
]
|
|
852
|
-
},
|
|
830
|
+
}, be = {
|
|
853
831
|
kind: "category",
|
|
854
832
|
name: "%{BKY_CATEGORY_LOOP}",
|
|
855
833
|
categorystyle: "loop_category",
|
|
@@ -871,20 +849,20 @@ const Z = {
|
|
|
871
849
|
type: "for_each_v1"
|
|
872
850
|
}
|
|
873
851
|
]
|
|
874
|
-
},
|
|
852
|
+
}, Ce = {
|
|
875
853
|
kind: "categoryToolbox",
|
|
876
|
-
contents: [
|
|
877
|
-
},
|
|
854
|
+
contents: [Oe, be]
|
|
855
|
+
}, me = { class: "position-relative w-100 h-100" }, ke = /* @__PURE__ */ F({
|
|
878
856
|
__name: "index",
|
|
879
857
|
props: {
|
|
880
858
|
type: {},
|
|
881
859
|
version: {}
|
|
882
860
|
},
|
|
883
861
|
emits: ["ready", "change"],
|
|
884
|
-
setup(
|
|
885
|
-
const
|
|
886
|
-
let
|
|
887
|
-
const
|
|
862
|
+
setup(t, { emit: e }) {
|
|
863
|
+
const n = H(), o = z(), { open: r } = j("blocklyEditorFlyout"), s = t, l = e, a = A(null);
|
|
864
|
+
let i;
|
|
865
|
+
const I = {
|
|
888
866
|
grid: {
|
|
889
867
|
length: 2,
|
|
890
868
|
snap: !0,
|
|
@@ -897,7 +875,7 @@ const Z = {
|
|
|
897
875
|
wheel: !0
|
|
898
876
|
},
|
|
899
877
|
readOnly: !1,
|
|
900
|
-
theme:
|
|
878
|
+
theme: o.current.value.dark ? "dark" : "light",
|
|
901
879
|
trashcan: !1,
|
|
902
880
|
zoom: {
|
|
903
881
|
maxScale: 1,
|
|
@@ -907,51 +885,51 @@ const Z = {
|
|
|
907
885
|
wheel: !0
|
|
908
886
|
}
|
|
909
887
|
};
|
|
910
|
-
|
|
911
|
-
if (!
|
|
888
|
+
N(async () => {
|
|
889
|
+
if (!a.value)
|
|
912
890
|
return;
|
|
913
|
-
await
|
|
914
|
-
let
|
|
915
|
-
|
|
891
|
+
await E(n.current.value);
|
|
892
|
+
let _;
|
|
893
|
+
s.type === "app" && s.version === "v1" && (_ = Ce), I.toolbox = _, i = oe(a.value, I), i.addChangeListener(y.disableOrphans), i.addChangeListener(K), await D(), l("ready", i);
|
|
916
894
|
});
|
|
917
|
-
function
|
|
918
|
-
|
|
895
|
+
function x() {
|
|
896
|
+
i && ne(i);
|
|
919
897
|
}
|
|
920
|
-
function
|
|
921
|
-
|
|
898
|
+
function K(_) {
|
|
899
|
+
l("change", _);
|
|
922
900
|
}
|
|
923
|
-
return
|
|
924
|
-
|
|
925
|
-
}),
|
|
926
|
-
var
|
|
927
|
-
|
|
928
|
-
}),
|
|
929
|
-
() =>
|
|
930
|
-
(
|
|
931
|
-
|
|
901
|
+
return M(() => {
|
|
902
|
+
r.value = !1;
|
|
903
|
+
}), k(r, (_) => {
|
|
904
|
+
var m;
|
|
905
|
+
_ || (m = i.getToolbox()) == null || m.clearSelection();
|
|
906
|
+
}), k(
|
|
907
|
+
() => n.current.value,
|
|
908
|
+
(_) => {
|
|
909
|
+
E(_);
|
|
932
910
|
}
|
|
933
|
-
),
|
|
934
|
-
() =>
|
|
935
|
-
(
|
|
936
|
-
|
|
911
|
+
), k(
|
|
912
|
+
() => o.current.value.dark,
|
|
913
|
+
(_) => {
|
|
914
|
+
he(_ ? "dark" : "light");
|
|
937
915
|
}
|
|
938
|
-
), (
|
|
939
|
-
const
|
|
940
|
-
return
|
|
941
|
-
|
|
916
|
+
), (_, m) => {
|
|
917
|
+
const w = V("resize");
|
|
918
|
+
return U(), Y("div", me, [
|
|
919
|
+
G(W("div", {
|
|
942
920
|
class: "w-100 h-100",
|
|
943
921
|
ref_key: "blocklyDiv",
|
|
944
|
-
ref:
|
|
922
|
+
ref: a,
|
|
945
923
|
id: "blocklyEditor"
|
|
946
924
|
}, null, 512), [
|
|
947
|
-
[
|
|
925
|
+
[w, x]
|
|
948
926
|
])
|
|
949
927
|
]);
|
|
950
928
|
};
|
|
951
929
|
}
|
|
952
|
-
}),
|
|
953
|
-
|
|
954
|
-
},
|
|
930
|
+
}), Se = (t) => {
|
|
931
|
+
t.component("x-blockly", ke);
|
|
932
|
+
}, Ee = { install: Se };
|
|
955
933
|
export {
|
|
956
|
-
|
|
934
|
+
Ee as default
|
|
957
935
|
};
|