Skip to content

Commit

Permalink
Merge pull request #2095 from google/rc/Oct_18
Browse files Browse the repository at this point in the history
October 2018 release
  • Loading branch information
rachel-fenichel authored Nov 1, 2018
2 parents 42172ba + 5654864 commit 09853c3
Show file tree
Hide file tree
Showing 254 changed files with 4,713 additions and 1,106 deletions.
460 changes: 236 additions & 224 deletions blockly_accessible_compressed.js

Large diffs are not rendered by default.

62 changes: 34 additions & 28 deletions blockly_accessible_uncompressed.js

Large diffs are not rendered by default.

459 changes: 236 additions & 223 deletions blockly_compressed.js

Large diffs are not rendered by default.

62 changes: 34 additions & 28 deletions blockly_uncompressed.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions blocks/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,29 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
"colour": "%{BKY_MATH_HUE}",
"tooltip": "%{BKY_MATH_RANDOM_FLOAT_TOOLTIP}",
"helpUrl": "%{BKY_MATH_RANDOM_FLOAT_HELPURL}"
},

// Block for calculating atan2 of [X] and [Y].
{
"type": "math_atan2",
"message0": "%{BKY_MATH_ATAN2_TITLE}",
"args0": [
{
"type": "input_value",
"name": "X",
"check": "Number"
},
{
"type": "input_value",
"name": "Y",
"check": "Number"
}
],
"inputsInline": true,
"output": "Number",
"colour": "%{BKY_MATH_HUE}",
"tooltip": "%{BKY_MATH_ATAN2_TOOLTIP}",
"helpUrl": "%{BKY_MATH_ATAN2_HELPURL}"
}
]); // END JSON EXTRACT (Do not delete this comment.)

