diff --git a/core/block.js b/core/block.js index 194c48b86..827887e1d 100644 --- a/core/block.js +++ b/core/block.js @@ -1454,7 +1454,7 @@ Blockly.Block.prototype.jsonInit = function(json) { var i = 0; while (json['message' + i] !== undefined) { this.interpolate_(json['message' + i], json['args' + i] || [], - json['lastDummyAlign' + i]); + json['lastDummyAlign' + i], warningPrefix); i++; } @@ -1578,9 +1578,11 @@ Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) { * @param {!Array} args Array of arguments to be interpolated. * @param {string|undefined} lastDummyAlign If a dummy input is added at the * end, how should it be aligned? + * @param {string} warningPrefix Warning prefix string identifying block. * @private */ -Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) { +Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign, + warningPrefix) { var tokens = Blockly.utils.tokenizeInterpolation(message); // Interpolate the arguments. Build a list of elements. var indexDup = []; @@ -1625,7 +1627,8 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) { var alignmentLookup = { 'LEFT': Blockly.ALIGN_LEFT, 'RIGHT': Blockly.ALIGN_RIGHT, - 'CENTRE': Blockly.ALIGN_CENTRE + 'CENTRE': Blockly.ALIGN_CENTRE, + 'CENTER': Blockly.ALIGN_CENTRE }; // Populate block with inputs and fields. var fieldStack = []; @@ -1673,7 +1676,14 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) { input.setCheck(element['check']); } if (element['align']) { - input.setAlign(alignmentLookup[element['align']]); + var align = !!element['align'] && element['align'].toUpperCase(); + var alignment = alignmentLookup[align]; + if (alignment != undefined) { + input.setAlign(alignment); + } else { + console.warn(warningPrefix + 'Illegal align value: ', + element['align']); + } } for (var j = 0; j < fieldStack.length; j++) { input.appendField(fieldStack[j][0], fieldStack[j][1]); diff --git a/core/renderers/common/info.js b/core/renderers/common/info.js index eed3591f1..664a20c98 100644 --- a/core/renderers/common/info.js +++ b/core/renderers/common/info.js @@ -380,7 +380,9 @@ Blockly.blockRendering.RenderInfo.prototype.addInput_ = function(input, activeRo this.constants_.DUMMY_INPUT_MIN_HEIGHT); activeRow.hasDummyInput = true; } - activeRow.align = input.align; + if (activeRow.align == null) { + activeRow.align = input.align; + } }; /** diff --git a/core/renderers/geras/info.js b/core/renderers/geras/info.js index 3df571bf2..cb929766a 100644 --- a/core/renderers/geras/info.js +++ b/core/renderers/geras/info.js @@ -119,7 +119,9 @@ Blockly.geras.RenderInfo.prototype.addInput_ = function(input, activeRow) { this.constants_.DUMMY_INPUT_MIN_HEIGHT); activeRow.hasDummyInput = true; } - activeRow.align = input.align; + if (activeRow.align == null) { + activeRow.align = input.align; + } }; /** diff --git a/core/renderers/measurables/rows.js b/core/renderers/measurables/rows.js index c2c977a14..1cf09ddcf 100644 --- a/core/renderers/measurables/rows.js +++ b/core/renderers/measurables/rows.js @@ -154,6 +154,13 @@ Blockly.blockRendering.Row = function(constants) { this.constants_ = constants; this.notchOffset = this.constants_.NOTCH_OFFSET_LEFT; + + /** + * Alignment of the row. + * @package + * @type {?number} + */ + this.align = null; }; /**