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.
Files changed (2) hide show
  1. package/index.js +21 -21
  2. 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
- hat,
5
- layout = [],
6
- inputs = {},
7
- fields = {},
8
- statements = {},
9
- previous = !hat,
10
- next = true,
11
- output,
12
- color,
13
- inline = true,
14
- deletable = true,
15
- tooltip = "",
16
- help = "",
17
- generator: blockGeneratorFallback,
18
- generators: blockGenerators = {}
19
- }) {
20
- let shadowDropdownOptions = [];
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;")}">${(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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;")}">${(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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly-fluid",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "A flexible proxy wrapper for Blockly blocks.",
5
5
  "main": "index.js",
6
6
  "scripts": {