x-block-lib 0.2.3 → 0.3.1
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/index.js +182 -223
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
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 {
|
|
3
|
-
import {
|
|
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 b, ref as C, onMounted as m, nextTick as k, onBeforeUnmount as S, watch as p, resolveDirective as T, openBlock as L, createElementBlock as E, withDirectives as I, createElementVNode as v } from "vue";
|
|
3
|
+
import { useLocale as B, useTheme as R } from "vuetify";
|
|
4
|
+
import { openConfirmDlg as x, openPromptDlg as P, useViewStack as F } from "x-essential-lib";
|
|
4
5
|
import * as e from "blockly/core";
|
|
5
|
-
import { javascriptGenerator as
|
|
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
|
-
}
|
|
12
|
-
const M = Symbol.for("vuetify:locale");
|
|
13
|
-
function K() {
|
|
14
|
-
const o = d(M);
|
|
15
|
-
if (!o)
|
|
16
|
-
throw new Error("[Vuetify] Could not find injected locale instance");
|
|
17
|
-
return o;
|
|
18
|
-
}
|
|
19
|
-
const A = Symbol.for("vuetify:theme");
|
|
20
|
-
function D() {
|
|
21
|
-
F("useTheme");
|
|
22
|
-
const o = d(A, null);
|
|
23
|
-
if (!o)
|
|
24
|
-
throw new Error("Could not find Vuetify theme injection");
|
|
25
|
-
return o;
|
|
26
|
-
}
|
|
6
|
+
import { javascriptGenerator as M, Order as K } from "blockly/javascript";
|
|
27
7
|
e.defineBlocksWithJsonArray([
|
|
28
8
|
{
|
|
29
9
|
type: "boolean_v1",
|
|
@@ -44,10 +24,10 @@ e.defineBlocksWithJsonArray([
|
|
|
44
24
|
helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
|
|
45
25
|
}
|
|
46
26
|
]);
|
|
47
|
-
|
|
48
|
-
return [o.getFieldValue("BOOL") === "TRUE" ? "true" : "false",
|
|
27
|
+
M.forBlock.boolean_v1 = function(o) {
|
|
28
|
+
return [o.getFieldValue("BOOL") === "TRUE" ? "true" : "false", K.ATOMIC];
|
|
49
29
|
};
|
|
50
|
-
const
|
|
30
|
+
const A = {
|
|
51
31
|
elseIfCount_: 0,
|
|
52
32
|
hasElse_: !1,
|
|
53
33
|
mutationToDom: function() {
|
|
@@ -71,23 +51,23 @@ const N = {
|
|
|
71
51
|
decompose: function(o) {
|
|
72
52
|
const t = o.newBlock("if_if_v1");
|
|
73
53
|
t.initSvg();
|
|
74
|
-
let
|
|
75
|
-
for (let
|
|
54
|
+
let r = t.nextConnection;
|
|
55
|
+
for (let n = 0; n < this.elseIfCount_; n++) {
|
|
76
56
|
const s = o.newBlock(
|
|
77
57
|
"if_else_if_v1"
|
|
78
58
|
);
|
|
79
|
-
s.initSvg(),
|
|
59
|
+
s.initSvg(), r.connect(s.previousConnection), r = s.nextConnection;
|
|
80
60
|
}
|
|
81
61
|
if (this.hasElse_) {
|
|
82
|
-
const
|
|
83
|
-
|
|
62
|
+
const n = o.newBlock("if_else_v1");
|
|
63
|
+
n.initSvg(), r.connect(n.previousConnection);
|
|
84
64
|
}
|
|
85
65
|
return t;
|
|
86
66
|
},
|
|
87
67
|
compose: function(o) {
|
|
88
68
|
let t = o.nextConnection.targetBlock();
|
|
89
69
|
this.elseIfCount_ = 0, this.hasElse_ = !1;
|
|
90
|
-
const
|
|
70
|
+
const r = [null], n = [null];
|
|
91
71
|
let s = null;
|
|
92
72
|
for (; t; ) {
|
|
93
73
|
if (t.isInsertionMarker()) {
|
|
@@ -96,9 +76,9 @@ const N = {
|
|
|
96
76
|
}
|
|
97
77
|
switch (t.type) {
|
|
98
78
|
case "if_else_if_v1":
|
|
99
|
-
this.elseIfCount_++,
|
|
79
|
+
this.elseIfCount_++, r.push(
|
|
100
80
|
t.valueConnection_
|
|
101
|
-
),
|
|
81
|
+
), n.push(
|
|
102
82
|
t.statementConnection_
|
|
103
83
|
);
|
|
104
84
|
break;
|
|
@@ -111,13 +91,13 @@ const N = {
|
|
|
111
91
|
t = t.getNextBlock();
|
|
112
92
|
}
|
|
113
93
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
114
|
-
n,
|
|
115
94
|
r,
|
|
95
|
+
n,
|
|
116
96
|
s
|
|
117
97
|
);
|
|
118
98
|
},
|
|
119
99
|
saveConnections: function(o) {
|
|
120
|
-
let t = o.nextConnection.targetBlock(),
|
|
100
|
+
let t = o.nextConnection.targetBlock(), r = 1;
|
|
121
101
|
for (; t; ) {
|
|
122
102
|
if (t.isInsertionMarker()) {
|
|
123
103
|
t = t.getNextBlock();
|
|
@@ -125,13 +105,13 @@ const N = {
|
|
|
125
105
|
}
|
|
126
106
|
switch (t.type) {
|
|
127
107
|
case "if_else_if_v1": {
|
|
128
|
-
const
|
|
129
|
-
t.valueConnection_ =
|
|
108
|
+
const n = this.getInput("IF" + r), s = this.getInput("DO" + r);
|
|
109
|
+
t.valueConnection_ = n && n.connection.targetConnection, t.statementConnection_ = s && s.connection.targetConnection, r++;
|
|
130
110
|
break;
|
|
131
111
|
}
|
|
132
112
|
case "if_else_v1": {
|
|
133
|
-
const
|
|
134
|
-
t.statementConnection_ =
|
|
113
|
+
const n = this.getInput("ELSE");
|
|
114
|
+
t.statementConnection_ = n && n.connection.targetConnection;
|
|
135
115
|
break;
|
|
136
116
|
}
|
|
137
117
|
default:
|
|
@@ -142,16 +122,16 @@ const N = {
|
|
|
142
122
|
},
|
|
143
123
|
rebuildShape_: function() {
|
|
144
124
|
const o = [null], t = [null];
|
|
145
|
-
let
|
|
146
|
-
this.getInput("ELSE") && (
|
|
147
|
-
for (let
|
|
148
|
-
const s = this.getInput("IF" +
|
|
149
|
-
o.push(s.connection.targetConnection), t.push(
|
|
125
|
+
let r = null;
|
|
126
|
+
this.getInput("ELSE") && (r = this.getInput("ELSE").connection.targetConnection);
|
|
127
|
+
for (let n = 1; this.getInput("IF" + n); n++) {
|
|
128
|
+
const s = this.getInput("IF" + n), l = this.getInput("DO" + n);
|
|
129
|
+
o.push(s.connection.targetConnection), t.push(l.connection.targetConnection);
|
|
150
130
|
}
|
|
151
131
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
152
132
|
o,
|
|
153
133
|
t,
|
|
154
|
-
|
|
134
|
+
r
|
|
155
135
|
);
|
|
156
136
|
},
|
|
157
137
|
updateShape_: function() {
|
|
@@ -162,16 +142,16 @@ const N = {
|
|
|
162
142
|
this.appendValueInput("IF" + o).setCheck("Boolean").appendField(e.Msg.LOGIC_ELSE_IF), this.appendStatementInput("DO" + o).appendField(e.Msg.LOGIC_DO);
|
|
163
143
|
this.hasElse_ && this.appendStatementInput("ELSE").appendField(e.Msg.LOGIC_ELSE);
|
|
164
144
|
},
|
|
165
|
-
reconnectChildBlocks_: function(o, t,
|
|
166
|
-
var
|
|
167
|
-
for (let
|
|
168
|
-
(
|
|
169
|
-
|
|
145
|
+
reconnectChildBlocks_: function(o, t, r) {
|
|
146
|
+
var n, s;
|
|
147
|
+
for (let l = 1; l <= this.elseIfCount_; l++)
|
|
148
|
+
(n = o[l]) == null || n.reconnect(this, "IF" + l), (s = t[l]) == null || s.reconnect(this, "DO" + l);
|
|
149
|
+
r == null || r.reconnect(this, "ELSE");
|
|
170
150
|
}
|
|
171
151
|
};
|
|
172
152
|
e.Extensions.registerMutator(
|
|
173
153
|
"if_v1_mutator",
|
|
174
|
-
|
|
154
|
+
A,
|
|
175
155
|
void 0,
|
|
176
156
|
["if_else_if_v1", "if_else_v1"]
|
|
177
157
|
);
|
|
@@ -223,12 +203,12 @@ e.defineBlocksWithJsonArray([
|
|
|
223
203
|
style: "logic_blocks"
|
|
224
204
|
}
|
|
225
205
|
]);
|
|
226
|
-
const
|
|
206
|
+
const w = {
|
|
227
207
|
customContextMenu: function(o) {
|
|
228
208
|
if (this.isInFlyout)
|
|
229
209
|
return;
|
|
230
|
-
const t = this.getField("VAR"),
|
|
231
|
-
if (!this.isCollapsed() &&
|
|
210
|
+
const t = this.getField("VAR"), r = t.getVariable(), n = r == null ? void 0 : r.name;
|
|
211
|
+
if (!this.isCollapsed() && n) {
|
|
232
212
|
const s = {
|
|
233
213
|
type: "variables_get",
|
|
234
214
|
fields: {
|
|
@@ -237,7 +217,7 @@ const V = {
|
|
|
237
217
|
};
|
|
238
218
|
o.push({
|
|
239
219
|
enabled: !0,
|
|
240
|
-
text: e.Msg.VARIABLES_SET_CREATE_GET.replace("%1",
|
|
220
|
+
text: e.Msg.VARIABLES_SET_CREATE_GET.replace("%1", n),
|
|
241
221
|
callback: e.ContextMenu.callbackFactory(this, s)
|
|
242
222
|
});
|
|
243
223
|
}
|
|
@@ -245,7 +225,7 @@ const V = {
|
|
|
245
225
|
};
|
|
246
226
|
e.Extensions.registerMixin(
|
|
247
227
|
"contextMenu_newGetVariableBlock_v1",
|
|
248
|
-
|
|
228
|
+
w
|
|
249
229
|
);
|
|
250
230
|
e.Extensions.register(
|
|
251
231
|
"flow_control_tooltip_v1",
|
|
@@ -254,16 +234,16 @@ e.Extensions.register(
|
|
|
254
234
|
CONTINUE: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}"
|
|
255
235
|
})
|
|
256
236
|
);
|
|
257
|
-
const
|
|
237
|
+
const D = /* @__PURE__ */ new Set([
|
|
258
238
|
"repeat_v1",
|
|
259
239
|
"for_each_v1",
|
|
260
240
|
"for_v1",
|
|
261
241
|
"while_until_v1"
|
|
262
|
-
]),
|
|
242
|
+
]), N = {
|
|
263
243
|
getSurroundLoop: function() {
|
|
264
244
|
let o = this;
|
|
265
245
|
do {
|
|
266
|
-
if (
|
|
246
|
+
if (D.has(o.type))
|
|
267
247
|
return !0;
|
|
268
248
|
o = o == null ? void 0 : o.getSurroundParent();
|
|
269
249
|
} while (o);
|
|
@@ -273,12 +253,12 @@ const U = /* @__PURE__ */ new Set([
|
|
|
273
253
|
const t = this.workspace;
|
|
274
254
|
if (!t.isDragging || t.isDragging() || o.type !== e.Events.BLOCK_MOVE && o.type !== e.Events.BLOCK_CREATE)
|
|
275
255
|
return;
|
|
276
|
-
const
|
|
277
|
-
if (console.log(o.type,
|
|
278
|
-
|
|
256
|
+
const r = this.getSurroundLoop();
|
|
257
|
+
if (console.log(o.type, r), this.setWarningText(
|
|
258
|
+
r ? null : e.Msg.LOOP_FLOW_CONTROL_WARNING
|
|
279
259
|
), !this.isInFlyout)
|
|
280
260
|
try {
|
|
281
|
-
e.Events.setRecordUndo(!1), this.setDisabledReason(!
|
|
261
|
+
e.Events.setRecordUndo(!1), this.setDisabledReason(!r, "FLOW_CONTROL_NOT_IN_LOOP");
|
|
282
262
|
} finally {
|
|
283
263
|
e.Events.setRecordUndo(!0);
|
|
284
264
|
}
|
|
@@ -286,7 +266,7 @@ const U = /* @__PURE__ */ new Set([
|
|
|
286
266
|
};
|
|
287
267
|
e.Extensions.registerMixin(
|
|
288
268
|
"flow_control_in_loop_check_v1",
|
|
289
|
-
|
|
269
|
+
N
|
|
290
270
|
);
|
|
291
271
|
e.defineBlocksWithJsonArray([
|
|
292
272
|
{
|
|
@@ -438,35 +418,35 @@ e.defineBlocksWithJsonArray([
|
|
|
438
418
|
}
|
|
439
419
|
]);
|
|
440
420
|
e.dialog.setConfirm(async (o, t) => {
|
|
441
|
-
const
|
|
421
|
+
const r = await x({
|
|
442
422
|
title: "",
|
|
443
423
|
text: o
|
|
444
424
|
});
|
|
445
|
-
t(!!
|
|
425
|
+
t(!!r);
|
|
446
426
|
});
|
|
447
|
-
e.dialog.setPrompt(async (o, t,
|
|
448
|
-
const
|
|
427
|
+
e.dialog.setPrompt(async (o, t, r) => {
|
|
428
|
+
const n = await P({
|
|
449
429
|
title: "",
|
|
450
430
|
value: t
|
|
451
431
|
});
|
|
452
|
-
n
|
|
432
|
+
r(n);
|
|
453
433
|
});
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
return
|
|
434
|
+
const U = (o, t) => {
|
|
435
|
+
const r = o[t];
|
|
436
|
+
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((n, s) => {
|
|
457
437
|
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(s.bind(null, new Error("Unknown variable dynamic import: " + t)));
|
|
458
438
|
});
|
|
459
439
|
};
|
|
460
440
|
async function f(o) {
|
|
461
|
-
const t = await
|
|
441
|
+
const t = await U(/* @__PURE__ */ Object.assign({ "./msg/en.ts": () => import("./en-Djut8W3R.js"), "./msg/zhHans.ts": () => import("./zhHans-D_qcn_1f.js") }), `./msg/${o}.ts`);
|
|
462
442
|
e.setLocale(t.default);
|
|
463
443
|
}
|
|
464
|
-
class
|
|
465
|
-
init({ contextMenu: t = !0, shortcut:
|
|
444
|
+
class V {
|
|
445
|
+
init({ contextMenu: t = !0, shortcut: r = !0 } = {
|
|
466
446
|
contextMenu: !0,
|
|
467
447
|
shortcut: !0
|
|
468
448
|
}) {
|
|
469
|
-
t && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()),
|
|
449
|
+
t && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), r && (e.ShortcutRegistry.registry.unregister(
|
|
470
450
|
e.ShortcutItems.names.COPY
|
|
471
451
|
), e.ShortcutRegistry.registry.unregister(
|
|
472
452
|
e.ShortcutItems.names.CUT
|
|
@@ -480,14 +460,14 @@ class G {
|
|
|
480
460
|
return e.Msg.CROSS_TAB_COPY ? e.Msg.CROSS_TAB_COPY : "Copy";
|
|
481
461
|
},
|
|
482
462
|
preconditionFn: function() {
|
|
483
|
-
const
|
|
484
|
-
return !
|
|
463
|
+
const r = e.getSelected();
|
|
464
|
+
return !r || !e.isDeletable(r) || !r.isDeletable() || !e.isDraggable(r) || !r.isMovable() || !e.isCopyable(r) ? "disabled" : "enabled";
|
|
485
465
|
},
|
|
486
|
-
callback: function(
|
|
487
|
-
var
|
|
466
|
+
callback: function(r) {
|
|
467
|
+
var n;
|
|
488
468
|
localStorage.setItem(
|
|
489
469
|
"blocklyStash",
|
|
490
|
-
JSON.stringify((
|
|
470
|
+
JSON.stringify((n = r.block) == null ? void 0 : n.toCopyData())
|
|
491
471
|
);
|
|
492
472
|
},
|
|
493
473
|
scopeType: e.ContextMenuRegistry.ScopeType.BLOCK,
|
|
@@ -501,20 +481,20 @@ class G {
|
|
|
501
481
|
displayText: function() {
|
|
502
482
|
return e.Msg.CROSS_TAB_PASTE ? e.Msg.CROSS_TAB_PASTE : "Paste";
|
|
503
483
|
},
|
|
504
|
-
preconditionFn: function(
|
|
505
|
-
var
|
|
506
|
-
const
|
|
507
|
-
if (!
|
|
484
|
+
preconditionFn: function(r) {
|
|
485
|
+
var l;
|
|
486
|
+
const n = localStorage.getItem("blocklyStash");
|
|
487
|
+
if (!n)
|
|
508
488
|
return "disabled";
|
|
509
|
-
const s = JSON.parse(
|
|
510
|
-
return !s || !((
|
|
489
|
+
const s = JSON.parse(n);
|
|
490
|
+
return !s || !((l = r.workspace) != null && l.isCapacityAvailable(s.typeCounts)) ? "disabled" : "enabled";
|
|
511
491
|
},
|
|
512
|
-
callback: function(
|
|
513
|
-
const
|
|
514
|
-
if (!
|
|
492
|
+
callback: function(r) {
|
|
493
|
+
const n = localStorage.getItem("blocklyStash");
|
|
494
|
+
if (!n)
|
|
515
495
|
return;
|
|
516
|
-
const s = JSON.parse(
|
|
517
|
-
s &&
|
|
496
|
+
const s = JSON.parse(n);
|
|
497
|
+
s && r.workspace && e.clipboard.paste(s, r.workspace);
|
|
518
498
|
},
|
|
519
499
|
scopeType: e.ContextMenuRegistry.ScopeType.WORKSPACE,
|
|
520
500
|
id: "blockPasteFromStorage",
|
|
@@ -526,29 +506,29 @@ class G {
|
|
|
526
506
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
527
507
|
e.utils.KeyCodes.C,
|
|
528
508
|
[e.utils.KeyCodes.CTRL]
|
|
529
|
-
),
|
|
509
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
530
510
|
e.utils.KeyCodes.C,
|
|
531
511
|
[e.utils.KeyCodes.ALT]
|
|
532
|
-
),
|
|
512
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
533
513
|
e.utils.KeyCodes.C,
|
|
534
514
|
[e.utils.KeyCodes.META]
|
|
535
515
|
), s = {
|
|
536
516
|
name: "copy",
|
|
537
|
-
preconditionFn: function(
|
|
538
|
-
if (
|
|
517
|
+
preconditionFn: function(l) {
|
|
518
|
+
if (l.options.readOnly || e.Gesture.inProgress())
|
|
539
519
|
return !1;
|
|
540
520
|
const a = e.getSelected();
|
|
541
521
|
return !(!a || !e.isDeletable(a) || !a.isDeletable() || !e.isDraggable(a) || !a.isMovable() || !e.isCopyable(a));
|
|
542
522
|
},
|
|
543
|
-
callback: function(
|
|
523
|
+
callback: function(l, a) {
|
|
544
524
|
a.preventDefault();
|
|
545
|
-
const
|
|
546
|
-
if (!
|
|
525
|
+
const i = e.getSelected();
|
|
526
|
+
if (!i || !e.isCopyable(i))
|
|
547
527
|
return !1;
|
|
548
|
-
const c =
|
|
549
|
-
return c ? (
|
|
528
|
+
const c = i.toCopyData();
|
|
529
|
+
return c ? (l.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
|
|
550
530
|
},
|
|
551
|
-
keyCodes: [t,
|
|
531
|
+
keyCodes: [t, r, n]
|
|
552
532
|
};
|
|
553
533
|
e.ShortcutRegistry.registry.register(s);
|
|
554
534
|
}
|
|
@@ -556,29 +536,29 @@ class G {
|
|
|
556
536
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
557
537
|
e.utils.KeyCodes.X,
|
|
558
538
|
[e.utils.KeyCodes.CTRL]
|
|
559
|
-
),
|
|
539
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
560
540
|
e.utils.KeyCodes.X,
|
|
561
541
|
[e.utils.KeyCodes.ALT]
|
|
562
|
-
),
|
|
542
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
563
543
|
e.utils.KeyCodes.X,
|
|
564
544
|
[e.utils.KeyCodes.META]
|
|
565
545
|
), s = {
|
|
566
546
|
name: "cut",
|
|
567
|
-
preconditionFn: function(
|
|
568
|
-
if (
|
|
547
|
+
preconditionFn: function(l) {
|
|
548
|
+
if (l.options.readOnly || e.Gesture.inProgress())
|
|
569
549
|
return !1;
|
|
570
550
|
const a = e.getSelected();
|
|
571
551
|
return !(!a || !e.isDeletable(a) || !a.isDeletable() || !e.isDraggable(a) || !a.isMovable() || !e.isCopyable(a) || a.workspace.isFlyout);
|
|
572
552
|
},
|
|
573
|
-
callback: function(
|
|
553
|
+
callback: function(l, a) {
|
|
574
554
|
a.preventDefault();
|
|
575
|
-
const
|
|
576
|
-
if (!
|
|
555
|
+
const i = e.getSelected();
|
|
556
|
+
if (!i || !e.isDeletable(i) || !i.isDeletable() || !e.isCopyable(i))
|
|
577
557
|
return !1;
|
|
578
|
-
const c =
|
|
579
|
-
return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)),
|
|
558
|
+
const c = i.toCopyData();
|
|
559
|
+
return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), i instanceof e.BlockSvg ? i.checkAndDelete() : i.dispose(), !0) : !1;
|
|
580
560
|
},
|
|
581
|
-
keyCodes: [t,
|
|
561
|
+
keyCodes: [t, r, n]
|
|
582
562
|
};
|
|
583
563
|
e.ShortcutRegistry.registry.register(s);
|
|
584
564
|
}
|
|
@@ -586,101 +566,101 @@ class G {
|
|
|
586
566
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
587
567
|
e.utils.KeyCodes.V,
|
|
588
568
|
[e.utils.KeyCodes.CTRL]
|
|
589
|
-
),
|
|
569
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
590
570
|
e.utils.KeyCodes.V,
|
|
591
571
|
[e.utils.KeyCodes.ALT]
|
|
592
|
-
),
|
|
572
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
593
573
|
e.utils.KeyCodes.V,
|
|
594
574
|
[e.utils.KeyCodes.META]
|
|
595
575
|
), s = {
|
|
596
576
|
name: "paste",
|
|
597
|
-
preconditionFn: function(
|
|
598
|
-
if (
|
|
577
|
+
preconditionFn: function(l) {
|
|
578
|
+
if (l.options.readOnly || e.Gesture.inProgress())
|
|
599
579
|
return !1;
|
|
600
580
|
const a = localStorage.getItem("blocklyStash");
|
|
601
581
|
if (!a)
|
|
602
582
|
return !1;
|
|
603
|
-
const
|
|
604
|
-
return !(!
|
|
583
|
+
const i = JSON.parse(a);
|
|
584
|
+
return !(!i || !l.isCapacityAvailable(i.typeCounts));
|
|
605
585
|
},
|
|
606
|
-
callback: function(
|
|
586
|
+
callback: function(l, a) {
|
|
607
587
|
a.preventDefault();
|
|
608
|
-
const
|
|
609
|
-
if (!
|
|
588
|
+
const i = localStorage.getItem("blocklyStash");
|
|
589
|
+
if (!i)
|
|
610
590
|
return !1;
|
|
611
|
-
const c = JSON.parse(
|
|
612
|
-
return c ? (e.clipboard.paste(c,
|
|
591
|
+
const c = JSON.parse(i);
|
|
592
|
+
return c ? (e.clipboard.paste(c, l), !0) : !1;
|
|
613
593
|
},
|
|
614
|
-
keyCodes: [t,
|
|
594
|
+
keyCodes: [t, r, n]
|
|
615
595
|
};
|
|
616
596
|
e.ShortcutRegistry.registry.register(s);
|
|
617
597
|
}
|
|
618
598
|
}
|
|
619
|
-
class
|
|
599
|
+
class Y {
|
|
620
600
|
init() {
|
|
621
601
|
const t = e.ContextMenuRegistry.registry.getItem("cleanWorkspace");
|
|
622
|
-
t && (t.callback = function(
|
|
623
|
-
const
|
|
624
|
-
if (!
|
|
602
|
+
t && (t.callback = function(r) {
|
|
603
|
+
const n = r.workspace;
|
|
604
|
+
if (!n)
|
|
625
605
|
return;
|
|
626
|
-
|
|
627
|
-
const s =
|
|
628
|
-
let
|
|
629
|
-
for (let a = 0,
|
|
630
|
-
if (!
|
|
606
|
+
n.setResizesEnabled(!1), e.Events.setGroup(!0);
|
|
607
|
+
const s = n.getTopBlocks(!0);
|
|
608
|
+
let l = 0;
|
|
609
|
+
for (let a = 0, i; i = s[a]; a++) {
|
|
610
|
+
if (!i.isMovable())
|
|
631
611
|
continue;
|
|
632
|
-
const c =
|
|
633
|
-
|
|
612
|
+
const c = i.getRelativeToSurfaceXY();
|
|
613
|
+
i.moveBy(-c.x, l - c.y, ["cleanup"]), i.snapToGrid(), l = i.getRelativeToSurfaceXY().y + i.getHeightWidth().height + 100;
|
|
634
614
|
}
|
|
635
|
-
e.Events.setGroup(!1),
|
|
615
|
+
e.Events.setGroup(!1), n.setResizesEnabled(!0);
|
|
636
616
|
});
|
|
637
617
|
}
|
|
638
618
|
}
|
|
639
|
-
function
|
|
619
|
+
function d(o) {
|
|
640
620
|
const t = o.getParent();
|
|
641
|
-
return t &&
|
|
621
|
+
return t && d(t) ? !0 : !t && !!(o.outputConnection || o.previousConnection);
|
|
642
622
|
}
|
|
643
|
-
class
|
|
623
|
+
class W {
|
|
644
624
|
init() {
|
|
645
625
|
const t = e.ContextMenuRegistry.registry.getItem("blockDisable");
|
|
646
|
-
t && (t.preconditionFn = function(
|
|
647
|
-
const
|
|
648
|
-
return
|
|
626
|
+
t && (t.preconditionFn = function(r) {
|
|
627
|
+
const n = r.block;
|
|
628
|
+
return n && !n.isInFlyout && n.workspace.options.disable && n.isEditable() ? n.getInheritedDisabled() || d(n) ? "disabled" : "enabled" : "hidden";
|
|
649
629
|
});
|
|
650
630
|
}
|
|
651
631
|
}
|
|
652
|
-
class
|
|
653
|
-
addBlockListeners_(t,
|
|
654
|
-
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t,
|
|
632
|
+
class G extends e.HorizontalFlyout {
|
|
633
|
+
addBlockListeners_(t, r, n) {
|
|
634
|
+
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, r, n);
|
|
655
635
|
}
|
|
656
636
|
isBlockCreatable(t) {
|
|
657
637
|
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
658
638
|
}
|
|
659
639
|
}
|
|
660
|
-
class
|
|
661
|
-
addBlockListeners_(t,
|
|
662
|
-
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t,
|
|
640
|
+
class H extends e.VerticalFlyout {
|
|
641
|
+
addBlockListeners_(t, r, n) {
|
|
642
|
+
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, r, n);
|
|
663
643
|
}
|
|
664
644
|
isBlockCreatable(t) {
|
|
665
645
|
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
666
646
|
}
|
|
667
647
|
}
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
const
|
|
673
|
-
|
|
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();
|
|
674
654
|
e.registry.register(
|
|
675
655
|
e.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
|
|
676
656
|
e.registry.DEFAULT,
|
|
677
|
-
|
|
657
|
+
G,
|
|
678
658
|
!0
|
|
679
659
|
);
|
|
680
660
|
e.registry.register(
|
|
681
661
|
e.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
|
|
682
662
|
e.registry.DEFAULT,
|
|
683
|
-
|
|
663
|
+
H,
|
|
684
664
|
!0
|
|
685
665
|
);
|
|
686
666
|
e.Themes.Classic.blockStyles = {
|
|
@@ -807,7 +787,7 @@ e.Themes.Classic.categoryStyles = {
|
|
|
807
787
|
colour: "#a55b80"
|
|
808
788
|
}
|
|
809
789
|
};
|
|
810
|
-
const
|
|
790
|
+
const j = e.Theme.defineTheme("light", {
|
|
811
791
|
name: "light",
|
|
812
792
|
base: e.Themes.Classic,
|
|
813
793
|
componentStyles: {
|
|
@@ -823,7 +803,7 @@ const Z = e.Theme.defineTheme("light", {
|
|
|
823
803
|
scrollbarOpacity: 0.4,
|
|
824
804
|
cursorColour: ""
|
|
825
805
|
}
|
|
826
|
-
}),
|
|
806
|
+
}), q = e.Theme.defineTheme("dark", {
|
|
827
807
|
name: "dark",
|
|
828
808
|
base: e.Themes.Classic,
|
|
829
809
|
componentStyles: {
|
|
@@ -840,18 +820,18 @@ const Z = e.Theme.defineTheme("light", {
|
|
|
840
820
|
cursorColour: ""
|
|
841
821
|
}
|
|
842
822
|
});
|
|
843
|
-
function
|
|
823
|
+
function $(o) {
|
|
844
824
|
const t = e.getMainWorkspace();
|
|
845
825
|
switch (console.log(t), o) {
|
|
846
826
|
case "light":
|
|
847
|
-
t.setTheme(
|
|
827
|
+
t.setTheme(j);
|
|
848
828
|
break;
|
|
849
829
|
case "dark":
|
|
850
|
-
t.setTheme(
|
|
830
|
+
t.setTheme(q);
|
|
851
831
|
break;
|
|
852
832
|
}
|
|
853
833
|
}
|
|
854
|
-
const
|
|
834
|
+
const Z = {
|
|
855
835
|
kind: "category",
|
|
856
836
|
name: "%{BKY_CATEGORY_LOGIC}",
|
|
857
837
|
categorystyle: "logic_category",
|
|
@@ -869,7 +849,7 @@ const te = {
|
|
|
869
849
|
type: "if_v1"
|
|
870
850
|
}
|
|
871
851
|
]
|
|
872
|
-
},
|
|
852
|
+
}, Q = {
|
|
873
853
|
kind: "category",
|
|
874
854
|
name: "%{BKY_CATEGORY_LOOP}",
|
|
875
855
|
categorystyle: "loop_category",
|
|
@@ -891,34 +871,10 @@ const te = {
|
|
|
891
871
|
type: "for_each_v1"
|
|
892
872
|
}
|
|
893
873
|
]
|
|
894
|
-
},
|
|
874
|
+
}, ee = {
|
|
895
875
|
kind: "categoryToolbox",
|
|
896
|
-
contents: [
|
|
897
|
-
}
|
|
898
|
-
function re(o, t) {
|
|
899
|
-
var s, i;
|
|
900
|
-
const n = t.value, r = {
|
|
901
|
-
passive: !((s = t.modifiers) != null && s.active)
|
|
902
|
-
};
|
|
903
|
-
window.addEventListener("resize", n, r), o._onResize = Object(o._onResize), o._onResize[t.instance.$.uid] = {
|
|
904
|
-
handler: n,
|
|
905
|
-
options: r
|
|
906
|
-
}, (i = t.modifiers) != null && i.quiet || n();
|
|
907
|
-
}
|
|
908
|
-
function se(o, t) {
|
|
909
|
-
var s;
|
|
910
|
-
if (!((s = o._onResize) != null && s[t.instance.$.uid]))
|
|
911
|
-
return;
|
|
912
|
-
const {
|
|
913
|
-
handler: n,
|
|
914
|
-
options: r
|
|
915
|
-
} = o._onResize[t.instance.$.uid];
|
|
916
|
-
window.removeEventListener("resize", n, r), delete o._onResize[t.instance.$.uid];
|
|
917
|
-
}
|
|
918
|
-
const ie = {
|
|
919
|
-
mounted: re,
|
|
920
|
-
unmounted: se
|
|
921
|
-
}, le = { class: "position-relative w-100 h-100" }, ae = /* @__PURE__ */ m({
|
|
876
|
+
contents: [Z, Q]
|
|
877
|
+
}, te = { class: "position-relative w-100 h-100" }, oe = /* @__PURE__ */ b({
|
|
922
878
|
__name: "index",
|
|
923
879
|
props: {
|
|
924
880
|
type: {},
|
|
@@ -926,9 +882,9 @@ const ie = {
|
|
|
926
882
|
},
|
|
927
883
|
emits: ["ready", "change"],
|
|
928
884
|
setup(o, { emit: t }) {
|
|
929
|
-
const
|
|
885
|
+
const r = B(), n = R(), { open: s } = F("blocklyEditorFlyout"), l = o, a = t, i = C(null);
|
|
930
886
|
let c;
|
|
931
|
-
const
|
|
887
|
+
const y = {
|
|
932
888
|
grid: {
|
|
933
889
|
length: 2,
|
|
934
890
|
snap: !0,
|
|
@@ -941,7 +897,7 @@ const ie = {
|
|
|
941
897
|
wheel: !0
|
|
942
898
|
},
|
|
943
899
|
readOnly: !1,
|
|
944
|
-
theme:
|
|
900
|
+
theme: n.current.value.dark ? "dark" : "light",
|
|
945
901
|
trashcan: !1,
|
|
946
902
|
zoom: {
|
|
947
903
|
maxScale: 1,
|
|
@@ -951,48 +907,51 @@ const ie = {
|
|
|
951
907
|
wheel: !0
|
|
952
908
|
}
|
|
953
909
|
};
|
|
954
|
-
|
|
955
|
-
if (!
|
|
910
|
+
m(async () => {
|
|
911
|
+
if (!i.value)
|
|
956
912
|
return;
|
|
957
|
-
await f(
|
|
913
|
+
await f(r.current.value);
|
|
958
914
|
let u;
|
|
959
|
-
|
|
915
|
+
l.type === "app" && l.version === "v1" && (u = ee), y.toolbox = u, c = e.inject(i.value, y), c.addChangeListener(e.Events.disableOrphans), c.addChangeListener(h), await k(), a("ready", c);
|
|
960
916
|
});
|
|
961
|
-
function
|
|
917
|
+
function g() {
|
|
962
918
|
c && e.svgResize(c);
|
|
963
919
|
}
|
|
964
|
-
function
|
|
920
|
+
function h(u) {
|
|
965
921
|
a("change", u);
|
|
966
922
|
}
|
|
967
|
-
return
|
|
923
|
+
return S(() => {
|
|
968
924
|
s.value = !1;
|
|
969
|
-
}),
|
|
925
|
+
}), p(s, (u) => {
|
|
970
926
|
var _;
|
|
971
927
|
u || (_ = c.getToolbox()) == null || _.clearSelection();
|
|
972
|
-
}),
|
|
973
|
-
() =>
|
|
928
|
+
}), p(
|
|
929
|
+
() => r.current.value,
|
|
974
930
|
(u) => {
|
|
975
931
|
f(u);
|
|
976
932
|
}
|
|
977
|
-
),
|
|
978
|
-
() =>
|
|
933
|
+
), p(
|
|
934
|
+
() => n.current.value.dark,
|
|
979
935
|
(u) => {
|
|
980
|
-
|
|
936
|
+
$(u ? "dark" : "light");
|
|
981
937
|
}
|
|
982
|
-
), (u, _) =>
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
938
|
+
), (u, _) => {
|
|
939
|
+
const O = T("resize");
|
|
940
|
+
return L(), E("div", te, [
|
|
941
|
+
I(v("div", {
|
|
942
|
+
class: "w-100 h-100",
|
|
943
|
+
ref_key: "blocklyDiv",
|
|
944
|
+
ref: i,
|
|
945
|
+
id: "blocklyEditor"
|
|
946
|
+
}, null, 512), [
|
|
947
|
+
[O, g]
|
|
948
|
+
])
|
|
949
|
+
]);
|
|
950
|
+
};
|
|
992
951
|
}
|
|
993
|
-
}),
|
|
994
|
-
o.component("x-blockly",
|
|
995
|
-
},
|
|
952
|
+
}), re = (o) => {
|
|
953
|
+
o.component("x-blockly", oe);
|
|
954
|
+
}, ae = { install: re };
|
|
996
955
|
export {
|
|
997
|
-
|
|
956
|
+
ae as default
|
|
998
957
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-block-lib",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"blockly": "^11.1.0",
|
|
26
26
|
"vue": "^3.4.27",
|
|
27
27
|
"vuetify": "^3.6.8",
|
|
28
|
-
"x-essential-lib": "^0.
|
|
28
|
+
"x-essential-lib": "^0.4.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@rushstack/eslint-patch": "^1.8.0",
|