chore: Run clang-format on core/*.js (#5589)

* Run clang-format on core/*.js

* Revert changes for css formatting
This commit is contained in:
Rachel Fenichel
2021-10-07 10:32:02 -07:00
committed by GitHub
parent 2b1f33cc7b
commit b25e24fd02
29 changed files with 177 additions and 181 deletions

View File

@@ -1220,8 +1220,7 @@ Block.prototype.setNextStatement = function(newBoolean, opt_check) {
opt_check = null;
}
if (!this.nextConnection) {
this.nextConnection =
this.makeConnection_(ConnectionType.NEXT_STATEMENT);
this.nextConnection = this.makeConnection_(ConnectionType.NEXT_STATEMENT);
}
this.nextConnection.setCheck(opt_check);
} else {
@@ -1255,8 +1254,7 @@ Block.prototype.setOutput = function(newBoolean, opt_check) {
'Remove previous connection prior to adding output ' +
'connection.');
}
this.outputConnection =
this.makeConnection_(ConnectionType.OUTPUT_VALUE);
this.outputConnection = this.makeConnection_(ConnectionType.OUTPUT_VALUE);
}
this.outputConnection.setCheck(opt_check);
} else {

View File

@@ -400,7 +400,8 @@ BlockDragger.prototype.updateToolboxStyle_ = function(isEnd) {
* @protected
*/
BlockDragger.prototype.fireMoveEvent_ = function() {
const event = new (eventUtils.get(eventUtils.BLOCK_MOVE))(this.draggingBlock_);
const event =
new (eventUtils.get(eventUtils.BLOCK_MOVE))(this.draggingBlock_);
event.oldCoordinate = this.startXY_;
event.recordNew();
eventUtils.fire(event);

View File

@@ -301,8 +301,8 @@ BlockSvg.prototype.select = function() {
eventUtils.enable();
}
}
const event =
new (eventUtils.get(eventUtils.SELECTED))(oldId, this.id, this.workspace.id);
const event = new (eventUtils.get(eventUtils.SELECTED))(
oldId, this.id, this.workspace.id);
eventUtils.fire(event);
common.setSelected(this);
this.addSelect();
@@ -316,8 +316,8 @@ BlockSvg.prototype.unselect = function() {
if (common.getSelected() != this) {
return;
}
const event =
new (eventUtils.get(eventUtils.SELECTED))(this.id, null, this.workspace.id);
const event = new (eventUtils.get(eventUtils.SELECTED))(
this.id, null, this.workspace.id);
event.workspaceId = this.workspace.id;
eventUtils.fire(event);
common.setSelected(null);
@@ -619,8 +619,8 @@ BlockSvg.prototype.getBoundingRectangle = function() {
*/
BlockSvg.prototype.markDirty = function() {
this.pathObject.constants = (/** @type {!WorkspaceSvg} */ (this.workspace))
.getRenderer()
.getConstants();
.getRenderer()
.getConstants();
for (let i = 0, input; (input = this.inputList[i]); i++) {
input.markDirty();
}
@@ -971,8 +971,8 @@ BlockSvg.prototype.toCopyData = function() {
return null;
}
return {
saveInfo: /** @type {!blocks.State} */(blocks.save(
this, {addCoordinates: true, addNextBlocks: false})),
saveInfo: /** @type {!blocks.State} */ (
blocks.save(this, {addCoordinates: true, addNextBlocks: false})),
source: this.workspace,
typeCounts: utils.getBlockTypeCounts(this, true)
};

View File

@@ -459,7 +459,7 @@ exports.setParentContainer = common.setParentContainer;
* @deprecated Use Blockly.utils.colour.hueToHex (September 2021).
* @alias Blockly.hueToHex
*/
exports.hueToHex = colour.hueToHex;
exports.hueToHex = colour.hueToHex;
/**
* @see browserEvents.bind
@@ -500,7 +500,7 @@ exports.ALIGN_RIGHT = constants.ALIGN.RIGHT;
/**
* @see common.svgResize
*/
exports.svgResize = common.svgResize;
exports.svgResize = common.svgResize;
/**
* Aliases for constants used for connection and input types.

View File

@@ -250,8 +250,8 @@ Comment.prototype.setVisible = function(visible) {
if (visible == this.isVisible()) {
return;
}
eventUtils.fire(
new (eventUtils.get(eventUtils.BUBBLE_OPEN))(this.block_, visible, 'comment'));
eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))(
this.block_, visible, 'comment'));
this.model_.pinned = visible;
if (visible) {
this.createBubble_();

View File

@@ -701,11 +701,10 @@ Connection.prototype.stashShadowState_ = function() {
* to reapply to the shadowDom_ and shadowState_ properties.
* @private
*/
Connection.prototype.applyShadowState_ =
function({shadowDom, shadowState}) {
this.shadowDom_ = shadowDom;
this.shadowState_ = shadowState;
};
Connection.prototype.applyShadowState_ = function({shadowDom, shadowState}) {
this.shadowDom_ = shadowDom;
this.shadowState_ = shadowState;
};
/**
* Sets the state of the shadow of this connection.
@@ -714,33 +713,33 @@ Connection.prototype.applyShadowState_ =
* connection to.
* @private
*/
Connection.prototype.setShadowStateInternal_ =
function({shadowDom = null, shadowState = null} = {}) {
// One or both of these should always be null.
// If neither is null, the shadowState will get priority.
this.shadowDom_ = shadowDom;
this.shadowState_ = shadowState;
Connection.prototype.setShadowStateInternal_ = function(
{shadowDom = null, shadowState = null} = {}) {
// One or both of these should always be null.
// If neither is null, the shadowState will get priority.
this.shadowDom_ = shadowDom;
this.shadowState_ = shadowState;
const target = this.targetBlock();
if (!target) {
this.respawnShadow_();
if (this.targetBlock() && this.targetBlock().isShadow()) {
this.serializeShadow_(this.targetBlock());
}
} else if (target.isShadow()) {
target.dispose(false);
this.respawnShadow_();
if (this.targetBlock() && this.targetBlock().isShadow()) {
this.serializeShadow_(this.targetBlock());
}
} else {
const shadow = this.createShadowBlock_(false);
this.serializeShadow_(shadow);
if (shadow) {
shadow.dispose(false);
}
}
};
const target = this.targetBlock();
if (!target) {
this.respawnShadow_();
if (this.targetBlock() && this.targetBlock().isShadow()) {
this.serializeShadow_(this.targetBlock());
}
} else if (target.isShadow()) {
target.dispose(false);
this.respawnShadow_();
if (this.targetBlock() && this.targetBlock().isShadow()) {
this.serializeShadow_(this.targetBlock());
}
} else {
const shadow = this.createShadowBlock_(false);
this.serializeShadow_(shadow);
if (shadow) {
shadow.dispose(false);
}
}
};
/**
* Creates a shadow block based on the current shadowState_ or shadowDom_.
@@ -761,14 +760,11 @@ Connection.prototype.createShadowBlock_ = function(attemptToConnect) {
let blockShadow;
if (shadowState) {
blockShadow = blocks.appendInternal(
shadowState,
parentBlock.workspace,
{
parentConnection: attemptToConnect ? this : undefined,
isShadow: true,
recordUndo: false,
});
blockShadow = blocks.appendInternal(shadowState, parentBlock.workspace, {
parentConnection: attemptToConnect ? this : undefined,
isShadow: true,
recordUndo: false,
});
return blockShadow;
}

View File

@@ -81,14 +81,14 @@ Object.defineProperties(exports, {
currentBlock: {
get: function() {
deprecation.warn(
'Blockly.ContextMenu.currentBlock', 'September 2021', 'September 2022',
'Blockly.Tooltip.getCurrentBlock()');
'Blockly.ContextMenu.currentBlock', 'September 2021',
'September 2022', 'Blockly.Tooltip.getCurrentBlock()');
return getCurrentBlock();
},
set: function(block) {
deprecation.warn(
'Blockly.ContextMenu.currentBlock', 'September 2021', 'September 2022',
'Blockly.Tooltip.setCurrentBlock(block)');
'Blockly.ContextMenu.currentBlock', 'September 2021',
'September 2022', 'Blockly.Tooltip.setCurrentBlock(block)');
setCurrentBlock(block);
},
},
@@ -210,9 +210,7 @@ const createWidget_ = function(menu) {
/** @type {!Element} */ (menuDom), 'blocklyContextMenu');
// Prevent system context menu when right-clicking a Blockly context menu.
browserEvents.conditionalBind(
/** @type {!EventTarget} */ (menuDom),
'contextmenu',
null,
/** @type {!EventTarget} */ (menuDom), 'contextmenu', null,
haltPropagation);
// Focus only after the initial render to avoid issue #1329.
menu.focus();
@@ -349,8 +347,7 @@ const workspaceCommentOption = function(ws, e) {
const addWsComment = function() {
const comment = new WorkspaceCommentSvg(
ws, Msg['WORKSPACE_COMMENT_DEFAULT_TEXT'],
WorkspaceCommentSvg.DEFAULT_SIZE,
WorkspaceCommentSvg.DEFAULT_SIZE);
WorkspaceCommentSvg.DEFAULT_SIZE, WorkspaceCommentSvg.DEFAULT_SIZE);
const injectionDiv = ws.getInjectionDiv();
// Bounding rect coordinates are in client coordinates, meaning that they

View File

@@ -261,24 +261,24 @@ const checkMutatorDialog = function(object, errorPrefix) {
* @throws {Error} If the object has only one of the functions, or either is
* not actually a function.
*/
const checkHasFunctionPair =
function(object, name1, name2, errorPrefix) {
var has1 = object[name1] !== undefined;
var has2 = object[name2] !== undefined;
const checkHasFunctionPair = function(object, name1, name2, errorPrefix) {
var has1 = object[name1] !== undefined;
var has2 = object[name2] !== undefined;
if (has1 && has2) {
if (typeof object[name1] != 'function') {
throw Error(errorPrefix + name1 + ' must be a function.');
} else if (typeof object[name2] != 'function') {
throw Error(errorPrefix + name2 + ' must be a function.');
}
return true;
} else if (!has1 && !has2) {
return false;
if (has1 && has2) {
if (typeof object[name1] != 'function') {
throw Error(errorPrefix + name1 + ' must be a function.');
} else if (typeof object[name2] != 'function') {
throw Error(errorPrefix + name2 + ' must be a function.');
}
throw Error(errorPrefix +
'Must have both or neither of "' + name1 + '" and "' + name2 + '"');
};
return true;
} else if (!has1 && !has2) {
return false;
}
throw Error(
errorPrefix + 'Must have both or neither of "' + name1 + '" and "' +
name2 + '"');
};
/**
* Checks that the given object required mutator properties.
@@ -289,7 +289,8 @@ const checkHasMutatorProperties = function(errorPrefix, object) {
var hasXmlHooks = checkXmlHooks(object, errorPrefix);
var hasJsonHooks = checkJsonHooks(object, errorPrefix);
if (!hasXmlHooks && !hasJsonHooks) {
throw Error(errorPrefix +
throw Error(
errorPrefix +
'Mutations must contain either XML hooks, or JSON hooks, or both');
}
// A block with a mutator isn't required to have a mutation dialog, but

View File

@@ -443,9 +443,10 @@ Field.prototype.toXml = function(fieldElement) {
/**
* Saves this fields value as something which can be serialized to JSON. Should
* only be called by the serialization system.
* @param {boolean=} _doFullSerialization If true, this signals to the field that
* if it normally just saves a reference to some state (eg variable fields)
* it should instead serialize the full state of the thing being referenced.
* @param {boolean=} _doFullSerialization If true, this signals to the field
* that if it normally just saves a reference to some state (eg variable
* fields) it should instead serialize the full state of the thing being
* referenced.
* @return {*} JSON serializable state.
* @package
*/
@@ -482,8 +483,8 @@ Field.prototype.loadState = function(state) {
Field.prototype.saveLegacyState = function(callingClass) {
if (callingClass.prototype.saveState === this.saveState &&
callingClass.prototype.toXml !== this.toXml) {
const elem = utilsXml.createElement("field");
elem.setAttribute("name", this.name || '');
const elem = utilsXml.createElement('field');
elem.setAttribute('name', this.name || '');
const text = Xml.domToText(this.toXml(elem));
return text.replace(
' xmlns="https://developers.google.com/blockly/xml"', '');

View File

@@ -38,14 +38,14 @@ const userAgent = goog.require('Blockly.utils.userAgent');
* changes to the field's value. Takes in a number & returns a
* validated number, or null to abort the change.
* @param {Object=} opt_config A map of options used to configure the field.
* See the [field creation documentation]{@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/angle#creation}
* See the [field creation documentation]{@link
* https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/angle#creation}
* for a list of properties this parameter supports.
* @extends {FieldTextInput}
* @constructor
* @alias Blockly.FieldAngle
*/
const FieldAngle = function(opt_value, opt_validator, opt_config) {
/**
* Should the angle increase as the angle picker is moved clockwise (true)
* or counterclockwise (false)
@@ -282,7 +282,8 @@ FieldAngle.prototype.showEditor_ = function(opt_e) {
this.dropdownCreate_();
DropDownDiv.getContentDiv().appendChild(this.editor_);
DropDownDiv.setColour(this.sourceBlock_.style.colourPrimary,
DropDownDiv.setColour(
this.sourceBlock_.style.colourPrimary,
this.sourceBlock_.style.colourTertiary);
DropDownDiv.showPositionedByField(this, this.dropdownDispose_.bind(this));
@@ -304,37 +305,39 @@ FieldAngle.prototype.dropdownCreate_ = function() {
'height': (FieldAngle.HALF * 2) + 'px',
'width': (FieldAngle.HALF * 2) + 'px',
'style': 'touch-action: none'
}, null);
},
null);
const circle = dom.createSvgElement(
Svg.CIRCLE, {
'cx': FieldAngle.HALF,
'cy': FieldAngle.HALF,
'r': FieldAngle.RADIUS,
'class': 'blocklyAngleCircle'
}, svg);
this.gauge_ = dom.createSvgElement(
Svg.PATH, {
'class': 'blocklyAngleGauge'
}, svg);
},
svg);
this.gauge_ =
dom.createSvgElement(Svg.PATH, {'class': 'blocklyAngleGauge'}, svg);
this.line_ = dom.createSvgElement(
Svg.LINE, {
'x1': FieldAngle.HALF,
'y1': FieldAngle.HALF,
'class': 'blocklyAngleLine'
}, svg);
},
svg);
// Draw markers around the edge.
for (let angle = 0; angle < 360; angle += 15) {
dom.createSvgElement(
Svg.LINE, {
'x1': FieldAngle.HALF + FieldAngle.RADIUS,
'y1': FieldAngle.HALF,
'x2': FieldAngle.HALF + FieldAngle.RADIUS -
(angle % 45 == 0 ? 10 : 5),
'x2':
FieldAngle.HALF + FieldAngle.RADIUS - (angle % 45 == 0 ? 10 : 5),
'y2': FieldAngle.HALF,
'class': 'blocklyAngleMarks',
'transform': 'rotate(' + angle + ',' +
FieldAngle.HALF + ',' + FieldAngle.HALF + ')'
}, svg);
'transform': 'rotate(' + angle + ',' + FieldAngle.HALF + ',' +
FieldAngle.HALF + ')'
},
svg);
}
// The angle picker is different from other fields in that it updates on
@@ -462,8 +465,8 @@ FieldAngle.prototype.updateGraph_ = function() {
if (clockwiseFlag) {
largeFlag = 1 - largeFlag;
}
path.push(' l ', x1, ',', y1,
' A ', FieldAngle.RADIUS, ',', FieldAngle.RADIUS,
path.push(
' l ', x1, ',', y1, ' A ', FieldAngle.RADIUS, ',', FieldAngle.RADIUS,
' 0 ', largeFlag, ' ', clockwiseFlag, ' ', x2, ',', y2, ' z');
}
this.gauge_.setAttribute('d', path.join(''));
@@ -496,8 +499,7 @@ FieldAngle.prototype.onHtmlInputKeyDown_ = function(e) {
}
if (multiplier) {
const value = /** @type {number} */ (this.getValue());
this.displayMouseOrKeyboardValue_(
value + (multiplier * this.round_));
this.displayMouseOrKeyboardValue_(value + (multiplier * this.round_));
e.preventDefault();
e.stopPropagation();
}

View File

@@ -217,9 +217,7 @@ FieldVariable.prototype.saveState = function(doFullSerialization) {
}
// Make sure the variable is initialized.
this.initModel();
const state = {
'id': this.variable_.getId()
};
const state = {'id': this.variable_.getId()};
if (doFullSerialization) {
state['name'] = this.variable_.name;
state['type'] = this.variable_.type;
@@ -239,9 +237,7 @@ FieldVariable.prototype.loadState = function(state) {
}
// This is necessary so that blocks in the flyout can have custom var names.
const variable = Variables.getOrCreateVariablePackage(
this.sourceBlock_.workspace,
state['id'] || null,
state['name'],
this.sourceBlock_.workspace, state['id'] || null, state['name'],
state['type'] || '');
this.setValue(variable.getId());
};

View File

@@ -699,7 +699,7 @@ Flyout.prototype.createFlyoutBlock_ = function(blockInfo) {
blockInfo['disabled'] !== 'true' && blockInfo['disabled'] !== true;
}
block = blocks.append(
/** @type {blocks.State} */ (blockInfo),this.workspace_);
/** @type {blocks.State} */ (blockInfo), this.workspace_);
}
}
@@ -934,7 +934,8 @@ Flyout.prototype.createBlock = function(originalBlock) {
// Fire a VarCreate event for each (if any) new variable created.
for (let i = 0; i < newVariables.length; i++) {
const thisVariable = newVariables[i];
eventUtils.fire(new (eventUtils.get(eventUtils.VAR_CREATE))(thisVariable));
eventUtils.fire(
new (eventUtils.get(eventUtils.VAR_CREATE))(thisVariable));
}
// Block events come after var events, in case they refer to newly created

View File

@@ -669,7 +669,8 @@ Gesture.prototype.handleWsStart = function(e, ws) {
* @private
*/
Gesture.prototype.fireWorkspaceClick_ = function(ws) {
eventUtils.fire(new (eventUtils.get(eventUtils.CLICK))(null, ws.id, 'workspace'));
eventUtils.fire(
new (eventUtils.get(eventUtils.CLICK))(null, ws.id, 'workspace'));
};
/**

View File

@@ -140,16 +140,16 @@ Menu.prototype.render = function(container) {
}
// Add event handlers.
this.mouseOverHandler_ =
browserEvents.conditionalBind(element, 'mouseover', this, this.handleMouseOver_, true);
this.clickHandler_ =
browserEvents.conditionalBind(element, 'click', this, this.handleClick_, true);
this.mouseOverHandler_ = browserEvents.conditionalBind(
element, 'mouseover', this, this.handleMouseOver_, true);
this.clickHandler_ = browserEvents.conditionalBind(
element, 'click', this, this.handleClick_, true);
this.mouseEnterHandler_ = browserEvents.conditionalBind(
element, 'mouseenter', this, this.handleMouseEnter_, true);
this.mouseLeaveHandler_ = browserEvents.conditionalBind(
element, 'mouseleave', this, this.handleMouseLeave_, true);
this.onKeyDownHandler_ =
browserEvents.conditionalBind(element, 'keydown', this, this.handleKeyEvent_);
this.onKeyDownHandler_ = browserEvents.conditionalBind(
element, 'keydown', this, this.handleKeyEvent_);
container.appendChild(element);
};
@@ -469,7 +469,7 @@ Menu.prototype.handleKeyEvent_ = function(e) {
Menu.prototype.getSize = function() {
const menuDom = this.getElement();
const menuSize = style.getSize(/** @type {!Element} */
(menuDom));
(menuDom));
// Recalculate height for the total content, not only box height.
menuSize.height = menuDom.scrollHeight;
return menuSize;

View File

@@ -299,8 +299,8 @@ Mutator.prototype.setVisible = function(visible) {
// No change.
return;
}
eventUtils.fire(
new (eventUtils.get(eventUtils.BUBBLE_OPEN))(this.block_, visible, 'mutator'));
eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))(
this.block_, visible, 'mutator'));
if (visible) {
// Create the bubble.
this.bubble_ = new Bubble(
@@ -378,8 +378,8 @@ Mutator.prototype.setVisible = function(visible) {
*/
Mutator.prototype.workspaceChanged_ = function(e) {
if (!(e.isUiEvent ||
(e.type == eventUtils.CHANGE && e.element == 'disabled') ||
e.type == eventUtils.CREATE)) {
(e.type == eventUtils.CHANGE && e.element == 'disabled') ||
e.type == eventUtils.CREATE)) {
this.updateWorkspace_();
}
};

View File

@@ -209,7 +209,7 @@ const flyoutCategory = function(workspace) {
const nameField = utilsXml.createElement('field');
nameField.setAttribute('name', 'NAME');
nameField.appendChild(
utilsXml.createTextNode(Msg['PROCEDURES_DEFNORETURN_PROCEDURE']));
utilsXml.createTextNode(Msg['PROCEDURES_DEFNORETURN_PROCEDURE']));
block.appendChild(nameField);
xmlList.push(block);
}
@@ -223,7 +223,7 @@ const flyoutCategory = function(workspace) {
const nameField = utilsXml.createElement('field');
nameField.setAttribute('name', 'NAME');
nameField.appendChild(
utilsXml.createTextNode(Msg['PROCEDURES_DEFRETURN_PROCEDURE']));
utilsXml.createTextNode(Msg['PROCEDURES_DEFRETURN_PROCEDURE']));
block.appendChild(nameField);
xmlList.push(block);
}

View File

@@ -304,16 +304,14 @@ RenderedConnection.prototype.highlight = function() {
this.type == ConnectionType.OUTPUT_VALUE) {
// Vertical line, puzzle tab, vertical line.
const yLen = renderConstants.TAB_OFFSET_FROM_TOP;
steps = svgPaths.moveBy(0, -yLen) +
svgPaths.lineOnAxis('v', yLen) + shape.pathDown +
svgPaths.lineOnAxis('v', yLen);
steps = svgPaths.moveBy(0, -yLen) + svgPaths.lineOnAxis('v', yLen) +
shape.pathDown + svgPaths.lineOnAxis('v', yLen);
} else {
const xLen =
renderConstants.NOTCH_OFFSET_LEFT - renderConstants.CORNER_RADIUS;
// Horizontal line, notch, horizontal line.
steps = svgPaths.moveBy(-xLen, 0) +
svgPaths.lineOnAxis('h', xLen) + shape.pathLeft +
svgPaths.lineOnAxis('h', xLen);
steps = svgPaths.moveBy(-xLen, 0) + svgPaths.lineOnAxis('h', xLen) +
shape.pathLeft + svgPaths.lineOnAxis('h', xLen);
}
const xy = this.sourceBlock_.getRelativeToSurfaceXY();
const x = this.x - xy.x;

View File

@@ -107,8 +107,8 @@ const registerCopy = function() {
name: names.COPY,
preconditionFn: function(workspace) {
const selected = common.getSelected();
return !workspace.options.readOnly && !Gesture.inProgress() &&
selected && selected.isDeletable() && selected.isMovable();
return !workspace.options.readOnly && !Gesture.inProgress() && selected &&
selected.isDeletable() && selected.isMovable();
},
callback: function(workspace, e) {
// Prevent the default copy behavior, which may beep or otherwise indicate
@@ -145,8 +145,8 @@ const registerCut = function() {
name: names.CUT,
preconditionFn: function(workspace) {
const selected = common.getSelected();
return !workspace.options.readOnly && !Gesture.inProgress() &&
selected && selected.isDeletable() && selected.isMovable() &&
return !workspace.options.readOnly && !Gesture.inProgress() && selected &&
selected.isDeletable() && selected.isMovable() &&
!selected.workspace.isFlyout;
},
callback: function() {

View File

@@ -71,8 +71,8 @@ Object.defineProperties(exports, {
visible: {
get: function() {
deprecation.warn(
'Blockly.Tooltip.visible', 'September 2021', 'September 2022',
'Blockly.Tooltip.isVisible()');
'Blockly.Tooltip.visible', 'September 2021', 'September 2022',
'Blockly.Tooltip.isVisible()');
return isVisible();
}
}
@@ -187,8 +187,8 @@ Object.defineProperties(exports, {
DIV: {
get: function() {
deprecation.warn(
'Blockly.Tooltip.DIV', 'September 2021', 'September 2022',
'Blockly.Tooltip.getDiv()');
'Blockly.Tooltip.DIV', 'September 2021', 'September 2022',
'Blockly.Tooltip.getDiv()');
return getDiv();
}
}

View File

@@ -631,8 +631,8 @@ Trashcan.prototype.click = function() {
* @private
*/
Trashcan.prototype.fireUiEvent_ = function(trashcanOpen) {
const uiEvent =
new (eventUtils.get(eventUtils.TRASHCAN_OPEN))(trashcanOpen, this.workspace_.id);
const uiEvent = new (eventUtils.get(eventUtils.TRASHCAN_OPEN))(
trashcanOpen, this.workspace_.id);
eventUtils.fire(uiEvent);
};
@@ -703,7 +703,7 @@ Trashcan.prototype.onDelete_ = function(event) {
*/
Trashcan.prototype.cleanBlockJson_ = function(json) {
// Create a deep copy.
json = /** @type {!blocks.State} */(JSON.parse(JSON.stringify(json)));
json = /** @type {!blocks.State} */ (JSON.parse(JSON.stringify(json)));
function cleanRec(json) {
if (!json) {

View File

@@ -77,8 +77,7 @@ exports.xml = xmlUtils;
* @alias Blockly.utils.noEvent
*/
const noEvent = function(e) {
deprecation.warn(
'Blockly.utils.noEvent', 'September 2021', 'September 2022');
deprecation.warn('Blockly.utils.noEvent', 'September 2021', 'September 2022');
// This event has been handled. No need to bubble up to the document.
e.preventDefault();
e.stopPropagation();
@@ -94,8 +93,8 @@ exports.noEvent = noEvent;
*/
const isTargetInput = function(e) {
deprecation.warn(
'Blockly.utils.isTargetInput', 'September 2021', 'September 2022',
'Blockly.browserEvents.isTargetInput');
'Blockly.utils.isTargetInput', 'September 2021', 'September 2022',
'Blockly.browserEvents.isTargetInput');
return browserEvents.isTargetInput(e);
};
exports.isTargetInput = isTargetInput;
@@ -199,8 +198,8 @@ getRelativeXY.XY_STYLE_REGEX_ =
*/
const isRightButton = function(e) {
deprecation.warn(
'Blockly.utils.isRightButton', 'September 2021', 'September 2022',
'Blockly.browserEvents.isRightButton');
'Blockly.utils.isRightButton', 'September 2021', 'September 2022',
'Blockly.browserEvents.isRightButton');
return browserEvents.isRightButton(e);
};
exports.isRightButton = isRightButton;
@@ -217,8 +216,8 @@ exports.isRightButton = isRightButton;
*/
const mouseToSvg = function(e, svg, matrix) {
deprecation.warn(
'Blockly.utils.mouseToSvg', 'September 2021', 'September 2022',
'Blockly.browserEvents.mouseToSvg');
'Blockly.utils.mouseToSvg', 'September 2021', 'September 2022',
'Blockly.browserEvents.mouseToSvg');
return browserEvents.mouseToSvg(e, svg, matrix);
};
exports.mouseToSvg = mouseToSvg;
@@ -233,8 +232,8 @@ exports.mouseToSvg = mouseToSvg;
*/
const getScrollDeltaPixels = function(e) {
deprecation.warn(
'Blockly.utils.getScrollDeltaPixels', 'September 2021', 'September 2022',
'Blockly.browserEvents.getScrollDeltaPixels');
'Blockly.utils.getScrollDeltaPixels', 'September 2021', 'September 2022',
'Blockly.browserEvents.getScrollDeltaPixels');
return browserEvents.getScrollDeltaPixels(e);
};
exports.getScrollDeltaPixels = getScrollDeltaPixels;

View File

@@ -117,7 +117,8 @@ VariableMap.prototype.renameVariableById = function(id, newName) {
*/
VariableMap.prototype.renameVariableAndUses_ = function(
variable, newName, blocks) {
eventUtils.fire(new (eventUtils.get(eventUtils.VAR_RENAME))(variable, newName));
eventUtils.fire(
new (eventUtils.get(eventUtils.VAR_RENAME))(variable, newName));
variable.name = newName;
for (let i = 0; i < blocks.length; i++) {
blocks[i].updateVarName(variable);

View File

@@ -94,8 +94,8 @@ Warning.prototype.setVisible = function(visible) {
if (visible == this.isVisible()) {
return;
}
eventUtils.fire(
new (eventUtils.get(eventUtils.BUBBLE_OPEN))(this.block_, visible, 'warning'));
eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))(
this.block_, visible, 'warning'));
if (visible) {
this.createBubble_();
} else {

View File

@@ -94,8 +94,8 @@ Object.defineProperties(exports, {
DIV: {
get: function() {
deprecation.warn(
'Blockly.WidgetDiv.DIV', 'September 2021', 'September 2022',
'Blockly.WidgetDiv.getDiv()');
'Blockly.WidgetDiv.DIV', 'September 2021', 'September 2022',
'Blockly.WidgetDiv.getDiv()');
return getDiv();
}
}

View File

@@ -273,8 +273,8 @@ WorkspaceComment.prototype.getContent = function() {
*/
WorkspaceComment.prototype.setContent = function(content) {
if (this.content_ != content) {
eventUtils.fire(
new (eventUtils.get(eventUtils.COMMENT_CHANGE))(this, this.content_, content));
eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_CHANGE))(
this, this.content_, content));
this.content_ = content;
}
};

View File

@@ -137,7 +137,8 @@ const WorkspaceCommentSvg = function(
* @type {boolean}
* @private
*/
this.useDragSurface_ = utils.is3dSupported() && !!workspace.getBlockDragSurface();
this.useDragSurface_ =
utils.is3dSupported() && !!workspace.getBlockDragSurface();
WorkspaceCommentSvg.superClass_.constructor.call(
this, workspace, content, height, width, opt_id);
@@ -272,8 +273,8 @@ WorkspaceCommentSvg.prototype.select = function() {
eventUtils.enable();
}
}
const event =
new (eventUtils.get(eventUtils.SELECTED))(oldId, this.id, this.workspace.id);
const event = new (eventUtils.get(eventUtils.SELECTED))(
oldId, this.id, this.workspace.id);
eventUtils.fire(event);
common.setSelected(this);
this.addSelect();
@@ -287,8 +288,8 @@ WorkspaceCommentSvg.prototype.unselect = function() {
if (common.getSelected() != this) {
return;
}
const event =
new (eventUtils.get(eventUtils.SELECTED))(this.id, null, this.workspace.id);
const event = new (eventUtils.get(eventUtils.SELECTED))(
this.id, null, this.workspace.id);
eventUtils.fire(event);
common.setSelected(null);
this.removeSelect();
@@ -347,8 +348,9 @@ WorkspaceCommentSvg.prototype.getRelativeToSurfaceXY = function() {
let x = 0;
let y = 0;
const dragSurfaceGroup =
this.useDragSurface_ ? this.workspace.getBlockDragSurface().getGroup() : null;
const dragSurfaceGroup = this.useDragSurface_ ?
this.workspace.getBlockDragSurface().getGroup() :
null;
let element = this.getSvgRoot();
if (element) {

View File

@@ -206,12 +206,12 @@ const WorkspaceSvg = function(
this.markerManager_ = new MarkerManager(this);
/**
* Map from function names to callbacks, for deciding what to do when a custom
* toolbox category is opened.
* @type {!Object<string, ?function(!Workspace):
* !toolbox.FlyoutDefinition>}
* @private
*/
* Map from function names to callbacks, for deciding what to do when a custom
* toolbox category is opened.
* @type {!Object<string, ?function(!Workspace):
* !toolbox.FlyoutDefinition>}
* @private
*/
this.toolboxCategoryCallbacks_ = Object.create(null);
/**
@@ -718,8 +718,8 @@ WorkspaceSvg.prototype.refreshTheme = function() {
this.setVisible(true);
}
const event =
new (eventUtils.get(eventUtils.THEME_CHANGE))(this.getTheme().name, this.id);
const event = new (eventUtils.get(eventUtils.THEME_CHANGE))(
this.getTheme().name, this.id);
eventUtils.fire(event);
};

View File

@@ -450,7 +450,8 @@ const domToWorkspace = function(xml, workspace) {
for (let i = 0, xmlChild; (xmlChild = xml.childNodes[i]); i++) {
const name = xmlChild.nodeName.toLowerCase();
const xmlChildElement = /** @type {!Element} */ (xmlChild);
if (name == 'block' || (name == 'shadow' && !eventUtils.getRecordUndo())) {
if (name == 'block' ||
(name == 'shadow' && !eventUtils.getRecordUndo())) {
// Allow top-level shadow blocks if recordUndo is disabled since
// that means an undo is in progress. Such a block is expected
// to be moved to a nested destination in the next operation.
@@ -632,7 +633,8 @@ const domToBlock = function(xmlBlock, workspace) {
// Fire a VarCreate event for each (if any) new variable created.
for (let i = 0; i < newVariables.length; i++) {
const thisVariable = newVariables[i];
eventUtils.fire(new (eventUtils.get(eventUtils.VAR_CREATE))(thisVariable));
eventUtils.fire(
new (eventUtils.get(eventUtils.VAR_CREATE))(thisVariable));
}
// Block events come after var events, in case they refer to newly created
// variables.

View File

@@ -491,8 +491,8 @@ ZoomControls.prototype.resetZoom_ = function(e) {
* @private
*/
ZoomControls.prototype.fireZoomEvent_ = function() {
const uiEvent =
new (eventUtils.get(eventUtils.CLICK))(null, this.workspace_.id, 'zoom_controls');
const uiEvent = new (eventUtils.get(eventUtils.CLICK))(
null, this.workspace_.id, 'zoom_controls');
eventUtils.fire(uiEvent);
};