Expand Down
2 changes: 1 addition & 1 deletion blocks/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
this.updateParams_();
// Update the mutator's variables if the mutator is open.
if (this.mutator.isVisible()) {
var blocks = this.mutator.workspace_.getAllBlocks();
var blocks = this.mutator.workspace_.getAllBlocks(false);
for (var i = 0, block; block = blocks[i]; i++) {
if (block.type == 'procedures_mutatorarg' &&
Blockly.Names.equals(oldName, block.getFieldValue('NAME'))) {
Expand Down
4 changes: 4 additions & 0 deletions blocks/variables_dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
}
var opposite_type;
var contextMenuMsg;
var id = this.getFieldValue('VAR');
var variableModel = this.workspace.getVariableById(id);
var varType = variableModel.type;
if (this.type == 'variables_get_dynamic') {
opposite_type = 'variables_set_dynamic';
contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET'];
Expand All @@ -115,6 +118,7 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
option.text = contextMenuMsg.replace('%1', name);
var xmlField = document.createElement('field');
xmlField.setAttribute('name', 'VAR');
xmlField.setAttribute('variabletype', varType);
xmlField.appendChild(document.createTextNode(name));
var xmlBlock = document.createElement('block');
xmlBlock.setAttribute('type', opposite_type);
Expand Down
84 changes: 43 additions & 41 deletions blocks_compressed.js

Large diffs are not rendered by default.

87 changes: 79 additions & 8 deletions core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ goog.require('Blockly.Mutator');
goog.require('Blockly.utils');
goog.require('Blockly.Warning');
goog.require('Blockly.Workspace');
goog.require('Blockly.Xml');

goog.require('goog.math.Coordinate');

Expand Down Expand Up @@ -146,6 +145,13 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
/** @type {boolean} */
this.RTL = workspace.RTL;

/**
* True if this block is an insertion marker.
* @type {boolean}
* @protected
*/
this.isInsertionMarker_ = false;

// Copy the type-specific functions and data from the prototype.
if (prototypeName) {
/** @type {string} */
Expand Down Expand Up @@ -362,7 +368,7 @@ Blockly.Block.prototype.unplugFromRow_ = function(opt_healStack) {
* @private
*/
Blockly.Block.prototype.getOnlyValueConnection_ = function() {
var connection = false;
var connection = null;
for (var i = 0; i < this.inputList.length; i++) {
var thisConnection = this.inputList[i].connection;
if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE) {
Expand Down Expand Up @@ -508,6 +514,29 @@ Blockly.Block.prototype.getNextBlock = function() {
return this.nextConnection && this.nextConnection.targetBlock();
};

/**
* Return the previous statement block directly connected to this block.
* @return {Blockly.Block} The previous statement block or null.
*/
Blockly.Block.prototype.getPreviousBlock = function() {
return this.previousConnection && this.previousConnection.targetBlock();
};

/**
* Return the connection on the first statement input on this block, or null if
* there are none.
* @return {Blockly.Connection} The first statement connection or null.
* @package
*/
Blockly.Block.prototype.getFirstStatementConnection = function() {
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection && input.connection.type == Blockly.NEXT_STATEMENT) {
return input.connection;
}
}
return null;
};

/**
* Return the top-most block in this block's tree.
* This will return itself if this block is at the top level.
Expand Down Expand Up @@ -655,6 +684,25 @@ Blockly.Block.prototype.setShadow = function(shadow) {
this.isShadow_ = shadow;
};

/**
* Get whether this block is an insertion marker block or not.
* @return {boolean} True if an insertion marker.
* @package
*/
Blockly.Block.prototype.isInsertionMarker = function() {
return this.isInsertionMarker_;
};

/**
* Set whether this block is an insertion marker block or not.
* Once set this cannot be unset.
* @param {boolean} insertionMarker True if an insertion marker.
* @package
*/
Blockly.Block.prototype.setInsertionMarker = function(insertionMarker) {
this.isInsertionMarker_ = insertionMarker;
};

/**
* Get whether this block is editable or not.
* @return {boolean} True if editable.
Expand Down Expand Up @@ -710,6 +758,29 @@ Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
}
};

/**
* Find the connection on this block that corresponds to the given connection
* on the other block.
* Used to match connections between a block and its insertion marker.
* @param {!Blockly.Block} otherBlock The other block to match against.
* @param {!Blockly.Connection} conn The other connection to match.
* @return {Blockly.Connection} the matching connection on this block, or null.
* @package
*/
Blockly.Block.prototype.getMatchingConnection = function(otherBlock, conn) {
var connections = this.getConnections_(true);
var otherConnections = otherBlock.getConnections_(true);
if (connections.length != otherConnections.length) {
throw Error("Connection lists did not match in length.");
}
for (var i = 0; i < otherConnections.length; i++) {
if (otherConnections[i] == conn) {
return connections[i];
}
}
return null;
};

/**
* Set the URL of this block's help page.
* @param {string|Function} url URL string for block help, or function that
Expand Down Expand Up @@ -782,7 +853,7 @@ Blockly.Block.prototype.setColour = function(colour) {
*/
Blockly.Block.prototype.setOnChange = function(onchangeFn) {
if (onchangeFn && typeof onchangeFn != 'function') {
throw new Error('onchange must be a function.');
throw Error('onchange must be a function.');
}
if (this.onchangeWrapper_) {
this.workspace.removeChangeListener(this.onchangeWrapper_);
Expand Down Expand Up @@ -1267,7 +1338,7 @@ Blockly.Block.prototype.jsonInitColour_ = function(json, warningPrefix) {
*/
Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
if (opt_disableCheck !== undefined && typeof opt_disableCheck != 'boolean') {
throw new Error('opt_disableCheck must be a boolean if provided');
throw Error('opt_disableCheck must be a boolean if provided');
}
if (!opt_disableCheck) {
var overwrites = [];
Expand All @@ -1277,7 +1348,7 @@ Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
}
}
if (overwrites.length) {
throw new Error('Mixin will overwrite block members: ' +
throw Error('Mixin will overwrite block members: ' +
JSON.stringify(overwrites));
}
}
Expand All @@ -1303,11 +1374,11 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
var token = tokens[i];
if (typeof token == 'number') {
if (token <= 0 || token > args.length) {
throw new Error('Block "' + this.type + '": ' +
throw Error('Block "' + this.type + '": ' +
'Message index %' + token + ' out of range.');
}
if (indexDup[token]) {
throw new Error('Block "' + this.type + '": ' +
throw Error('Block "' + this.type + '": ' +
'Message index %' + token + ' duplicated.');
}
indexDup[token] = true;
Expand All @@ -1321,7 +1392,7 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
}
}
if (indexCount != args.length) {
throw new Error('Block "' + this.type + '": ' +
throw Error('Block "' + this.type + '": ' +
'Message does not reference all ' + args.length + ' arg(s).');
}
// Add last dummy input if needed.
Expand Down
3 changes: 2 additions & 1 deletion core/block_drag_surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ Blockly.BlockDragSurfaceSvg.prototype.setBlocksAndShow = function(blocks) {
* @param {number} y Y translation in workspace coordinates.
* @param {number} scale Scale of the group.
*/
Blockly.BlockDragSurfaceSvg.prototype.translateAndScaleGroup = function(x, y, scale) {
Blockly.BlockDragSurfaceSvg.prototype.translateAndScaleGroup = function(x, y,
scale) {
this.scale_ = scale;
// This is a work-around to prevent a the blocks from rendering
// fuzzy while they are being dragged on the drag surface.
Expand Down
13 changes: 8 additions & 5 deletions core/block_dragger.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,20 @@ Blockly.BlockDragger.initIconData_ = function(block) {
* Start dragging a block. This includes moving it to the drag surface.
* @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has
* moved from the position at mouse down, in pixel units.
* @param {boolean} healStack whether or not to heal the stack after disconnecting
* @param {boolean} healStack Whether or not to heal the stack after
* disconnecting.
* @package
*/
Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY, healStack) {
Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY,
healStack) {
if (!Blockly.Events.getGroup()) {
Blockly.Events.setGroup(true);
}

// Mutators don't have the same type of z-ordering as the normal workspace during a drag.
// They have to rely on the order of the blocks in the svg. For performance reasons that
// usually happens at the end of a drag, but do it at the beginning for mutators.
// Mutators don't have the same type of z-ordering as the normal workspace
// during a drag. They have to rely on the order of the blocks in the SVG.
// For performance reasons that usually happens at the end of a drag,
// but do it at the beginning for mutators.
if (this.workspace_.isMutator) {
this.draggingBlock_.bringToFront();
}
Expand Down
6 changes: 3 additions & 3 deletions core/block_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ goog.provide('Blockly.Events.Move'); // Deprecated.

goog.require('Blockly.Events');
goog.require('Blockly.Events.Abstract');
goog.require('Blockly.Xml.utils');

goog.require('goog.dom');
goog.require('goog.math.Coordinate');


Expand Down Expand Up @@ -273,7 +273,7 @@ Blockly.Events.Create.prototype.fromJson = function(json) {
Blockly.Events.Create.prototype.run = function(forward) {
var workspace = this.getEventWorkspace_();
if (forward) {
var xml = goog.dom.createDom('xml');
var xml = Blockly.Xml.utils.createElement('xml');
xml.appendChild(this.xml);
Blockly.Xml.domToWorkspace(xml, workspace);
} else {
Expand Down Expand Up @@ -363,7 +363,7 @@ Blockly.Events.Delete.prototype.run = function(forward) {
}
}
} else {
var xml = goog.dom.createDom('xml');
var xml = Blockly.Xml.utils.createElement('xml');
xml.appendChild(this.oldXml);
Blockly.Xml.domToWorkspace(xml, workspace);
}
Expand Down
30 changes: 25 additions & 5 deletions core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
* @type {SVGElement}
* @private
*/
this.svgPath_ = Blockly.utils.createSvgElement('path', {'class': 'blocklyPath'},
this.svgGroup_);
this.svgPath_ = Blockly.utils.createSvgElement('path',
{'class': 'blocklyPath'}, this.svgGroup_);

/**
* @type {SVGElement}
Expand All @@ -93,7 +93,8 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
* @type {boolean}
* @private
*/
this.useDragSurface_ = Blockly.utils.is3dSupported() && !!workspace.blockDragSurface_;
this.useDragSurface_ =
Blockly.utils.is3dSupported() && !!workspace.blockDragSurface_;

Blockly.Tooltip.bindMouseEvents(this.svgPath_);
Blockly.BlockSvg.superClass_.constructor.call(this,
Expand Down Expand Up @@ -311,7 +312,8 @@ Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() {
// the translation of the drag surface itself.
if (this.useDragSurface_ &&
this.workspace.blockDragSurface_.getCurrentBlock() == element) {
var surfaceTranslation = this.workspace.blockDragSurface_.getSurfaceTranslation();
var surfaceTranslation =
this.workspace.blockDragSurface_.getSurfaceTranslation();
x += surfaceTranslation.x;
y += surfaceTranslation.y;
}
Expand Down Expand Up @@ -566,7 +568,7 @@ Blockly.BlockSvg.prototype.createTabList_ = function() {
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field instanceof Blockly.FieldTextInput) {
// TODO(# 1276): Also support dropdown fields.
// TODO (#1276): Also support dropdown fields.
list.push(field);
}
}
Expand Down Expand Up @@ -794,6 +796,24 @@ Blockly.BlockSvg.prototype.setShadow = function(shadow) {
this.updateColour();
};

/**
* Set whether this block is an insertion marker block or not.
* Once set this cannot be unset.
* @param {boolean} insertionMarker True if an insertion marker.
* @package
*/
Blockly.BlockSvg.prototype.setInsertionMarker = function(insertionMarker) {
if (this.isInsertionMarker_ == insertionMarker) {
return; // No change.
}
this.isInsertionMarker_ = insertionMarker;
if (this.isInsertionMarker_) {
this.setColour(Blockly.INSERTION_MARKER_COLOUR);
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyInsertionMarker');
}
};

/**
* Return the root node of the SVG or null if none exists.
* @return {Element} The root SVG node (probably a group).
Expand Down
Loading

0 comments on commit 09853c3

Please sign in to comment.