blockly-fluid 1.2.18 → 1.3.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/index.js +12 -8
- package/package.json +1 -1
- package/utils/escapeXml.js +8 -0
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const escapeXml = require("./utils/escapeXml.js");
|
|
2
|
+
|
|
1
3
|
module.exports = (Blockly, { generator: languageGeneratorFallback, generators: languageGenerators = {}, translate = (text) => text } = {}) => {
|
|
2
4
|
const Blocks = new Proxy({}, {
|
|
3
5
|
set(_, name, configuration = {}) {
|
|
@@ -59,10 +61,10 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
59
61
|
if (typeof input.default === "function") (input.default = input.default());
|
|
60
62
|
if (typeof input.options === "function") (input.options = input.options());
|
|
61
63
|
|
|
62
|
-
const
|
|
64
|
+
const shadowDropdownName = `shadow_dropdown_${name.length}_${name}_${token.length}_${token}`;
|
|
63
65
|
|
|
64
|
-
if (!Blocks[
|
|
65
|
-
Blocks[
|
|
66
|
+
if (!Blocks[shadowDropdownName]) {
|
|
67
|
+
Blocks[shadowDropdownName] = {
|
|
66
68
|
layout: "DROPDOWN",
|
|
67
69
|
fields: {
|
|
68
70
|
DROPDOWN: {
|
|
@@ -81,14 +83,16 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
81
83
|
};
|
|
82
84
|
};
|
|
83
85
|
|
|
84
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="
|
|
86
|
+
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="${escapeXml(shadowDropdownName)}}"></shadow>`, "text/xml").firstChild);
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
if (input.variable) {
|
|
88
90
|
if (typeof input.variable === "function") (input.variable = input.variable());
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
const shadowVariableName = `shadow_variable_${name.length}_${name}_${token.length}_${token}`;
|
|
93
|
+
|
|
94
|
+
if (!Blocks[shadowVariableName]) {
|
|
95
|
+
Blocks[shadowVariableName] = {
|
|
92
96
|
layout: "VARIABLE",
|
|
93
97
|
fields: {
|
|
94
98
|
VARIABLE: {
|
|
@@ -105,13 +109,13 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
105
109
|
};
|
|
106
110
|
};
|
|
107
111
|
|
|
108
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="
|
|
112
|
+
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="${escapeXml(shadowVariableName)}"><field name="VARIABLE">${input.variable}</field></shadow>`, "text/xml").firstChild);
|
|
109
113
|
};
|
|
110
114
|
|
|
111
115
|
if (input.shadow) {
|
|
112
116
|
if (typeof input.shadow === "function") (input.shadow = input.shadow());
|
|
113
117
|
|
|
114
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_${((typeof input.shadow.type === "function") ? input.shadow.type() : (input.shadow.type || "text"))
|
|
118
|
+
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_${escapeXml((typeof input.shadow.type === "function") ? input.shadow.type() : (input.shadow.type || "text"))}">${(typeof input.shadow.content === "function") ? input.shadow.content() : (input.shadow.content || "")}</shadow>`, "text/xml").firstChild);
|
|
115
119
|
};
|
|
116
120
|
} else if (field) {
|
|
117
121
|
const dummy = this.appendDummyInput();
|
package/package.json
CHANGED