@digipair/skill-web-editor 0.4.11 → 0.4.12
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/blockly-to-json.cjs.js +3 -1
- package/blockly-to-json.esm.js +3 -1
- package/index.cjs2.js +95 -7
- package/index.esm2.js +95 -7
- package/package.json +1 -1
- package/pins-to-blockly.cjs.js +32 -10
- package/pins-to-blockly.esm.js +32 -10
package/blockly-to-json.cjs.js
CHANGED
|
@@ -146,9 +146,11 @@ jsonGenerator.generatePin = function(block) {
|
|
|
146
146
|
}
|
|
147
147
|
} else {
|
|
148
148
|
const codeToAdd = getCodeFromBlock(connectedBlock);
|
|
149
|
+
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
149
150
|
if (inputName === 'pins') {
|
|
150
|
-
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
151
151
|
code += ` "${inputName}": [${inputCode}],`;
|
|
152
|
+
} else if (inputName.includes('__CONDITION__/')) {
|
|
153
|
+
conditionCode += ` "${inputName.split('__CONDITION__/')[1]}": ${inputCode},`;
|
|
152
154
|
} else if (codeToAdd !== 'undefined') {
|
|
153
155
|
propertiesCode += ` "${inputName}": ${codeToAdd},`;
|
|
154
156
|
}
|
package/blockly-to-json.esm.js
CHANGED
|
@@ -144,9 +144,11 @@ jsonGenerator.generatePin = function(block) {
|
|
|
144
144
|
}
|
|
145
145
|
} else {
|
|
146
146
|
const codeToAdd = getCodeFromBlock(connectedBlock);
|
|
147
|
+
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
147
148
|
if (inputName === 'pins') {
|
|
148
|
-
const inputCode = jsonGenerator.customStatementToCode(block, inputName);
|
|
149
149
|
code += ` "${inputName}": [${inputCode}],`;
|
|
150
|
+
} else if (inputName.includes('__CONDITION__/')) {
|
|
151
|
+
conditionCode += ` "${inputName.split('__CONDITION__/')[1]}": ${inputCode},`;
|
|
150
152
|
} else if (codeToAdd !== 'undefined') {
|
|
151
153
|
propertiesCode += ` "${inputName}": ${codeToAdd},`;
|
|
152
154
|
}
|
package/index.cjs2.js
CHANGED
|
@@ -2661,13 +2661,13 @@ function generateBlockFromPins(pinsSettings, workspace) {
|
|
|
2661
2661
|
const parameterType = getParameterType(parameter.schema.items);
|
|
2662
2662
|
for (const propertyValue of valueToLoad.reverse()){
|
|
2663
2663
|
const parameterBlock = parameterType === 'component' ? generateBlockFromComponent(propertyValue, workspace, library, parameter.schema.items.$ref) : generateBlockFromPins(propertyValue, workspace);
|
|
2664
|
-
const
|
|
2665
|
-
connectBlock(parameterBlock,
|
|
2664
|
+
const inputConnection = pinsBlock.getInput(parameter.name).connection;
|
|
2665
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2666
2666
|
}
|
|
2667
2667
|
} else {
|
|
2668
2668
|
const parameterBlock = generateParameterBlock(parameter.schema, valueToLoad, workspace, library);
|
|
2669
|
-
const
|
|
2670
|
-
connectBlock(parameterBlock,
|
|
2669
|
+
const inputConnection = pinsBlock.getInput(parameter.name).connection;
|
|
2670
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2671
2671
|
}
|
|
2672
2672
|
}
|
|
2673
2673
|
for (const event of pinsDefinition['x-events'] || []){
|
|
@@ -2681,6 +2681,42 @@ function generateBlockFromPins(pinsSettings, workspace) {
|
|
|
2681
2681
|
connectBlock(parameterBlock, inputConnection);
|
|
2682
2682
|
}
|
|
2683
2683
|
}
|
|
2684
|
+
const conditions = [
|
|
2685
|
+
{
|
|
2686
|
+
name: 'if',
|
|
2687
|
+
schema: {
|
|
2688
|
+
type: 'boolean'
|
|
2689
|
+
}
|
|
2690
|
+
},
|
|
2691
|
+
{
|
|
2692
|
+
name: 'each',
|
|
2693
|
+
schema: {
|
|
2694
|
+
type: 'array',
|
|
2695
|
+
items: {
|
|
2696
|
+
type: 'object'
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
];
|
|
2701
|
+
for (const parameter of conditions){
|
|
2702
|
+
var _parameter_schema_items;
|
|
2703
|
+
if (!pinsSettings.conditions || !Object.prototype.hasOwnProperty.call(pinsSettings.conditions, parameter.name)) {
|
|
2704
|
+
continue;
|
|
2705
|
+
}
|
|
2706
|
+
const valueToLoad = pinsSettings.conditions[parameter.name];
|
|
2707
|
+
if (parameter.schema.type === 'array' && ((_parameter_schema_items = parameter.schema.items) == null ? void 0 : _parameter_schema_items.$ref)) {
|
|
2708
|
+
const parameterType = getParameterType(parameter.schema.items);
|
|
2709
|
+
for (const propertyValue of valueToLoad.reverse()){
|
|
2710
|
+
const parameterBlock = parameterType === 'component' ? generateBlockFromComponent(propertyValue, workspace, library, parameter.schema.items.$ref) : generateBlockFromPins(propertyValue, workspace);
|
|
2711
|
+
const inputConnection = pinsBlock.getInput('__CONDITION__/' + parameter.name).connection;
|
|
2712
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2713
|
+
}
|
|
2714
|
+
} else {
|
|
2715
|
+
const parameterBlock = generateParameterBlock(parameter.schema, valueToLoad, workspace, library);
|
|
2716
|
+
const inputConnection = pinsBlock.getInput('__CONDITION__/' + parameter.name).connection;
|
|
2717
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2684
2720
|
return pinsBlock;
|
|
2685
2721
|
}
|
|
2686
2722
|
function generateBlockFromComponent(componentSettings, workspace, library, component$ref) {
|
|
@@ -2921,13 +2957,13 @@ function itemListFromPinsSettings(pinsSettings, pinsDefinition) {
|
|
|
2921
2957
|
if (pinsSettings.conditions.if) {
|
|
2922
2958
|
inputArray.push({
|
|
2923
2959
|
id: '__CONDITION__/if',
|
|
2924
|
-
name: '
|
|
2960
|
+
name: '#if'
|
|
2925
2961
|
});
|
|
2926
2962
|
}
|
|
2927
2963
|
if (pinsSettings.conditions.each) {
|
|
2928
2964
|
inputArray.push({
|
|
2929
2965
|
id: '__CONDITION__/each',
|
|
2930
|
-
name: '
|
|
2966
|
+
name: '#each'
|
|
2931
2967
|
});
|
|
2932
2968
|
}
|
|
2933
2969
|
}
|
|
@@ -3414,7 +3450,51 @@ class GenericSceneElement extends s {
|
|
|
3414
3450
|
scrollbars: true,
|
|
3415
3451
|
drag: true,
|
|
3416
3452
|
wheel: true
|
|
3417
|
-
}
|
|
3453
|
+
},
|
|
3454
|
+
theme: Blockly.Theme.defineTheme('modest', {
|
|
3455
|
+
blockStyles: {
|
|
3456
|
+
logic_blocks: {
|
|
3457
|
+
colourPrimary: '#D1C4E9',
|
|
3458
|
+
colourSecondary: '#EDE7F6',
|
|
3459
|
+
colorTertiary: '#B39DDB'
|
|
3460
|
+
},
|
|
3461
|
+
loop_blocks: {
|
|
3462
|
+
colourPrimary: '#A5D6A7',
|
|
3463
|
+
colourSecondary: '#E8F5E9',
|
|
3464
|
+
colorTertiary: '#66BB6A'
|
|
3465
|
+
},
|
|
3466
|
+
math_blocks: {
|
|
3467
|
+
colourPrimary: '#2196F3',
|
|
3468
|
+
colourSecondary: '#1E88E5',
|
|
3469
|
+
colorTertiary: '#0D47A1'
|
|
3470
|
+
},
|
|
3471
|
+
text_blocks: {
|
|
3472
|
+
colourPrimary: '#FFCA28',
|
|
3473
|
+
colourSecondary: '#FFF8E1',
|
|
3474
|
+
colorTertiary: '#FF8F00'
|
|
3475
|
+
},
|
|
3476
|
+
list_blocks: {
|
|
3477
|
+
colourPrimary: '#4DB6AC',
|
|
3478
|
+
colourSecondary: '#B2DFDB',
|
|
3479
|
+
colorTertiary: '#009688'
|
|
3480
|
+
},
|
|
3481
|
+
variable_blocks: {
|
|
3482
|
+
colourPrimary: '#EF9A9A',
|
|
3483
|
+
colourSecondary: '#FFEBEE',
|
|
3484
|
+
colorTertiary: '#EF5350'
|
|
3485
|
+
},
|
|
3486
|
+
variable_dynamic_blocks: {
|
|
3487
|
+
colourPrimary: '#EF9A9A',
|
|
3488
|
+
colourSecondary: '#FFEBEE',
|
|
3489
|
+
colorTertiary: '#EF5350'
|
|
3490
|
+
},
|
|
3491
|
+
procedure_blocks: {
|
|
3492
|
+
colourPrimary: '#D7CCC8',
|
|
3493
|
+
colourSecondary: '#EFEBE9',
|
|
3494
|
+
colorTertiary: '#BCAAA4'
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
})
|
|
3418
3498
|
});
|
|
3419
3499
|
this.workspace.addChangeListener((e)=>{
|
|
3420
3500
|
if (e.isUiEvent || e.type == Blockly.Events.FINISHED_LOADING) {
|
|
@@ -3465,6 +3545,14 @@ class GenericSceneElement extends s {
|
|
|
3465
3545
|
height: 30px;
|
|
3466
3546
|
line-height: 30px;
|
|
3467
3547
|
}
|
|
3548
|
+
|
|
3549
|
+
.blocklyPath {
|
|
3550
|
+
stroke: #fff;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
.blocklyPathDark {
|
|
3554
|
+
fill: #fff;
|
|
3555
|
+
}
|
|
3468
3556
|
</style>
|
|
3469
3557
|
|
|
3470
3558
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
package/index.esm2.js
CHANGED
|
@@ -2659,13 +2659,13 @@ function generateBlockFromPins(pinsSettings, workspace) {
|
|
|
2659
2659
|
const parameterType = getParameterType(parameter.schema.items);
|
|
2660
2660
|
for (const propertyValue of valueToLoad.reverse()){
|
|
2661
2661
|
const parameterBlock = parameterType === 'component' ? generateBlockFromComponent(propertyValue, workspace, library, parameter.schema.items.$ref) : generateBlockFromPins(propertyValue, workspace);
|
|
2662
|
-
const
|
|
2663
|
-
connectBlock(parameterBlock,
|
|
2662
|
+
const inputConnection = pinsBlock.getInput(parameter.name).connection;
|
|
2663
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2664
2664
|
}
|
|
2665
2665
|
} else {
|
|
2666
2666
|
const parameterBlock = generateParameterBlock(parameter.schema, valueToLoad, workspace, library);
|
|
2667
|
-
const
|
|
2668
|
-
connectBlock(parameterBlock,
|
|
2667
|
+
const inputConnection = pinsBlock.getInput(parameter.name).connection;
|
|
2668
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2669
2669
|
}
|
|
2670
2670
|
}
|
|
2671
2671
|
for (const event of pinsDefinition['x-events'] || []){
|
|
@@ -2679,6 +2679,42 @@ function generateBlockFromPins(pinsSettings, workspace) {
|
|
|
2679
2679
|
connectBlock(parameterBlock, inputConnection);
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
+
const conditions = [
|
|
2683
|
+
{
|
|
2684
|
+
name: 'if',
|
|
2685
|
+
schema: {
|
|
2686
|
+
type: 'boolean'
|
|
2687
|
+
}
|
|
2688
|
+
},
|
|
2689
|
+
{
|
|
2690
|
+
name: 'each',
|
|
2691
|
+
schema: {
|
|
2692
|
+
type: 'array',
|
|
2693
|
+
items: {
|
|
2694
|
+
type: 'object'
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
];
|
|
2699
|
+
for (const parameter of conditions){
|
|
2700
|
+
var _parameter_schema_items;
|
|
2701
|
+
if (!pinsSettings.conditions || !Object.prototype.hasOwnProperty.call(pinsSettings.conditions, parameter.name)) {
|
|
2702
|
+
continue;
|
|
2703
|
+
}
|
|
2704
|
+
const valueToLoad = pinsSettings.conditions[parameter.name];
|
|
2705
|
+
if (parameter.schema.type === 'array' && ((_parameter_schema_items = parameter.schema.items) == null ? void 0 : _parameter_schema_items.$ref)) {
|
|
2706
|
+
const parameterType = getParameterType(parameter.schema.items);
|
|
2707
|
+
for (const propertyValue of valueToLoad.reverse()){
|
|
2708
|
+
const parameterBlock = parameterType === 'component' ? generateBlockFromComponent(propertyValue, workspace, library, parameter.schema.items.$ref) : generateBlockFromPins(propertyValue, workspace);
|
|
2709
|
+
const inputConnection = pinsBlock.getInput('__CONDITION__/' + parameter.name).connection;
|
|
2710
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2711
|
+
}
|
|
2712
|
+
} else {
|
|
2713
|
+
const parameterBlock = generateParameterBlock(parameter.schema, valueToLoad, workspace, library);
|
|
2714
|
+
const inputConnection = pinsBlock.getInput('__CONDITION__/' + parameter.name).connection;
|
|
2715
|
+
connectBlock(parameterBlock, inputConnection);
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2682
2718
|
return pinsBlock;
|
|
2683
2719
|
}
|
|
2684
2720
|
function generateBlockFromComponent(componentSettings, workspace, library, component$ref) {
|
|
@@ -2919,13 +2955,13 @@ function itemListFromPinsSettings(pinsSettings, pinsDefinition) {
|
|
|
2919
2955
|
if (pinsSettings.conditions.if) {
|
|
2920
2956
|
inputArray.push({
|
|
2921
2957
|
id: '__CONDITION__/if',
|
|
2922
|
-
name: '
|
|
2958
|
+
name: '#if'
|
|
2923
2959
|
});
|
|
2924
2960
|
}
|
|
2925
2961
|
if (pinsSettings.conditions.each) {
|
|
2926
2962
|
inputArray.push({
|
|
2927
2963
|
id: '__CONDITION__/each',
|
|
2928
|
-
name: '
|
|
2964
|
+
name: '#each'
|
|
2929
2965
|
});
|
|
2930
2966
|
}
|
|
2931
2967
|
}
|
|
@@ -3412,7 +3448,51 @@ class GenericSceneElement extends s {
|
|
|
3412
3448
|
scrollbars: true,
|
|
3413
3449
|
drag: true,
|
|
3414
3450
|
wheel: true
|
|
3415
|
-
}
|
|
3451
|
+
},
|
|
3452
|
+
theme: Blockly.Theme.defineTheme('modest', {
|
|
3453
|
+
blockStyles: {
|
|
3454
|
+
logic_blocks: {
|
|
3455
|
+
colourPrimary: '#D1C4E9',
|
|
3456
|
+
colourSecondary: '#EDE7F6',
|
|
3457
|
+
colorTertiary: '#B39DDB'
|
|
3458
|
+
},
|
|
3459
|
+
loop_blocks: {
|
|
3460
|
+
colourPrimary: '#A5D6A7',
|
|
3461
|
+
colourSecondary: '#E8F5E9',
|
|
3462
|
+
colorTertiary: '#66BB6A'
|
|
3463
|
+
},
|
|
3464
|
+
math_blocks: {
|
|
3465
|
+
colourPrimary: '#2196F3',
|
|
3466
|
+
colourSecondary: '#1E88E5',
|
|
3467
|
+
colorTertiary: '#0D47A1'
|
|
3468
|
+
},
|
|
3469
|
+
text_blocks: {
|
|
3470
|
+
colourPrimary: '#FFCA28',
|
|
3471
|
+
colourSecondary: '#FFF8E1',
|
|
3472
|
+
colorTertiary: '#FF8F00'
|
|
3473
|
+
},
|
|
3474
|
+
list_blocks: {
|
|
3475
|
+
colourPrimary: '#4DB6AC',
|
|
3476
|
+
colourSecondary: '#B2DFDB',
|
|
3477
|
+
colorTertiary: '#009688'
|
|
3478
|
+
},
|
|
3479
|
+
variable_blocks: {
|
|
3480
|
+
colourPrimary: '#EF9A9A',
|
|
3481
|
+
colourSecondary: '#FFEBEE',
|
|
3482
|
+
colorTertiary: '#EF5350'
|
|
3483
|
+
},
|
|
3484
|
+
variable_dynamic_blocks: {
|
|
3485
|
+
colourPrimary: '#EF9A9A',
|
|
3486
|
+
colourSecondary: '#FFEBEE',
|
|
3487
|
+
colorTertiary: '#EF5350'
|
|
3488
|
+
},
|
|
3489
|
+
procedure_blocks: {
|
|
3490
|
+
colourPrimary: '#D7CCC8',
|
|
3491
|
+
colourSecondary: '#EFEBE9',
|
|
3492
|
+
colorTertiary: '#BCAAA4'
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
})
|
|
3416
3496
|
});
|
|
3417
3497
|
this.workspace.addChangeListener((e)=>{
|
|
3418
3498
|
if (e.isUiEvent || e.type == Blockly.Events.FINISHED_LOADING) {
|
|
@@ -3463,6 +3543,14 @@ class GenericSceneElement extends s {
|
|
|
3463
3543
|
height: 30px;
|
|
3464
3544
|
line-height: 30px;
|
|
3465
3545
|
}
|
|
3546
|
+
|
|
3547
|
+
.blocklyPath {
|
|
3548
|
+
stroke: #fff;
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3551
|
+
.blocklyPathDark {
|
|
3552
|
+
fill: #fff;
|
|
3553
|
+
}
|
|
3466
3554
|
</style>
|
|
3467
3555
|
|
|
3468
3556
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
package/package.json
CHANGED
package/pins-to-blockly.cjs.js
CHANGED
|
@@ -11,7 +11,7 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
|
|
|
11
11
|
args2: [],
|
|
12
12
|
message3: '',
|
|
13
13
|
args3: [],
|
|
14
|
-
colour: '#
|
|
14
|
+
colour: '#4285f4',
|
|
15
15
|
tooltip: 'library : ' + library.info.title,
|
|
16
16
|
inputsInline: false,
|
|
17
17
|
previousStatement: null,
|
|
@@ -32,7 +32,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
requiredFields.push('');
|
|
35
|
-
const mutatorToolbox =
|
|
35
|
+
const mutatorToolbox = [
|
|
36
|
+
...parameters.map((param)=>param.name).filter((name)=>!requiredFields.includes(name)),
|
|
37
|
+
'__CONDITION__/if',
|
|
38
|
+
'__CONDITION__/each'
|
|
39
|
+
];
|
|
36
40
|
if (methodData.tags) {
|
|
37
41
|
if (methodData.tags.includes('needPins') && !methodData.tags.includes('requirePins')) {
|
|
38
42
|
mutatorToolbox.push('pins');
|
|
@@ -114,11 +118,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
|
|
|
114
118
|
function getComponentBlockDefinition(library, componentName, methodData, componentId) {
|
|
115
119
|
const blockDefinition = {
|
|
116
120
|
type: componentId,
|
|
117
|
-
message0: library.info['x-icon'] + ' ' + componentName,
|
|
121
|
+
message0: library.info['x-icon'] + ' ' + (methodData.summary || componentName),
|
|
118
122
|
args0: [],
|
|
119
123
|
message1: '',
|
|
120
124
|
args1: [],
|
|
121
|
-
colour: '#
|
|
125
|
+
colour: '#ffca28',
|
|
122
126
|
tooltip: 'library : ' + library.info.title,
|
|
123
127
|
inputsInline: false,
|
|
124
128
|
previousStatement: null,
|
|
@@ -130,19 +134,19 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
|
|
|
130
134
|
const mutatorToolbox = [];
|
|
131
135
|
const parameters = Object.keys(properties).map((propertyName)=>({
|
|
132
136
|
name: propertyName,
|
|
137
|
+
summary: properties[propertyName].summary || propertyName,
|
|
133
138
|
schema: properties[propertyName]
|
|
134
139
|
}));
|
|
135
140
|
let messageIndex = 0;
|
|
136
141
|
parameters.forEach((parameter, _index)=>{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
mutatorToolbox.push(propertyName);
|
|
142
|
+
if (!requiredFields.includes(parameter.name)) {
|
|
143
|
+
mutatorToolbox.push(parameter.name);
|
|
140
144
|
} else {
|
|
141
145
|
var _parameter_schema, _parameter_schema1, _parameter_schema2;
|
|
142
146
|
blockDefinition['args1'].push({
|
|
143
147
|
type: 'field_label',
|
|
144
148
|
name: 'NAME_INPUT',
|
|
145
|
-
text:
|
|
149
|
+
text: parameter.summary + '*'
|
|
146
150
|
});
|
|
147
151
|
if (((_parameter_schema = parameter.schema) == null ? void 0 : _parameter_schema.type) === 'array' && (((_parameter_schema1 = parameter.schema) == null ? void 0 : _parameter_schema1.items.$ref) === 'https://www.pinser.world/schemas/pinsSettings' || ((_parameter_schema2 = parameter.schema) == null ? void 0 : _parameter_schema2.items.$ref.includes('#/components/schemas/')))) {
|
|
148
152
|
blockDefinition['message1'] += ' %' + (messageIndex * 2 + 1) + ' %' + (messageIndex * 2 + 2) + ' %' + (messageIndex * 2 + 3);
|
|
@@ -323,12 +327,30 @@ function initializeMutator() {
|
|
|
323
327
|
}
|
|
324
328
|
};
|
|
325
329
|
}
|
|
326
|
-
function generateMutator(mutatorName, toolboxItem, requiredFields,
|
|
330
|
+
function generateMutator(mutatorName, toolboxItem, requiredFields, originParameters) {
|
|
331
|
+
const parameters = [
|
|
332
|
+
...originParameters,
|
|
333
|
+
{
|
|
334
|
+
name: '__CONDITION__/if',
|
|
335
|
+
schema: {
|
|
336
|
+
type: 'boolean'
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: '__CONDITION__/each',
|
|
341
|
+
schema: {
|
|
342
|
+
type: 'array',
|
|
343
|
+
items: {
|
|
344
|
+
type: 'object'
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
];
|
|
327
349
|
const toolboxList = [];
|
|
328
350
|
for (const item of toolboxItem){
|
|
329
351
|
Blockly.Blocks[mutatorName + '/' + item] = {
|
|
330
352
|
init: function() {
|
|
331
|
-
this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item);
|
|
353
|
+
this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item.includes('__CONDITION__/') ? item.replace('__CONDITION__/', '#') : item);
|
|
332
354
|
this.setPreviousStatement(true);
|
|
333
355
|
this.setNextStatement(true);
|
|
334
356
|
this.setColour(0);
|
package/pins-to-blockly.esm.js
CHANGED
|
@@ -9,7 +9,7 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
|
|
|
9
9
|
args2: [],
|
|
10
10
|
message3: '',
|
|
11
11
|
args3: [],
|
|
12
|
-
colour: '#
|
|
12
|
+
colour: '#4285f4',
|
|
13
13
|
tooltip: 'library : ' + library.info.title,
|
|
14
14
|
inputsInline: false,
|
|
15
15
|
previousStatement: null,
|
|
@@ -30,7 +30,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
requiredFields.push('');
|
|
33
|
-
const mutatorToolbox =
|
|
33
|
+
const mutatorToolbox = [
|
|
34
|
+
...parameters.map((param)=>param.name).filter((name)=>!requiredFields.includes(name)),
|
|
35
|
+
'__CONDITION__/if',
|
|
36
|
+
'__CONDITION__/each'
|
|
37
|
+
];
|
|
34
38
|
if (methodData.tags) {
|
|
35
39
|
if (methodData.tags.includes('needPins') && !methodData.tags.includes('requirePins')) {
|
|
36
40
|
mutatorToolbox.push('pins');
|
|
@@ -112,11 +116,11 @@ function getPinsBlockDefinition(library, methodData, pinsId) {
|
|
|
112
116
|
function getComponentBlockDefinition(library, componentName, methodData, componentId) {
|
|
113
117
|
const blockDefinition = {
|
|
114
118
|
type: componentId,
|
|
115
|
-
message0: library.info['x-icon'] + ' ' + componentName,
|
|
119
|
+
message0: library.info['x-icon'] + ' ' + (methodData.summary || componentName),
|
|
116
120
|
args0: [],
|
|
117
121
|
message1: '',
|
|
118
122
|
args1: [],
|
|
119
|
-
colour: '#
|
|
123
|
+
colour: '#ffca28',
|
|
120
124
|
tooltip: 'library : ' + library.info.title,
|
|
121
125
|
inputsInline: false,
|
|
122
126
|
previousStatement: null,
|
|
@@ -128,19 +132,19 @@ function getComponentBlockDefinition(library, componentName, methodData, compone
|
|
|
128
132
|
const mutatorToolbox = [];
|
|
129
133
|
const parameters = Object.keys(properties).map((propertyName)=>({
|
|
130
134
|
name: propertyName,
|
|
135
|
+
summary: properties[propertyName].summary || propertyName,
|
|
131
136
|
schema: properties[propertyName]
|
|
132
137
|
}));
|
|
133
138
|
let messageIndex = 0;
|
|
134
139
|
parameters.forEach((parameter, _index)=>{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
mutatorToolbox.push(propertyName);
|
|
140
|
+
if (!requiredFields.includes(parameter.name)) {
|
|
141
|
+
mutatorToolbox.push(parameter.name);
|
|
138
142
|
} else {
|
|
139
143
|
var _parameter_schema, _parameter_schema1, _parameter_schema2;
|
|
140
144
|
blockDefinition['args1'].push({
|
|
141
145
|
type: 'field_label',
|
|
142
146
|
name: 'NAME_INPUT',
|
|
143
|
-
text:
|
|
147
|
+
text: parameter.summary + '*'
|
|
144
148
|
});
|
|
145
149
|
if (((_parameter_schema = parameter.schema) == null ? void 0 : _parameter_schema.type) === 'array' && (((_parameter_schema1 = parameter.schema) == null ? void 0 : _parameter_schema1.items.$ref) === 'https://www.pinser.world/schemas/pinsSettings' || ((_parameter_schema2 = parameter.schema) == null ? void 0 : _parameter_schema2.items.$ref.includes('#/components/schemas/')))) {
|
|
146
150
|
blockDefinition['message1'] += ' %' + (messageIndex * 2 + 1) + ' %' + (messageIndex * 2 + 2) + ' %' + (messageIndex * 2 + 3);
|
|
@@ -321,12 +325,30 @@ function initializeMutator() {
|
|
|
321
325
|
}
|
|
322
326
|
};
|
|
323
327
|
}
|
|
324
|
-
function generateMutator(mutatorName, toolboxItem, requiredFields,
|
|
328
|
+
function generateMutator(mutatorName, toolboxItem, requiredFields, originParameters) {
|
|
329
|
+
const parameters = [
|
|
330
|
+
...originParameters,
|
|
331
|
+
{
|
|
332
|
+
name: '__CONDITION__/if',
|
|
333
|
+
schema: {
|
|
334
|
+
type: 'boolean'
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: '__CONDITION__/each',
|
|
339
|
+
schema: {
|
|
340
|
+
type: 'array',
|
|
341
|
+
items: {
|
|
342
|
+
type: 'object'
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
];
|
|
325
347
|
const toolboxList = [];
|
|
326
348
|
for (const item of toolboxItem){
|
|
327
349
|
Blockly.Blocks[mutatorName + '/' + item] = {
|
|
328
350
|
init: function() {
|
|
329
|
-
this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item);
|
|
351
|
+
this.appendDummyInput(item).appendField(item.includes('__EVENT__/') ? item.replace('__EVENT__/', '@') : item.includes('__CONDITION__/') ? item.replace('__CONDITION__/', '#') : item);
|
|
330
352
|
this.setPreviousStatement(true);
|
|
331
353
|
this.setNextStatement(true);
|
|
332
354
|
this.setColour(0);
|