blockly-fluid 1.3.21 → 1.3.22
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 +19 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -82,15 +82,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
82
82
|
output: true,
|
|
83
83
|
|
|
84
84
|
generator: ({ DROPDOWN }) => [
|
|
85
|
-
`"${
|
|
86
|
-
(Object.entries(
|
|
87
|
-
(Object.prototype.toString.call(input.options) === "[object Object]")
|
|
88
|
-
? input.options
|
|
89
|
-
: {}
|
|
90
|
-
).find((option) => option[1] === DROPDOWN)?.[0] || DROPDOWN)
|
|
91
|
-
.replaceAll("\\", "\\\\")
|
|
92
|
-
.replaceAll(`"`, `\\"`)
|
|
93
|
-
}"`,
|
|
85
|
+
`"${DROPDOWN.replaceAll("\\", "\\\\").replaceAll(`"`, `\\"`)}"`,
|
|
94
86
|
"atomic"
|
|
95
87
|
]
|
|
96
88
|
};
|
|
@@ -243,7 +235,10 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
243
235
|
Blockly.Python,
|
|
244
236
|
Blockly.Lua,
|
|
245
237
|
Blockly.PHP
|
|
246
|
-
].filter(Boolean).map((codeGenerator) => [
|
|
238
|
+
].filter(Boolean).map((codeGenerator) => [
|
|
239
|
+
codeGenerator.name_,
|
|
240
|
+
codeGenerator
|
|
241
|
+
])),
|
|
247
242
|
...languageGenerators,
|
|
248
243
|
...{
|
|
249
244
|
Fallback: languageGeneratorFallback
|
|
@@ -312,7 +307,19 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
312
307
|
])),
|
|
313
308
|
...(input.name) ? {
|
|
314
309
|
[input.name]: (({
|
|
315
|
-
[Blockly.INPUT_VALUE]: () =>
|
|
310
|
+
[Blockly.INPUT_VALUE]: () => {
|
|
311
|
+
const initialValue = languageGenerator.valueToCode(block, input.name, languageGenerator.ORDER_ATOMIC);
|
|
312
|
+
|
|
313
|
+
const optionValue = Object.entries(
|
|
314
|
+
(Object.prototype.toString.call(inputs[input.name].options) === "[object Object]")
|
|
315
|
+
? inputs[input.name].options
|
|
316
|
+
: {}
|
|
317
|
+
).find((option) => (
|
|
318
|
+
`"${option[1].replaceAll("\\", "\\\\").replaceAll(`"`, `\\"`)}"` === initialValue
|
|
319
|
+
))?.[0];
|
|
320
|
+
|
|
321
|
+
return (optionValue) ? `"${optionValue.replaceAll("\\", "\\\\").replaceAll(`"`, `\\"`)}"` : initialValue;
|
|
322
|
+
},
|
|
316
323
|
[Blockly.NEXT_STATEMENT]: () => languageGenerator.statementToCode(block, input.name)
|
|
317
324
|
})[input.type] || (() => null))()
|
|
318
325
|
} : {}
|
|
@@ -336,11 +343,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
336
343
|
output: true,
|
|
337
344
|
|
|
338
345
|
generator: ({ TEXT }) => [
|
|
339
|
-
`"${
|
|
340
|
-
TEXT
|
|
341
|
-
.replaceAll("\\", "\\\\")
|
|
342
|
-
.replaceAll(`"`, `\\"`)
|
|
343
|
-
}"`,
|
|
346
|
+
`"${TEXT.replaceAll("\\", "\\\\").replaceAll(`"`, `\\"`)}"`,
|
|
344
347
|
"atomic"
|
|
345
348
|
]
|
|
346
349
|
};
|