blockly-fluid 1.2.18 → 1.3.0
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 +9 -9
- 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,8 @@ 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
|
-
|
|
63
|
-
|
|
64
|
-
if (!Blocks[`shadow_dropdown_${dropdownId}`]) {
|
|
65
|
-
Blocks[`shadow_dropdown_${dropdownId}`] = {
|
|
64
|
+
if (!Blocks[`shadow_dropdown_${token}`]) {
|
|
65
|
+
Blocks[`shadow_dropdown_${token}`] = {
|
|
66
66
|
layout: "DROPDOWN",
|
|
67
67
|
fields: {
|
|
68
68
|
DROPDOWN: {
|
|
@@ -81,14 +81,14 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_dropdown_${
|
|
84
|
+
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_dropdown_${escapeXml(token)}}"></shadow>`, "text/xml").firstChild);
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
if (input.variable) {
|
|
88
88
|
if (typeof input.variable === "function") (input.variable = input.variable());
|
|
89
89
|
|
|
90
|
-
if (!Blocks[`shadow_variable_${
|
|
91
|
-
Blocks[`shadow_variable_${
|
|
90
|
+
if (!Blocks[`shadow_variable_${token}`]) {
|
|
91
|
+
Blocks[`shadow_variable_${token}`] = {
|
|
92
92
|
layout: "VARIABLE",
|
|
93
93
|
fields: {
|
|
94
94
|
VARIABLE: {
|
|
@@ -105,13 +105,13 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_variable_${
|
|
108
|
+
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_variable_${escapeXml(token)}"><field name="VARIABLE">${input.variable}</field></shadow>`, "text/xml").firstChild);
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
if (input.shadow) {
|
|
112
112
|
if (typeof input.shadow === "function") (input.shadow = input.shadow());
|
|
113
113
|
|
|
114
|
-
valueInput.connection.setShadowDom(new DOMParser().parseFromString(`<shadow type="shadow_${((typeof input.shadow.type === "function") ? input.shadow.type() : (input.shadow.type || "text"))
|
|
114
|
+
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
115
|
};
|
|
116
116
|
} else if (field) {
|
|
117
117
|
const dummy = this.appendDummyInput();
|
package/package.json
CHANGED