gobstones-blockly 0.24.1 → 0.24.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d88924a989d399a728b813487e67cfd8ec26262a4023a6ad73efbcb8533edb58
4
- data.tar.gz: ce83426445cd63e1f0d46087700b8e64e59df9d83ae4e2fccba7a2b96ccb35f1
3
+ metadata.gz: 257925d093065b1837bb02d37c6b9f6eed733b41cfd8570585e45c17bf2a2a83
4
+ data.tar.gz: 8379df1044a1c264cfabe412f4946707f705e6b0e191dc17f9f34ee48726f168
5
5
  SHA512:
6
- metadata.gz: 787ef83b2e0cf328c1ba811ff131e851bcd4e85c6c2e8e7b691a45f70a41ff8295b819bca66c25420653645f77eadd54e2ee4a6297861172c187f365d3879839
7
- data.tar.gz: d84c91fdc753d29ee4215cdc97b80c5e1708c852ba7e6de95bbe0d43224f39c130c49d2f1dbe14ae6ab51e7cb7d7935f8be2abc28f9f3eca82ba903120ab00a4
6
+ metadata.gz: 3bed96f1ef11357e218eea4f32f9e901652c9a596be79b3fd033f3ee3c2373c234c07f0b1413794543329f6c6c4f396860dc6ddede126f3e63b996abfaf4b6ec
7
+ data.tar.gz: 851c803b2c74322653ba6d1b6cb99a9001cd9126481ee254665ca3c245bfcee69c4d07c342b68e736a89ce4a40a64e013024434ada414c3a48424d0760d223ad
@@ -4061,11 +4061,11 @@ const getLocalMediaSize = (name) => hasLocalMedia(name) ? 16 : 0;
4061
4061
  * @this Blockly.Block
4062
4062
  */
4063
4063
  Blockly.createBlockSvg = function(workspace, name, f) {
4064
- var newBlock = workspace.newBlock(name);
4065
- //newBlock.setEditable(false);
4066
- f(newBlock);
4067
- newBlock.initSvg();
4068
- newBlock.render();
4064
+ var newBlock = workspace.newBlock(name);
4065
+ //newBlock.setEditable(false);
4066
+ f(newBlock);
4067
+ newBlock.initSvg();
4068
+ newBlock.render();
4069
4069
  };
4070
4070
 
4071
4071
  const createVariable = (parent, name) => {
@@ -4079,161 +4079,168 @@ const createVariable = (parent, name) => {
4079
4079
  });
4080
4080
  }
4081
4081
 
4082
+ const triggerRefresh = (block) => {
4083
+ getOptions(block).parentController.onBlocklyWorkspaceUpdate();
4084
+ };
4085
+
4082
4086
  // ---
4083
4087
 
4084
4088
  Blockly.Blocks.Program = {
4085
- init: function () {
4086
- this.jsonInit({
4087
- "type": "Program",
4088
- "message0": "%1 %2 %3",
4089
- "args0": [
4090
- {
4091
- "type": "field_label",
4092
- "text": "programa"
4093
- },
4094
- {
4095
- "type": "input_dummy"
4096
- },
4097
- {
4098
- "type": "input_statement",
4099
- "name": "program",
4100
- "check": ["Statement"]
4101
- }
4102
- ]
4103
- })
4104
- this.setColour(Blockly.CUSTOM_COLORS.Program || Blockly.CUSTOM_COLORS.program);
4105
- this.setDeletable(true);
4106
- this.setEditable(true);
4107
- this.setMovable(true);
4108
- },
4109
-
4110
- setDisabledAndUpdateTimestamp: function(disabled) {
4111
- this.setDisabled(disabled);
4112
- if (!disabled) this.$timestamp = Date.now();
4113
- },
4114
-
4115
- mutationToDom: function() {
4116
- var container = document.createElement("mutation");
4117
- container.setAttribute("timestamp", this.$timestamp || Date.now());
4118
- return container;
4119
- },
4120
-
4121
- domToMutation: function(xmlElement) {
4122
- const timestamp = xmlElement.getAttribute("timestamp");
4123
- this.$timestamp = timestamp || Date.now();
4124
- },
4089
+ init: function () {
4090
+ this.jsonInit({
4091
+ "type": "Program",
4092
+ "message0": "%1 %2 %3",
4093
+ "args0": [
4094
+ {
4095
+ "type": "field_label",
4096
+ "text": "programa"
4097
+ },
4098
+ {
4099
+ "type": "input_dummy"
4100
+ },
4101
+ {
4102
+ "type": "input_statement",
4103
+ "name": "program",
4104
+ "check": ["Statement"]
4105
+ }
4106
+ ]
4107
+ })
4108
+ this.setColour(Blockly.CUSTOM_COLORS.Program || Blockly.CUSTOM_COLORS.program);
4109
+ this.setDeletable(true);
4110
+ this.setEditable(true);
4111
+ this.setMovable(true);
4112
+ },
4113
+
4114
+ setDisabledAndUpdateTimestamp: function(disabled) {
4115
+ this.setDisabled(disabled);
4116
+ if (!disabled) this.$timestamp = Date.now();
4117
+ },
4118
+
4119
+ mutationToDom: function() {
4120
+ var container = document.createElement("mutation");
4121
+ container.setAttribute("timestamp", this.$timestamp || Date.now());
4122
+ return container;
4123
+ },
4124
+
4125
+ domToMutation: function(xmlElement) {
4126
+ const timestamp = xmlElement.getAttribute("timestamp");
4127
+ this.$timestamp = timestamp || Date.now();
4128
+ },
4125
4129
 
4126
4130
  };
4127
4131
 
