blockly-fluid 1.3.7 → 1.3.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.
- package/index.js +9 -5
- package/package.json +1 -1
- package/utils/dedent.js +15 -0
package/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
const dedent = require("./utils/dedent.js");
|
|
1
2
|
const escapeXml = require("./utils/escapeXml.js");
|
|
2
3
|
|
|
3
4
|
module.exports = (Blockly, { generator: languageGeneratorFallback, generators: languageGenerators = {}, translate = (text) => text } = {}) => {
|
|
4
5
|
const Blocks = new Proxy({}, {
|
|
6
|
+
get(_, name) {
|
|
7
|
+
return Blockly.Blocks[name];
|
|
8
|
+
},
|
|
9
|
+
|
|
5
10
|
set(_, name, configuration = {}) {
|
|
6
11
|
if (typeof configuration === "function") (configuration = configuration());
|
|
7
12
|
|
|
@@ -131,6 +136,9 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
131
136
|
case "number":
|
|
132
137
|
dummy.appendField(new Blockly.FieldNumber(...[
|
|
133
138
|
translate((typeof field.default === "function") ? field.default() : (field.default || 0)),
|
|
139
|
+
(typeof field.minimum === "function") ? field.minimum() : (field.minimum || null),
|
|
140
|
+
(typeof field.maximum === "function") ? field.maximum() : (field.maximum || null),
|
|
141
|
+
(typeof field.stepSize === "function") ? field.stepSize() : (field.stepSize || null),
|
|
134
142
|
...(field.validator) ? [field.validator] : []
|
|
135
143
|
]), token);
|
|
136
144
|
|
|
@@ -255,7 +263,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
255
263
|
};
|
|
256
264
|
};
|
|
257
265
|
|
|
258
|
-
languageGenerator.forBlock[name] = (block) => (((code) => {
|
|
266
|
+
languageGenerator.forBlock[name] = (block) => dedent(((code) => {
|
|
259
267
|
if (!output) return code;
|
|
260
268
|
|
|
261
269
|
return (Array.isArray(code)) ? [
|
|
@@ -293,10 +301,6 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
293
301
|
});
|
|
294
302
|
|
|
295
303
|
return true;
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
get(_, name) {
|
|
299
|
-
return Blockly.Blocks[name];
|
|
300
304
|
}
|
|
301
305
|
});
|
|
302
306
|
|
package/package.json
CHANGED
package/utils/dedent.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = (strings, ...values) => {
|
|
2
|
+
let text = String.raw({ raw: strings }, ...values);
|
|
3
|
+
|
|
4
|
+
text = text.replace(/^\n/, "").replace(/\n$/, "");
|
|
5
|
+
|
|
6
|
+
const indent = text.match(/^[ \t]*(?=\S)/gm);
|
|
7
|
+
|
|
8
|
+
if (indent) {
|
|
9
|
+
const minimumIndent = Math.min(...indent.map(i => i.length));
|
|
10
|
+
|
|
11
|
+
text = text.replace(new RegExp(`^[ \\t]{${minimumIndent}}`, "gm"), "");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return text;
|
|
15
|
+
};
|