gobstones-blockly 0.18.0 → 0.18.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feb2595a317dc38ed739f495938f3cc7fe2d635cec35dbcf81e2cebdd8def04d
4
- data.tar.gz: 1ac9279dbfaeed5723d6d769b79c006078b9b676ed0a82aebd722ef2bc6fd614
3
+ metadata.gz: f16c1d9e0f8d7d1c45571bf145bee056a35f937074d518da0ec2e7acbb4d3763
4
+ data.tar.gz: ae42b6ed27a22e0b2c4f4aa38eb1e3da75dc5fd46b483e6031e64761c76416c7
5
5
  SHA512:
6
- metadata.gz: 62da51f613fc533c1c968558099f7e987972ab9c98a5c1543b1b0a719a48c1be990d6b7303d1799565e164d098a4971531c77eb064f30d02c092957f07e2f8fd
7
- data.tar.gz: 34dbc8bf8b7ab184170a2a3de93685d27fc49a3e2d42d01866999292e11f19b7bea009728af7a658210e89ae53e07cbe5fa902e5c3a1bf7486206b548111f823
6
+ metadata.gz: 8b813b850a0e7d8d98f08f1b8f4af3b721977f66193992d47ebf5b91c87eb46af34995646ae7470328527df0e02bbf604d1371b8434f38d0d28ca1dcc7f9b387
7
+ data.tar.gz: 12e3a730263d9360d216fe9c8fbbc932feb42ede7892f5d9ebae0378238a7e78a9c1eff9446c85781d7c5c9293998e5f0f73787ec12aaf2f7c16f74c00c3e241
@@ -62,7 +62,7 @@ Example:
62
62
  <block type="math_number"></block>
63
63
  <block type="ColorSelector"></block>
64
64
  <block type="DireccionSelector"></block>
65
- <block type="BoolSelector"></block>
65
+ <block type="BoolSelector"></block>
66
66
  </category>
67
67
  <category name="Expresiones primitivas">
68
68
  <block type="hayBolitas"></block>
@@ -78,9 +78,9 @@ Example:
78
78
  <block type="OperadorDeComparacion"></block>
79
79
  <block type="OperadorLogico"></block>
80
80
  <block type="not"></block>
81
- <block type="siguiente"></block>
82
- <block type="previo"></block>
83
- <block type="opuesto"></block>
81
+ <block type="siguiente"></block>
82
+ <block type="previo"></block>
83
+ <block type="opuesto"></block>
84
84
  </category>
85
85
  </category>
86
86
  <category name="Definiciones">