4128
4132
  Blockly.Blocks.InteractiveProgram = {
4129
- init: function () {
4130
- this.jsonInit({
4131
- "type": "InteractiveProgram",
4132
- "message0": "%1 %2 %3",
4133
- "args0": [
4134
- {
4135
- "type": "field_label",
4136
- "text": "programa interactivo"
4137
- },
4138
- {
4139
- "type": "input_dummy"
4140
- },
4141
- {
4142
- "type": "input_statement",
4143
- "name": "interactiveprogram",
4144
- "check": ["InteractiveBinding"]
4145
- }
4146
- ]
4147
- });
4148
- this.setColour(Blockly.CUSTOM_COLORS.InteractiveProgram || Blockly.CUSTOM_COLORS.interactiveProgram);
4149
- this.setDeletable(true);
4150
- this.setEditable(true);
4151
- this.setMovable(true);
4152
- },
4153
-
4154
- customContextMenu: function(options) {
4155
- options.unshift({ text: `Agregar timeout`, enabled: !this.$timeout, callback: () => {
4156
- let x = '';
4157
- while (isNaN(parseInt(x)) || parseInt(x) <= 0)
4158
- x = prompt("Ingrese un número en milisegundos");
4159
- x = parseInt(x);
4160
-
4161
- this._addTimeout(x);
4162
- }});
4163
-
4164
- options.unshift({ text: `Agregar inicialización`, enabled: !this.$init, callback: () => {
4165
- this._addInit();
4166
- }});
4167
- },
4168
-
4169
- setDisabledAndUpdateTimestamp: function(disabled) {
4170
- this.setDisabled(disabled);
4171
- if (!disabled) this.$timestamp = Date.now();
4172
- },
4173
-
4174
- mutationToDom: function() {
4175
- var container = document.createElement("mutation");
4176
- if (this.$init) container.setAttribute("init", this.$init);
4177
- if (this.$timeout) container.setAttribute("timeout", this.$timeout);
4178
-
4179
- container.setAttribute("timestamp", this.$timestamp || Date.now());
4180
- return container;
4181
- },
4182
-
4183
- domToMutation: function(xmlElement) {
4184
- const init = xmlElement.getAttribute("init");
4185
- const timeout = xmlElement.getAttribute("timeout");
4186
- const timestamp = xmlElement.getAttribute("timestamp");
4187
-
4188
- if (init) this._addInit()
4189
- if (timeout) this._addTimeout(parseInt(timeout));
4190
- this.$timestamp = timestamp || Date.now();
4191
- },
4192
-
4193
- _addInit() {
4194
- this.$init = true;
4133
+ init: function () {
4134
+ this.jsonInit({
4135
+ "type": "InteractiveProgram",
4136
+ "message0": "%1 %2 %3",
4137
+ "args0": [
4138
+ {
4139
+ "type": "field_label",
4140
+ "text": "programa interactivo"
4141
+ },
4142
+ {
4143
+ "type": "input_dummy"
4144
+ },
4145
+ {
4146
+ "type": "input_statement",
4147
+ "name": "interactiveprogram",
4148
+ "check": ["InteractiveBinding"]
4149
+ }
4150
+ ]
4151
+ });
4152
+ this.setColour(Blockly.CUSTOM_COLORS.InteractiveProgram || Blockly.CUSTOM_COLORS.interactiveProgram);
4153
+ this.setDeletable(true);
4154
+ this.setEditable(true);
4155
+ this.setMovable(true);
4156
+ },
4157
+
4158
+ customContextMenu: function(options) {
4159
+ options.unshift({ text: `Agregar timeout`, enabled: !this.$timeout, callback: () => {
4160
+ let x = prompt("Ingrese un número en milisegundos");
4161
+ if (isNaN(parseInt(x)) || parseInt(x) <= 0) return;
4162
+ x = parseInt(x);
4163
+
4164
+ this._addTimeout(x);
4165
+ }});
4166
+
4167
+ options.unshift({ text: `Agregar inicialización`, enabled: !this.$init, callback: () => {
4168
+ this._addInit();
4169
+ }});
4170
+ },
4171
+
4172
+ setDisabledAndUpdateTimestamp: function(disabled) {
4173
+ this.setDisabled(disabled);
4174
+ if (!disabled) this.$timestamp = Date.now();
4175
+ },
4176
+
4177
+ mutationToDom: function() {
4178
+ var container = document.createElement("mutation");
4179
+ if (this.$init) container.setAttribute("init", this.$init);
4180
+ if (this.$timeout) container.setAttribute("timeout", this.$timeout);
4181
+
4182
+ container.setAttribute("timestamp", this.$timestamp || Date.now());
4183
+ return container;
4184
+ },
4185
+
4186
+ domToMutation: function(xmlElement) {
4187
+ const init = xmlElement.getAttribute("init");
4188
+ const timeout = xmlElement.getAttribute("timeout");
4189
+ const timestamp = xmlElement.getAttribute("timestamp");
4190
+
4191
+ if (init) this._addInit()
4192
+ if (timeout) this._addTimeout(parseInt(timeout));
4193
+ this.$timestamp = timestamp || Date.now();
4194
+ },
4195
+
4196
+ _addInit() {
4197
+ this.$init = true;
4195
4198
 
4196
4199
  const icon = "minus.png";
4197
- var removeButton = new Blockly.FieldImage(
4198
- getLocalMediaUrl(this, icon),
4199
- getLocalMediaSize(icon),
4200
- getLocalMediaSize(icon),
4201
- "Eliminar",
4202
- function() {
4203
- this.$init = false;
4204
- this.removeInput("initlabel");
4205
- this.removeInput("init");
4206
- this.removeInput("statementsLabel");
4207
- }.bind(this)
4208
- );
4209
-
4210
- this.appendDummyInput("initlabel").appendField('Al inicializar:').appendField(removeButton);
4211
- this.appendStatementInput('init').setCheck(["Statement"]);
4212
- this.appendDummyInput("statementsLabel").appendField('Al apretar...');
4213
- this.moveInputBefore("init", "interactiveprogram");
4214
- this.moveInputBefore("initlabel", "init");
4215
- this.moveInputBefore("statementsLabel", "interactiveprogram");
4216
- },
4217
-
4218
- _addTimeout(timeout) {
4219
- this.$timeout = timeout;
4200
+ var removeButton = new Blockly.FieldImage(
4201
+ getLocalMediaUrl(this, icon),
4202
+ getLocalMediaSize(icon),
4203
+ getLocalMediaSize(icon),
4204
+ "Eliminar",
4205
+ function() {
4206
+ this.$init = false;
4207
+ this.removeInput("initlabel");
4208
+ this.removeInput("init");
4209
+ this.removeInput("statementsLabel");
4210
+ triggerRefresh(this);
4211
+ }.bind(this)
4212
+ );
4213
+
4214
+ this.appendDummyInput("initlabel").appendField('Al inicializar:').appendField(removeButton);
4215
+ this.appendStatementInput('init').setCheck(["Statement"]);
4216
+ this.appendDummyInput("statementsLabel").appendField('Al apretar...');
4217
+ this.moveInputBefore("init", "interactiveprogram");
4218
+ this.moveInputBefore("initlabel", "init");
4219
+ this.moveInputBefore("statementsLabel", "interactiveprogram");
4220
+ triggerRefresh(this);
4221
+ },
4222
+
4223
+ _addTimeout(timeout) {
4224
+ this.$timeout = timeout;
4220
4225
 
4221
4226
  const icon = "minus.png";
4222
- var removeButton = new Blockly.FieldImage(
4223
- getLocalMediaUrl(this, icon),
4224
- getLocalMediaSize(icon),
4225
- getLocalMediaSize(icon),
4226
- "Eliminar",
4227
- function() {
4228
- this.$timeout = undefined;
4229
- this.removeInput("timeoutlabel");
4230
- this.removeInput("timeout");
4231
- }.bind(this)
4232
- );
4233
-
4234
- this.appendDummyInput("timeoutlabel").appendField(`Al estar inactivo ${timeout} milisegundos:`).appendField(removeButton);
4235
- this.appendStatementInput('timeout').setCheck(["Statement"]);
4236
- }
4227
+ var removeButton = new Blockly.FieldImage(
4228
+ getLocalMediaUrl(this, icon),
4229
+ getLocalMediaSize(icon),
4230
+ getLocalMediaSize(icon),
4231
+ "Eliminar",
4232
+ function() {
4233
+ this.$timeout = undefined;
4234
+ this.removeInput("timeoutlabel");
4235
+ this.removeInput("timeout");
4236
+ triggerRefresh(this);
4237
+ }.bind(this)
4238
+ );
4239
+
4240
+ this.appendDummyInput("timeoutlabel").appendField(`Al estar inactivo ${timeout} milisegundos:`).appendField(removeButton);
4241
+ this.appendStatementInput('timeout').setCheck(["Statement"]);
4242
+ triggerRefresh(this);
4243
+ }
4237
4244
  };
4238
4245
 
4239
4246
  // -------------------------------------
