blockly-fluid 1.2.8 → 1.2.10

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.
Files changed (2) hide show
  1. package/index.js +21 -36
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -61,7 +61,27 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
61
61
  if (typeof input.default === "function") (input.default = input.default());
62
62
  if (typeof input.options === "function") (input.options = input.options());
63
63
 
64
- valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_dropdown><field name="DROPDOWN">${encodeURIComponent(JSON.stringify([input.default, ...((Array.isArray(field.options)) ? field.options.map((option) => [option, option]) : Object.entries(field.options)).map(([name, text]) => [translate((typeof text === "function") ? text() : text), (typeof name === "function") ? name() : name])]))}</field></shadow>`, "text/xml").firstChild);
64
+ const dropdownId = 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])]));
65
+
66
+ Blocks[`shadow_dropdown_${dropdownId}`] = {
67
+ layout: "DROPDOWN",
68
+ fields: {
69
+ DROPDOWN: {
70
+ type: "dropdown",
71
+ default: input.default,
72
+ options: input.options
73
+ }
74
+ },
75
+ color,
76
+ output: true,
77
+
78
+ generator: ({ DROPDOWN = `""` }) => [
79
+ `"${DROPDOWN}"`,
80
+ "atomic"
81
+ ]
82
+ };
83
+
84
+ valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_dropdown_${dropdownId}"></shadow>`, "text/xml").firstChild);
65
85
  };
66
86
 
67
87
  if (input.shadow) {
@@ -270,40 +290,5 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
270
290
  ]
271
291
  };
272
292
 
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
-
308
293
  return Blocks;
309
294
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly-fluid",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "description": "A flexible proxy wrapper for Blockly blocks.",
5
5
  "main": "index.js",
6
6
  "scripts": {