blockly-fluid 1.2.0 → 1.2.2
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/index.js +21 -21
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
module.exports = (Blockly, { generator: languageGeneratorFallback, generators: languageGenerators = {}, translate = (text) => text } = {}) => {
|
|
2
2
|
const Blocks = new Proxy({}, {
|
|
3
|
-
set(_, name, {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
set(_, name, configuration = {}) {
|
|
4
|
+
if (typeof configuration === "function") (configuration = configuration());
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
hat,
|
|
8
|
+
layout = [],
|
|
9
|
+
inputs = {},
|
|
10
|
+
fields = {},
|
|
11
|
+
statements = {},
|
|
12
|
+
previous = !hat,
|
|
13
|
+
next = true,
|
|
14
|
+
output,
|
|
15
|
+
color,
|
|
16
|
+
inline = true,
|
|
17
|
+
deletable = true,
|
|
18
|
+
tooltip = "",
|
|
19
|
+
help = "",
|
|
20
|
+
generator: blockGeneratorFallback,
|
|
21
|
+
generators: blockGenerators = {}
|
|
22
|
+
} = configuration;
|
|
21
23
|
|
|
22
24
|
Blockly.Blocks[name] = {
|
|
23
25
|
init: function () {
|
|
@@ -55,14 +57,12 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
55
57
|
if (typeof input.options === "function") (input.options = input.options());
|
|
56
58
|
|
|
57
59
|
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_dropdown"><field name="DROPDOWN">${(typeof input.default === "function") ? input.default() : (input.default || "")}</field></shadow>`, "text/xml").firstChild);
|
|
58
|
-
|
|
59
|
-
shadowDropdownOptions = Object.entries(input.options).map(([name, text]) => [translate((typeof text === "function") ? text() : text), (typeof name === "function") ? name() : name]);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
if (input.shadow) {
|
|
63
63
|
if (typeof input.shadow === "function") (input.shadow = input.shadow());
|
|
64
64
|
|
|
65
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="${((typeof input.shadow.type === "function") ? input.shadow.type() : (input.shadow.type || "text")).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'")}">${(typeof input.shadow.content === "function") ? input.shadow.content() : (input.shadow.content || "")}</shadow>`, "text/xml").firstChild);
|
|
65
|
+
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_${((typeof input.shadow.type === "function") ? input.shadow.type() : (input.shadow.type || "text")).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'")}">${(typeof input.shadow.content === "function") ? input.shadow.content() : (input.shadow.content || "")}</shadow>`, "text/xml").firstChild);
|
|
66
66
|
};
|
|
67
67
|
} else if (field) {
|
|
68
68
|
const dummy = this.appendDummyInput();
|