@@ -4241,9 +4248,9 @@ Blockly.Blocks.InteractiveProgram = {
4241
4248
  // -------------------------------------
4242
4249
 
4243
4250
  const modifiers = [
4244
- [ 'SHIFT', 'SHIFT' ],
4245
- [ 'CTRL', 'CTRL' ],
4246
- [ 'ALT', 'ALT' ]
4251
+ [ 'SHIFT', 'SHIFT' ],
4252
+ [ 'CTRL', 'CTRL' ],
4253
+ [ 'ALT', 'ALT' ]
4247
4254
  ];
4248
4255
 
4249
4256
  const getModifiersInput = (block) => block.inputList[1];
@@ -4251,51 +4258,51 @@ const getModifierFields = (block) => getModifiersInput(block).fieldRow.slice(2);
4251
4258
  const getModifierDropdownFields = (block) => getModifierFields(block).filter(it => it.constructor === Blockly.FieldDropdown);
4252
4259
  const getModifierValues = (block) => getModifierDropdownFields(block).map(it => it.getValue());
4253
4260
  const getAvailableModifiers = (block) => {
4254
- const currentModifiers = getModifierValues(block);
4261
+ const currentModifiers = getModifierValues(block);
4255
4262
 
4256
- return modifiers.filter(it =>
4257
- currentModifiers.indexOf(it[1]) === -1
4258
- );
4263
+ return modifiers.filter(it =>
4264
+ currentModifiers.indexOf(it[1]) === -1
4265
+ );
4259
4266
  };
4260
4267
  const updateModifierMenuGenerators = (block, nameToIgnore) => {
4261
- const availableModifiers = getAvailableModifiers(block);
4262
- const dropdowns = getModifierDropdownFields(block);
4268
+ const availableModifiers = getAvailableModifiers(block);
4269
+ const dropdowns = getModifierDropdownFields(block);
4263
4270
 
4264
- for (var dropdown of dropdowns) {
4265
- if (dropdown.name !== nameToIgnore)
4266
- dropdown.menuGenerator_ = modifiers.filter(it => {
4267
- return it[1] === dropdown.getValue() || availableModifiers.some(availableModifier => availableModifier[1] === it[1])
4268
- });
4271
+ for (var dropdown of dropdowns) {
4272
+ if (dropdown.name !== nameToIgnore)
4273
+ dropdown.menuGenerator_ = modifiers.filter(it => {
4274
+ return it[1] === dropdown.getValue() || availableModifiers.some(availableModifier => availableModifier[1] === it[1])
4275
+ });
4269
4276
 
4270
- }
4277
+ }
4271
4278
  }
4272
4279
 
4273
4280
  createInteractiveBinding = (name, keys) => {
4274
- return {
4275
- init: function () {
4276
- this.jsonInit({
4277
- message0: "%1 %2 %3 %4",
4278
- type: "InteractiveBinding",
4279
- previousStatement: "InteractiveBinding",
4280
- nextStatement: "InteractiveBinding",
4281
- args0: [
4282
- {
4283
- "type": "field_label",
4284
- "text": "Al apretar " + name
4285
- },
4281
+ return {
4282
+ init: function () {
4283
+ this.jsonInit({
4284
+ message0: "%1 %2 %3 %4",
4285
+ type: "InteractiveBinding",
4286
+ previousStatement: "InteractiveBinding",
4287
+ nextStatement: "InteractiveBinding",
4288
+ args0: [
4289
+ {
4290
+ "type": "field_label",
4291
+ "text": "Al apretar " + name
4292
+ },
4286
4293
  { "type": "input_dummy" },
4287
4294
  {
4288
4295
  "type": "field_label",
4289
4296
  "text": "➣"
4290
4297
  },
4291
- {
4292
- type: "field_dropdown",
4293
- name: "InteractiveBindingDropdownKey",
4294
- options: keys.map(it => [it.name, it.code]),
4295
- }
4296
- ],
4297
- colour: Blockly.CUSTOM_COLORS.InteractiveBinding || Blockly.CUSTOM_COLORS.interactiveBinding
4298
- });
4298
+ {
4299
+ type: "field_dropdown",
4300
+ name: "InteractiveBindingDropdownKey",
4301
+ options: keys.map(it => [it.name, it.code]),
4302
+ }
4303
+ ],
4304
+ colour: Blockly.CUSTOM_COLORS.InteractiveBinding || Blockly.CUSTOM_COLORS.interactiveBinding
4305
+ });
4299
4306
 
4300
4307
  this.appendStatementInput('block').setCheck(["Statement"]);
4301
4308
 
@@ -4324,88 +4331,90 @@ createInteractiveBinding = (name, keys) => {
4324
4331
  self._cleanModifiers();
4325
4332
  }
4326
4333
  ));
4327
- },
4328
-
4329
- customContextMenu: function(options) {
4330
- const modifiersCount = getModifierFields(this).length / 2;
4331
-
4332
- options.unshift({ text: `Limpiar modificadores`, enabled: modifiersCount > 0, callback: () => {
4333
- this._cleanModifiers();
4334
- }});
4335
- options.unshift({ text: `Agregar modificador`, enabled: modifiersCount < modifiers.length, callback: () => {
4336
- this._addModifier();
4337
- }});
4338
- },
4339
-
4340
- mutationToDom: function() {
4341
- var container = document.createElement("mutation");
4342
- container.setAttribute("modifierscount", getModifierValues(this).length.toString());
4343
- return container;
4344
- },
4345
-
4346
- domToMutation: function(xmlElement) {
4347
- const $modifiersCount = xmlElement.getAttribute("modifierscount");
4348
- if ($modifiersCount) {
4349
- const count = parseInt($modifiersCount);
4350
- for (var i = 0; i < count; i++)
4351
- this._addModifier();
4352
- }
4334
+ },
4335
+
4336
+ customContextMenu: function(options) {
4337
+ const modifiersCount = getModifierFields(this).length / 2;
4338
+
4339
+ options.unshift({ text: `Limpiar modificadores`, enabled: modifiersCount > 0, callback: () => {
4340
+ this._cleanModifiers();
4341
+ }});
4342
+ options.unshift({ text: `Agregar modificador`, enabled: modifiersCount < modifiers.length, callback: () => {
4343
+ this._addModifier();
4344
+ }});
4345
+ },
4346
+
4347
+ mutationToDom: function() {
4348
+ var container = document.createElement("mutation");
4349
+ container.setAttribute("modifierscount", getModifierValues(this).length.toString());
4350
+ return container;
4351
+ },
4352
+
4353
+ domToMutation: function(xmlElement) {
4354
+ const $modifiersCount = xmlElement.getAttribute("modifierscount");
4355
+ if ($modifiersCount) {
4356
+ const count = parseInt($modifiersCount);
4357
+ for (var i = 0; i < count; i++)
4358
+ this._addModifier();
4359
+ }
4353
4360
 
4354
- setTimeout(() => {
4355
- updateModifierMenuGenerators(this);
4356
- }, 0);
4357
- },
4361
+ setTimeout(() => {
4362
+ updateModifierMenuGenerators(this);
4363
+ }, 0);
4364
+ },
4358
4365
 
4359
- _addModifier() {
4360
- const availableModifiers = getAvailableModifiers(this);
4366
+ _addModifier() {
4367
+ const availableModifiers = getAvailableModifiers(this);
4361
4368
 
4362
- const self = this;
4363
- const id = getModifierValues(this).length + 1;
4364
- const labelName = "l" + id;
4365
- const dropdownName = "d" + id;
4369
+ const self = this;
4370
+ const id = getModifierValues(this).length + 1;
4371
+ const labelName = "l" + id;
4372
+ const dropdownName = "d" + id;
4366
4373
 
4367
- getModifiersInput(this).appendField("+").appendField(new Blockly.FieldDropdown(availableModifiers, (newValue) => {
4368
- setTimeout(() => {
4369
- updateModifierMenuGenerators(self, dropdownName)
4370
- }, 0);
4371
- }));
4374
+ getModifiersInput(this).appendField("+").appendField(new Blockly.FieldDropdown(availableModifiers, (newValue) => {
4375
+ setTimeout(() => {
4376
+ updateModifierMenuGenerators(self, dropdownName)
4377
+ }, 0);
4378
+ }));
4372
4379
 
4373
- const addedFields = getModifierFields(this).slice(-2);
4374
- addedFields[0].name = labelName;
4375
- addedFields[1].name = dropdownName;
4380
+ const addedFields = getModifierFields(this).slice(-2);
4381
+ addedFields[0].name = labelName;
4382
+ addedFields[1].name = dropdownName;
4376
4383
 
4377
- updateModifierMenuGenerators(this, dropdownName);
4378
- },
4384
+ updateModifierMenuGenerators(this, dropdownName);
4385
+ triggerRefresh(this);
4386
+ },
4379
4387
 
4380
- _cleanModifiers() {
4381
- const fieldsToRemove = getModifierFields(this);
4388
+ _cleanModifiers() {
4389
+ const fieldsToRemove = getModifierFields(this);
4382
4390
 
4383
- for (var field of fieldsToRemove)
4384
- getModifiersInput(this).removeField(field.name);
4385
- }
4386
- }
4391
+ for (var field of fieldsToRemove)
4392
+ getModifiersInput(this).removeField(field.name);
4393
+ triggerRefresh(this);
4394
+ }
4395
+ }
4387
4396
  };
4388
4397
 
4389
4398
  Blockly.Blocks.InteractiveLetterBinding = createInteractiveBinding("letra", [
4390
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
4399
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
4391
4400
  ].map(it => ({ code: it, name: it })));
4392
4401
 
4393
4402
  Blockly.Blocks.InteractiveNumberBinding = createInteractiveBinding("número", [
4394
- '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
4403
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
4395
4404
  ].map(it => ({ code: it, name: it })));
4396
4405
 
4397
4406
  Blockly.Blocks.InteractiveKeyBinding = createInteractiveBinding("tecla", [
4398
- { code: 'LEFT', name: '←' },
4399
- { code: 'RIGHT', name: '→' },
4400
- { code: 'UP', name: '↑' },
4401
- { code: 'DOWN', name: '↓' },
4402
- { code: 'MINUS', name: '-' },
4403
- { code: 'SPACE', name: 'Espacio' },
4404
- { code: 'RETURN', name: 'Enter' },
4405
- { code: 'TAB', name: 'Tab' },
4406
- { code: 'BACKSPACE', name: 'Borrar' },
4407
- { code: 'DELETE', name: 'Suprimir' },
4408
- { code: 'ESCAPE', name: 'Escape' }
4407
+ { code: 'LEFT', name: '←' },
4408
+ { code: 'RIGHT', name: '→' },
4409
+ { code: 'UP', name: '↑' },
4410
+ { code: 'DOWN', name: '↓' },
4411
+ { code: 'MINUS', name: '-' },
4412
+ { code: 'SPACE', name: 'Espacio' },
4413
+ { code: 'RETURN', name: 'Enter' },
4414
+ { code: 'TAB', name: 'Tab' },
4415
+ { code: 'BACKSPACE', name: 'Borrar' },
4416
+ { code: 'DELETE', name: 'Suprimir' },
4417
+ { code: 'ESCAPE', name: 'Escape' }
4409
4418
  ]);
4410
4419
 
4411
4420
  // ------------------------------------------------------