@@ -5072,15 +5072,18 @@ Blockly.GobstonesLanguage.addPragma = function(block, str){
5072
5072
  Blockly.utils.genUid.soup_ = Blockly.utils.genUid.soup_.replace(/@/g,"a");
5073
5073
 
5074
5074
  function getCustomTeacherDropdownValue(block) {
5075
+ // TODO: Hackeada de compromiso
5076
+
5075
5077
  try {
5076
- const inputs = block.inputList;
5077
- const lastInput = inputs[inputs.length - 1];
5078
- const fields = lastInput.fieldRow;
5079
- const lastField = fields[fields.length - 1];
5080
-
5081
- if (lastField.name === 'custom_teacher_dropdown')
5082
- return lastField.getValue();
5083
- } catch(e) { // TODO: Sacar esto
5078
+ const getCustomTeacherDropdown = (field) => field.name === 'custom_teacher_dropdown';
5079
+
5080
+ const input = block.inputList.find((input) =>
5081
+ input.fieldRow.some(getCustomTeacherDropdown)
5082
+ );
5083
+ const field = input.fieldRow.find(getCustomTeacherDropdown);
5084
+
5085
+ return field.getValue();
5086
+ } catch(e) {
5084
5087
  return null;
5085
5088
  }
5086
5089
  }
@@ -6141,9 +6144,9 @@ Blockly.ErrorInforming.CssContent = [
6141
6144
  const attributes = definition.attributes;
6142
6145
 
6143
6146
  const dropdown = definition.attributes && definition.attributes.block_dropdown;
6144
- const dropdownOptions = dropdown && dropdown.match(/\("\w+" *, *'[^']*'\)/g);
6147
+ const dropdownOptions = dropdown && dropdown.match(/\("[^"]+" *, *'[^']*'\)/g);
6145
6148
  return dropdownOptions && dropdownOptions.map((option) => {
6146
- const parts = option.match(/^\("(\w+)" *, *'([^']*)'\)$/);
6149
+ const parts = option.match(/^\("([^"]+)" *, *'([^']*)'\)$/);
6147
6150
  return [parts[1], parts[2]];
6148
6151
  });
6149
6152
  },
@@ -6161,11 +6164,12 @@ Blockly.ErrorInforming.CssContent = [
6161
6164
  const parts = (customName ? this._getParts : this._getPartsByConvention.bind(this, true))
6162
6165
  .bind(this)(finalName);
6163
6166
 
6167
+ const self = this;
6168
+
6164
6169
  // Bloque
6165
6170
  Blockly.Blocks[name] = {
6166
- init: function () {
6167
- let argsIndex = 1;
6168
- this.setColour(Blockly.CUSTOM_COLORS.primitiveProcedure);
6171
+ init: function () {
6172
+ this.setColour(Blockly.CUSTOM_COLORS.primitiveProcedure);
6169
6173
 
6170
6174
  if (icon) {
6171
6175
  this.appendDummyInput().appendField(new Blockly.FieldImage(
@@ -6176,37 +6180,19 @@ Blockly.ErrorInforming.CssContent = [
6176
6180
  ));
6177
6181
  }
6178
6182
 
6179
- for (var i in parts) {
6180
- if (i == (parts.length - 1)) {
6181
- this.appendDummyInput().appendField(parts[i]);
6182
-
6183
- if (dropdownOptions) {
6184
- this.removeInput('arg1');
6185
- this.jsonInit({
6186
- message0: parts[i - 1] + " %1",
6187
- args0: [
6188
- {
6189
- type: 'field_dropdown',
6190
- name: "custom_teacher_dropdown",
6191
- options: dropdownOptions
6192
- }
6193
- ]
6194
- });
6195
- }
6196
- } else {
6197
- this.appendValueInput('arg' + argsIndex).appendField(parts[i]);
6198
- argsIndex++;
6199
- }
6200
- }
6201
- this.setPreviousStatement(true);
6202
- this.setNextStatement(true);
6203
- this.setInputsInline(true);
6204
- }
6183
+ self._definePrimitiveHolesOrDropdown(this, parts, dropdownOptions);
6184
+
6185
+ this.setPreviousStatement(true);
6186
+ this.setNextStatement(true);
6187
+ this.setInputsInline(true);
6188
+ }
6205
6189
  };
6190
+
6206
6191
  let argsList = [];
6207
6192
  for(var i=1;i<parts.length;i++) {
6208
6193
  argsList.push('arg' + i);
6209
6194
  }
6195
+
6210
6196
  // Generator
6211
6197
  Blockly.GobstonesLanguage[name] = procBlockCodeGenerator(name, argsList);
6212
6198
  },
@@ -6235,10 +6221,11 @@ Blockly.ErrorInforming.CssContent = [
6235
6221
  const parts = (customName ? this._getParts : this._getPartsByConvention.bind(this, false))
6236
6222
  .bind(this)(finalName);
6237
6223
 
6224
+ const self = this;
6225
+
6238
6226
  // Bloque
6239
6227
  Blockly.Blocks[name] = {
6240
6228
  init: function () {
6241
- let argsIndex = 1;
6242
6229
  this.setColour(Blockly.CUSTOM_COLORS.primitiveFunction);
6243
6230
 
6244
6231
  if (icon) {
@@ -6250,38 +6237,20 @@ Blockly.ErrorInforming.CssContent = [
6250
6237
  ));
6251
6238
  }
6252
6239
 
6253
- for (var i in parts) {
6254
- if (i == (parts.length - 1)) {
6255
- this.appendDummyInput().appendField(parts[i]);
6256
-
6257
- if (dropdownOptions) {
6258
- this.removeInput('arg1');
6259
- this.jsonInit({
6260
- message0: parts[i - 1] + " %1",
6261
- args0: [
6262
- {
6263
- type: 'field_dropdown',
6264
- name: "custom_teacher_dropdown",
6265
- options: dropdownOptions
6266
- }
6267
- ]
6268
- });
6269
- }
6270
- } else {
6271
- this.appendValueInput('arg' + argsIndex).appendField(parts[i]);
6272
- argsIndex++;
6273
- }
6274
- }
6240
+ self._definePrimitiveHolesOrDropdown(this, parts, dropdownOptions);
6241
+
6275
6242
  this.setPreviousStatement(false);
6276
6243
  this.setNextStatement(false);
6277
6244
  this.setInputsInline(true);
6278
6245
  this.setOutput('var');
6279
6246
  }
6280
6247
  };
6248
+
6281
6249
  let argsList = [];
6282
6250
  for(var i=1;i<parts.length;i++) {
6283
6251
  argsList.push('arg' + i);
6284
6252
  }
6253
+
6285
6254
  // Generator
6286
6255
  Blockly.GobstonesLanguage[name] = functionBlockCodeGenerator(name, argsList);
6287
6256
  },
@@ -6296,6 +6265,36 @@ Blockly.ErrorInforming.CssContent = [
6296
6265
  }
6297
6266
  },
6298
6267
 
6268
+ _definePrimitiveHolesOrDropdown: function (block, parts, dropdownOptions) {
6269
+ if (dropdownOptions) {
6270
+ if (parts.length !== 2) throw new Error("Only one parameter is supported when using block_dropdown");
6271
+
6272
+ // En Space (U+2002)
6273
+ dropdownOptions.forEach((opt) => opt[0] = opt[0].replace(/ /g, " "));
6274
+
6275
+ block.jsonInit({
6276
+ message0: parts.join('%1'),
6277
+ args0: [
6278
+ {
6279
+ type: 'field_dropdown',
6280
+ name: "custom_teacher_dropdown",
6281
+ options: dropdownOptions
6282
+ }
6283
+ ]
6284
+ });
6285
+ } else {
6286
+ let argsIndex = 1;
6287
+ for (var i in parts) {
6288
+ if (i == parts.length - 1) {
6289
+ block.appendDummyInput().appendField(parts[i]);
6290
+ } else {
6291
+ block.appendValueInput('arg' + argsIndex).appendField(parts[i]);
6292
+ argsIndex++;
6293
+ }
6294
+ }
6295
+ }
6296
+ },
6297
+
6299
6298
  _onBlocklyWorkspaceUpdate: function () {
6300
6299
  let xml = Blockly.Xml.workspaceToDom(this.workspace);
6301
6300
  this._blocklyWorkspaceXML = Blockly.Xml.domToText(xml);
@@ -6524,12 +6523,12 @@ Blockly.ErrorInforming.CssContent = [
6524
6523
  attached: function() {
6525
6524
  this._definePrimitiveProcedures();
6526
6525
  this._definePrimitiveFunctions();
6527
- // create workspace
6526
+ // create workspace
6528
6527
  var blocklyDiv = this.$$('#blocklyDiv');
6529
6528
  this.blocklyDiv = blocklyDiv;
6530
6529
  this._fixSize();
6531
6530
  this._fixScroll();
6532
- this.workspace = Blockly.inject(blocklyDiv, {
6531
+ this.workspace = Blockly.inject(blocklyDiv, {
6533
6532
  toolbox: this._createToolbox(),
6534
6533
  media: this.get("media"),
6535
6534
  toolboxPosition: "start",
@@ -6542,7 +6541,7 @@ Blockly.ErrorInforming.CssContent = [
6542
6541
  controls: true,
6543
6542
  wheel: true
6544
6543
  }
6545
- });
6544
+ });
6546
6545
  var _this = this;
6547
6546
  this.workspace.addChangeListener(function (a, b, c) {
6548
6547
  Blockly.Events.disableOrphans(a, b, c);
@@ -1,5 +1,5 @@
1
1
  module Gobstones
2
2
  module Blockly
3
- VERSION = "0.18.0"
3
+ VERSION = "0.18.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobstones-blockly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler