x-block-lib 0.3.4 → 0.3.19
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-gskixv9t.js → blockly-kru4jhu1.js} +1234 -2275
- package/dist/components/blockly/index.vue.d.ts +2 -0
- package/dist/core/locale/msg/en/index.d.ts +5 -5
- package/dist/core/locale/msg/en/logic.d.ts +13 -0
- package/dist/core/locale/msg/en/loop.d.ts +11 -0
- package/dist/core/locale/msg/zhHans/index.d.ts +5 -5
- package/dist/core/locale/msg/zhHans/logic.d.ts +13 -0
- package/dist/core/locale/msg/zhHans/loop.d.ts +11 -0
- package/dist/{zhHans-dmzotd2n.js → en-jrrs2wmb.js} +15 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +197 -192
- package/dist/zhHans-jrrs2wmb.js +35 -0
- package/package.json +16 -15
- package/dist/en-c75t6n0y.js +0 -27
package/dist/index.js
CHANGED
|
@@ -1,9 +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 {
|
|
4
|
-
import { openConfirmDlg as
|
|
5
|
-
import { d as
|
|
6
|
-
|
|
2
|
+
import { defineComponent as A, ref as N, onMounted as D, onBeforeUnmount as M, watch as C, resolveDirective as V, openBlock as U, createElementBlock as Y, withDirectives as G, createElementVNode as W } from "vue";
|
|
3
|
+
import { storeToRefs as H } from "pinia";
|
|
4
|
+
import { openConfirmDlg as z, openPromptDlg as X, useGlobalStore as J, useViewStack as j } from "x-essential-lib";
|
|
5
|
+
import { d as h, j as $, O as q, E as p, u as i, M as f, C as Q, a as d, b as R, s as Z, S as u, c as L, g as O, i as m, e as I, f as b, h as g, k as B, G as v, B as ee, T as k, l as x, m as te, n as oe, o as ne } from "./blockly-kru4jhu1.js";
|
|
6
|
+
h([
|
|
7
7
|
{
|
|
8
8
|
type: "boolean_v1",
|
|
9
9
|
message0: "%1",
|
|
@@ -32,7 +32,7 @@ const re = {
|
|
|
32
32
|
mutationToDom: function() {
|
|
33
33
|
if (this.elseIfCount_ <= 0 && !this.hasElse_)
|
|
34
34
|
return null;
|
|
35
|
-
const t =
|
|
35
|
+
const t = i.xml.createElement("mutation");
|
|
36
36
|
return this.elseIfCount_ > 0 && t.setAttribute("elseIf", String(this.elseIfCount_)), this.hasElse_ && t.setAttribute("else", "TRUE"), t;
|
|
37
37
|
},
|
|
38
38
|
domToMutation: function(t) {
|
|
@@ -50,23 +50,23 @@ const re = {
|
|
|
50
50
|
decompose: function(t) {
|
|
51
51
|
const e = t.newBlock("if_if_v1");
|
|
52
52
|
e.initSvg();
|
|
53
|
-
let
|
|
54
|
-
for (let
|
|
53
|
+
let n = e.nextConnection;
|
|
54
|
+
for (let o = 0; o < this.elseIfCount_; o++) {
|
|
55
55
|
const r = t.newBlock(
|
|
56
56
|
"if_else_if_v1"
|
|
57
57
|
);
|
|
58
|
-
r.initSvg(),
|
|
58
|
+
r.initSvg(), n.connect(r.previousConnection), n = r.nextConnection;
|
|
59
59
|
}
|
|
60
60
|
if (this.hasElse_) {
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const o = t.newBlock("if_else_v1");
|
|
62
|
+
o.initSvg(), n.connect(o.previousConnection);
|
|
63
63
|
}
|
|
64
64
|
return e;
|
|
65
65
|
},
|
|
66
66
|
compose: function(t) {
|
|
67
67
|
let e = t.nextConnection.targetBlock();
|
|
68
68
|
this.elseIfCount_ = 0, this.hasElse_ = !1;
|
|
69
|
-
const
|
|
69
|
+
const n = [null], o = [null];
|
|
70
70
|
let r = null;
|
|
71
71
|
for (; e; ) {
|
|
72
72
|
if (e.isInsertionMarker()) {
|
|
@@ -75,9 +75,9 @@ const re = {
|
|
|
75
75
|
}
|
|
76
76
|
switch (e.type) {
|
|
77
77
|
case "if_else_if_v1":
|
|
78
|
-
this.elseIfCount_++,
|
|
78
|
+
this.elseIfCount_++, n.push(
|
|
79
79
|
e.valueConnection_
|
|
80
|
-
),
|
|
80
|
+
), o.push(
|
|
81
81
|
e.statementConnection_
|
|
82
82
|
);
|
|
83
83
|
break;
|
|
@@ -90,13 +90,13 @@ const re = {
|
|
|
90
90
|
e = e.getNextBlock();
|
|
91
91
|
}
|
|
92
92
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
93
|
-
o,
|
|
94
93
|
n,
|
|
94
|
+
o,
|
|
95
95
|
r
|
|
96
96
|
);
|
|
97
97
|
},
|
|
98
98
|
saveConnections: function(t) {
|
|
99
|
-
let e = t.nextConnection.targetBlock(),
|
|
99
|
+
let e = t.nextConnection.targetBlock(), n = 1;
|
|
100
100
|
for (; e; ) {
|
|
101
101
|
if (e.isInsertionMarker()) {
|
|
102
102
|
e = e.getNextBlock();
|
|
@@ -104,13 +104,13 @@ const re = {
|
|
|
104
104
|
}
|
|
105
105
|
switch (e.type) {
|
|
106
106
|
case "if_else_if_v1": {
|
|
107
|
-
const
|
|
108
|
-
e.valueConnection_ =
|
|
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++;
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
case "if_else_v1": {
|
|
112
|
-
const
|
|
113
|
-
e.statementConnection_ =
|
|
112
|
+
const o = this.getInput("ELSE");
|
|
113
|
+
e.statementConnection_ = o && o.connection.targetConnection;
|
|
114
114
|
break;
|
|
115
115
|
}
|
|
116
116
|
default:
|
|
@@ -121,16 +121,16 @@ const re = {
|
|
|
121
121
|
},
|
|
122
122
|
rebuildShape_: function() {
|
|
123
123
|
const t = [null], e = [null];
|
|
124
|
-
let
|
|
125
|
-
this.getInput("ELSE") && (
|
|
126
|
-
for (let
|
|
127
|
-
const r = this.getInput("IF" +
|
|
128
|
-
t.push(r.connection.targetConnection), e.push(
|
|
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);
|
|
129
129
|
}
|
|
130
130
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
131
131
|
t,
|
|
132
132
|
e,
|
|
133
|
-
|
|
133
|
+
n
|
|
134
134
|
);
|
|
135
135
|
},
|
|
136
136
|
updateShape_: function() {
|
|
@@ -141,11 +141,11 @@ const re = {
|
|
|
141
141
|
this.appendValueInput("IF" + t).setCheck("Boolean").appendField(f.LOGIC_ELSE_IF), this.appendStatementInput("DO" + t).appendField(f.LOGIC_DO);
|
|
142
142
|
this.hasElse_ && this.appendStatementInput("ELSE").appendField(f.LOGIC_ELSE);
|
|
143
143
|
},
|
|
144
|
-
reconnectChildBlocks_: function(t, e,
|
|
145
|
-
var
|
|
146
|
-
for (let
|
|
147
|
-
(
|
|
148
|
-
|
|
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");
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
p.registerMutator(
|
|
@@ -154,7 +154,7 @@ p.registerMutator(
|
|
|
154
154
|
void 0,
|
|
155
155
|
["if_else_if_v1", "if_else_v1"]
|
|
156
156
|
);
|
|
157
|
-
|
|
157
|
+
h([
|
|
158
158
|
{
|
|
159
159
|
type: "if_v1",
|
|
160
160
|
message0: "%{BKY_LOGIC_IF} %1",
|
|
@@ -206,8 +206,8 @@ const se = {
|
|
|
206
206
|
customContextMenu: function(t) {
|
|
207
207
|
if (this.isInFlyout)
|
|
208
208
|
return;
|
|
209
|
-
const e = this.getField("VAR"),
|
|
210
|
-
if (!this.isCollapsed() &&
|
|
209
|
+
const e = this.getField("VAR"), n = e.getVariable(), o = n == null ? void 0 : n.name;
|
|
210
|
+
if (!this.isCollapsed() && o) {
|
|
211
211
|
const r = {
|
|
212
212
|
type: "variables_get",
|
|
213
213
|
fields: {
|
|
@@ -216,7 +216,7 @@ const se = {
|
|
|
216
216
|
};
|
|
217
217
|
t.push({
|
|
218
218
|
enabled: !0,
|
|
219
|
-
text: f.VARIABLES_SET_CREATE_GET.replace("%1",
|
|
219
|
+
text: f.VARIABLES_SET_CREATE_GET.replace("%1", o),
|
|
220
220
|
callback: Q.callbackFactory(this, r)
|
|
221
221
|
});
|
|
222
222
|
}
|
|
@@ -250,16 +250,16 @@ const ae = /* @__PURE__ */ new Set([
|
|
|
250
250
|
},
|
|
251
251
|
onchange: function(t) {
|
|
252
252
|
const e = this.workspace;
|
|
253
|
-
if (!e.isDragging || e.isDragging() || t.type !==
|
|
253
|
+
if (!e.isDragging || e.isDragging() || t.type !== d.BLOCK_MOVE && t.type !== d.BLOCK_CREATE)
|
|
254
254
|
return;
|
|
255
|
-
const
|
|
256
|
-
if (console.log(t.type,
|
|
257
|
-
|
|
255
|
+
const n = this.getSurroundLoop();
|
|
256
|
+
if (console.log(t.type, n), this.setWarningText(
|
|
257
|
+
n ? null : f.LOOP_FLOW_CONTROL_WARNING
|
|
258
258
|
), !this.isInFlyout)
|
|
259
259
|
try {
|
|
260
|
-
|
|
260
|
+
d.setRecordUndo(!1), this.setDisabledReason(!n, "FLOW_CONTROL_NOT_IN_LOOP");
|
|
261
261
|
} finally {
|
|
262
|
-
|
|
262
|
+
d.setRecordUndo(!0);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
};
|
|
@@ -267,7 +267,7 @@ p.registerMixin(
|
|
|
267
267
|
"flow_control_in_loop_check_v1",
|
|
268
268
|
le
|
|
269
269
|
);
|
|
270
|
-
|
|
270
|
+
h([
|
|
271
271
|
{
|
|
272
272
|
type: "flow_control_v1",
|
|
273
273
|
message0: "%1",
|
|
@@ -295,7 +295,7 @@ p.register(
|
|
|
295
295
|
"VAR"
|
|
296
296
|
)
|
|
297
297
|
);
|
|
298
|
-
|
|
298
|
+
h([
|
|
299
299
|
{
|
|
300
300
|
type: "for_v1",
|
|
301
301
|
message0: "%{BKY_LOOP_V1_FOR_TITLE}",
|
|
@@ -346,7 +346,7 @@ p.register(
|
|
|
346
346
|
"VAR"
|
|
347
347
|
)
|
|
348
348
|
);
|
|
349
|
-
|
|
349
|
+
h([
|
|
350
350
|
{
|
|
351
351
|
type: "for_each_v1",
|
|
352
352
|
message0: "%{BKY_LOOP_V1_FOR_EACH_TITLE}",
|
|
@@ -383,7 +383,7 @@ p.register(
|
|
|
383
383
|
UNTIL: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}"
|
|
384
384
|
})
|
|
385
385
|
);
|
|
386
|
-
|
|
386
|
+
h([
|
|
387
387
|
{
|
|
388
388
|
type: "while_until_v1",
|
|
389
389
|
message0: "%1 %2",
|
|
@@ -416,41 +416,48 @@ g([
|
|
|
416
416
|
extensions: ["while_until_tooltip_v1"]
|
|
417
417
|
}
|
|
418
418
|
]);
|
|
419
|
-
|
|
420
|
-
const
|
|
419
|
+
R.setConfirm(async (t, e) => {
|
|
420
|
+
const n = await z({
|
|
421
421
|
title: "",
|
|
422
422
|
text: t
|
|
423
423
|
});
|
|
424
|
-
e(!!
|
|
424
|
+
e(!!n);
|
|
425
425
|
});
|
|
426
|
-
|
|
427
|
-
const
|
|
426
|
+
R.setPrompt(async (t, e, n) => {
|
|
427
|
+
const o = await X({
|
|
428
428
|
title: "",
|
|
429
429
|
value: e
|
|
430
430
|
});
|
|
431
|
-
o
|
|
431
|
+
n(o);
|
|
432
432
|
});
|
|
433
|
-
const ie = (t, e) => {
|
|
433
|
+
const ie = (t, e, n) => {
|
|
434
434
|
const o = t[e];
|
|
435
|
-
return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((
|
|
436
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
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
|
+
);
|
|
437
444
|
});
|
|
438
445
|
};
|
|
439
|
-
async function
|
|
440
|
-
const e = await ie(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-
|
|
446
|
+
async function P(t) {
|
|
447
|
+
const e = await ie(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-jrrs2wmb.js"), "./msg/zhHans/index.ts": () => import("./zhHans-jrrs2wmb.js") }), `./msg/${t}/index.ts`, 4);
|
|
441
448
|
Z(e.default);
|
|
442
449
|
}
|
|
443
450
|
class ce {
|
|
444
|
-
init({ contextMenu: e = !0, shortcut:
|
|
451
|
+
init({ contextMenu: e = !0, shortcut: n = !0 } = {
|
|
445
452
|
contextMenu: !0,
|
|
446
453
|
shortcut: !0
|
|
447
454
|
}) {
|
|
448
|
-
e && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()),
|
|
449
|
-
|
|
455
|
+
e && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), n && (u.registry.unregister(
|
|
456
|
+
L.names.COPY
|
|
450
457
|
), u.registry.unregister(
|
|
451
|
-
|
|
458
|
+
L.names.CUT
|
|
452
459
|
), u.registry.unregister(
|
|
453
|
-
|
|
460
|
+
L.names.PASTE
|
|
454
461
|
), this.blockCopyToStorageShortcut(), this.blockCutToStorageShortcut(), this.blockPasteFromStorageShortcut());
|
|
455
462
|
}
|
|
456
463
|
blockCopyToStorageContextMenu() {
|
|
@@ -459,172 +466,172 @@ class ce {
|
|
|
459
466
|
return f.CROSS_TAB_COPY ? f.CROSS_TAB_COPY : "Copy";
|
|
460
467
|
},
|
|
461
468
|
preconditionFn: function() {
|
|
462
|
-
const
|
|
463
|
-
return !
|
|
469
|
+
const n = O();
|
|
470
|
+
return !n || !m(n) || !n.isDeletable() || !I(n) || !n.isMovable() || !b(n) ? "disabled" : "enabled";
|
|
464
471
|
},
|
|
465
|
-
callback: function(
|
|
466
|
-
var
|
|
472
|
+
callback: function(n) {
|
|
473
|
+
var o;
|
|
467
474
|
localStorage.setItem(
|
|
468
475
|
"blocklyStash",
|
|
469
|
-
JSON.stringify((
|
|
476
|
+
JSON.stringify((o = n.block) == null ? void 0 : o.toCopyData())
|
|
470
477
|
);
|
|
471
478
|
},
|
|
472
|
-
scopeType:
|
|
479
|
+
scopeType: g.ScopeType.BLOCK,
|
|
473
480
|
id: "blockCopyToStorage",
|
|
474
481
|
weight: 0
|
|
475
482
|
};
|
|
476
|
-
|
|
483
|
+
g.registry.register(e);
|
|
477
484
|
}
|
|
478
485
|
blockPasteFromStorageContextMenu() {
|
|
479
486
|
const e = {
|
|
480
487
|
displayText: function() {
|
|
481
488
|
return f.CROSS_TAB_PASTE ? f.CROSS_TAB_PASTE : "Paste";
|
|
482
489
|
},
|
|
483
|
-
preconditionFn: function(
|
|
484
|
-
var
|
|
485
|
-
const
|
|
486
|
-
if (!
|
|
490
|
+
preconditionFn: function(n) {
|
|
491
|
+
var s;
|
|
492
|
+
const o = localStorage.getItem("blocklyStash");
|
|
493
|
+
if (!o)
|
|
487
494
|
return "disabled";
|
|
488
|
-
const r = JSON.parse(
|
|
489
|
-
return !r || !((
|
|
495
|
+
const r = JSON.parse(o);
|
|
496
|
+
return !r || !((s = n.workspace) != null && s.isCapacityAvailable(r.typeCounts)) ? "disabled" : "enabled";
|
|
490
497
|
},
|
|
491
|
-
callback: function(
|
|
492
|
-
const
|
|
493
|
-
if (!
|
|
498
|
+
callback: function(n) {
|
|
499
|
+
const o = localStorage.getItem("blocklyStash");
|
|
500
|
+
if (!o)
|
|
494
501
|
return;
|
|
495
|
-
const r = JSON.parse(
|
|
496
|
-
r &&
|
|
502
|
+
const r = JSON.parse(o);
|
|
503
|
+
r && n.workspace && B.paste(r, n.workspace);
|
|
497
504
|
},
|
|
498
|
-
scopeType:
|
|
505
|
+
scopeType: g.ScopeType.WORKSPACE,
|
|
499
506
|
id: "blockPasteFromStorage",
|
|
500
507
|
weight: 0
|
|
501
508
|
};
|
|
502
|
-
|
|
509
|
+
g.registry.register(e);
|
|
503
510
|
}
|
|
504
511
|
blockCopyToStorageShortcut() {
|
|
505
512
|
const e = u.registry.createSerializedKey(
|
|
506
|
-
|
|
507
|
-
[
|
|
508
|
-
), o = u.registry.createSerializedKey(
|
|
509
|
-
c.KeyCodes.C,
|
|
510
|
-
[c.KeyCodes.ALT]
|
|
513
|
+
i.KeyCodes.C,
|
|
514
|
+
[i.KeyCodes.CTRL]
|
|
511
515
|
), n = u.registry.createSerializedKey(
|
|
512
|
-
|
|
513
|
-
[
|
|
516
|
+
i.KeyCodes.C,
|
|
517
|
+
[i.KeyCodes.ALT]
|
|
518
|
+
), o = u.registry.createSerializedKey(
|
|
519
|
+
i.KeyCodes.C,
|
|
520
|
+
[i.KeyCodes.META]
|
|
514
521
|
), r = {
|
|
515
522
|
name: "copy",
|
|
516
|
-
preconditionFn: function(
|
|
517
|
-
if (
|
|
523
|
+
preconditionFn: function(s) {
|
|
524
|
+
if (s.options.readOnly || v.inProgress())
|
|
518
525
|
return !1;
|
|
519
|
-
const
|
|
520
|
-
return !(!
|
|
526
|
+
const a = O();
|
|
527
|
+
return !(!a || !m(a) || !a.isDeletable() || !I(a) || !a.isMovable() || !b(a));
|
|
521
528
|
},
|
|
522
|
-
callback: function(
|
|
523
|
-
|
|
524
|
-
const
|
|
525
|
-
if (!
|
|
529
|
+
callback: function(s, a) {
|
|
530
|
+
a.preventDefault();
|
|
531
|
+
const l = O();
|
|
532
|
+
if (!l || !b(l))
|
|
526
533
|
return !1;
|
|
527
|
-
const
|
|
528
|
-
return
|
|
534
|
+
const c = l.toCopyData();
|
|
535
|
+
return c ? (s.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
|
|
529
536
|
},
|
|
530
|
-
keyCodes: [e,
|
|
537
|
+
keyCodes: [e, n, o]
|
|
531
538
|
};
|
|
532
539
|
u.registry.register(r);
|
|
533
540
|
}
|
|
534
541
|
blockCutToStorageShortcut() {
|
|
535
542
|
const e = u.registry.createSerializedKey(
|
|
536
|
-
|
|
537
|
-
[
|
|
538
|
-
), o = u.registry.createSerializedKey(
|
|
539
|
-
c.KeyCodes.X,
|
|
540
|
-
[c.KeyCodes.ALT]
|
|
543
|
+
i.KeyCodes.X,
|
|
544
|
+
[i.KeyCodes.CTRL]
|
|
541
545
|
), n = u.registry.createSerializedKey(
|
|
542
|
-
|
|
543
|
-
[
|
|
546
|
+
i.KeyCodes.X,
|
|
547
|
+
[i.KeyCodes.ALT]
|
|
548
|
+
), o = u.registry.createSerializedKey(
|
|
549
|
+
i.KeyCodes.X,
|
|
550
|
+
[i.KeyCodes.META]
|
|
544
551
|
), r = {
|
|
545
552
|
name: "cut",
|
|
546
|
-
preconditionFn: function(
|
|
547
|
-
if (
|
|
553
|
+
preconditionFn: function(s) {
|
|
554
|
+
if (s.options.readOnly || v.inProgress())
|
|
548
555
|
return !1;
|
|
549
|
-
const
|
|
550
|
-
return !(!
|
|
556
|
+
const a = O();
|
|
557
|
+
return !(!a || !m(a) || !a.isDeletable() || !I(a) || !a.isMovable() || !b(a) || a.workspace.isFlyout);
|
|
551
558
|
},
|
|
552
|
-
callback: function(
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
if (!
|
|
559
|
+
callback: function(s, a) {
|
|
560
|
+
a.preventDefault();
|
|
561
|
+
const l = O();
|
|
562
|
+
if (!l || !m(l) || !l.isDeletable() || !b(l))
|
|
556
563
|
return !1;
|
|
557
|
-
const
|
|
558
|
-
return
|
|
564
|
+
const c = l.toCopyData();
|
|
565
|
+
return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), l instanceof ee ? l.checkAndDelete() : l.dispose(), !0) : !1;
|
|
559
566
|
},
|
|
560
|
-
keyCodes: [e,
|
|
567
|
+
keyCodes: [e, n, o]
|
|
561
568
|
};
|
|
562
569
|
u.registry.register(r);
|
|
563
570
|
}
|
|
564
571
|
blockPasteFromStorageShortcut() {
|
|
565
572
|
const e = u.registry.createSerializedKey(
|
|
566
|
-
|
|
567
|
-
[
|
|
568
|
-
), o = u.registry.createSerializedKey(
|
|
569
|
-
c.KeyCodes.V,
|
|
570
|
-
[c.KeyCodes.ALT]
|
|
573
|
+
i.KeyCodes.V,
|
|
574
|
+
[i.KeyCodes.CTRL]
|
|
571
575
|
), n = u.registry.createSerializedKey(
|
|
572
|
-
|
|
573
|
-
[
|
|
576
|
+
i.KeyCodes.V,
|
|
577
|
+
[i.KeyCodes.ALT]
|
|
578
|
+
), o = u.registry.createSerializedKey(
|
|
579
|
+
i.KeyCodes.V,
|
|
580
|
+
[i.KeyCodes.META]
|
|
574
581
|
), r = {
|
|
575
582
|
name: "paste",
|
|
576
|
-
preconditionFn: function(
|
|
577
|
-
if (
|
|
583
|
+
preconditionFn: function(s) {
|
|
584
|
+
if (s.options.readOnly || v.inProgress())
|
|
578
585
|
return !1;
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
586
|
+
const a = localStorage.getItem("blocklyStash");
|
|
587
|
+
if (!a)
|
|
581
588
|
return !1;
|
|
582
|
-
const
|
|
583
|
-
return !(!
|
|
589
|
+
const l = JSON.parse(a);
|
|
590
|
+
return !(!l || !s.isCapacityAvailable(l.typeCounts));
|
|
584
591
|
},
|
|
585
|
-
callback: function(
|
|
586
|
-
|
|
587
|
-
const
|
|
588
|
-
if (!
|
|
592
|
+
callback: function(s, a) {
|
|
593
|
+
a.preventDefault();
|
|
594
|
+
const l = localStorage.getItem("blocklyStash");
|
|
595
|
+
if (!l)
|
|
589
596
|
return !1;
|
|
590
|
-
const
|
|
591
|
-
return
|
|
597
|
+
const c = JSON.parse(l);
|
|
598
|
+
return c ? (B.paste(c, s), !0) : !1;
|
|
592
599
|
},
|
|
593
|
-
keyCodes: [e,
|
|
600
|
+
keyCodes: [e, n, o]
|
|
594
601
|
};
|
|
595
602
|
u.registry.register(r);
|
|
596
603
|
}
|
|
597
604
|
}
|
|
598
605
|
class ue {
|
|
599
606
|
init() {
|
|
600
|
-
const e =
|
|
601
|
-
e && (e.callback = function(
|
|
602
|
-
const
|
|
603
|
-
if (!
|
|
607
|
+
const e = g.registry.getItem("cleanWorkspace");
|
|
608
|
+
e && (e.callback = function(n) {
|
|
609
|
+
const o = n.workspace;
|
|
610
|
+
if (!o)
|
|
604
611
|
return;
|
|
605
|
-
|
|
606
|
-
const r =
|
|
607
|
-
let
|
|
608
|
-
for (let
|
|
609
|
-
if (!
|
|
612
|
+
o.setResizesEnabled(!1), d.setGroup(!0);
|
|
613
|
+
const r = o.getTopBlocks(!0);
|
|
614
|
+
let s = 0;
|
|
615
|
+
for (let a = 0, l; l = r[a]; a++) {
|
|
616
|
+
if (!l.isMovable())
|
|
610
617
|
continue;
|
|
611
|
-
const
|
|
612
|
-
|
|
618
|
+
const c = l.getRelativeToSurfaceXY();
|
|
619
|
+
l.moveBy(-c.x, s - c.y, ["cleanup"]), l.snapToGrid(), s = l.getRelativeToSurfaceXY().y + l.getHeightWidth().height + 100;
|
|
613
620
|
}
|
|
614
|
-
|
|
621
|
+
d.setGroup(!1), o.setResizesEnabled(!0);
|
|
615
622
|
});
|
|
616
623
|
}
|
|
617
624
|
}
|
|
618
|
-
function
|
|
625
|
+
function K(t) {
|
|
619
626
|
const e = t.getParent();
|
|
620
|
-
return e &&
|
|
627
|
+
return e && K(e) ? !0 : !e && !!(t.outputConnection || t.previousConnection);
|
|
621
628
|
}
|
|
622
629
|
class _e {
|
|
623
630
|
init() {
|
|
624
|
-
const e =
|
|
625
|
-
e && (e.preconditionFn = function(
|
|
626
|
-
const
|
|
627
|
-
return
|
|
631
|
+
const e = g.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() || K(o) ? "disabled" : "enabled" : "hidden";
|
|
628
635
|
});
|
|
629
636
|
}
|
|
630
637
|
}
|
|
@@ -634,7 +641,7 @@ const fe = new ue();
|
|
|
634
641
|
fe.init();
|
|
635
642
|
const ye = new _e();
|
|
636
643
|
ye.init();
|
|
637
|
-
|
|
644
|
+
k.Classic.blockStyles = {
|
|
638
645
|
color_blocks: {
|
|
639
646
|
colourPrimary: "#a5745b",
|
|
640
647
|
colourSecondary: "#ede3de",
|
|
@@ -708,7 +715,7 @@ C.Classic.blockStyles = {
|
|
|
708
715
|
hat: ""
|
|
709
716
|
}
|
|
710
717
|
};
|
|
711
|
-
|
|
718
|
+
k.Classic.categoryStyles = {
|
|
712
719
|
calc_category: {
|
|
713
720
|
colour: "#757575"
|
|
714
721
|
},
|
|
@@ -758,9 +765,9 @@ C.Classic.categoryStyles = {
|
|
|
758
765
|
colour: "#a55b80"
|
|
759
766
|
}
|
|
760
767
|
};
|
|
761
|
-
const de =
|
|
768
|
+
const de = x.defineTheme("light", {
|
|
762
769
|
name: "light",
|
|
763
|
-
base:
|
|
770
|
+
base: k.Classic,
|
|
764
771
|
componentStyles: {
|
|
765
772
|
workspaceBackgroundColour: "#ffffff",
|
|
766
773
|
toolboxBackgroundColour: "#eeeeee",
|
|
@@ -774,9 +781,9 @@ const de = P.defineTheme("light", {
|
|
|
774
781
|
scrollbarOpacity: 0.4,
|
|
775
782
|
cursorColour: ""
|
|
776
783
|
}
|
|
777
|
-
}), ge =
|
|
784
|
+
}), ge = x.defineTheme("dark", {
|
|
778
785
|
name: "dark",
|
|
779
|
-
base:
|
|
786
|
+
base: k.Classic,
|
|
780
787
|
componentStyles: {
|
|
781
788
|
workspaceBackgroundColour: "#1e1e1e",
|
|
782
789
|
toolboxBackgroundColour: "#272727",
|
|
@@ -845,17 +852,18 @@ const Oe = {
|
|
|
845
852
|
}, Ce = {
|
|
846
853
|
kind: "categoryToolbox",
|
|
847
854
|
contents: [Oe, be]
|
|
848
|
-
}, me = { class: "position-relative w-100 h-100" }, ke = /* @__PURE__ */
|
|
855
|
+
}, me = { class: "position-relative w-100 h-100" }, ke = /* @__PURE__ */ A({
|
|
849
856
|
__name: "index",
|
|
850
857
|
props: {
|
|
851
858
|
type: {},
|
|
852
|
-
version: {}
|
|
859
|
+
version: {},
|
|
860
|
+
active: { type: Boolean }
|
|
853
861
|
},
|
|
854
862
|
emits: ["ready", "change"],
|
|
855
863
|
setup(t, { emit: e }) {
|
|
856
|
-
const
|
|
857
|
-
let
|
|
858
|
-
const
|
|
864
|
+
const n = J(), { locale: o, dark: r } = H(n), { open: s } = j("blocklyEditorFlyout"), a = t, l = e, c = N();
|
|
865
|
+
let y;
|
|
866
|
+
const E = {
|
|
859
867
|
grid: {
|
|
860
868
|
length: 2,
|
|
861
869
|
snap: !0,
|
|
@@ -868,7 +876,7 @@ const Oe = {
|
|
|
868
876
|
wheel: !0
|
|
869
877
|
},
|
|
870
878
|
readOnly: !1,
|
|
871
|
-
theme:
|
|
879
|
+
theme: r.value ? "dark" : "light",
|
|
872
880
|
trashcan: !1,
|
|
873
881
|
zoom: {
|
|
874
882
|
maxScale: 1,
|
|
@@ -879,43 +887,40 @@ const Oe = {
|
|
|
879
887
|
}
|
|
880
888
|
};
|
|
881
889
|
D(async () => {
|
|
882
|
-
if (!
|
|
890
|
+
if (!c.value)
|
|
883
891
|
return;
|
|
884
|
-
await
|
|
892
|
+
await P(o.value);
|
|
885
893
|
let _;
|
|
886
|
-
a.type === "app" && a.version === "v1" && (_ = Ce),
|
|
894
|
+
a.type === "app" && a.version === "v1" && (_ = Ce), E.toolbox = _, y = oe(c.value, E), y.addChangeListener(d.disableOrphans), y.addChangeListener(F), setTimeout(() => {
|
|
895
|
+
S(), l("ready", y);
|
|
896
|
+
}, 1);
|
|
897
|
+
}), M(() => {
|
|
898
|
+
s.value = !1;
|
|
887
899
|
});
|
|
888
|
-
function
|
|
889
|
-
|
|
900
|
+
function S() {
|
|
901
|
+
y && ne(y);
|
|
890
902
|
}
|
|
891
|
-
function
|
|
903
|
+
function F(_) {
|
|
892
904
|
l("change", _);
|
|
893
905
|
}
|
|
894
|
-
return
|
|
895
|
-
|
|
896
|
-
}),
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
()
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
), k(
|
|
905
|
-
() => n.current.value.dark,
|
|
906
|
-
(_) => {
|
|
907
|
-
he(_ ? "dark" : "light");
|
|
908
|
-
}
|
|
909
|
-
), (_, m) => {
|
|
906
|
+
return C(o, (_) => {
|
|
907
|
+
P(_);
|
|
908
|
+
}), C(r, (_) => {
|
|
909
|
+
he(_ ? "dark" : "light");
|
|
910
|
+
}), C(s, (_) => {
|
|
911
|
+
var T;
|
|
912
|
+
_ || (T = y.getToolbox()) == null || T.clearSelection();
|
|
913
|
+
}), C(() => a.active, (_) => {
|
|
914
|
+
_ && setTimeout(() => S(), 0);
|
|
915
|
+
}), (_, T) => {
|
|
910
916
|
const w = V("resize");
|
|
911
917
|
return U(), Y("div", me, [
|
|
912
918
|
G(W("div", {
|
|
913
919
|
class: "w-100 h-100",
|
|
914
920
|
ref_key: "blocklyDiv",
|
|
915
|
-
ref:
|
|
916
|
-
id: "blocklyEditor"
|
|
921
|
+
ref: c
|
|
917
922
|
}, null, 512), [
|
|
918
|
-
[w,
|
|
923
|
+
[w, S]
|
|
919
924
|
])
|
|
920
925
|
]);
|
|
921
926
|
};
|