blockly-fluid 1.2.7 → 1.2.9
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 +39 -21
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -58,27 +58,10 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
if (input.options) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
fields: {
|
|
66
|
-
DROPDOWN: {
|
|
67
|
-
type: "dropdown",
|
|
68
|
-
default: input.default,
|
|
69
|
-
options: input.options
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
color,
|
|
73
|
-
output: true,
|
|
74
|
-
|
|
75
|
-
generator: ({ DROPDOWN = `""` }) => [
|
|
76
|
-
`"${DROPDOWN}"`,
|
|
77
|
-
"atomic"
|
|
78
|
-
]
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_dropdown_${dropdownId}"><field name="DROPDOWN"></field></shadow>`, "text/xml").firstChild);
|
|
61
|
+
if (typeof input.default === "function") (input.default = input.default());
|
|
62
|
+
if (typeof input.options === "function") (input.options = input.options());
|
|
63
|
+
|
|
64
|
+
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_dropdown><field name="DROPDOWN">${encodeURIComponent(JSON.stringify([input.default, ...((Array.isArray(input.options)) ? input.options.map((option) => [option, option]) : Object.entries(input.options)).map(([name, text]) => [translate((typeof text === "function") ? text() : text), (typeof name === "function") ? name() : name])]))}</field></shadow>`, "text/xml").firstChild);
|
|
82
65
|
};
|
|
83
66
|
|
|
84
67
|
if (input.shadow) {
|
|
@@ -287,5 +270,40 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
287
270
|
]
|
|
288
271
|
};
|
|
289
272
|
|
|
273
|
+
Blockly.Blocks['shadow_dropdown'] = {
|
|
274
|
+
init: function() {
|
|
275
|
+
console.log(this.getFieldValue("DROPDOWN"));
|
|
276
|
+
|
|
277
|
+
this.appendDummyInput()
|
|
278
|
+
.appendField("number")
|
|
279
|
+
.appendField(new Blockly.FieldNumber(0), "NUM");
|
|
280
|
+
this.setOutput(true, "Number"); // This makes it a value block
|
|
281
|
+
this.setColour(230);
|
|
282
|
+
this.setTooltip("A minimal block that outputs a number");
|
|
283
|
+
this.setHelpUrl("");
|
|
284
|
+
|
|
285
|
+
console.log(this.getFieldValue("DROPDOWN"));
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
/*Blocks[`shadow_dropdown_${dropdownId}`] = {
|
|
291
|
+
layout: "DROPDOWN",
|
|
292
|
+
fields: {
|
|
293
|
+
DROPDOWN: {
|
|
294
|
+
type: "dropdown",
|
|
295
|
+
default: input.default,
|
|
296
|
+
options: input.options
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
color,
|
|
300
|
+
output: true,
|
|
301
|
+
|
|
302
|
+
generator: ({ DROPDOWN = `""` }) => [
|
|
303
|
+
`"${DROPDOWN}"`,
|
|
304
|
+
"atomic"
|
|
305
|
+
]
|
|
306
|
+
};*/
|
|
307
|
+
|
|
290
308
|
return Blocks;
|
|
291
309
|
};
|