x-block-lib 0.2.0 → 0.2.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/core/blocks/index.d.ts +1 -0
- package/dist/core/blocks/logic/index.d.ts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/locale/msg/en.d.ts +6 -1
- package/dist/core/locale/msg/zhHans.d.ts +6 -1
- package/dist/core/plugins/customCleanUp/index.d.ts +3 -0
- package/dist/core/plugins/disableTopBlocks/index.d.ts +3 -0
- package/dist/core/plugins/readOnlyFlyout/index.d.ts +9 -0
- package/dist/core/toolbox/app/v1/index.d.ts +17 -2
- package/dist/core/toolbox/common/logic/v1/index.d.ts +15 -0
- package/dist/en-CCqtrcN-.js +11 -0
- package/dist/index.js +263 -199
- package/dist/zhHans---jf3OTZ.js +11 -0
- package/package.json +2 -1
- package/dist/en-DYxpcVy9.js +0 -4
- package/dist/zhHans-DjWw6Iqb.js +0 -4
- /package/dist/core/blocks/{downloadAsset → logic/boolean}/v1/index.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './logic';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './boolean/v1';
|
package/dist/core/index.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Blockly from 'blockly/core';
|
|
2
|
+
export declare class ReadOnlyHorizontalFlyout extends Blockly.HorizontalFlyout {
|
|
3
|
+
protected addBlockListeners_(root: SVGElement, block: Blockly.BlockSvg, rect: SVGElement): void;
|
|
4
|
+
isBlockCreatable(block: Blockly.BlockSvg): boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class ReadOnlyVerticalFlyout extends Blockly.VerticalFlyout {
|
|
7
|
+
protected addBlockListeners_(root: SVGElement, block: Blockly.BlockSvg, rect: SVGElement): void;
|
|
8
|
+
isBlockCreatable(block: Blockly.BlockSvg): boolean;
|
|
9
|
+
}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const toolbox: {
|
|
2
|
+
kind: string;
|
|
3
|
+
contents: {
|
|
4
|
+
kind: string;
|
|
5
|
+
name: string;
|
|
6
|
+
categorystyle: string;
|
|
7
|
+
contents: ({
|
|
8
|
+
kind: string;
|
|
9
|
+
text: string;
|
|
10
|
+
type?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
kind: string;
|
|
13
|
+
type: string;
|
|
14
|
+
text?: undefined;
|
|
15
|
+
})[];
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
3
18
|
export default toolbox;
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".blocklyToolboxDiv{overflow-x:hidden;width:56px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
|
|
2
|
+
import { getCurrentInstance as C, inject as p, defineComponent as h, ref as k, onMounted as _, nextTick as T, onBeforeUnmount as O, watch as d, openBlock as v, createElementBlock as R, withDirectives as B, createElementVNode as L } from "vue";
|
|
3
|
+
import { openConfirmDlg as w, openPromptDlg as E, useViewStack as x } from "x-essential-lib";
|
|
3
4
|
import * as e from "blockly/core";
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import { javascriptGenerator as M, Order as P } from "blockly/javascript";
|
|
6
|
+
function D(s, t) {
|
|
7
|
+
const o = C();
|
|
6
8
|
if (!o)
|
|
7
|
-
throw new Error(`[Vuetify] ${
|
|
9
|
+
throw new Error(`[Vuetify] ${s} must be called from inside a setup function`);
|
|
8
10
|
return o;
|
|
9
11
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
12
|
+
const K = Symbol.for("vuetify:locale");
|
|
13
|
+
function A() {
|
|
14
|
+
const s = p(K);
|
|
15
|
+
if (!s)
|
|
14
16
|
throw new Error("[Vuetify] Could not find injected locale instance");
|
|
15
|
-
return
|
|
17
|
+
return s;
|
|
16
18
|
}
|
|
17
|
-
const
|
|
19
|
+
const F = Symbol.for("vuetify:theme");
|
|
18
20
|
function I() {
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
21
|
+
D("useTheme");
|
|
22
|
+
const s = p(F, null);
|
|
23
|
+
if (!s)
|
|
22
24
|
throw new Error("Could not find Vuetify theme injection");
|
|
23
|
-
return
|
|
25
|
+
return s;
|
|
24
26
|
}
|
|
25
|
-
e.
|
|
26
|
-
|
|
27
|
+
e.defineBlocksWithJsonArray([
|
|
28
|
+
{
|
|
29
|
+
type: "boolean_v1",
|
|
30
|
+
message0: "%1",
|
|
31
|
+
args0: [
|
|
32
|
+
{
|
|
33
|
+
type: "field_dropdown",
|
|
34
|
+
name: "BOOL",
|
|
35
|
+
options: [
|
|
36
|
+
["%{BKY_LOGIC_BOOLEAN_FALSE}", "FALSE"],
|
|
37
|
+
["%{BKY_LOGIC_BOOLEAN_TRUE}", "TRUE"]
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
output: "Boolean",
|
|
42
|
+
style: "logic_blocks",
|
|
43
|
+
tooltip: "%{BKY_LOGIC_V1_BOOLEAN_TOOLTIP}",
|
|
44
|
+
helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
|
|
45
|
+
}
|
|
46
|
+
]);
|
|
47
|
+
M.forBlock.boolean_v1 = function(s) {
|
|
48
|
+
return [s.getFieldValue("BOOL") === "TRUE" ? "true" : "false", P.ATOMIC];
|
|
49
|
+
};
|
|
50
|
+
e.dialog.setConfirm(async (s, t) => {
|
|
51
|
+
const o = await w({
|
|
27
52
|
title: "",
|
|
28
|
-
text:
|
|
53
|
+
text: s
|
|
29
54
|
});
|
|
30
55
|
t(!!o);
|
|
31
56
|
});
|
|
32
|
-
e.dialog.setPrompt(async (
|
|
33
|
-
const
|
|
57
|
+
e.dialog.setPrompt(async (s, t, o) => {
|
|
58
|
+
const r = await E({
|
|
34
59
|
title: "",
|
|
35
60
|
value: t
|
|
36
61
|
});
|
|
37
|
-
o(
|
|
62
|
+
o(r);
|
|
38
63
|
});
|
|
39
|
-
const
|
|
40
|
-
const o =
|
|
41
|
-
return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((
|
|
42
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
64
|
+
const z = (s, t) => {
|
|
65
|
+
const o = s[t];
|
|
66
|
+
return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((r, i) => {
|
|
67
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, new Error("Unknown variable dynamic import: " + t)));
|
|
43
68
|
});
|
|
44
69
|
};
|
|
45
|
-
async function
|
|
46
|
-
const t = await
|
|
47
|
-
e.setLocale(t);
|
|
70
|
+
async function g(s) {
|
|
71
|
+
const t = await z(/* @__PURE__ */ Object.assign({ "./msg/en.ts": () => import("./en-CCqtrcN-.js"), "./msg/zhHans.ts": () => import("./zhHans---jf3OTZ.js") }), `./msg/${s}.ts`);
|
|
72
|
+
e.setLocale(t.default);
|
|
48
73
|
}
|
|
49
|
-
class
|
|
74
|
+
class V {
|
|
50
75
|
init({ contextMenu: t = !0, shortcut: o = !0 } = {
|
|
51
76
|
contextMenu: !0,
|
|
52
77
|
shortcut: !0
|
|
@@ -64,21 +89,15 @@ class F {
|
|
|
64
89
|
displayText: function() {
|
|
65
90
|
return e.Msg.CROSS_TAB_COPY ? e.Msg.CROSS_TAB_COPY : "Copy";
|
|
66
91
|
},
|
|
67
|
-
preconditionFn: function(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!a)
|
|
71
|
-
return "disabled";
|
|
72
|
-
const c = (s = o.workspace) == null ? void 0 : s.getBlockById(
|
|
73
|
-
a.id
|
|
74
|
-
);
|
|
75
|
-
return !c || !c.isDeletable() || !c.isMovable() ? "disabled" : "enabled";
|
|
92
|
+
preconditionFn: function() {
|
|
93
|
+
const o = e.getSelected();
|
|
94
|
+
return !o || !e.isDeletable(o) || !o.isDeletable() || !e.isDraggable(o) || !o.isMovable() || !e.isCopyable(o) ? "disabled" : "enabled";
|
|
76
95
|
},
|
|
77
96
|
callback: function(o) {
|
|
78
|
-
var
|
|
97
|
+
var r;
|
|
79
98
|
localStorage.setItem(
|
|
80
99
|
"blocklyStash",
|
|
81
|
-
JSON.stringify((
|
|
100
|
+
JSON.stringify((r = o.block) == null ? void 0 : r.toCopyData())
|
|
82
101
|
);
|
|
83
102
|
},
|
|
84
103
|
scopeType: e.ContextMenuRegistry.ScopeType.BLOCK,
|
|
@@ -93,19 +112,19 @@ class F {
|
|
|
93
112
|
return e.Msg.CROSS_TAB_PASTE ? e.Msg.CROSS_TAB_PASTE : "Paste";
|
|
94
113
|
},
|
|
95
114
|
preconditionFn: function(o) {
|
|
96
|
-
var
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
115
|
+
var l;
|
|
116
|
+
const r = localStorage.getItem("blocklyStash");
|
|
117
|
+
if (!r)
|
|
99
118
|
return "disabled";
|
|
100
|
-
const
|
|
101
|
-
return !
|
|
119
|
+
const i = JSON.parse(r);
|
|
120
|
+
return !i || !((l = o.workspace) != null && l.isCapacityAvailable(i.typeCounts)) ? "disabled" : "enabled";
|
|
102
121
|
},
|
|
103
122
|
callback: function(o) {
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
123
|
+
const r = localStorage.getItem("blocklyStash");
|
|
124
|
+
if (!r)
|
|
106
125
|
return;
|
|
107
|
-
const
|
|
108
|
-
|
|
126
|
+
const i = JSON.parse(r);
|
|
127
|
+
i && o.workspace && e.clipboard.paste(i, o.workspace);
|
|
109
128
|
},
|
|
110
129
|
scopeType: e.ContextMenuRegistry.ScopeType.WORKSPACE,
|
|
111
130
|
id: "blockPasteFromStorage",
|
|
@@ -114,136 +133,166 @@ class F {
|
|
|
114
133
|
e.ContextMenuRegistry.registry.register(t);
|
|
115
134
|
}
|
|
116
135
|
blockCopyToStorageShortcut() {
|
|
117
|
-
const t =
|
|
118
|
-
name: "copy",
|
|
119
|
-
preconditionFn: function(s) {
|
|
120
|
-
if (s.options.readOnly || e.Gesture.inProgress())
|
|
121
|
-
return !1;
|
|
122
|
-
const n = e.getSelected();
|
|
123
|
-
if (!n)
|
|
124
|
-
return !1;
|
|
125
|
-
const i = s.getBlockById(
|
|
126
|
-
n.id
|
|
127
|
-
);
|
|
128
|
-
return !(!i || !i.isDeletable() || !i.isMovable() || i.isInMutator);
|
|
129
|
-
},
|
|
130
|
-
callback: function(s, n) {
|
|
131
|
-
n.preventDefault();
|
|
132
|
-
const i = e.getSelected();
|
|
133
|
-
if (!i)
|
|
134
|
-
return !1;
|
|
135
|
-
const l = s.getBlockById(
|
|
136
|
-
i.id
|
|
137
|
-
);
|
|
138
|
-
return l ? (s.hideChaff(), localStorage.setItem(
|
|
139
|
-
"blocklyStash",
|
|
140
|
-
JSON.stringify(l.toCopyData())
|
|
141
|
-
), !0) : !1;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
e.ShortcutRegistry.registry.register(t);
|
|
145
|
-
const o = e.ShortcutRegistry.registry.createSerializedKey(
|
|
136
|
+
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
146
137
|
e.utils.KeyCodes.C,
|
|
147
138
|
[e.utils.KeyCodes.CTRL]
|
|
148
|
-
)
|
|
149
|
-
e.ShortcutRegistry.registry.addKeyMapping(o, t.name);
|
|
150
|
-
const a = e.ShortcutRegistry.registry.createSerializedKey(
|
|
139
|
+
), o = e.ShortcutRegistry.registry.createSerializedKey(
|
|
151
140
|
e.utils.KeyCodes.C,
|
|
152
141
|
[e.utils.KeyCodes.ALT]
|
|
153
|
-
)
|
|
154
|
-
e.ShortcutRegistry.registry.addKeyMapping(a, t.name);
|
|
155
|
-
const c = e.ShortcutRegistry.registry.createSerializedKey(
|
|
142
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
156
143
|
e.utils.KeyCodes.C,
|
|
157
144
|
[e.utils.KeyCodes.META]
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const t = {
|
|
163
|
-
name: "cut",
|
|
164
|
-
preconditionFn: function(s) {
|
|
165
|
-
if (s.options.readOnly || e.Gesture.inProgress())
|
|
145
|
+
), i = {
|
|
146
|
+
name: "copy",
|
|
147
|
+
preconditionFn: function(l) {
|
|
148
|
+
if (l.options.readOnly || e.Gesture.inProgress())
|
|
166
149
|
return !1;
|
|
167
150
|
const n = e.getSelected();
|
|
168
|
-
|
|
169
|
-
return !1;
|
|
170
|
-
const i = s.getBlockById(
|
|
171
|
-
n.id
|
|
172
|
-
);
|
|
173
|
-
return !(!i || !i.isDeletable() || !i.isMovable() || s.isFlyout);
|
|
151
|
+
return !(!n || !e.isDeletable(n) || !n.isDeletable() || !e.isDraggable(n) || !n.isMovable() || !e.isCopyable(n));
|
|
174
152
|
},
|
|
175
|
-
callback: function(
|
|
153
|
+
callback: function(l, n) {
|
|
176
154
|
n.preventDefault();
|
|
177
|
-
const
|
|
178
|
-
if (!
|
|
155
|
+
const a = e.getSelected();
|
|
156
|
+
if (!a || !e.isCopyable(a))
|
|
179
157
|
return !1;
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"blocklyStash",
|
|
185
|
-
JSON.stringify(l.toCopyData())
|
|
186
|
-
), e.Events.setGroup(!0), l.dispose(!0), e.Events.setGroup(!1), !0) : !1;
|
|
187
|
-
}
|
|
158
|
+
const c = a.toCopyData();
|
|
159
|
+
return c ? (l.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
|
|
160
|
+
},
|
|
161
|
+
keyCodes: [t, o, r]
|
|
188
162
|
};
|
|
189
|
-
e.ShortcutRegistry.registry.register(
|
|
190
|
-
|
|
163
|
+
e.ShortcutRegistry.registry.register(i);
|
|
164
|
+
}
|
|
165
|
+
blockCutToStorageShortcut() {
|
|
166
|
+
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
191
167
|
e.utils.KeyCodes.X,
|
|
192
168
|
[e.utils.KeyCodes.CTRL]
|
|
193
|
-
)
|
|
194
|
-
e.ShortcutRegistry.registry.addKeyMapping(o, t.name);
|
|
195
|
-
const a = e.ShortcutRegistry.registry.createSerializedKey(
|
|
169
|
+
), o = e.ShortcutRegistry.registry.createSerializedKey(
|
|
196
170
|
e.utils.KeyCodes.X,
|
|
197
171
|
[e.utils.KeyCodes.ALT]
|
|
198
|
-
)
|
|
199
|
-
e.ShortcutRegistry.registry.addKeyMapping(a, t.name);
|
|
200
|
-
const c = e.ShortcutRegistry.registry.createSerializedKey(
|
|
172
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
201
173
|
e.utils.KeyCodes.X,
|
|
202
174
|
[e.utils.KeyCodes.META]
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const t = {
|
|
208
|
-
name: "paste",
|
|
209
|
-
preconditionFn: function(s) {
|
|
210
|
-
if (s.options.readOnly || e.Gesture.inProgress())
|
|
211
|
-
return !1;
|
|
212
|
-
const n = localStorage.getItem("blocklyStash");
|
|
213
|
-
if (!n)
|
|
175
|
+
), i = {
|
|
176
|
+
name: "cut",
|
|
177
|
+
preconditionFn: function(l) {
|
|
178
|
+
if (l.options.readOnly || e.Gesture.inProgress())
|
|
214
179
|
return !1;
|
|
215
|
-
const
|
|
216
|
-
return !(!
|
|
180
|
+
const n = e.getSelected();
|
|
181
|
+
return !(!n || !e.isDeletable(n) || !n.isDeletable() || !e.isDraggable(n) || !n.isMovable() || !e.isCopyable(n) || n.workspace.isFlyout);
|
|
217
182
|
},
|
|
218
|
-
callback: function(
|
|
183
|
+
callback: function(l, n) {
|
|
219
184
|
n.preventDefault();
|
|
220
|
-
const
|
|
221
|
-
if (!
|
|
185
|
+
const a = e.getSelected();
|
|
186
|
+
if (!a || !e.isDeletable(a) || !a.isDeletable() || !e.isCopyable(a))
|
|
222
187
|
return !1;
|
|
223
|
-
const
|
|
224
|
-
return
|
|
225
|
-
}
|
|
188
|
+
const c = a.toCopyData();
|
|
189
|
+
return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), a instanceof e.BlockSvg ? a.checkAndDelete() : a.dispose(), !0) : !1;
|
|
190
|
+
},
|
|
191
|
+
keyCodes: [t, o, r]
|
|
226
192
|
};
|
|
227
|
-
e.ShortcutRegistry.registry.register(
|
|
228
|
-
|
|
193
|
+
e.ShortcutRegistry.registry.register(i);
|
|
194
|
+
}
|
|
195
|
+
blockPasteFromStorageShortcut() {
|
|
196
|
+
const t = e.ShortcutRegistry.registry.createSerializedKey(
|
|
229
197
|
e.utils.KeyCodes.V,
|
|
230
198
|
[e.utils.KeyCodes.CTRL]
|
|
231
|
-
)
|
|
232
|
-
e.ShortcutRegistry.registry.addKeyMapping(o, t.name);
|
|
233
|
-
const a = e.ShortcutRegistry.registry.createSerializedKey(
|
|
199
|
+
), o = e.ShortcutRegistry.registry.createSerializedKey(
|
|
234
200
|
e.utils.KeyCodes.V,
|
|
235
201
|
[e.utils.KeyCodes.ALT]
|
|
236
|
-
)
|
|
237
|
-
e.ShortcutRegistry.registry.addKeyMapping(a, t.name);
|
|
238
|
-
const c = e.ShortcutRegistry.registry.createSerializedKey(
|
|
202
|
+
), r = e.ShortcutRegistry.registry.createSerializedKey(
|
|
239
203
|
e.utils.KeyCodes.V,
|
|
240
204
|
[e.utils.KeyCodes.META]
|
|
241
|
-
)
|
|
242
|
-
|
|
205
|
+
), i = {
|
|
206
|
+
name: "paste",
|
|
207
|
+
preconditionFn: function(l) {
|
|
208
|
+
if (l.options.readOnly || e.Gesture.inProgress())
|
|
209
|
+
return !1;
|
|
210
|
+
const n = localStorage.getItem("blocklyStash");
|
|
211
|
+
if (!n)
|
|
212
|
+
return !1;
|
|
213
|
+
const a = JSON.parse(n);
|
|
214
|
+
return !(!a || !l.isCapacityAvailable(a.typeCounts));
|
|
215
|
+
},
|
|
216
|
+
callback: function(l, n) {
|
|
217
|
+
n.preventDefault();
|
|
218
|
+
const a = localStorage.getItem("blocklyStash");
|
|
219
|
+
if (!a)
|
|
220
|
+
return !1;
|
|
221
|
+
const c = JSON.parse(a);
|
|
222
|
+
return c ? (e.clipboard.paste(c, l), !0) : !1;
|
|
223
|
+
},
|
|
224
|
+
keyCodes: [t, o, r]
|
|
225
|
+
};
|
|
226
|
+
e.ShortcutRegistry.registry.register(i);
|
|
243
227
|
}
|
|
244
228
|
}
|
|
245
|
-
|
|
246
|
-
|
|
229
|
+
class U {
|
|
230
|
+
init() {
|
|
231
|
+
const t = e.ContextMenuRegistry.registry.getItem("cleanWorkspace");
|
|
232
|
+
t && (t.callback = function(o) {
|
|
233
|
+
const r = o.workspace;
|
|
234
|
+
if (!r)
|
|
235
|
+
return;
|
|
236
|
+
r.setResizesEnabled(!1), e.Events.setGroup(!0);
|
|
237
|
+
const i = r.getTopBlocks(!0);
|
|
238
|
+
let l = 0;
|
|
239
|
+
for (let n = 0, a; a = i[n]; n++) {
|
|
240
|
+
if (!a.isMovable())
|
|
241
|
+
continue;
|
|
242
|
+
const c = a.getRelativeToSurfaceXY();
|
|
243
|
+
a.moveBy(-c.x, l - c.y, ["cleanup"]), a.snapToGrid(), l = a.getRelativeToSurfaceXY().y + a.getHeightWidth().height + 100;
|
|
244
|
+
}
|
|
245
|
+
e.Events.setGroup(!1), r.setResizesEnabled(!0);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function b(s) {
|
|
250
|
+
const t = s.getParent();
|
|
251
|
+
return t && b(t) ? !0 : !t && !!(s.outputConnection || s.previousConnection);
|
|
252
|
+
}
|
|
253
|
+
class Y {
|
|
254
|
+
init() {
|
|
255
|
+
const t = e.ContextMenuRegistry.registry.getItem("blockDisable");
|
|
256
|
+
t && (t.preconditionFn = function(o) {
|
|
257
|
+
const r = o.block;
|
|
258
|
+
return r && !r.isInFlyout && r.workspace.options.disable && r.isEditable() ? r.getInheritedDisabled() || b(r) ? "disabled" : "enabled" : "hidden";
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
class N extends e.HorizontalFlyout {
|
|
263
|
+
addBlockListeners_(t, o, r) {
|
|
264
|
+
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, o, r);
|
|
265
|
+
}
|
|
266
|
+
isBlockCreatable(t) {
|
|
267
|
+
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
class G extends e.VerticalFlyout {
|
|
271
|
+
addBlockListeners_(t, o, r) {
|
|
272
|
+
e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, o, r);
|
|
273
|
+
}
|
|
274
|
+
isBlockCreatable(t) {
|
|
275
|
+
return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const X = new V();
|
|
279
|
+
X.init({ contextMenu: !0, shortcut: !0 });
|
|
280
|
+
const j = new U();
|
|
281
|
+
j.init();
|
|
282
|
+
const W = new Y();
|
|
283
|
+
W.init();
|
|
284
|
+
e.registry.register(
|
|
285
|
+
e.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
|
|
286
|
+
e.registry.DEFAULT,
|
|
287
|
+
N,
|
|
288
|
+
!0
|
|
289
|
+
);
|
|
290
|
+
e.registry.register(
|
|
291
|
+
e.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
|
|
292
|
+
e.registry.DEFAULT,
|
|
293
|
+
G,
|
|
294
|
+
!0
|
|
295
|
+
);
|
|
247
296
|
e.Themes.Classic.blockStyles = {
|
|
248
297
|
color_blocks: {
|
|
249
298
|
colourPrimary: "#a5745b",
|
|
@@ -368,7 +417,7 @@ e.Themes.Classic.categoryStyles = {
|
|
|
368
417
|
colour: "#a55b80"
|
|
369
418
|
}
|
|
370
419
|
};
|
|
371
|
-
const
|
|
420
|
+
const $ = e.Theme.defineTheme("light", {
|
|
372
421
|
name: "light",
|
|
373
422
|
base: e.Themes.Classic,
|
|
374
423
|
componentStyles: {
|
|
@@ -384,7 +433,7 @@ const L = e.Theme.defineTheme("light", {
|
|
|
384
433
|
scrollbarOpacity: 0.4,
|
|
385
434
|
cursorColour: ""
|
|
386
435
|
}
|
|
387
|
-
}),
|
|
436
|
+
}), J = e.Theme.defineTheme("dark", {
|
|
388
437
|
name: "dark",
|
|
389
438
|
base: e.Themes.Classic,
|
|
390
439
|
componentStyles: {
|
|
@@ -401,55 +450,69 @@ const L = e.Theme.defineTheme("light", {
|
|
|
401
450
|
cursorColour: ""
|
|
402
451
|
}
|
|
403
452
|
});
|
|
404
|
-
function
|
|
453
|
+
function H(s) {
|
|
405
454
|
const t = e.getMainWorkspace();
|
|
406
|
-
switch (console.log(t),
|
|
455
|
+
switch (console.log(t), s) {
|
|
407
456
|
case "light":
|
|
408
|
-
t.setTheme(
|
|
457
|
+
t.setTheme($);
|
|
409
458
|
break;
|
|
410
459
|
case "dark":
|
|
411
|
-
t.setTheme(
|
|
460
|
+
t.setTheme(J);
|
|
412
461
|
break;
|
|
413
462
|
}
|
|
414
463
|
}
|
|
415
|
-
const
|
|
464
|
+
const q = {
|
|
465
|
+
kind: "category",
|
|
466
|
+
name: "%{BKY_CATEGORY_LOGIC}",
|
|
467
|
+
categorystyle: "logic_category",
|
|
468
|
+
contents: [
|
|
469
|
+
{
|
|
470
|
+
kind: "label",
|
|
471
|
+
text: "%{BKY_LABEL_BOOLEAN}"
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
kind: "block",
|
|
475
|
+
type: "boolean_v1"
|
|
476
|
+
}
|
|
477
|
+
]
|
|
478
|
+
}, Z = {
|
|
416
479
|
kind: "categoryToolbox",
|
|
417
|
-
contents: []
|
|
480
|
+
contents: [q]
|
|
418
481
|
};
|
|
419
|
-
function
|
|
420
|
-
var
|
|
421
|
-
const o = t.value,
|
|
422
|
-
passive: !((
|
|
482
|
+
function Q(s, t) {
|
|
483
|
+
var i, l;
|
|
484
|
+
const o = t.value, r = {
|
|
485
|
+
passive: !((i = t.modifiers) != null && i.active)
|
|
423
486
|
};
|
|
424
|
-
window.addEventListener("resize", o,
|
|
487
|
+
window.addEventListener("resize", o, r), s._onResize = Object(s._onResize), s._onResize[t.instance.$.uid] = {
|
|
425
488
|
handler: o,
|
|
426
|
-
options:
|
|
427
|
-
}, (
|
|
489
|
+
options: r
|
|
490
|
+
}, (l = t.modifiers) != null && l.quiet || o();
|
|
428
491
|
}
|
|
429
|
-
function
|
|
430
|
-
var
|
|
431
|
-
if (!((
|
|
492
|
+
function ee(s, t) {
|
|
493
|
+
var i;
|
|
494
|
+
if (!((i = s._onResize) != null && i[t.instance.$.uid]))
|
|
432
495
|
return;
|
|
433
496
|
const {
|
|
434
497
|
handler: o,
|
|
435
|
-
options:
|
|
436
|
-
} =
|
|
437
|
-
window.removeEventListener("resize", o,
|
|
498
|
+
options: r
|
|
499
|
+
} = s._onResize[t.instance.$.uid];
|
|
500
|
+
window.removeEventListener("resize", o, r), delete s._onResize[t.instance.$.uid];
|
|
438
501
|
}
|
|
439
|
-
const
|
|
440
|
-
mounted:
|
|
441
|
-
unmounted:
|
|
442
|
-
},
|
|
502
|
+
const te = {
|
|
503
|
+
mounted: Q,
|
|
504
|
+
unmounted: ee
|
|
505
|
+
}, oe = { class: "position-relative w-100 h-100" }, re = /* @__PURE__ */ h({
|
|
443
506
|
__name: "index",
|
|
444
507
|
props: {
|
|
445
508
|
type: {},
|
|
446
509
|
version: {}
|
|
447
510
|
},
|
|
448
511
|
emits: ["ready", "change"],
|
|
449
|
-
setup(
|
|
450
|
-
const o =
|
|
451
|
-
let
|
|
452
|
-
const
|
|
512
|
+
setup(s, { emit: t }) {
|
|
513
|
+
const o = A(), r = I(), { open: i } = x("blocklyEditorFlyout"), l = s, n = t, a = k(null);
|
|
514
|
+
let c;
|
|
515
|
+
const f = {
|
|
453
516
|
grid: {
|
|
454
517
|
length: 2,
|
|
455
518
|
snap: !0,
|
|
@@ -461,7 +524,8 @@ const X = {
|
|
|
461
524
|
scrollbars: !0,
|
|
462
525
|
wheel: !0
|
|
463
526
|
},
|
|
464
|
-
|
|
527
|
+
readOnly: !1,
|
|
528
|
+
theme: r.current.value.dark ? "dark" : "light",
|
|
465
529
|
trashcan: !1,
|
|
466
530
|
zoom: {
|
|
467
531
|
maxScale: 1,
|
|
@@ -471,48 +535,48 @@ const X = {
|
|
|
471
535
|
wheel: !0
|
|
472
536
|
}
|
|
473
537
|
};
|
|
474
|
-
|
|
475
|
-
if (!
|
|
538
|
+
_(async () => {
|
|
539
|
+
if (!a.value)
|
|
476
540
|
return;
|
|
477
|
-
await
|
|
541
|
+
await g(o.current.value);
|
|
478
542
|
let u;
|
|
479
|
-
|
|
543
|
+
l.type === "app" && l.version === "v1" && (u = Z), f.toolbox = u, c = e.inject(a.value, f), c.addChangeListener(e.Events.disableOrphans), c.addChangeListener(S), await T(), n("ready", c);
|
|
480
544
|
});
|
|
481
|
-
function
|
|
482
|
-
|
|
545
|
+
function m() {
|
|
546
|
+
c && e.svgResize(c);
|
|
483
547
|
}
|
|
484
548
|
function S(u) {
|
|
485
549
|
n("change", u);
|
|
486
550
|
}
|
|
487
|
-
return
|
|
488
|
-
|
|
489
|
-
}), d(
|
|
551
|
+
return O(() => {
|
|
552
|
+
i.value = !1;
|
|
553
|
+
}), d(i, (u) => {
|
|
490
554
|
var y;
|
|
491
|
-
u || (y =
|
|
555
|
+
u || (y = c.getToolbox()) == null || y.clearSelection();
|
|
492
556
|
}), d(
|
|
493
557
|
() => o.current.value,
|
|
494
558
|
(u) => {
|
|
495
|
-
|
|
559
|
+
g(u);
|
|
496
560
|
}
|
|
497
561
|
), d(
|
|
498
|
-
() =>
|
|
562
|
+
() => r.current.value.dark,
|
|
499
563
|
(u) => {
|
|
500
|
-
|
|
564
|
+
H(u ? "dark" : "light");
|
|
501
565
|
}
|
|
502
|
-
), (u, y) => (v(), R("div",
|
|
503
|
-
|
|
566
|
+
), (u, y) => (v(), R("div", oe, [
|
|
567
|
+
B(L("div", {
|
|
504
568
|
class: "w-100 h-100",
|
|
505
569
|
ref_key: "blocklyDiv",
|
|
506
|
-
ref:
|
|
570
|
+
ref: a,
|
|
507
571
|
id: "blocklyEditor"
|
|
508
572
|
}, null, 512), [
|
|
509
|
-
[
|
|
573
|
+
[te, m]
|
|
510
574
|
])
|
|
511
575
|
]));
|
|
512
576
|
}
|
|
513
|
-
}),
|
|
514
|
-
|
|
515
|
-
},
|
|
577
|
+
}), se = (s) => {
|
|
578
|
+
s.component("x-blockly", re);
|
|
579
|
+
}, le = { install: se };
|
|
516
580
|
export {
|
|
517
|
-
|
|
581
|
+
le as default
|
|
518
582
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-block-lib",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"vite": "^5.2.0",
|
|
47
47
|
"vite-plugin-css-injected-by-js": "^3.5.0",
|
|
48
48
|
"vite-plugin-vuetify": "^2.0.3",
|
|
49
|
+
"vue-i18n": "^9.13.1",
|
|
49
50
|
"vue-tsc": "^2.0.6"
|
|
50
51
|
}
|
|
51
52
|
}
|
package/dist/en-DYxpcVy9.js
DELETED
package/dist/zhHans-DjWw6Iqb.js
DELETED
|
File without changes
|