x-block-lib 0.3.0 → 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 +133 -163
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,39 +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 {
|
|
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";
|
|
3
5
|
import * as e from "blockly/core";
|
|
4
|
-
import { javascriptGenerator as
|
|
5
|
-
const T = Vue.getCurrentInstance;
|
|
6
|
-
function L(o, t) {
|
|
7
|
-
const n = T();
|
|
8
|
-
if (!n)
|
|
9
|
-
throw new Error(`[Vuetify] ${o} must be called from inside a setup function`);
|
|
10
|
-
return n;
|
|
11
|
-
}
|
|
12
|
-
Vue.computed;
|
|
13
|
-
const E = Vue.inject;
|
|
14
|
-
Vue.provide;
|
|
15
|
-
Vue.ref;
|
|
16
|
-
const v = Symbol.for("vuetify:locale");
|
|
17
|
-
function I() {
|
|
18
|
-
const o = E(v);
|
|
19
|
-
if (!o)
|
|
20
|
-
throw new Error("[Vuetify] Could not find injected locale instance");
|
|
21
|
-
return o;
|
|
22
|
-
}
|
|
23
|
-
Vue.computed;
|
|
24
|
-
const B = Vue.inject;
|
|
25
|
-
Vue.provide;
|
|
26
|
-
Vue.ref;
|
|
27
|
-
Vue.watch;
|
|
28
|
-
Vue.watchEffect;
|
|
29
|
-
const R = Symbol.for("vuetify:theme");
|
|
30
|
-
function x() {
|
|
31
|
-
L("useTheme");
|
|
32
|
-
const o = B(R, null);
|
|
33
|
-
if (!o)
|
|
34
|
-
throw new Error("Could not find Vuetify theme injection");
|
|
35
|
-
return o;
|
|
36
|
-
}
|
|
6
|
+
import { javascriptGenerator as M, Order as K } from "blockly/javascript";
|
|
37
7
|
e.defineBlocksWithJsonArray([
|
|
38
8
|
{
|
|
39
9
|
type: "boolean_v1",
|
|
@@ -54,10 +24,10 @@ e.defineBlocksWithJsonArray([
|
|
|
54
24
|
helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
|
|
55
25
|
}
|
|
56
26
|
]);
|
|
57
|
-
|
|
58
|
-
return [o.getFieldValue("BOOL") === "TRUE" ? "true" : "false",
|
|
27
|
+
M.forBlock.boolean_v1 = function(o) {
|
|
28
|
+
return [o.getFieldValue("BOOL") === "TRUE" ? "true" : "false", K.ATOMIC];
|
|
59
29
|
};
|
|
60
|
-
const
|
|
30
|
+
const A = {
|
|
61
31
|
elseIfCount_: 0,
|
|
62
32
|
hasElse_: !1,
|
|
63
33
|
mutationToDom: function() {
|
|
@@ -81,23 +51,23 @@ const P = {
|
|
|
81
51
|
decompose: function(o) {
|
|
82
52
|
const t = o.newBlock("if_if_v1");
|
|
83
53
|
t.initSvg();
|
|
84
|
-
let
|
|
85
|
-
for (let
|
|
54
|
+
let r = t.nextConnection;
|
|
55
|
+
for (let n = 0; n < this.elseIfCount_; n++) {
|
|
86
56
|
const s = o.newBlock(
|
|
87
57
|
"if_else_if_v1"
|
|
88
58
|
);
|
|
89
|
-
s.initSvg(),
|
|
59
|
+
s.initSvg(), r.connect(s.previousConnection), r = s.nextConnection;
|
|
90
60
|
}
|
|
91
61
|
if (this.hasElse_) {
|
|
92
|
-
const
|
|
93
|
-
|
|
62
|
+
const n = o.newBlock("if_else_v1");
|
|
63
|
+
n.initSvg(), r.connect(n.previousConnection);
|
|
94
64
|
}
|
|
95
65
|
return t;
|
|
96
66
|
},
|
|
97
67
|
compose: function(o) {
|
|
98
68
|
let t = o.nextConnection.targetBlock();
|
|
99
69
|
this.elseIfCount_ = 0, this.hasElse_ = !1;
|
|
100
|
-
const
|
|
70
|
+
const r = [null], n = [null];
|
|
101
71
|
let s = null;
|
|
102
72
|
for (; t; ) {
|
|
103
73
|
if (t.isInsertionMarker()) {
|
|
@@ -106,9 +76,9 @@ const P = {
|
|
|
106
76
|
}
|
|
107
77
|
switch (t.type) {
|
|
108
78
|
case "if_else_if_v1":
|
|
109
|
-
this.elseIfCount_++,
|
|
79
|
+
this.elseIfCount_++, r.push(
|
|
110
80
|
t.valueConnection_
|
|
111
|
-
),
|
|
81
|
+
), n.push(
|
|
112
82
|
t.statementConnection_
|
|
113
83
|
);
|
|
114
84
|
break;
|
|
@@ -121,13 +91,13 @@ const P = {
|
|
|
121
91
|
t = t.getNextBlock();
|
|
122
92
|
}
|
|
123
93
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
124
|
-
n,
|
|
125
94
|
r,
|
|
95
|
+
n,
|
|
126
96
|
s
|
|
127
97
|
);
|
|
128
98
|
},
|
|
129
99
|
saveConnections: function(o) {
|
|
130
|
-
let t = o.nextConnection.targetBlock(),
|
|
100
|
+
let t = o.nextConnection.targetBlock(), r = 1;
|
|
131
101
|
for (; t; ) {
|
|
132
102
|
if (t.isInsertionMarker()) {
|
|
133
103
|
t = t.getNextBlock();
|
|
@@ -135,13 +105,13 @@ const P = {
|
|
|
135
105
|
}
|
|
136
106
|
switch (t.type) {
|
|
137
107
|
case "if_else_if_v1": {
|
|
138
|
-
const
|
|
139
|
-
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++;
|
|
140
110
|
break;
|
|
141
111
|
}
|
|
142
112
|
case "if_else_v1": {
|
|
143
|
-
const
|
|
144
|
-
t.statementConnection_ =
|
|
113
|
+
const n = this.getInput("ELSE");
|
|
114
|
+
t.statementConnection_ = n && n.connection.targetConnection;
|
|
145
115
|
break;
|
|
146
116
|
}
|
|
147
117
|
default:
|
|
@@ -152,16 +122,16 @@ const P = {
|
|
|
152
122
|
},
|
|
153
123
|
rebuildShape_: function() {
|
|
154
124
|
const o = [null], t = [null];
|
|
155
|
-
let
|
|
156
|
-
this.getInput("ELSE") && (
|
|
157
|
-
for (let
|
|
158
|
-
const s = this.getInput("IF" +
|
|
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);
|
|
159
129
|
o.push(s.connection.targetConnection), t.push(l.connection.targetConnection);
|
|
160
130
|
}
|
|
161
131
|
this.updateShape_(), this.reconnectChildBlocks_(
|
|
162
132
|
o,
|
|
163
133
|
t,
|
|
164
|
-
|
|
134
|
+
r
|
|
165
135
|
);
|
|
166
136
|
},
|
|
167
137
|
updateShape_: function() {
|
|
@@ -172,16 +142,16 @@ const P = {
|
|
|
172
142
|
this.appendValueInput("IF" + o).setCheck("Boolean").appendField(e.Msg.LOGIC_ELSE_IF), this.appendStatementInput("DO" + o).appendField(e.Msg.LOGIC_DO);
|
|
173
143
|
this.hasElse_ && this.appendStatementInput("ELSE").appendField(e.Msg.LOGIC_ELSE);
|
|
174
144
|
},
|
|
175
|
-
reconnectChildBlocks_: function(o, t,
|
|
176
|
-
var
|
|
145
|
+
reconnectChildBlocks_: function(o, t, r) {
|
|
146
|
+
var n, s;
|
|
177
147
|
for (let l = 1; l <= this.elseIfCount_; l++)
|
|
178
|
-
(
|
|
179
|
-
|
|
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");
|
|
180
150
|
}
|
|
181
151
|
};
|
|
182
152
|
e.Extensions.registerMutator(
|
|
183
153
|
"if_v1_mutator",
|
|
184
|
-
|
|
154
|
+
A,
|
|
185
155
|
void 0,
|
|
186
156
|
["if_else_if_v1", "if_else_v1"]
|
|
187
157
|
);
|
|
@@ -237,8 +207,8 @@ const w = {
|
|
|
237
207
|
customContextMenu: function(o) {
|
|
238
208
|
if (this.isInFlyout)
|
|
239
209
|
return;
|
|
240
|
-
const t = this.getField("VAR"),
|
|
241
|
-
if (!this.isCollapsed() &&
|
|
210
|
+
const t = this.getField("VAR"), r = t.getVariable(), n = r == null ? void 0 : r.name;
|
|
211
|
+
if (!this.isCollapsed() && n) {
|
|
242
212
|
const s = {
|
|
243
213
|
type: "variables_get",
|
|
244
214
|
fields: {
|
|
@@ -247,7 +217,7 @@ const w = {
|
|
|
247
217
|
};
|
|
248
218
|
o.push({
|
|
249
219
|
enabled: !0,
|
|
250
|
-
text: e.Msg.VARIABLES_SET_CREATE_GET.replace("%1",
|
|
220
|
+
text: e.Msg.VARIABLES_SET_CREATE_GET.replace("%1", n),
|
|
251
221
|
callback: e.ContextMenu.callbackFactory(this, s)
|
|
252
222
|
});
|
|
253
223
|
}
|
|
@@ -264,16 +234,16 @@ e.Extensions.register(
|
|
|
264
234
|
CONTINUE: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}"
|
|
265
235
|
})
|
|
266
236
|
);
|
|
267
|
-
const
|
|
237
|
+
const D = /* @__PURE__ */ new Set([
|
|
268
238
|
"repeat_v1",
|
|
269
239
|
"for_each_v1",
|
|
270
240
|
"for_v1",
|
|
271
241
|
"while_until_v1"
|
|
272
|
-
]),
|
|
242
|
+
]), N = {
|
|
273
243
|
getSurroundLoop: function() {
|
|
274
244
|
let o = this;
|
|
275
245
|
do {
|
|
276
|
-
if (
|
|
246
|
+
if (D.has(o.type))
|
|
277
247
|
return !0;
|
|
278
248
|
o = o == null ? void 0 : o.getSurroundParent();
|
|
279
249
|
} while (o);
|
|
@@ -283,12 +253,12 @@ const V = /* @__PURE__ */ new Set([
|
|
|
283
253
|
const t = this.workspace;
|
|
284
254
|
if (!t.isDragging || t.isDragging() || o.type !== e.Events.BLOCK_MOVE && o.type !== e.Events.BLOCK_CREATE)
|
|
285
255
|
return;
|
|
286
|
-
const
|
|
287
|
-
if (console.log(o.type,
|
|
288
|
-
|
|
256
|
+
const r = this.getSurroundLoop();
|
|
257
|
+
if (console.log(o.type, r), this.setWarningText(
|
|
258
|
+
r ? null : e.Msg.LOOP_FLOW_CONTROL_WARNING
|
|
289
259
|
), !this.isInFlyout)
|
|
290
260
|
try {
|
|
291
|
-
e.Events.setRecordUndo(!1), this.setDisabledReason(!
|
|
261
|
+
e.Events.setRecordUndo(!1), this.setDisabledReason(!r, "FLOW_CONTROL_NOT_IN_LOOP");
|
|
292
262
|
} finally {
|
|
293
263
|
e.Events.setRecordUndo(!0);
|
|
294
264
|
}
|
|
@@ -296,7 +266,7 @@ const V = /* @__PURE__ */ new Set([
|
|
|
296
266
|
};
|
|
297
267
|
e.Extensions.registerMixin(
|
|
298
268
|
"flow_control_in_loop_check_v1",
|
|
299
|
-
|
|
269
|
+
N
|
|
300
270
|
);
|
|
301
271
|
e.defineBlocksWithJsonArray([
|
|
302
272
|
{
|
|
@@ -448,35 +418,35 @@ e.defineBlocksWithJsonArray([
|
|
|
448
418
|
}
|
|
449
419
|
]);
|
|
450
420
|
e.dialog.setConfirm(async (o, t) => {
|
|
451
|
-
const
|
|
421
|
+
const r = await x({
|
|
452
422
|
title: "",
|
|
453
423
|
text: o
|
|
454
424
|
});
|
|
455
|
-
t(!!
|
|
425
|
+
t(!!r);
|
|
456
426
|
});
|
|
457
|
-
e.dialog.setPrompt(async (o, t,
|
|
458
|
-
const
|
|
427
|
+
e.dialog.setPrompt(async (o, t, r) => {
|
|
428
|
+
const n = await P({
|
|
459
429
|
title: "",
|
|
460
430
|
value: t
|
|
461
431
|
});
|
|
462
|
-
n
|
|
432
|
+
r(n);
|
|
463
433
|
});
|
|
464
|
-
const
|
|
465
|
-
const
|
|
466
|
-
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) => {
|
|
467
437
|
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(s.bind(null, new Error("Unknown variable dynamic import: " + t)));
|
|
468
438
|
});
|
|
469
439
|
};
|
|
470
440
|
async function f(o) {
|
|
471
|
-
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`);
|
|
472
442
|
e.setLocale(t.default);
|
|
473
443
|
}
|
|
474
|
-
class
|
|
475
|
-
init({ contextMenu: t = !0, shortcut:
|
|
444
|
+
class V {
|
|
445
|
+
init({ contextMenu: t = !0, shortcut: r = !0 } = {
|
|
476
446
|
contextMenu: !0,
|
|
477
447
|
shortcut: !0
|
|
478
448
|
}) {
|
|
479
|
-
t && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()),
|
|
449
|
+
t && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), r && (e.ShortcutRegistry.registry.unregister(
|
|
480
450
|
e.ShortcutItems.names.COPY
|
|
481
451
|
), e.ShortcutRegistry.registry.unregister(
|
|
482
452
|
e.ShortcutItems.names.CUT
|
|
@@ -490,14 +460,14 @@ class K {
|
|
|
490
460
|
return e.Msg.CROSS_TAB_COPY ? e.Msg.CROSS_TAB_COPY : "Copy";
|
|
491
461
|
},
|
|
492
462
|
preconditionFn: function() {
|
|
493
|
-
const
|
|
494
|
-
return !
|
|
463
|
+
const r = e.getSelected();
|
|
464
|
+
return !r || !e.isDeletable(r) || !r.isDeletable() || !e.isDraggable(r) || !r.isMovable() || !e.isCopyable(r) ? "disabled" : "enabled";
|
|
495
465
|
},
|
|
496
|
-
callback: function(
|
|
497
|
-
var
|
|
466
|
+
callback: function(r) {
|
|
467
|
+
var n;
|
|
498
468
|
localStorage.setItem(
|
|
499
469
|
"blocklyStash",
|
|
500
|
-
JSON.stringify((
|
|
470
|
+
JSON.stringify((n = r.block) == null ? void 0 : n.toCopyData())
|
|
501
471
|
);
|
|
502
472
|
},
|
|
503
473
|
scopeType: e.ContextMenuRegistry.ScopeType.BLOCK,
|
|
@@ -511,20 +481,20 @@ class K {
|
|
|
511
481
|
displayText: function() {
|
|
512
482
|
return e.Msg.CROSS_TAB_PASTE ? e.Msg.CROSS_TAB_PASTE : "Paste";
|
|
513
483
|
},
|
|
514
|
-
preconditionFn: function(
|
|
484
|
+
preconditionFn: function(r) {
|
|
515
485
|
var l;
|
|
516
|
-
const
|
|
517
|
-
if (!
|
|
486
|
+
const n = localStorage.getItem("blocklyStash");
|
|
487
|
+
if (!n)
|
|
518
488
|
return "disabled";
|
|
519
|
-
const s = JSON.parse(
|
|
520
|
-
return !s || !((l =
|
|
489
|
+
const s = JSON.parse(n);
|
|
490
|
+
return !s || !((l = r.workspace) != null && l.isCapacityAvailable(s.typeCounts)) ? "disabled" : "enabled";
|
|
521
491
|
},
|
|
522
|
-
callback: function(
|
|
523
|
-
const
|
|
524
|
-
if (!
|
|
492
|
+
callback: function(r) {
|
|
493
|
+
const n = localStorage.getItem("blocklyStash");
|
|
494
|
+
if (!n)
|
|
525
495
|
return;
|
|
526
|
-
const s = JSON.parse(
|
|
527
|
-
s &&
|
|
496
|
+
const s = JSON.parse(n);
|
|
497
|
+
s && r.workspace && e.clipboard.paste(s, r.workspace);
|
|
528
498
|
},
|
|
529
499
|
scopeType: e.ContextMenuRegistry.ScopeType.WORKSPACE,
|
|
530
500
|
id: "blockPasteFromStorage",
|
|
@@ -536,10 +506,10 @@ class K {
|
|
|
536
506
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
537
507
|
e.utils.KeyCodes.C,
|
|
538
508
|
[e.utils.KeyCodes.CTRL]
|
|
539
|
-
),
|
|
509
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
540
510
|
e.utils.KeyCodes.C,
|
|
541
511
|
[e.utils.KeyCodes.ALT]
|
|
542
|
-
),
|
|
512
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
543
513
|
e.utils.KeyCodes.C,
|
|
544
514
|
[e.utils.KeyCodes.META]
|
|
545
515
|
), s = {
|
|
@@ -558,7 +528,7 @@ class K {
|
|
|
558
528
|
const c = i.toCopyData();
|
|
559
529
|
return c ? (l.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
|
|
560
530
|
},
|
|
561
|
-
keyCodes: [t,
|
|
531
|
+
keyCodes: [t, r, n]
|
|
562
532
|
};
|
|
563
533
|
e.ShortcutRegistry.registry.register(s);
|
|
564
534
|
}
|
|
@@ -566,10 +536,10 @@ class K {
|
|
|
566
536
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
567
537
|
e.utils.KeyCodes.X,
|
|
568
538
|
[e.utils.KeyCodes.CTRL]
|
|
569
|
-
),
|
|
539
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
570
540
|
e.utils.KeyCodes.X,
|
|
571
541
|
[e.utils.KeyCodes.ALT]
|
|
572
|
-
),
|
|
542
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
573
543
|
e.utils.KeyCodes.X,
|
|
574
544
|
[e.utils.KeyCodes.META]
|
|
575
545
|
), s = {
|
|
@@ -588,7 +558,7 @@ class K {
|
|
|
588
558
|
const c = i.toCopyData();
|
|
589
559
|
return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), i instanceof e.BlockSvg ? i.checkAndDelete() : i.dispose(), !0) : !1;
|
|
590
560
|
},
|
|
591
|
-
keyCodes: [t,
|
|
561
|
+
keyCodes: [t, r, n]
|
|
592
562
|
};
|
|
593
563
|
e.ShortcutRegistry.registry.register(s);
|
|
594
564
|
}
|
|
@@ -596,10 +566,10 @@ class K {
|
|
|
596
566
|
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
597
567
|
e.utils.KeyCodes.V,
|
|
598
568
|
[e.utils.KeyCodes.CTRL]
|
|
599
|
-
),
|
|
569
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
600
570
|
e.utils.KeyCodes.V,
|
|
601
571
|
[e.utils.KeyCodes.ALT]
|
|
602
|
-
),
|
|
572
|
+
), n = e.ShortcutRegistry.registry.createSerializedKey(
|
|
603
573
|
e.utils.KeyCodes.V,
|
|
604
574
|
[e.utils.KeyCodes.META]
|
|
605
575
|
), s = {
|
|
@@ -621,20 +591,20 @@ class K {
|
|
|
621
591
|
const c = JSON.parse(i);
|
|
622
592
|
return c ? (e.clipboard.paste(c, l), !0) : !1;
|
|
623
593
|
},
|
|
624
|
-
keyCodes: [t,
|
|
594
|
+
keyCodes: [t, r, n]
|
|
625
595
|
};
|
|
626
596
|
e.ShortcutRegistry.registry.register(s);
|
|
627
597
|
}
|
|
628
598
|
}
|
|
629
|
-
class
|
|
599
|
+
class Y {
|
|
630
600
|
init() {
|
|
631
601
|
const t = e.ContextMenuRegistry.registry.getItem("cleanWorkspace");
|
|
632
|
-
t && (t.callback = function(
|
|
633
|
-
const
|
|
634
|
-
if (!
|
|
602
|
+
t && (t.callback = function(r) {
|
|
603
|
+
const n = r.workspace;
|
|
604
|
+
if (!n)
|
|
635
605
|
return;
|
|
636
|
-
|
|
637
|
-
const s =
|
|
606
|
+
n.setResizesEnabled(!1), e.Events.setGroup(!0);
|
|
607
|
+
const s = n.getTopBlocks(!0);
|
|
638
608
|
let l = 0;
|
|
639
609
|
for (let a = 0, i; i = s[a]; a++) {
|
|
640
610
|
if (!i.isMovable())
|
|
@@ -642,7 +612,7 @@ class A {
|
|
|
642
612
|
const c = i.getRelativeToSurfaceXY();
|
|
643
613
|
i.moveBy(-c.x, l - c.y, ["cleanup"]), i.snapToGrid(), l = i.getRelativeToSurfaceXY().y + i.getHeightWidth().height + 100;
|
|
644
614
|
}
|
|
645
|
-
e.Events.setGroup(!1),
|
|
615
|
+
e.Events.setGroup(!1), n.setResizesEnabled(!0);
|
|
646
616
|
});
|
|
647
617
|
}
|
|
648
618
|
}
|
|
@@ -650,47 +620,47 @@ function d(o) {
|
|
|
650
620
|
const t = o.getParent();
|
|
651
621
|
return t && d(t) ? !0 : !t && !!(o.outputConnection || o.previousConnection);
|
|
652
622
|
}
|
|
653
|
-
class
|
|
623
|
+
class W {
|
|
654
624
|
init() {
|
|
655
625
|
const t = e.ContextMenuRegistry.registry.getItem("blockDisable");
|
|
656
|
-
t && (t.preconditionFn = function(
|
|
657
|
-
const
|
|
658
|
-
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";
|
|
659
629
|
});
|
|
660
630
|
}
|
|
661
631
|
}
|
|
662
|
-
class
|
|
663
|
-
addBlockListeners_(t,
|
|
664
|
-
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);
|
|
665
635
|
}
|
|
666
636
|
isBlockCreatable(t) {
|
|
667
637
|
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
668
638
|
}
|
|
669
639
|
}
|
|
670
|
-
class
|
|
671
|
-
addBlockListeners_(t,
|
|
672
|
-
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);
|
|
673
643
|
}
|
|
674
644
|
isBlockCreatable(t) {
|
|
675
645
|
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
676
646
|
}
|
|
677
647
|
}
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
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();
|
|
684
654
|
e.registry.register(
|
|
685
655
|
e.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
|
|
686
656
|
e.registry.DEFAULT,
|
|
687
|
-
|
|
657
|
+
G,
|
|
688
658
|
!0
|
|
689
659
|
);
|
|
690
660
|
e.registry.register(
|
|
691
661
|
e.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
|
|
692
662
|
e.registry.DEFAULT,
|
|
693
|
-
|
|
663
|
+
H,
|
|
694
664
|
!0
|
|
695
665
|
);
|
|
696
666
|
e.Themes.Classic.blockStyles = {
|
|
@@ -817,7 +787,7 @@ e.Themes.Classic.categoryStyles = {
|
|
|
817
787
|
colour: "#a55b80"
|
|
818
788
|
}
|
|
819
789
|
};
|
|
820
|
-
const
|
|
790
|
+
const j = e.Theme.defineTheme("light", {
|
|
821
791
|
name: "light",
|
|
822
792
|
base: e.Themes.Classic,
|
|
823
793
|
componentStyles: {
|
|
@@ -833,7 +803,7 @@ const H = e.Theme.defineTheme("light", {
|
|
|
833
803
|
scrollbarOpacity: 0.4,
|
|
834
804
|
cursorColour: ""
|
|
835
805
|
}
|
|
836
|
-
}),
|
|
806
|
+
}), q = e.Theme.defineTheme("dark", {
|
|
837
807
|
name: "dark",
|
|
838
808
|
base: e.Themes.Classic,
|
|
839
809
|
componentStyles: {
|
|
@@ -850,18 +820,18 @@ const H = e.Theme.defineTheme("light", {
|
|
|
850
820
|
cursorColour: ""
|
|
851
821
|
}
|
|
852
822
|
});
|
|
853
|
-
function
|
|
823
|
+
function $(o) {
|
|
854
824
|
const t = e.getMainWorkspace();
|
|
855
825
|
switch (console.log(t), o) {
|
|
856
826
|
case "light":
|
|
857
|
-
t.setTheme(
|
|
827
|
+
t.setTheme(j);
|
|
858
828
|
break;
|
|
859
829
|
case "dark":
|
|
860
|
-
t.setTheme(
|
|
830
|
+
t.setTheme(q);
|
|
861
831
|
break;
|
|
862
832
|
}
|
|
863
833
|
}
|
|
864
|
-
const
|
|
834
|
+
const Z = {
|
|
865
835
|
kind: "category",
|
|
866
836
|
name: "%{BKY_CATEGORY_LOGIC}",
|
|
867
837
|
categorystyle: "logic_category",
|
|
@@ -879,7 +849,7 @@ const J = {
|
|
|
879
849
|
type: "if_v1"
|
|
880
850
|
}
|
|
881
851
|
]
|
|
882
|
-
},
|
|
852
|
+
}, Q = {
|
|
883
853
|
kind: "category",
|
|
884
854
|
name: "%{BKY_CATEGORY_LOOP}",
|
|
885
855
|
categorystyle: "loop_category",
|
|
@@ -901,10 +871,10 @@ const J = {
|
|
|
901
871
|
type: "for_each_v1"
|
|
902
872
|
}
|
|
903
873
|
]
|
|
904
|
-
},
|
|
874
|
+
}, ee = {
|
|
905
875
|
kind: "categoryToolbox",
|
|
906
|
-
contents: [
|
|
907
|
-
},
|
|
876
|
+
contents: [Z, Q]
|
|
877
|
+
}, te = { class: "position-relative w-100 h-100" }, oe = /* @__PURE__ */ b({
|
|
908
878
|
__name: "index",
|
|
909
879
|
props: {
|
|
910
880
|
type: {},
|
|
@@ -912,9 +882,9 @@ const J = {
|
|
|
912
882
|
},
|
|
913
883
|
emits: ["ready", "change"],
|
|
914
884
|
setup(o, { emit: t }) {
|
|
915
|
-
const
|
|
885
|
+
const r = B(), n = R(), { open: s } = F("blocklyEditorFlyout"), l = o, a = t, i = C(null);
|
|
916
886
|
let c;
|
|
917
|
-
const
|
|
887
|
+
const y = {
|
|
918
888
|
grid: {
|
|
919
889
|
length: 2,
|
|
920
890
|
snap: !0,
|
|
@@ -927,7 +897,7 @@ const J = {
|
|
|
927
897
|
wheel: !0
|
|
928
898
|
},
|
|
929
899
|
readOnly: !1,
|
|
930
|
-
theme:
|
|
900
|
+
theme: n.current.value.dark ? "dark" : "light",
|
|
931
901
|
trashcan: !1,
|
|
932
902
|
zoom: {
|
|
933
903
|
maxScale: 1,
|
|
@@ -937,12 +907,12 @@ const J = {
|
|
|
937
907
|
wheel: !0
|
|
938
908
|
}
|
|
939
909
|
};
|
|
940
|
-
|
|
910
|
+
m(async () => {
|
|
941
911
|
if (!i.value)
|
|
942
912
|
return;
|
|
943
|
-
await f(
|
|
913
|
+
await f(r.current.value);
|
|
944
914
|
let u;
|
|
945
|
-
l.type === "app" && l.version === "v1" && (u =
|
|
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);
|
|
946
916
|
});
|
|
947
917
|
function g() {
|
|
948
918
|
c && e.svgResize(c);
|
|
@@ -950,25 +920,25 @@ const J = {
|
|
|
950
920
|
function h(u) {
|
|
951
921
|
a("change", u);
|
|
952
922
|
}
|
|
953
|
-
return
|
|
923
|
+
return S(() => {
|
|
954
924
|
s.value = !1;
|
|
955
|
-
}),
|
|
925
|
+
}), p(s, (u) => {
|
|
956
926
|
var _;
|
|
957
927
|
u || (_ = c.getToolbox()) == null || _.clearSelection();
|
|
958
|
-
}),
|
|
959
|
-
() =>
|
|
928
|
+
}), p(
|
|
929
|
+
() => r.current.value,
|
|
960
930
|
(u) => {
|
|
961
931
|
f(u);
|
|
962
932
|
}
|
|
963
|
-
),
|
|
964
|
-
() =>
|
|
933
|
+
), p(
|
|
934
|
+
() => n.current.value.dark,
|
|
965
935
|
(u) => {
|
|
966
|
-
|
|
936
|
+
$(u ? "dark" : "light");
|
|
967
937
|
}
|
|
968
938
|
), (u, _) => {
|
|
969
|
-
const O =
|
|
970
|
-
return
|
|
971
|
-
|
|
939
|
+
const O = T("resize");
|
|
940
|
+
return L(), E("div", te, [
|
|
941
|
+
I(v("div", {
|
|
972
942
|
class: "w-100 h-100",
|
|
973
943
|
ref_key: "blocklyDiv",
|
|
974
944
|
ref: i,
|
|
@@ -979,9 +949,9 @@ const J = {
|
|
|
979
949
|
]);
|
|
980
950
|
};
|
|
981
951
|
}
|
|
982
|
-
}),
|
|
983
|
-
o.component("x-blockly",
|
|
984
|
-
},
|
|
952
|
+
}), re = (o) => {
|
|
953
|
+
o.component("x-blockly", oe);
|
|
954
|
+
}, ae = { install: re };
|
|
985
955
|
export {
|
|
986
|
-
|
|
956
|
+
ae as default
|
|
987
957
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-block-lib",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
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.4.
|
|
28
|
+
"x-essential-lib": "^0.4.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@rushstack/eslint-patch": "^1.8.0",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"typescript": "^5.2.2",
|
|
46
46
|
"vite": "^5.2.0",
|
|
47
47
|
"vite-plugin-css-injected-by-js": "^3.5.0",
|
|
48
|
-
"vite-plugin-externals": "^0.6.2",
|
|
49
48
|
"vite-plugin-vuetify": "^2.0.3",
|
|
50
49
|
"vue-i18n": "^9.13.1",
|
|
51
50
|
"vue-tsc": "^2.0.6"
|