@@ -4413,53 +4422,53 @@ Blockly.Blocks.InteractiveKeyBinding = createInteractiveBinding("tecla", [
4413
4422
  // ------------------------------------------------------
4414
4423
 
4415
4424
  Blockly.Blocks.RepeticionSimple = {
4416
- init: function () {
4417
- this.jsonInit({
4418
- type: "Statement",
4419
- previousStatement: "Statement",
4420
- nextStatement: "Statement",
4421
- });
4425
+ init: function () {
4426
+ this.jsonInit({
4427
+ type: "Statement",
4428
+ previousStatement: "Statement",
4429
+ nextStatement: "Statement",
4430
+ });
4422
4431
 
4423
- this.setColour(Blockly.CUSTOM_COLORS.RepeticionSimple || Blockly.CUSTOM_COLORS.controlStructure);
4424
- this.appendValueInput('count')
4425
- .appendField('repetir');
4426
- this.appendDummyInput()
4427
- .appendField('veces');
4428
- this.appendStatementInput('block').setCheck(["Statement"]);
4429
- this.setInputsInline(true);
4430
- }
4432
+ this.setColour(Blockly.CUSTOM_COLORS.RepeticionSimple || Blockly.CUSTOM_COLORS.controlStructure);
4433
+ this.appendValueInput('count')
4434
+ .appendField('repetir');
4435
+ this.appendDummyInput()
4436
+ .appendField('veces');
4437
+ this.appendStatementInput('block').setCheck(["Statement"]);
4438
+ this.setInputsInline(true);
4439
+ }
4431
4440
  };
4432
4441
 
4433
4442
  Blockly.Blocks.RepeticionCondicional = {
4434
- init: function () {
4435
- this.jsonInit({
4436
- type: "Statement",
4437
- previousStatement: "Statement",
4438
- nextStatement: "Statement",
4439
- });
4443
+ init: function () {
4444
+ this.jsonInit({
4445
+ type: "Statement",
4446
+ previousStatement: "Statement",
4447
+ nextStatement: "Statement",
4448
+ });
4440
4449
 
4441
- this.setColour(Blockly.CUSTOM_COLORS.RepeticionCondicional || Blockly.CUSTOM_COLORS.controlStructure);
4442
- this.appendValueInput('condicion')
4443
- .appendField('repetir hasta que');
4444
- this.appendStatementInput('block').setCheck(["Statement"]);
4445
- this.setInputsInline(true);
4446
- }
4450
+ this.setColour(Blockly.CUSTOM_COLORS.RepeticionCondicional || Blockly.CUSTOM_COLORS.controlStructure);
4451
+ this.appendValueInput('condicion')
4452
+ .appendField('repetir hasta que');
4453
+ this.appendStatementInput('block').setCheck(["Statement"]);
4454
+ this.setInputsInline(true);
4455
+ }
4447
4456
  };
4448
4457
 
4449
4458
  Blockly.Blocks.AlternativaSimple = {
4450
- init: function () {
4451
- this.jsonInit({
4452
- type: "Statement",
4453
- previousStatement: "Statement",
4454
- nextStatement: "Statement"
4455
- });
4459
+ init: function () {
4460
+ this.jsonInit({
4461
+ type: "Statement",
4462
+ previousStatement: "Statement",
4463
+ nextStatement: "Statement"
4464
+ });
4456
4465
 
4457
- this.setColour(Blockly.CUSTOM_COLORS.AlternativaSimple || Blockly.CUSTOM_COLORS.controlStructure);
4458
- this.appendValueInput('condicion')
4459
- .appendField(Blockly.Msg["CONTROLS_IF_MSG_IF"]);
4460
- this.appendStatementInput('block').setCheck(["Statement"]);
4461
- this.setInputsInline(true);
4462
- }
4466
+ this.setColour(Blockly.CUSTOM_COLORS.AlternativaSimple || Blockly.CUSTOM_COLORS.controlStructure);
4467
+ this.appendValueInput('condicion')
4468
+ .appendField(Blockly.Msg["CONTROLS_IF_MSG_IF"]);
4469
+ this.appendStatementInput('block').setCheck(["Statement"]);
4470
+ this.setInputsInline(true);
4471
+ }
4463
4472
  };
4464
4473
 
4465
4474
  Blockly.Msg["CONTROLS_IF_MSG_ELSE"] = "si no";
@@ -4469,107 +4478,109 @@ Blockly.Msg["CONTROLS_IF_MSG_THEN"] = "";
4469
4478
  delete Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN.compose;
4470
4479
  delete Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN.decompose;
4471
4480
  Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN.updateShape_ = function() {
4472
- // Delete everything.
4473
- if (this.getInput('block2')) {
4474
- this.removeInput('block2');
4475
- }
4476
- var i = 1;
4477
- while (this.getInput('IF' + i)) {
4478
- this.removeInput('IF' + i);
4479
- this.removeInput('DO' + i);
4480
- i++;
4481
- }
4482
- // Rebuild block.
4483
- for (var i = 1; i <= this.elseifCount_; i++) {
4484
- this.appendValueInput('IF' + i)
4485
- .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
4486
- this.appendStatementInput('DO' + i)
4487
- .setCheck(["Statement"])
4488
- }
4489
- if (this.elseCount_) {
4490
- this.appendStatementInput('block2')
4491
- .setCheck(["Statement"])
4492
- .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
4493
- }
4481
+ // Delete everything.
4482
+ if (this.getInput('block2')) {
4483
+ this.removeInput('block2');
4484
+ }
4485
+ var i = 1;
4486
+ while (this.getInput('IF' + i)) {
4487
+ this.removeInput('IF' + i);
4488
+ this.removeInput('DO' + i);
4489
+ i++;
4490
+ }
4491
+ // Rebuild block.
4492
+ for (var i = 1; i <= this.elseifCount_; i++) {
4493
+ this.appendValueInput('IF' + i)
4494
+ .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
4495
+ this.appendStatementInput('DO' + i)
4496
+ .setCheck(["Statement"])
4497
+ }
4498
+ if (this.elseCount_) {
4499
+ this.appendStatementInput('block2')
4500
+ .setCheck(["Statement"])
4501
+ .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
4502
+ }
4503
+
4504
+ triggerRefresh(this);
4494
4505
  };
4495
4506
  Blockly.Extensions.registerMutator(
4496
- "controls_if_mutator_without_ui",
4497
- Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,
4498
- null,
4499
- []
4507
+ "controls_if_mutator_without_ui",
4508
+ Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,
4509
+ null,
4510
+ []
4500
4511
  );
4501
4512
 
4502
4513
  Blockly.Blocks.AlternativaCompleta = {
4503
- init: function () {
4504
- this.jsonInit({
4505
- "type": "Statement",
4506
- "previousStatement": "Statement",
4507
- "nextStatement": "Statement",
4508
- "message0": "%{BKY_CONTROLS_IF_MSG_IF} %1",
4509
- "args0": [
4510
- {
4511
- "type": "input_value",
4512
- "name": "condicion"
4513
- }
4514
- ],
4515
- "message1": "%{BKY_CONTROLS_IF_MSG_THEN} %1",
4516
- "args1": [
4517
- {
4518
- "type": "input_statement",
4519
- "name": "block1",
4520
- "check": ["Statement"]
4521
- }
4522
- ],
4523
- "colour": "%{BKY_LOGIC_HUE}",
4524
- "helpUrl": "%{BKY_CONTROLS_IF_HELPURL}",
4525
- "mutator": "controls_if_mutator_without_ui",
4526
- "extensions": ["controls_if_tooltip"]
4527
- });
4514
+ init: function () {
4515
+ this.jsonInit({
4516
+ "type": "Statement",
4517
+ "previousStatement": "Statement",
4518
+ "nextStatement": "Statement",
4519
+ "message0": "%{BKY_CONTROLS_IF_MSG_IF} %1",
4520
+ "args0": [
4521
+ {
4522
+ "type": "input_value",
4523
+ "name": "condicion"
4524
+ }
4525
+ ],
4526
+ "message1": "%{BKY_CONTROLS_IF_MSG_THEN} %1",
4527
+ "args1": [
4528
+ {
4529
+ "type": "input_statement",
4530
+ "name": "block1",
4531
+ "check": ["Statement"]
4532
+ }
4533
+ ],
4534
+ "colour": "%{BKY_LOGIC_HUE}",
4535
+ "helpUrl": "%{BKY_CONTROLS_IF_HELPURL}",
4536
+ "mutator": "controls_if_mutator_without_ui",
4537
+ "extensions": ["controls_if_tooltip"]
4538
+ });
4528
4539
 
4529
- this.setColour(Blockly.CUSTOM_COLORS.AlternativaCompleta || Blockly.CUSTOM_COLORS.controlStructure);
4530
- this.setInputsInline(true);
4540
+ this.setColour(Blockly.CUSTOM_COLORS.AlternativaCompleta || Blockly.CUSTOM_COLORS.controlStructure);
4541
+ this.setInputsInline(true);
4531
4542
 
4532
- this.elseCount_++;
4533
- this.updateShape_();
4534
- },
4535
- customContextMenu: function(options) {
4536
- options.unshift({ text: `Limpiar ramas 'si no, si'`, enabled: true, callback: () => {
4537
- this.elseifCount_ = 0;
4543
+ this.elseCount_++;
4544
+ this.updateShape_();
4545
+ },
4546
+ customContextMenu: function(options) {
4547
+ options.unshift({ text: `Limpiar ramas 'si no, si'`, enabled: true, callback: () => {
4548
+ this.elseifCount_ = 0;
4538
4549
 
4539
- this.updateShape_();
4540
- }});
4550
+ this.updateShape_();
4551
+ }});
4541
4552
 
4542
- options.unshift({ text: `Agregar 'si no, si'`, enabled: true, callback: () => {
4543
- this.elseifCount_++;
4553
+ options.unshift({ text: `Agregar 'si no, si'`, enabled: true, callback: () => {
4554
+ this.elseifCount_++;
4544
4555
 
4545
- const valueConnections = [null];
4546
- const statementConnections = [null];
4547
- const elseStatementConnection = this.getInput("block2").connection.targetConnection;
4548
- let k;
4549
- let input;
4556
+ const valueConnections = [null];
4557
+ const statementConnections = [null];
4558
+ const elseStatementConnection = this.getInput("block2").connection.targetConnection;
4559
+ let k;
4560
+ let input;
4550
4561
 
4551
- k = 1;
4552
- while (input = this.getInput("IF" + k)) {
4553
- valueConnections.push(input.connection.targetConnection);
4554
- k++;
4555
- }
4562
+ k = 1;
4563
+ while (input = this.getInput("IF" + k)) {
4564
+ valueConnections.push(input.connection.targetConnection);
4565
+ k++;
4566
+ }
4556
4567
 
4557
- k = 1;
4558
- while (input = this.getInput("DO" + k)) {
4559
- statementConnections.push(input.connection.targetConnection);
4560
- k++;
4561
- }
4568
+ k = 1;
4569
+ while (input = this.getInput("DO" + k)) {
4570
+ statementConnections.push(input.connection.targetConnection);
4571
+ k++;
4572
+ }
4562
4573
 
4563
- this.updateShape_();
4574
+ this.updateShape_();
4564
4575
 
4565
- // Reconnect any child blocks.
4566
- for (var i = 1; i <= this.elseifCount_; i++) {
4567
- Blockly.Mutator.reconnect(valueConnections[i], this, 'IF' + i);
4568
- Blockly.Mutator.reconnect(statementConnections[i], this, 'DO' + i);
4569
- }
4570
- Blockly.Mutator.reconnect(elseStatementConnection, this, 'block2');
4571
- }});
4572
- }
4576
+ // Reconnect any child blocks.
4577
+ for (var i = 1; i <= this.elseifCount_; i++) {
4578
+ Blockly.Mutator.reconnect(valueConnections[i], this, 'IF' + i);
4579
+ Blockly.Mutator.reconnect(statementConnections[i], this, 'DO' + i);
4580
+ }
4581
+ Blockly.Mutator.reconnect(elseStatementConnection, this, 'block2');
4582
+ }});
4583
+ }
4573
4584
  };
4574
4585
 
4575
4586
  // ------------------------------------------------------
@@ -4577,126 +4588,126 @@ Blockly.Blocks.AlternativaCompleta = {
4577
4588
  // ------------------------------------------------------
4578
4589
 
4579
4590
  Blockly.Blocks.Poner = {
4580
- init: function () {
4591
+ init: function () {
4581
4592
  const icon = "putStone.png";
4582
4593
 
4583
- this.jsonInit({
4584
- message0: '%1 Poner %2',
4585
- type: "Statement",
4586
- previousStatement: "Statement",
4587
- nextStatement: "Statement",
4588
- args0: [
4594
+ this.jsonInit({
4595
+ message0: '%1 Poner %2',
4596
+ type: "Statement",
4597
+ previousStatement: "Statement",
4598
+ nextStatement: "Statement",
4599
+ args0: [
4589
4600
  {
4590
4601
  "type": "field_image",
4591
4602
  "src": getLocalMediaUrl(this, icon),
4592
4603
  "width": getLocalMediaSize(icon),
4593
4604
  "height": getLocalMediaSize(icon)
4594
4605
  },
4595
- {
4596
- type: 'input_value',
4597
- name: 'COLOR'
4598
- }
4599
- ],
4600
- colour: Blockly.CUSTOM_COLORS.Poner || Blockly.CUSTOM_COLORS.primitiveCommand,
4601
- tooltip: 'Poner color en casillero.',
4602
- inputsInline: true
4603
- });
4604
- }
4606
+ {
4607
+ type: 'input_value',
4608
+ name: 'COLOR'
4609
+ }
4610
+ ],
4611
+ colour: Blockly.CUSTOM_COLORS.Poner || Blockly.CUSTOM_COLORS.primitiveCommand,
4612
+ tooltip: 'Poner color en casillero.',
4613
+ inputsInline: true
4614
+ });
4615
+ }
4605
4616
  };
4606
4617
 
4607
4618
  Blockly.Blocks.Sacar = {
4608
- init: function () {
4619
+ init: function () {
4609
4620
  const icon = "removeStone.png";
4610
4621
 
4611
- this.jsonInit({
4612
- type: "Statement",
4613
- previousStatement: "Statement",
4614
- nextStatement: "Statement",
4615
- message0: '%1 Sacar %2',
4616
- args0: [
4622
+ this.jsonInit({
4623
+ type: "Statement",
4624
+ previousStatement: "Statement",
4625
+ nextStatement: "Statement",
4626
+ message0: '%1 Sacar %2',
4627
+ args0: [
4617
4628
  {
4618
4629
  "type": "field_image",
4619
4630
  "src": getLocalMediaUrl(this, icon),
4620
4631
  "width": getLocalMediaSize(icon),
4621
4632
  "height": getLocalMediaSize(icon)
4622
4633
  },
4623
- {
4624
- type: 'input_value',
4625
- name: 'COLOR'
4626
- }
4627
- ],
4628
- colour: Blockly.CUSTOM_COLORS.Sacar || Blockly.CUSTOM_COLORS.primitiveCommand,
4629
- tooltip: 'Sacar color de casillero.',
4630
- inputsInline: true
4631
- });
4632
- }
4634
+ {
4635
+ type: 'input_value',
4636
+ name: 'COLOR'
4637
+ }
4638
+ ],
4639
+ colour: Blockly.CUSTOM_COLORS.Sacar || Blockly.CUSTOM_COLORS.primitiveCommand,
4640
+ tooltip: 'Sacar color de casillero.',
4641
+ inputsInline: true
4642
+ });
4643
+ }
4633
4644
  };
4634
4645
 
4635
4646
  Blockly.Blocks.Mover = {
4636
- init: function () {
4647
+ init: function () {
4637
4648
  const icon = "move.png";
4638
4649
 
4639
- this.jsonInit({
4640
- type: "Statement",
4641
- previousStatement: "Statement",
4642
- nextStatement: "Statement",
4643
- message0: '%1 Mover %2',
4644
- args0: [
4650
+ this.jsonInit({
4651
+ type: "Statement",
4652
+ previousStatement: "Statement",
4653
+ nextStatement: "Statement",
4654
+ message0: '%1 Mover %2',
4655
+ args0: [
4645
4656
  {
4646
4657
  "type": "field_image",
4647
4658
  "src": getLocalMediaUrl(this, icon),
4648
4659
  "width": getLocalMediaSize(icon),
4649
4660
  "height": getLocalMediaSize(icon)
4650
4661
  },
4651
- {
4652
- type: 'input_value',
4653
- name: 'DIRECCION'
4654
- }
4655
- ],
4656
- colour: Blockly.CUSTOM_COLORS.Mover || Blockly.CUSTOM_COLORS.primitiveCommand,
4657
- tooltip: 'Mover en una dirección.',
4658
- inputsInline: true
4659
- });
4660
- }
4662
+ {
4663
+ type: 'input_value',
4664
+ name: 'DIRECCION'
4665
+ }
4666
+ ],
4667
+ colour: Blockly.CUSTOM_COLORS.Mover || Blockly.CUSTOM_COLORS.primitiveCommand,
4668
+ tooltip: 'Mover en una dirección.',
4669
+ inputsInline: true
4670
+ });
4671
+ }
4661
4672
  };
4662
4673
 
4663
4674
  Blockly.Blocks.IrAlBorde = {
4664
- init: function () {
4675
+ init: function () {
4665
4676
  const icon = "goToEdge.png";
4666
4677
 
4667
- this.jsonInit({
4668
- type: "Statement",
4669
- previousStatement: "Statement",
4670
- nextStatement: "Statement",
4671
- message0: '%1 Ir al borde %2',
4672
- args0: [
4678
+ this.jsonInit({
4679
+ type: "Statement",
4680
+ previousStatement: "Statement",
4681
+ nextStatement: "Statement",
4682
+ message0: '%1 Ir al borde %2',
4683
+ args0: [
4673
4684
  {
4674
4685
  "type": "field_image",
4675
4686
  "src": getLocalMediaUrl(this, icon),
4676
4687
  "width": getLocalMediaSize(icon),
4677
4688
  "height": getLocalMediaSize(icon)
4678
4689
  },
4679
- {
4680
- type: 'input_value',
4681
- name: 'DIRECCION'
4682
- }
4683
- ],
4684
- colour: Blockly.CUSTOM_COLORS.IrAlBorde || Blockly.CUSTOM_COLORS.primitiveCommand,
4685
- tooltip: 'Ir al borde del tablero.',
4686
- inputsInline: true
4687
- });
4688
- }
4690
+ {
4691
+ type: 'input_value',
4692
+ name: 'DIRECCION'
4693
+ }
4694
+ ],
4695
+ colour: Blockly.CUSTOM_COLORS.IrAlBorde || Blockly.CUSTOM_COLORS.primitiveCommand,
4696
+ tooltip: 'Ir al borde del tablero.',
4697
+ inputsInline: true
4698
+ });
4699
+ }
4689
4700
  };
4690
4701
 
4691
4702
  Blockly.Blocks.VaciarTablero = {
4692
- init: function () {
4703
+ init: function () {
4693
4704
  const icon = "emptyBoard.png";
4694
4705
 
4695
- this.jsonInit({
4696
- type: "Statement",
4697
- previousStatement: "Statement",
4698
- nextStatement: "Statement",
4699
- message0: '%1 Vaciar tablero',
4706
+ this.jsonInit({
4707
+ type: "Statement",
4708
+ previousStatement: "Statement",
4709
+ nextStatement: "Statement",
4710
+ message0: '%1 Vaciar tablero',
4700
4711
  args0: [
4701
4712
  {
4702
4713
  "type": "field_image",
@@ -4705,82 +4716,82 @@ Blockly.Blocks.VaciarTablero = {
4705
4716
  "height": getLocalMediaSize(icon)
4706
4717
  },
4707
4718
  ],
4708
- colour: Blockly.CUSTOM_COLORS.VaciarTablero || Blockly.CUSTOM_COLORS.primitiveCommand,
4709
- tooltip: 'Vaciar el tablero.',
4710
- inputsInline: true
4711
- });
4712
- }
4719
+ colour: Blockly.CUSTOM_COLORS.VaciarTablero || Blockly.CUSTOM_COLORS.primitiveCommand,
4720
+ tooltip: 'Vaciar el tablero.',
4721
+ inputsInline: true
4722
+ });
4723
+ }
4713
4724
  };
4714
4725
 
4715
4726
  Blockly.Blocks.BOOM = {
4716
- init: function () {
4727
+ init: function () {
4717
4728
  const icon = "boom.png";
4718
4729
 
4719
- this.jsonInit({
4720
- "type": "Statement",
4721
- "previousStatement": "Statement",
4722
- "nextStatement": "Statement",
4723
- "lastDummyAlign0": "RIGHT",
4724
- "message0": "%1 Hacer ¡BOOM! porque: %2 %3",
4725
- "args0": [
4730
+ this.jsonInit({
4731
+ "type": "Statement",
4732
+ "previousStatement": "Statement",
4733
+ "nextStatement": "Statement",
4734
+ "lastDummyAlign0": "RIGHT",
4735
+ "message0": "%1 Hacer ¡BOOM! porque: %2 %3",
4736
+ "args0": [
4726
4737
  {
4727
4738
  "type": "field_image",
4728
4739
  "src": getLocalMediaUrl(this, icon),
4729
4740
  "width": getLocalMediaSize(icon),
4730
4741
  "height": getLocalMediaSize(icon)
4731
4742
  },
4732
- {
4733
- "type": "input_dummy"
4734
- },
4735
- {
4736
- "type": "field_input",
4737
- "name": "boomDescription",
4738
- "text": "Ingresar motivo..."
4739
- }
4740
- ],
4741
- "inputsInline": false,
4742
- "colour": Blockly.CUSTOM_COLORS.BOOM || Blockly.CUSTOM_COLORS.primitiveCommand,
4743
- "tooltip": "Este comando hace que estalle todo."
4744
- });
4745
- }
4743
+ {
4744
+ "type": "input_dummy"
4745
+ },
4746
+ {
4747
+ "type": "field_input",
4748
+ "name": "boomDescription",
4749
+ "text": "Ingresar motivo..."
4750
+ }
4751
+ ],
4752
+ "inputsInline": false,
4753
+ "colour": Blockly.CUSTOM_COLORS.BOOM || Blockly.CUSTOM_COLORS.primitiveCommand,
4754
+ "tooltip": "Este comando hace que estalle todo."
4755
+ });
4756
+ }
4746
4757
  };
4747
4758
 
4748
4759
  Blockly.Blocks.makeShadowEventListener = function(event){
4749
- if(event.blockId == this.id && event.newParentId){
4750
- this.setShadow(true);
4751
- }
4760
+ if(event.blockId == this.id && event.newParentId){
4761
+ this.setShadow(true);
4762
+ }
4752
4763
  };
4753
4764
 
4754
4765
  Blockly.Blocks.ComandoCompletar = {
4755
- init: function () {
4756
- this.jsonInit({
4757
- "type": "Statement",
4758
- "previousStatement": "Statement",
4759
- "nextStatement": "Statement",
4760
- "lastDummyAlign0": "RIGHT",
4761
- "message0": "COMPLETAR",
4762
- "colour": Blockly.CUSTOM_COLORS.ComandoCompletar || Blockly.CUSTOM_COLORS.complete,
4763
- "tooltip": "Tenés que reemplazar este bloque por tu solución"
4764
- });
4765
- },
4766
+ init: function () {
4767
+ this.jsonInit({
4768
+ "type": "Statement",
4769
+ "previousStatement": "Statement",
4770
+ "nextStatement": "Statement",
4771
+ "lastDummyAlign0": "RIGHT",
4772
+ "message0": "COMPLETAR",
4773
+ "colour": Blockly.CUSTOM_COLORS.ComandoCompletar || Blockly.CUSTOM_COLORS.complete,
4774
+ "tooltip": "Tenés que reemplazar este bloque por tu solución"
4775
+ });
4776
+ },
4766
4777
 
4767
- onchange: Blockly.Blocks.makeShadowEventListener
4778
+ onchange: Blockly.Blocks.makeShadowEventListener
4768
4779
  };
4769
4780
 
4770
4781
  Blockly.Blocks.AsociacionDeTeclaCompletar = {
4771
- init: function () {
4772
- this.jsonInit({
4773
- "type": "InteractiveBinding",
4774
- "previousStatement": "InteractiveBinding",
4775
- "nextStatement": "InteractiveBinding",
4776
- "lastDummyAlign0": "RIGHT",
4777
- "message0": "COMPLETAR",
4778
- "colour": Blockly.CUSTOM_COLORS.AsociacionDeTeclaCompletar || Blockly.CUSTOM_COLORS.complete,
4779
- "tooltip": "Tenés que reemplazar este bloque por tu solución"
4780
- });
4781
- },
4782
+ init: function () {
4783
+ this.jsonInit({
4784
+ "type": "InteractiveBinding",
4785
+ "previousStatement": "InteractiveBinding",
4786
+ "nextStatement": "InteractiveBinding",
4787
+ "lastDummyAlign0": "RIGHT",
4788
+ "message0": "COMPLETAR",
4789
+ "colour": Blockly.CUSTOM_COLORS.AsociacionDeTeclaCompletar || Blockly.CUSTOM_COLORS.complete,
4790
+ "tooltip": "Tenés que reemplazar este bloque por tu solución"
4791
+ });
4792
+ },
4782
4793
 
4783
- onchange: Blockly.Blocks.makeShadowEventListener
4794
+ onchange: Blockly.Blocks.makeShadowEventListener
4784
4795
  };
4785
4796
 
4786
4797
  // ------------------------------------------------------
@@ -4800,7 +4811,7 @@ function deepCopyObj(aObject) {
4800
4811
  const oldMathNumber = Blockly.Blocks.math_number;
4801
4812
  Blockly.Blocks.math_number = deepCopyObj(Blockly.Blocks.math_number);
4802
4813
  Blockly.Blocks.math_number.init = function() {
4803
- oldMathNumber.init.call(this);
4814
+ oldMathNumber.init.call(this);
4804
4815
 
4805
4816
  const icon = "number.png";
4806
4817
  var iconField = new Blockly.FieldImage(
@@ -4809,30 +4820,30 @@ Blockly.Blocks.math_number.init = function() {
4809
4820
  getLocalMediaSize(icon)
4810
4821
  );
4811
4822
  this.inputList[0].insertFieldAt(0, iconField);
4812
- this.setColour(Blockly.CUSTOM_COLORS.math_number || Blockly.CUSTOM_COLORS.literalExpression);
4823
+ this.setColour(Blockly.CUSTOM_COLORS.math_number || Blockly.CUSTOM_COLORS.literalExpression);
4813
4824
  }
4814
4825
 
4815
4826
  Blockly.Blocks.ExpresionCompletar = {
4816
- init: function () {
4817
- this.jsonInit({
4818
- "type": "completar_expression",
4819
- "message0": "COMPLETAR",
4820
- "output": "any",
4821
- "colour": Blockly.CUSTOM_COLORS.ExpresionCompletar || Blockly.CUSTOM_COLORS.complete,
4822
- "tooltip": "Tenés que reemplazar este bloque por tu solución"
4823
- });
4824
- },
4827
+ init: function () {
4828
+ this.jsonInit({
4829
+ "type": "completar_expression",
4830
+ "message0": "COMPLETAR",
4831
+ "output": "any",
4832
+ "colour": Blockly.CUSTOM_COLORS.ExpresionCompletar || Blockly.CUSTOM_COLORS.complete,
4833
+ "tooltip": "Tenés que reemplazar este bloque por tu solución"
4834
+ });
4835
+ },
4825
4836
 
4826
- onchange: Blockly.Blocks.makeShadowEventListener
4837
+ onchange: Blockly.Blocks.makeShadowEventListener
4827
4838
  };
4828
4839
 
4829
4840
  function createLiteralSelectorBlock(type,values){
4830
- return {
4831
- init: function () {
4832
- this.jsonInit({
4833
- type: type,
4834
- message0: "%1 %2",
4835
- args0: [
4841
+ return {
4842
+ init: function () {
4843
+ this.jsonInit({
4844
+ type: type,
4845
+ message0: "%1 %2",
4846
+ args0: [
4836
4847
  {
4837
4848
  "type": "field_image",
4838
4849
  "src": "",
@@ -4840,16 +4851,16 @@ function createLiteralSelectorBlock(type,values){
4840
4851
  "height": 16
4841
4852
  },
4842
4853
  {
4843
- type: "field_dropdown",
4844
- name: type + "Dropdown",
4845
- options: values.map(value => [value,value])
4854
+ type: "field_dropdown",
4855
+ name: type + "Dropdown",
4856
+ options: values.map(value => [value,value])
4846
4857
  }
4847
- ],
4848
- output: type,
4849
- colour: Blockly.CUSTOM_COLORS[`${type}Selector`] || Blockly.CUSTOM_COLORS.literalExpression,
4850
- tooltip: "Escoger " + type,
4851
- });
4852
- },
4858
+ ],
4859
+ output: type,
4860
+ colour: Blockly.CUSTOM_COLORS[`${type}Selector`] || Blockly.CUSTOM_COLORS.literalExpression,
4861
+ tooltip: "Escoger " + type,
4862
+ });
4863
+ },
4853
4864
 
4854
4865
  onchange: function(event) {
4855
4866
  const [image, dropdown] = this.inputList[0].fieldRow;
@@ -4857,7 +4868,7 @@ function createLiteralSelectorBlock(type,values){
4857
4868
 
4858
4869
  image.setValue(getLocalMediaUrl(this, `${type.toLowerCase()}-${value.toLowerCase()}.svg`));
4859
4870
  }
4860
- };
4871
+ };
4861
4872
  }
4862
4873
 
4863
4874
  Blockly.Blocks.ColorSelector = createLiteralSelectorBlock('Color',['Rojo','Verde','Negro','Azul']);
@@ -4898,6 +4909,7 @@ Blockly.Blocks.List = {
4898
4909
  const input = this.appendValueInput('element' + this.length);
4899
4910
  this._addRemoveButtonFor(input);
4900
4911
  this._addAddButton();
4912
+ triggerRefresh(this);
4901
4913
  },
4902
4914
 
4903
4915
  _removeElement: function(input) {
@@ -4911,6 +4923,7 @@ Blockly.Blocks.List = {
4911
4923
  id++;
4912
4924
  }
4913
4925
  }
4926
+ triggerRefresh(this);
4914
4927
  },
4915
4928
 
4916
4929
  _addAddButton: function() {
@@ -5000,22 +5013,22 @@ Blockly.Blocks.ForEach = {
5000
5013
  };
5001
5014
 
5002
5015
  function createSingleParameterExpressionBlock(blockText,returnType, colorType = "operator"){
5003
- return {
5004
- init: function () {
5005
- this.jsonInit({
5006
- message0: blockText + ' %1',
5007
- args0: [
5008
- {
5009
- type: 'input_value',
5010
- name: 'VALUE'
5011
- }
5012
- ],
5013
- colour: Blockly.CUSTOM_COLORS[this.type] || Blockly.CUSTOM_COLORS[colorType],
5014
- inputsInline: true,
5015
- output: returnType
5016
- })
5017
- }
5018
- };
5016
+ return {
5017
+ init: function () {
5018
+ this.jsonInit({
5019
+ message0: blockText + ' %1',
5020
+ args0: [
5021
+ {
5022
+ type: 'input_value',
5023
+ name: 'VALUE'
5024
+ }
5025
+ ],
5026
+ colour: Blockly.CUSTOM_COLORS[this.type] || Blockly.CUSTOM_COLORS[colorType],
5027
+ inputsInline: true,
5028
+ output: returnType
5029
+ })
5030
+ }
5031
+ };
5019
5032
  }
5020
5033
 
5021
5034
  Blockly.Blocks.hayBolitas = createSingleParameterExpressionBlock('hay bolitas','Bool', "primitiveExpression");
@@ -5027,132 +5040,132 @@ Blockly.Blocks.nroBolitas = createSingleParameterExpressionBlock('número de bol
5027
5040
  // ------------------------------------------------------
5028
5041
 
5029
5042
  Blockly.Blocks.OperadorDeComparacion = {
5030
- init: function () {
5031
- this.jsonInit({
5032
- message0: '%1 %2 %3 %4',
5033
- args0: [
5034
- {
5035
- type: 'input_value',
5036
- name: 'arg1'
5037
- },
5038
- {
5039
- type: 'field_dropdown',
5040
- name: 'RELATION',
5041
- options: [['==', '=='], ['/=', '/='], ['<=', '<='], ['<', '<'], ['>=', '>='], ['>', '>']]
5042
- },
5043
- {
5044
- type: 'input_dummy'
5045
- },
5046
- {
5047
- type: 'input_value',
5048
- name: 'arg2'
5049
- }
5050
- ],
5051
- colour: Blockly.CUSTOM_COLORS.OperadorDeComparacion || Blockly.CUSTOM_COLORS.operator,
5052
- inputsInline: false,
5053
- output: 'Bool'
5054
- });
5055
- }
5043
+ init: function () {
5044
+ this.jsonInit({
5045
+ message0: '%1 %2 %3 %4',
5046
+ args0: [
5047
+ {
5048
+ type: 'input_value',
5049
+ name: 'arg1'
5050
+ },
5051
+ {
5052
+ type: 'field_dropdown',
5053
+ name: 'RELATION',
5054
+ options: [['==', '=='], ['/=', '/='], ['<=', '<='], ['<', '<'], ['>=', '>='], ['>', '>']]
5055
+ },
5056
+ {
5057
+ type: 'input_dummy'
5058
+ },
5059
+ {
5060
+ type: 'input_value',
5061
+ name: 'arg2'
5062
+ }
5063
+ ],
5064
+ colour: Blockly.CUSTOM_COLORS.OperadorDeComparacion || Blockly.CUSTOM_COLORS.operator,
5065
+ inputsInline: false,
5066
+ output: 'Bool'
5067
+ });
5068
+ }
5056
5069
  };
5057
5070
 
5058
5071
  Blockly.Blocks.OperadorNumerico = {
5059
- init: function () {
5060
- this.jsonInit({
5061
- message0: '%1 %2 %3 %4',
5062
- args0: [
5063
- {
5064
- type: 'input_value',
5065
- name: 'arg1'
5066
- },
5067
- {
5068
- type: 'field_dropdown',
5069
- name: 'OPERATOR',
5070
- options: [['+', '+'], ['-', '-'], ['*', '*'], ['div', 'div'], ['mod', 'mod'], ['^', '^']]
5071
- },
5072
- {
5073
- type: 'input_dummy'
5074
- },
5075
- {
5076
- type: 'input_value',
5077
- name: 'arg2'
5078
- }
5079
- ],
5080
- colour: Blockly.CUSTOM_COLORS.OperadorNumerico || Blockly.CUSTOM_COLORS.operator,
5081
- inputsInline: false,
5082
- output: 'Number'
5083
- });
5084
- }
5072
+ init: function () {
5073
+ this.jsonInit({
5074
+ message0: '%1 %2 %3 %4',
5075
+ args0: [
5076
+ {
5077
+ type: 'input_value',
5078
+ name: 'arg1'
5079
+ },
5080
+ {
5081
+ type: 'field_dropdown',
5082
+ name: 'OPERATOR',
5083
+ options: [['+', '+'], ['-', '-'], ['*', '*'], ['div', 'div'], ['mod', 'mod'], ['^', '^']]
5084
+ },
5085
+ {
5086
+ type: 'input_dummy'
5087
+ },
5088
+ {
5089
+ type: 'input_value',
5090
+ name: 'arg2'
5091
+ }
5092
+ ],
5093
+ colour: Blockly.CUSTOM_COLORS.OperadorNumerico || Blockly.CUSTOM_COLORS.operator,
5094
+ inputsInline: false,
5095
+ output: 'Number'
5096
+ });
5097
+ }
5085
5098
  };
5086
5099
 
5087
5100
  Blockly.Blocks.OperadorLogico = {
5088
- init: function () {
5089
- this.jsonInit({
5090
- message0: '%1 %2 %3 %4',
5091
- args0: [
5092
- {
5093
- type: 'input_value',
5094
- name: 'arg1'
5095
- },
5096
- {
5097
- type: 'field_dropdown',
5098
- name: 'OPERATOR',
5099
- options: [['y también', 'AND'], ['o bien', '||']]
5100
- },
5101
- {
5102
- type: 'input_dummy'
5103
- },
5104
- {
5105
- type: 'input_value',
5106
- name: 'arg2'
5107
- }
5108
- ],
5109
- colour: Blockly.CUSTOM_COLORS.OperadorLogico || Blockly.CUSTOM_COLORS.operator,
5110
- inputsInline: false,
5111
- output: 'Bool'
5112
- });
5113
- }
5101
+ init: function () {
5102
+ this.jsonInit({
5103
+ message0: '%1 %2 %3 %4',
5104
+ args0: [
5105
+ {
5106
+ type: 'input_value',
5107
+ name: 'arg1'
5108
+ },
5109
+ {
5110
+ type: 'field_dropdown',
5111
+ name: 'OPERATOR',
5112
+ options: [['y también', 'AND'], ['o bien', '||']]
5113
+ },
5114
+ {
5115
+ type: 'input_dummy'
5116
+ },
5117
+ {
5118
+ type: 'input_value',
5119
+ name: 'arg2'
5120
+ }
5121
+ ],
5122
+ colour: Blockly.CUSTOM_COLORS.OperadorLogico || Blockly.CUSTOM_COLORS.operator,
5123
+ inputsInline: false,
5124
+ output: 'Bool'
5125
+ });
5126
+ }
5114
5127
  };
5115
5128
 
5116
5129
  Blockly.Blocks.Asignacion = {
5117
- init: function () {
5130
+ init: function () {
5118
5131
  const icon = "assignation.png";
5119
5132
 
5120
- this.jsonInit({
5121
- "type": "asignacion",
5122
- "message0": "%1 Recordar que %2 %3 vale %4 %5",
5123
- "args0": [
5133
+ this.jsonInit({
5134
+ "type": "asignacion",
5135
+ "message0": "%1 Recordar que %2 %3 vale %4 %5",
5136
+ "args0": [
5124
5137
  {
5125
5138
  "type": "field_image",
5126
5139
  "src": getLocalMediaUrl(this, icon),
5127
5140
  "width": getLocalMediaSize(icon),
5128
5141
  "height": getLocalMediaSize(icon)
5129
5142
  },
5130
- {
5131
- "type": "field_input",
5132
- "name": "varName",
5133
- "text": "una variable",
5134
- "class": Blockly.Procedures.rename
5135
- },
5136
- {
5137
- "type": "input_dummy"
5138
- },
5139
- {
5140
- "type": "input_dummy"
5141
- },
5142
- {
5143
- "type": "input_value",
5144
- "name": "varValue"
5145
- }
5146
- ],
5147
- "inputsInline": true,
5148
- "previousStatement": null,
5149
- "nextStatement": null,
5150
- "colour": Blockly.CUSTOM_COLORS.Asignacion || Blockly.CUSTOM_COLORS.assignation,
5151
- "tooltip": "",
5152
- "helpUrl": ""
5153
- });
5143
+ {
5144
+ "type": "field_input",
5145
+ "name": "varName",
5146
+ "text": "una variable",
5147
+ "class": Blockly.Procedures.rename
5148
+ },
5149
+ {
5150
+ "type": "input_dummy"
5151
+ },
5152
+ {
5153
+ "type": "input_dummy"
5154
+ },
5155
+ {
5156
+ "type": "input_value",
5157
+ "name": "varValue"
5158
+ }
5159
+ ],
5160
+ "inputsInline": true,
5161
+ "previousStatement": null,
5162
+ "nextStatement": null,
5163
+ "colour": Blockly.CUSTOM_COLORS.Asignacion || Blockly.CUSTOM_COLORS.assignation,
5164
+ "tooltip": "",
5165
+ "helpUrl": ""
5166
+ });
5154
5167
 
5155
- var self = this;
5168
+ var self = this;
5156
5169
 
5157
5170
  const handIcon = "hand.png";
5158
5171
  var createGetterButton = new Blockly.FieldImage(
@@ -5161,70 +5174,70 @@ Blockly.Blocks.Asignacion = {
5161
5174
  getLocalMediaSize(handIcon),
5162
5175
  "Obtener variable",
5163
5176
  function() {
5164
- var name = self.getFieldValue('varName');
5165
- self.createVariableBlock(name);
5177
+ var name = self.getFieldValue('varName');
5178
+ self.createVariableBlock(name);
5166
5179
  }
5167
5180
  );
5168
5181
 
5169
5182
  this.appendDummyInput().appendField(createGetterButton);
5170
- },
5183
+ },
5171
5184
 
5172
- customContextMenu: function(options) {
5173
- var name = this.getFieldValue('varName');
5185
+ customContextMenu: function(options) {
5186
+ var name = this.getFieldValue('varName');
5174
5187
 
5175
- options.unshift({ text: `Crear ${name}`, enabled: true, callback: () => {
5176
- this.createVariableBlock(name);
5177
- }});
5178
- },
5188
+ options.unshift({ text: `Crear ${name}`, enabled: true, callback: () => {
5189
+ this.createVariableBlock(name);
5190
+ }});
5191
+ },
5179
5192
 
5180
- createVariableBlock: function(name) {
5181
- return createVariable(this, name);
5182
- }
5193
+ createVariableBlock: function(name) {
5194
+ return createVariable(this, name);
5195
+ }
5183
5196
  };
5184
5197
 
5185
5198
 
5186
5199
  Blockly.Blocks.variables_get = {
5187
- init: function () {
5188
- this.jsonInit({
5189
- "type": "variables_get",
5190
- "message0": "%1",
5191
- "args0": [
5192
- {
5193
- "type": "field_input",
5194
- "name": "VAR",
5195
- "text": "nombre de variable"
5196
- }
5197
- ],
5198
- "output": null,
5199
- "colour": Blockly.CUSTOM_COLORS.variable,
5200
- "tooltip": "",
5201
- "helpUrl": "",
5202
- });
5203
- },
5204
- mutationToDom: function() {
5205
- var container = document.createElement('mutation');
5206
- container.setAttribute('var', this.getFieldValue('VAR'));
5207
- if (this.$parent) container.setAttribute("parent", this.$parent);
5208
- return container;
5209
- },
5210
- domToMutation: function(xmlElement) {
5211
- var var_name = xmlElement.getAttribute('var');
5212
- this.setFieldValue(var_name, 'VAR');
5213
- this.$parent = xmlElement.getAttribute("parent") || null;
5214
- },
5215
-
5216
- onchange: function(event){
5217
- if (this.$parent) {
5218
- this.getField("VAR").EDITABLE = false;
5219
- this.setColour(Blockly.CUSTOM_COLORS.parameter);
5220
- } else {
5221
- this.setColour(Blockly.CUSTOM_COLORS.variable);
5222
- }
5200
+ init: function () {
5201
+ this.jsonInit({
5202
+ "type": "variables_get",
5203
+ "message0": "%1",
5204
+ "args0": [
5205
+ {
5206
+ "type": "field_input",
5207
+ "name": "VAR",
5208
+ "text": "nombre de variable"
5209
+ }
5210
+ ],
5211
+ "output": null,
5212
+ "colour": Blockly.CUSTOM_COLORS.variable,
5213
+ "tooltip": "",
5214
+ "helpUrl": "",
5215
+ });
5216
+ },
5217
+ mutationToDom: function() {
5218
+ var container = document.createElement('mutation');
5219
+ container.setAttribute('var', this.getFieldValue('VAR'));
5220
+ if (this.$parent) container.setAttribute("parent", this.$parent);
5221
+ return container;
5222
+ },
5223
+ domToMutation: function(xmlElement) {
5224
+ var var_name = xmlElement.getAttribute('var');
5225
+ this.setFieldValue(var_name, 'VAR');
5226
+ this.$parent = xmlElement.getAttribute("parent") || null;
5227
+ },
5223
5228
 
5224
- if (event.blockId == this.id && event.type == Blockly.Events.BLOCK_DELETE) {
5225
- // do something with parent
5226
- }
5227
- }
5229
+ onchange: function(event){
5230
+ if (this.$parent) {
5231
+ this.getField("VAR").EDITABLE = false;
5232
+ this.setColour(Blockly.CUSTOM_COLORS.parameter);
5233
+ } else {
5234
+ this.setColour(Blockly.CUSTOM_COLORS.variable);
5235
+ }
5236
+
5237
+ if (event.blockId == this.id && event.type == Blockly.Events.BLOCK_DELETE) {
5238
+ // do something with parent
5239
+ }
5240
+ }
5228
5241
  };
5229
5242
 
5230
5243
  Blockly.Blocks.OperadoresDeEnumeracion = {
@@ -5258,14 +5271,14 @@ Blockly.Blocks.opuesto = createSingleParameterExpressionBlock('opuesto','*');
5258
5271
  // Necesario para sanitizar nombres de procedimientos.
5259
5272
  // En la interfaz de bloques de gobstones por ahora vamos a dejar pasar sólo espacios y letras con tilde
5260
5273
  Blockly.Blocks.GobstonesSanitizer = function(name){
5261
- return name.replace(/[^A-Za-z0-9ÁÉÍÓÚÑáéíóúñ_ ]/g,'');
5274
+ return name.replace(/[^A-Za-z0-9ÁÉÍÓÚÑáéíóúñ_ ]/g,'');
5262
5275
  };
5263
5276
 
5264
5277
 
5265
5278
  Blockly.Procedures.OldRename = Blockly.Procedures.rename;
5266
5279
  Blockly.Procedures.rename = function(name){
5267
- return Blockly.Procedures.OldRename.call(this,
5268
- Blockly.Blocks.GobstonesSanitizer(name));
5280
+ return Blockly.Procedures.OldRename.call(this,
5281
+ Blockly.Blocks.GobstonesSanitizer(name));
5269
5282
  };
5270
5283
 
5271
5284
  // Necesario para sanitizar nombres de parámetros.
@@ -5273,8 +5286,8 @@ Blockly.Procedures.rename = function(name){
5273
5286
  // Mirá, mirá cómo rompo el encapsulamiento y repito código, mirá.
5274
5287
  Blockly.Blocks.procedures_mutatorarg.validator_old = Blockly.Blocks.procedures_mutatorarg.validator_;
5275
5288
  Blockly.Blocks.procedures_mutatorarg.validator_ = function(name){
5276
- return Blockly.Blocks.procedures_mutatorarg.validator_old.call(this,
5277
- Blockly.Blocks.GobstonesSanitizer(name));
5289
+ return Blockly.Blocks.procedures_mutatorarg.validator_old.call(this,
5290
+ Blockly.Blocks.GobstonesSanitizer(name));
5278
5291
  };
5279
5292
  </script>
5280
5293
  <script>/* global Blockly, goog */
@@ -6609,14 +6622,6 @@ Blockly.ErrorInforming.CssContent = [
6609
6622
  }
6610
6623
  },
6611
6624
 
6612
- _onBlocklyWorkspaceUpdate: function () {
6613
- let xml = Blockly.Xml.workspaceToDom(this.workspace);
6614
- this._blocklyWorkspaceXML = Blockly.Xml.domToText(xml);
6615
- this.workspaceXml = this._blocklyWorkspaceXML;
6616
- this._keepOnlyAProgram(xml);
6617
- this._checkParameterBounds(xml);
6618
- },
6619
-
6620
6625
  _keepOnlyAProgram(xml) {
6621
6626
  const findProgram = (programType) => {
6622
6627
  const children = xml.children;
@@ -6914,11 +6919,12 @@ Blockly.ErrorInforming.CssContent = [
6914
6919
  });
6915
6920
  this.workspace.options.localMedia = this.localMedia;
6916
6921
  this.workspace.options.localMediaSuffix = this.localMediaSuffix;
6922
+ this.workspace.options.parentController = this;
6917
6923
 
6918
6924
  var _this = this;
6919
6925
  this.workspace.addChangeListener(function (a, b, c) {
6920
6926
  Blockly.Events.disableOrphans(a, b, c);
6921
- _this._onBlocklyWorkspaceUpdate();
6927
+ _this.onBlocklyWorkspaceUpdate();
6922
6928
  });
6923
6929
  this.resetWorkspace()
6924
6930
  this._onresize();
@@ -7054,7 +7060,15 @@ Blockly.ErrorInforming.CssContent = [
7054
7060
  setTimeout(() => {
7055
7061
  this.workspaceXml = xml;
7056
7062
  }, 1);
7057
- }
7063
+ },
7064
+
7065
+ onBlocklyWorkspaceUpdate: function () {
7066
+ let xml = Blockly.Xml.workspaceToDom(this.workspace);
7067
+ this._blocklyWorkspaceXML = Blockly.Xml.domToText(xml);
7068
+ this.workspaceXml = this._blocklyWorkspaceXML;
7069
+ this._keepOnlyAProgram(xml);
7070
+ this._checkParameterBounds(xml);
7071
+ },
7058
7072
  });
7059
7073
  </script>
7060
7074
  </dom-module>