chore: runs clang format on all files (#5627)

This commit is contained in:
alschmiedt
2021-10-21 15:22:24 -07:00
committed by GitHub
parent 6dc0f90959
commit 0f3c06306f
36 changed files with 209 additions and 130 deletions

View File

@@ -1123,7 +1123,8 @@ Block.prototype.getVarModels = function() {
Block.prototype.updateVarName = function(variable) {
for (let i = 0, input; (input = this.inputList[i]); i++) {
for (let j = 0, field; (field = input.fieldRow[j]); j++) {
if (field.referencesVariables() && variable.getId() === field.getValue()) {
if (field.referencesVariables() &&
variable.getId() === field.getValue()) {
field.refreshVariableName();
}
}

View File

@@ -748,8 +748,7 @@ exports.zelos = zelos;
// accessors on one copy would call get/set functions on the other
// copy!)
if (globalThis.goog && globalThis.Blockly &&
typeof globalThis.Blockly === 'object' &&
globalThis.Blockly !== exports) {
typeof globalThis.Blockly === 'object' && globalThis.Blockly !== exports) {
const descriptors = Object.getOwnPropertyDescriptors(exports);
const accessors = {};
for (const key in descriptors) {

View File

@@ -604,7 +604,7 @@ const registerHelp = function() {
scope) {
const block = scope.block;
const url = (typeof block.helpUrl === 'function') ? block.helpUrl() :
block.helpUrl;
block.helpUrl;
if (url) {
return 'enabled';
}

View File

@@ -39,8 +39,8 @@ const register = function(cssContent) {
if (Array.isArray(cssContent)) {
deprecation.warn(
'Registering CSS by passing an array of strings', 'September 2021',
'September 2022', 'css.register passing a multiline string');
'Registering CSS by passing an array of strings', 'September 2021',
'September 2022', 'css.register passing a multiline string');
content += ('\n' + cssContent.join('\n'));
} else {
// Add new cssContent in the global content.

View File

@@ -145,4 +145,3 @@ Object.defineProperties(exports, {
},
},
});

View File

@@ -139,7 +139,8 @@ BlockChange.prototype.run = function(forward) {
block.domToMutation(
Xml.textToDom(/** @type {string} */ (value) || '<mutation/>'));
}
eventUtils.fire(new BlockChange(block, 'mutation', null, oldState, value));
eventUtils.fire(
new BlockChange(block, 'mutation', null, oldState, value));
break;
}
default:

View File

@@ -50,8 +50,8 @@ const BlockCreate = function(opt_block) {
* JSON representation of the block that was just created.
* @type {!blocks.State}
*/
this.json = /** @type {!blocks.State} */ (blocks.save(
opt_block, {addCoordinates: true}));
this.json = /** @type {!blocks.State} */ (
blocks.save(opt_block, {addCoordinates: true}));
};
object.inherits(BlockCreate, BlockBase);

View File

@@ -59,8 +59,8 @@ const BlockDelete = function(opt_block) {
* JSON representation of the block that was just deleted.
* @type {!blocks.State}
*/
this.oldJson = /** @type {!blocks.State} */ (blocks.save(
opt_block, {addCoordinates: true}));
this.oldJson = /** @type {!blocks.State} */ (
blocks.save(opt_block, {addCoordinates: true}));
};
object.inherits(BlockDelete, BlockBase);
@@ -95,7 +95,7 @@ BlockDelete.prototype.fromJson = function(json) {
this.oldXml = Xml.textToDom(json['oldXml']);
this.ids = json['ids'];
this.wasShadow =
json['wasShadow'] || this.oldXml.tagName.toLowerCase() === 'shadow';
json['wasShadow'] || this.oldXml.tagName.toLowerCase() === 'shadow';
this.oldJson = /** @type {!blocks.State} */ (json['oldJson']);
if (json['recordUndo'] !== undefined) {
this.recordUndo = json['recordUndo'];

View File

@@ -97,6 +97,7 @@ CommentChange.prototype.run = function(forward) {
comment.setContent(contents);
};
registry.register(registry.Type.EVENT, eventUtils.COMMENT_CHANGE, CommentChange);
registry.register(
registry.Type.EVENT, eventUtils.COMMENT_CHANGE, CommentChange);
exports.CommentChange = CommentChange;

View File

@@ -76,6 +76,7 @@ CommentCreate.prototype.run = function(forward) {
CommentBase.CommentCreateDeleteHelper(this, forward);
};
registry.register(registry.Type.EVENT, eventUtils.COMMENT_CREATE, CommentCreate);
registry.register(
registry.Type.EVENT, eventUtils.COMMENT_CREATE, CommentCreate);
exports.CommentCreate = CommentCreate;

View File

@@ -73,6 +73,7 @@ CommentDelete.prototype.run = function(forward) {
CommentBase.CommentCreateDeleteHelper(this, !forward);
};
registry.register(registry.Type.EVENT, eventUtils.COMMENT_DELETE, CommentDelete);
registry.register(
registry.Type.EVENT, eventUtils.COMMENT_DELETE, CommentDelete);
exports.CommentDelete = CommentDelete;

View File

@@ -100,6 +100,7 @@ ViewportChange.prototype.fromJson = function(json) {
this.oldScale = json['oldScale'];
};
registry.register(registry.Type.EVENT, eventUtils.VIEWPORT_CHANGE, ViewportChange);
registry.register(
registry.Type.EVENT, eventUtils.VIEWPORT_CHANGE, ViewportChange);
exports.ViewportChange = ViewportChange;

View File

@@ -255,25 +255,85 @@ FieldColour.prototype.getText = function() {
*/
FieldColour.COLOURS = [
// grays
'#ffffff', '#cccccc', '#c0c0c0', '#999999', '#666666', '#333333', '#000000',
'#ffffff',
'#cccccc',
'#c0c0c0',
'#999999',
'#666666',
'#333333',
'#000000',
// reds
'#ffcccc', '#ff6666', '#ff0000', '#cc0000', '#990000', '#660000', '#330000',
'#ffcccc',
'#ff6666',
'#ff0000',
'#cc0000',
'#990000',
'#660000',
'#330000',
// oranges
'#ffcc99', '#ff9966', '#ff9900', '#ff6600', '#cc6600', '#993300', '#663300',
'#ffcc99',
'#ff9966',
'#ff9900',
'#ff6600',
'#cc6600',
'#993300',
'#663300',
// yellows
'#ffff99', '#ffff66', '#ffcc66', '#ffcc33', '#cc9933', '#996633', '#663333',
'#ffff99',
'#ffff66',
'#ffcc66',
'#ffcc33',
'#cc9933',
'#996633',
'#663333',
// olives
'#ffffcc', '#ffff33', '#ffff00', '#ffcc00', '#999900', '#666600', '#333300',
'#ffffcc',
'#ffff33',
'#ffff00',
'#ffcc00',
'#999900',
'#666600',
'#333300',
// greens
'#99ff99', '#66ff99', '#33ff33', '#33cc00', '#009900', '#006600', '#003300',
'#99ff99',
'#66ff99',
'#33ff33',
'#33cc00',
'#009900',
'#006600',
'#003300',
// turquoises
'#99ffff', '#33ffff', '#66cccc', '#00cccc', '#339999', '#336666', '#003333',
'#99ffff',
'#33ffff',
'#66cccc',
'#00cccc',
'#339999',
'#336666',
'#003333',
// blues
'#ccffff', '#66ffff', '#33ccff', '#3366ff', '#3333ff', '#000099', '#000066',
'#ccffff',
'#66ffff',
'#33ccff',
'#3366ff',
'#3333ff',
'#000099',
'#000066',
// purples
'#ccccff', '#9999ff', '#6666cc', '#6633ff', '#6600cc', '#333399', '#330099',
'#ccccff',
'#9999ff',
'#6666cc',
'#6633ff',
'#6600cc',
'#333399',
'#330099',
// violets
'#ffccff', '#ff99ff', '#cc66cc', '#cc33cc', '#993399', '#663366', '#330033',
'#ffccff',
'#ff99ff',
'#cc66cc',
'#cc33cc',
'#993399',
'#663366',
'#330033',
];
/**

View File

@@ -343,19 +343,22 @@ const loadSounds = function(pathToMedia, workspace) {
const audioMgr = workspace.getAudioManager();
audioMgr.load(
[
pathToMedia + 'click.mp3', pathToMedia + 'click.wav',
pathToMedia + 'click.mp3',
pathToMedia + 'click.wav',
pathToMedia + 'click.ogg',
],
'click');
audioMgr.load(
[
pathToMedia + 'disconnect.wav', pathToMedia + 'disconnect.mp3',
pathToMedia + 'disconnect.wav',
pathToMedia + 'disconnect.mp3',
pathToMedia + 'disconnect.ogg',
],
'disconnect');
audioMgr.load(
[
pathToMedia + 'delete.mp3', pathToMedia + 'delete.ogg',
pathToMedia + 'delete.mp3',
pathToMedia + 'delete.ogg',
pathToMedia + 'delete.wav',
],
'delete');

View File

@@ -94,7 +94,7 @@ const Options = function(options) {
toolboxAtStart ? toolbox.Position.TOP : toolbox.Position.BOTTOM;
} else {
toolboxPosition = (toolboxAtStart === rtl) ? toolbox.Position.RIGHT :
toolbox.Position.LEFT;
toolbox.Position.LEFT;
}
let hasCss = options['css'];

View File

@@ -328,7 +328,8 @@ exports.mutatorOpenListener = mutatorOpenListener;
* @param {!Abstract} e The event that triggered this listener.
*/
const mutatorChangeListener = function(e) {
if (e.type !== eventUtils.BLOCK_CREATE && e.type !== eventUtils.BLOCK_DELETE &&
if (e.type !== eventUtils.BLOCK_CREATE &&
e.type !== eventUtils.BLOCK_DELETE &&
e.type !== eventUtils.BLOCK_CHANGE) {
return;
}

View File

@@ -72,7 +72,7 @@ exports.isDebuggerEnabled = isDebuggerEnabled;
* to register.
* @throws {Error} if a renderer with the same name has already been registered.
*/
const register = function(name, rendererClass) {
const register = function(name, rendererClass) {
registry.register(registry.Type.RENDERER, name, rendererClass);
};
exports.register = register;

View File

@@ -784,7 +784,8 @@ ConstantProvider.prototype.makeJaggedTeeth = function() {
const width = this.JAGGED_TEETH_WIDTH;
const mainPath = svgPaths.line([
svgPaths.point(width, height / 4), svgPaths.point(-width * 2, height / 2),
svgPaths.point(width, height / 4),
svgPaths.point(-width * 2, height / 2),
svgPaths.point(width, height / 4),
]);
return {height: height, width: width, path: mainPath};
@@ -800,7 +801,8 @@ ConstantProvider.prototype.makeStartHat = function() {
const width = this.START_HAT_WIDTH;
const mainPath = svgPaths.curve('c', [
svgPaths.point(30, -height), svgPaths.point(70, -height),
svgPaths.point(30, -height),
svgPaths.point(70, -height),
svgPaths.point(width, 0),
]);
return {height: height, width: width, path: mainPath};
@@ -837,7 +839,8 @@ ConstantProvider.prototype.makePuzzleTab = function() {
'c',
[
svgPaths.point(0, forward * control1Y),
svgPaths.point(-width, back * control2Y), endPoint1,
svgPaths.point(-width, back * control2Y),
endPoint1,
]) +
svgPaths.curve(
's', [svgPaths.point(width, back * control3Y), endPoint2]);

View File

@@ -2,7 +2,7 @@
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
*/
/**
* @fileoverview Block rendering debugging functionality.

View File

@@ -147,8 +147,7 @@ MarkerSvg.prototype.isCursor = function() {
* @package
*/
MarkerSvg.prototype.createDom = function() {
const className =
this.isCursor() ? CURSOR_CLASS : MARKER_CLASS;
const className = this.isCursor() ? CURSOR_CLASS : MARKER_CLASS;
this.svgGroup_ = dom.createSvgElement(Svg.G, {'class': className}, null);

View File

@@ -64,8 +64,7 @@ ConstantProvider.prototype.getCSS_ = function(selector) {
// Insertion marker.
selector + ' .blocklyInsertionMarker>.blocklyPathLight,',
selector + ' .blocklyInsertionMarker>.blocklyPathDark {',
'fill-opacity: ' + this.INSERTION_MARKER_OPACITY + ';',
'stroke: none;',
'fill-opacity: ' + this.INSERTION_MARKER_OPACITY + ';', 'stroke: none;',
'}',
/* eslint-enable indent */
]);

View File

@@ -215,7 +215,8 @@ HighlightConstantProvider.prototype.makePuzzleTab = function() {
svgPaths.curve(
'q',
[
svgPaths.point(-width * 0.05, 10), svgPaths.point(width * 0.3, 9.5),
svgPaths.point(-width * 0.05, 10),
svgPaths.point(width * 0.3, 9.5),
]) +
svgPaths.moveBy(width * 0.67, -1.9) +
svgPaths.lineOnAxis('v', verticalOverlap);
@@ -272,12 +273,14 @@ HighlightConstantProvider.prototype.makeJaggedTeeth = function() {
HighlightConstantProvider.prototype.makeStartHat = function() {
const hatHeight = this.constantProvider.START_HAT.height;
const pathRtl = svgPaths.moveBy(25, -8.7) + svgPaths.curve('c', [
svgPaths.point(29.7, -6.2), svgPaths.point(57.2, -0.5),
svgPaths.point(29.7, -6.2),
svgPaths.point(57.2, -0.5),
svgPaths.point(75, 8.7),
]);
const pathLtr = svgPaths.curve('c', [
svgPaths.point(17.8, -9.2), svgPaths.point(45.3, -14.9),
svgPaths.point(17.8, -9.2),
svgPaths.point(45.3, -14.9),
svgPaths.point(75, -8.7),
]) + svgPaths.moveTo(100.5, hatHeight + 0.5);
return {

View File

@@ -59,7 +59,8 @@ InputRow.prototype.measure = function() {
if (Types.isInput(elem)) {
if (Types.isStatementInput(elem)) {
connectedBlockWidths += elem.connectedBlockWidth;
} else if (Types.isExternalInput(elem) && elem.connectedBlockWidth !== 0) {
} else if (
Types.isExternalInput(elem) && elem.connectedBlockWidth !== 0) {
connectedBlockWidths +=
(elem.connectedBlockWidth - elem.connectionWidth);
}

View File

@@ -38,7 +38,7 @@ const RoundCorner = function(constants, opt_position) {
RoundCorner.superClass_.constructor.call(this, constants);
this.type =
((!opt_position || opt_position === 'left') ? Types.LEFT_ROUND_CORNER :
Types.RIGHT_ROUND_CORNER) |
Types.RIGHT_ROUND_CORNER) |
Types.CORNER;
this.width = this.constants_.CORNER_RADIUS;
// The rounded corner extends into the next row by 4 so we only take the

View File

@@ -38,7 +38,7 @@ const SquareCorner = function(constants, opt_position) {
SquareCorner.superClass_.constructor.call(this, constants);
this.type =
((!opt_position || opt_position === 'left') ? Types.LEFT_SQUARE_CORNER :
Types.RIGHT_SQUARE_CORNER) |
Types.RIGHT_SQUARE_CORNER) |
Types.CORNER;
this.height = this.constants_.NO_PADDING;
this.width = this.constants_.NO_PADDING;

View File

@@ -52,7 +52,7 @@ const Types = {
ROW: 1 << 20, // Row.
TOP_ROW: 1 << 21, // Top Row.
BOTTOM_ROW: 1 << 22, // Bottom Row.
INPUT_ROW: 1 << 23, // Input Row.
INPUT_ROW: 1 << 23, // Input Row.
};
/**

View File

@@ -216,21 +216,21 @@ const ConstantProvider = function() {
0: 5 * this.GRID_UNIT, // Field in hexagon.
1: 2 * this.GRID_UNIT, // Hexagon in hexagon.
2: 5 * this.GRID_UNIT, // Round in hexagon.
3: 5 * this.GRID_UNIT, // Square in hexagon.
3: 5 * this.GRID_UNIT, // Square in hexagon.
},
2: {
// Outer shape: round.
0: 3 * this.GRID_UNIT, // Field in round.
1: 3 * this.GRID_UNIT, // Hexagon in round.
2: 1 * this.GRID_UNIT, // Round in round.
3: 2 * this.GRID_UNIT, // Square in round.
3: 2 * this.GRID_UNIT, // Square in round.
},
3: {
// Outer shape: square.
0: 2 * this.GRID_UNIT, // Field in square.
1: 2 * this.GRID_UNIT, // Hexagon in square.
2: 2 * this.GRID_UNIT, // Round in square.
3: 2 * this.GRID_UNIT, // Square in square.
3: 2 * this.GRID_UNIT, // Square in square.
},
};
@@ -455,7 +455,8 @@ ConstantProvider.prototype.makeStartHat = function() {
const width = this.START_HAT_WIDTH;
const mainPath = svgPaths.curve('c', [
svgPaths.point(25, -height), svgPaths.point(71, -height),
svgPaths.point(25, -height),
svgPaths.point(71, -height),
svgPaths.point(width, 0),
]);
return {height: height, width: width, path: mainPath};

View File

@@ -271,8 +271,7 @@ RenderInfo.prototype.addInput_ = function(input, activeRow) {
activeRow.rightAlignedDummyInput = input;
} else if (input.type === inputTypes.STATEMENT) {
// Handle statements without next connections correctly.
activeRow.elements.push(
new StatementInput(this.constants_, input));
activeRow.elements.push(new StatementInput(this.constants_, input));
activeRow.hasStatement = true;
if (activeRow.align === null) {
@@ -327,7 +326,7 @@ RenderInfo.prototype.adjustXPosition_ = function() {
const nextSpacer = this.rows[i + 1];
const hasPrevNotch = i === 2 ? !!this.topRow.hasPreviousConnection :
!!prevSpacer.followsStatement;
!!prevSpacer.followsStatement;
const hasNextNotch = i + 2 >= this.rows.length - 1 ?
!!this.bottomRow.hasNextConnection :
!!nextSpacer.precedesStatement;
@@ -505,7 +504,8 @@ RenderInfo.prototype.getNegativeSpacing_ = function(elem) {
return 0;
}
// Special case for hexagonal output.
if (outerShape === constants.SHAPES.HEXAGONAL && outerShape !== innerShape) {
if (outerShape === constants.SHAPES.HEXAGONAL &&
outerShape !== innerShape) {
return 0;
}
return connectionWidth -

View File

@@ -91,15 +91,12 @@ exports.State = State;
* could not be serialied (eg it was an insertion marker).
* @alias Blockly.serialization.blocks.save
*/
const save = function(
block,
{
addCoordinates = false,
addInputBlocks = true,
addNextBlocks = true,
doFullSerialization = true,
} = {}
) {
const save = function(block, {
addCoordinates = false,
addInputBlocks = true,
addNextBlocks = true,
doFullSerialization = true,
} = {}) {
if (block.isInsertionMarker()) {
return null;
}
@@ -176,8 +173,10 @@ const saveExtraState = function(block, state) {
} else if (block.mutationToDom) {
const extraState = block.mutationToDom();
if (extraState !== null) {
state['extraState'] = Xml.domToText(extraState).replace(
' xmlns="https://developers.google.com/blockly/xml"', '');
state['extraState'] =
Xml.domToText(extraState)
.replace(
' xmlns="https://developers.google.com/blockly/xml"', '');
}
}
};
@@ -262,8 +261,8 @@ const saveNextBlocks = function(block, state, doFullSerialization) {
if (!block.nextConnection) {
return;
}
const connectionState = saveConnection(
block.nextConnection, doFullSerialization);
const connectionState =
saveConnection(block.nextConnection, doFullSerialization);
if (connectionState) {
state['next'] = connectionState;
}
@@ -329,15 +328,11 @@ exports.append = append;
* @alias Blockly.serialization.blocks.appendInternal
* @package
*/
const appendInternal = function(
state,
workspace,
{
parentConnection = undefined,
isShadow = false,
recordUndo = false,
} = {}
) {
const appendInternal = function(state, workspace, {
parentConnection = undefined,
isShadow = false,
recordUndo = false,
} = {}) {
const prevRecordUndo = eventUtils.getRecordUndo();
eventUtils.setRecordUndo(recordUndo);
const existingGroup = eventUtils.getGroup();
@@ -382,14 +377,10 @@ exports.appendInternal = appendInternal;
* False by default.
* @return {!Block} The block that was just appended.
*/
const appendPrivate = function(
state,
workspace,
{
parentConnection = undefined,
isShadow = false,
} = {}
) {
const appendPrivate = function(state, workspace, {
parentConnection = undefined,
isShadow = false,
} = {}) {
if (!state['type']) {
throw new MissingBlockType(state);
}
@@ -486,7 +477,7 @@ const tryToConnectParent = function(parentConnection, child, state) {
throw new MissingConnection('output', child, state);
}
connected = parentConnection.connect(childConnection);
} else { // Statement type.
} else { // Statement type.
childConnection = child.previousConnection;
if (!childConnection) {
throw new MissingConnection('previous', child, state);
@@ -500,12 +491,10 @@ const tryToConnectParent = function(parentConnection, child, state) {
checker.getErrorMessage(
checker.canConnectWithReason(
childConnection, parentConnection, false),
childConnection,
parentConnection),
parentConnection.type === inputTypes.VALUE ?
'output connection' : 'previous connection',
child,
state);
childConnection, parentConnection),
parentConnection.type === inputTypes.VALUE ? 'output connection' :
'previous connection',
child, state);
}
};
@@ -606,8 +595,7 @@ const loadConnection = function(connection, connectionState) {
}
if (connectionState['block']) {
appendPrivate(
connectionState['block'],
connection.getSourceBlock().workspace,
connectionState['block'], connection.getSourceBlock().workspace,
{parentConnection: connection});
}
};
@@ -657,15 +645,15 @@ class BlockSerializer {
save(workspace) {
const blockStates = [];
for (const block of workspace.getTopBlocks(false)) {
const state = saveBlock(
block, {addCoordinates: true, doFullSerialization: false});
const state =
saveBlock(block, {addCoordinates: true, doFullSerialization: false});
if (state) {
blockStates.push(state);
}
}
if (blockStates.length) {
return {
'languageVersion': 0, // Currently unused.
'languageVersion': 0, // Currently unused.
'blocks': blockStates,
};
}

View File

@@ -17,13 +17,13 @@
*/
goog.module('Blockly.serialization.workspaces');
goog.module.declareLegacyNamespace();
const dom = goog.require('Blockly.utils.dom');
const eventUtils = goog.require('Blockly.Events.utils');
const registry = goog.require('Blockly.registry');
// eslint-disable-next-line no-unused-vars
const {Workspace} = goog.require('Blockly.Workspace');
/**
* Returns the state of the workspace as a plain JavaScript object.
@@ -43,7 +43,7 @@ const save = function(workspace) {
return state;
};
exports.save = save;
/**
* Loads the variable represented by the given state into the given workspace.
* @param {!Object<string, *>} state The state of the workspace to deserialize
@@ -60,9 +60,10 @@ const load = function(state, workspace, {recordUndo = false} = {}) {
return;
}
const deserializers = Object.entries(serializerMap)
.sort(([, {priority: priorityA}], [, {priority: priorityB}]) =>
priorityB - priorityA);
const deserializers =
Object.entries(serializerMap).sort(([, {priority: priorityA}], [
, {priority: priorityB}
]) => priorityB - priorityA);
const prevRecordUndo = eventUtils.getRecordUndo();
eventUtils.setRecordUndo(recordUndo);
@@ -75,7 +76,7 @@ const load = function(state, workspace, {recordUndo = false} = {}) {
if (workspace.setResizesEnabled) {
workspace.setResizesEnabled(false);
}
// We want to trigger clearing in reverse priority order so plugins don't end
// up missing dependencies.
for (const [, deserializer] of deserializers.reverse()) {

View File

@@ -51,7 +51,6 @@ let categoryStyles = {
* @type {Theme}
* @alias Blockly.Themes.Classic
*/
const Classic =
new Theme('classic', defaultBlockStyles, categoryStyles);
const Classic = new Theme('classic', defaultBlockStyles, categoryStyles);
exports.Classic = Classic;

View File

@@ -118,7 +118,8 @@ CollapsibleToolboxCategory.prototype.parseContents_ = function(categoryDef) {
// Separators can exist as either a flyout item or a toolbox item so
// decide where it goes based on the type of the previous item.
if (!registry.hasItem(registry.Type.TOOLBOX_ITEM, itemDef['kind']) ||
(itemDef['kind'].toLowerCase() === ToolboxSeparator.registrationName &&
(itemDef['kind'].toLowerCase() ===
ToolboxSeparator.registrationName &&
prevIsFlyoutItem)) {
const flyoutItem = /** @type {toolbox.FlyoutItemInfo} */ (itemDef);
this.flyoutItems_.push(flyoutItem);

View File

@@ -159,13 +159,12 @@ exports.shouldHandleEvent = shouldHandleEvent;
* @alias Blockly.Touch.getTouchIdentifierFromEvent
*/
const getTouchIdentifierFromEvent = function(e) {
return e.pointerId !== undefined ?
e.pointerId :
return e.pointerId !== undefined ? e.pointerId :
(e.changedTouches && e.changedTouches[0] &&
e.changedTouches[0].identifier !== undefined &&
e.changedTouches[0].identifier !== null) ?
e.changedTouches[0].identifier :
'mouse';
e.changedTouches[0].identifier :
'mouse';
};
exports.getTouchIdentifierFromEvent = getTouchIdentifierFromEvent;

View File

@@ -258,7 +258,8 @@ exports.scrollIntoContainerView = scrollIntoContainerView;
* in form of goog.math.Coordinate(scrollLeft, scrollTop).
* @alias Blockly.utils.style.getContainerOffsetToScrollInto
*/
const getContainerOffsetToScrollInto = function(element, container, opt_center) {
const getContainerOffsetToScrollInto = function(
element, container, opt_center) {
// Absolute position of the element's border's top left corner.
const elementPos = getPageOffset(element);
// Absolute position of the container's border's top left corner.

View File

@@ -112,72 +112,86 @@ isTablet = isIPad || (isAndroid && !has('Mobile')) || has('Silk');
isMobile = !isTablet && (isIPod || isIPhone || isAndroid || has('IEMobile'));
})((globalThis['navigator'] && globalThis['navigator']['userAgent']) || '');
/** @const {string}
/**
* @const {string}
* @alias Blockly.utils.userAgent.raw
*/
exports.raw = rawUserAgent;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.IE
*/
exports.IE = isIe;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.EDGE
*/
exports.EDGE = isEdge;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.JavaFx
*/
exports.JavaFx = isJavaFx;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.CHROME
*/
exports.CHROME = isChrome;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.WEBKIT
*/
exports.WEBKIT = isWebKit;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.GECKO
*/
exports.GECKO = isGecko;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.ANDROID
*/
exports.ANDROID = isAndroid;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.IPAD
*/
exports.IPAD = isIPad;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.IPOD
*/
exports.IPOD = isIPod;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.IPHONE
*/
exports.IPHONE = isIPhone;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.MAC
*/
exports.MAC = isMac;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.TABLET
*/
exports.TABLET = isTablet;
/** @const {boolean}
/**
* @const {boolean}
* @alias Blockly.utils.userAgent.MOBILE
*/
exports.MOBILE = isMobile;

View File

@@ -272,7 +272,8 @@ const blockToDom = function(block, opt_noId) {
element.appendChild(container);
}
}
const nextShadow = block.nextConnection && block.nextConnection.getShadowDom();
const nextShadow =
block.nextConnection && block.nextConnection.getShadowDom();
if (nextShadow && (!nextBlock || !nextBlock.isShadow())) {
container.appendChild(cloneShadow(nextShadow, opt_noId));
}
@@ -483,7 +484,8 @@ const domToWorkspace = function(xml, workspace) {
/** @type {!WorkspaceSvg} */ (workspace), width);
}
} else {
const {WorkspaceComment} = goog.module.get('Blockly.WorkspaceComment');
const {WorkspaceComment} =
goog.module.get('Blockly.WorkspaceComment');
if (!WorkspaceComment) {
console.warn(
'Missing require for Blockly.WorkspaceComment, ' +
@@ -537,7 +539,7 @@ const appendDomToWorkspace = function(xml, workspace) {
// Load the new blocks into the workspace and get the IDs of the new blocks.
const newBlockIds = domToWorkspace(xml, workspace);
if (bbox && bbox.top !== bbox.bottom) { // check if any previous block
let offsetY = 0; // offset to add to y of the new block
let offsetY = 0; // offset to add to y of the new block
let offsetX = 0;
const farY = bbox.bottom; // bottom position
const topX = workspace.RTL ? bbox.right : bbox.left; // x of bounding box