From 0ffdc6106d87c80628258b87a9fc75808be638de Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Mon, 9 Aug 2021 12:24:06 -0700 Subject: [PATCH] Migrate core/block_svg.js to goog.module syntax (#5323) * Migrate core/block_svg.js to ES6 const/let * Migrate core/block_svg.js to goog.module * Migrate core/block_svg.js to named requires * clang-format core/block_svg.js * Migrate to goog.module.get for optional Comment/Warning in core/block_svg.js * Lint changes in core/block_svg.js --- core/block_svg.js | 836 +++++++++++++++++++++++----------------------- tests/deps.js | 2 +- 2 files changed, 420 insertions(+), 418 deletions(-) diff --git a/core/block_svg.js b/core/block_svg.js index fbd3dd5dc..027b0c71b 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -10,93 +10,110 @@ */ 'use strict'; -goog.provide('Blockly.BlockSvg'); +goog.module('Blockly.BlockSvg'); +goog.module.declareLegacyNamespace(); -goog.require('Blockly.ASTNode'); -goog.require('Blockly.Block'); -goog.require('Blockly.blockAnimations'); -goog.require('Blockly.blockRendering.IPathObject'); -goog.require('Blockly.browserEvents'); -goog.require('Blockly.common'); -goog.require('Blockly.connectionTypes'); -goog.require('Blockly.constants'); -goog.require('Blockly.ContextMenu'); -goog.require('Blockly.ContextMenuRegistry'); -goog.require('Blockly.Events'); +const ASTNode = goog.require('Blockly.ASTNode'); +const Block = goog.require('Blockly.Block'); +/* eslint-disable-next-line no-unused-vars */ +const BlockRenderingDebug = goog.requireType('Blockly.blockRendering.Debug'); +/* eslint-disable-next-line no-unused-vars */ +const Comment = goog.requireType('Blockly.Comment'); +/* eslint-disable-next-line no-unused-vars */ +const Connection = goog.requireType('Blockly.Connection'); +const ContextMenu = goog.require('Blockly.ContextMenu'); +const ContextMenuRegistry = goog.require('Blockly.ContextMenuRegistry'); +const Coordinate = goog.require('Blockly.utils.Coordinate'); +const Events = goog.require('Blockly.Events'); +/* eslint-disable-next-line no-unused-vars */ +const Field = goog.requireType('Blockly.Field'); +const FieldLabel = goog.require('Blockly.FieldLabel'); +/* eslint-disable-next-line no-unused-vars */ +const IASTNodeLocationSvg = goog.require('Blockly.IASTNodeLocationSvg'); +/* eslint-disable-next-line no-unused-vars */ +const IBoundedElement = goog.require('Blockly.IBoundedElement'); +/* eslint-disable-next-line no-unused-vars */ +const ICopyable = goog.require('Blockly.ICopyable'); +/* eslint-disable-next-line no-unused-vars */ +const IDraggable = goog.require('Blockly.IDraggable'); +/* eslint-disable-next-line no-unused-vars */ +const IPathObject = goog.require('Blockly.blockRendering.IPathObject'); +/* eslint-disable-next-line no-unused-vars */ +const Icon = goog.requireType('Blockly.Icon'); +/* eslint-disable-next-line no-unused-vars */ +const Input = goog.requireType('Blockly.Input'); +const MarkerManager = goog.require('Blockly.MarkerManager'); +const Msg = goog.require('Blockly.Msg'); +/* eslint-disable-next-line no-unused-vars */ +const Mutator = goog.requireType('Blockly.Mutator'); +const Rect = goog.require('Blockly.utils.Rect'); +const RenderedConnection = goog.require('Blockly.RenderedConnection'); +const Svg = goog.require('Blockly.utils.Svg'); +const TabNavigateCursor = goog.require('Blockly.TabNavigateCursor'); +/* eslint-disable-next-line no-unused-vars */ +const Theme = goog.requireType('Blockly.Theme'); +const Tooltip = goog.require('Blockly.Tooltip'); +/* eslint-disable-next-line no-unused-vars */ +const Warning = goog.requireType('Blockly.Warning'); +/* eslint-disable-next-line no-unused-vars */ +const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg'); +const Xml = goog.require('Blockly.Xml'); +const blockAnimations = goog.require('Blockly.blockAnimations'); +const browserEvents = goog.require('Blockly.browserEvents'); +const common = goog.require('Blockly.common'); +const connectionTypes = goog.require('Blockly.connectionTypes'); +const constants = goog.require('Blockly.constants'); +const deprecation = goog.require('Blockly.utils.deprecation'); +const dom = goog.require('Blockly.utils.dom'); +const internalConstants = goog.require('Blockly.internalConstants'); +const object = goog.require('Blockly.utils.object'); +const userAgent = goog.require('Blockly.utils.userAgent'); +const utils = goog.require('Blockly.utils'); /** @suppress {extraRequire} */ goog.require('Blockly.Events.BlockMove'); /** @suppress {extraRequire} */ goog.require('Blockly.Events.Selected'); -goog.require('Blockly.IASTNodeLocationSvg'); -goog.require('Blockly.IBoundedElement'); -goog.require('Blockly.ICopyable'); -goog.require('Blockly.IDraggable'); -goog.require('Blockly.internalConstants'); -goog.require('Blockly.Msg'); -goog.require('Blockly.RenderedConnection'); -goog.require('Blockly.TabNavigateCursor'); -goog.require('Blockly.Tooltip'); /** @suppress {extraRequire} */ goog.require('Blockly.Touch'); -goog.require('Blockly.utils'); -goog.require('Blockly.utils.Coordinate'); -goog.require('Blockly.utils.deprecation'); -goog.require('Blockly.utils.dom'); -goog.require('Blockly.utils.object'); -goog.require('Blockly.utils.Rect'); -goog.require('Blockly.utils.Svg'); -goog.require('Blockly.utils.userAgent'); -goog.require('Blockly.Xml'); - -goog.requireType('Blockly.blockRendering.Debug'); -goog.requireType('Blockly.Comment'); -goog.requireType('Blockly.Connection'); -goog.requireType('Blockly.Field'); -goog.requireType('Blockly.Input'); -goog.requireType('Blockly.Mutator'); -goog.requireType('Blockly.Theme'); -goog.requireType('Blockly.Warning'); -goog.requireType('Blockly.WorkspaceSvg'); /** * Class for a block's SVG representation. * Not normally called directly, workspace.newBlock() is preferred. - * @param {!Blockly.WorkspaceSvg} workspace The block's workspace. + * @param {!WorkspaceSvg} workspace The block's workspace. * @param {?string} prototypeName Name of the language object containing * type-specific functions for this block. * @param {string=} opt_id Optional ID. Use this ID if provided, otherwise * create a new ID. - * @extends {Blockly.Block} - * @implements {Blockly.IASTNodeLocationSvg} - * @implements {Blockly.IBoundedElement} - * @implements {Blockly.ICopyable} - * @implements {Blockly.IDraggable} + * @extends {Block} + * @implements {IASTNodeLocationSvg} + * @implements {IBoundedElement} + * @implements {ICopyable} + * @implements {IDraggable} * @constructor */ -Blockly.BlockSvg = function(workspace, prototypeName, opt_id) { +const BlockSvg = function(workspace, prototypeName, opt_id) { // Create core elements for the block. /** * @type {!SVGGElement} * @private */ - this.svgGroup_ = Blockly.utils.dom.createSvgElement( - Blockly.utils.Svg.G, {}, null); + this.svgGroup_ = dom.createSvgElement(Svg.G, {}, null); this.svgGroup_.translate_ = ''; /** * A block style object. - * @type {!Blockly.Theme.BlockStyle} + * @type {!Theme.BlockStyle} */ this.style = workspace.getRenderer().getConstants().getBlockStyle(null); /** * The renderer's path object. - * @type {Blockly.blockRendering.IPathObject} + * @type {IPathObject} * @package */ - this.pathObject = workspace.getRenderer().makePathObject( - this.svgGroup_, this.style); + this.pathObject = + workspace.getRenderer().makePathObject(this.svgGroup_, this.style); /** @type {boolean} */ this.rendered = false; @@ -109,14 +126,14 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) { this.renderIsInProgress_ = false; - /** @type {!Blockly.WorkspaceSvg} */ + /** @type {!WorkspaceSvg} */ this.workspace = workspace; - /** @type {Blockly.RenderedConnection} */ + /** @type {RenderedConnection} */ this.outputConnection = null; - /** @type {Blockly.RenderedConnection} */ + /** @type {RenderedConnection} */ this.nextConnection = null; - /** @type {Blockly.RenderedConnection} */ + /** @type {RenderedConnection} */ this.previousConnection = null; /** @@ -126,36 +143,35 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) { * @private */ this.useDragSurface_ = - Blockly.utils.is3dSupported() && !!workspace.getBlockDragSurface(); + utils.is3dSupported() && !!workspace.getBlockDragSurface(); - var svgPath = this.pathObject.svgPath; + const svgPath = this.pathObject.svgPath; svgPath.tooltip = this; - Blockly.Tooltip.bindMouseEvents(svgPath); - Blockly.BlockSvg.superClass_.constructor.call(this, - workspace, prototypeName, opt_id); + Tooltip.bindMouseEvents(svgPath); + BlockSvg.superClass_.constructor.call(this, workspace, prototypeName, opt_id); // Expose this block's ID on its top-level SVG group. if (this.svgGroup_.dataset) { this.svgGroup_.dataset['id'] = this.id; - } else if (Blockly.utils.userAgent.IE) { + } else if (userAgent.IE) { // SVGElement.dataset is not available on IE11, but data-* properties // can be set with setAttribute(). this.svgGroup_.setAttribute('data-id', this.id); } }; -Blockly.utils.object.inherits(Blockly.BlockSvg, Blockly.Block); +object.inherits(BlockSvg, Block); /** * Height of this block, not including any statement blocks above or below. * Height is in workspace units. */ -Blockly.BlockSvg.prototype.height = 0; +BlockSvg.prototype.height = 0; /** * Width of this block, including any connected value blocks. * Width is in workspace units. */ -Blockly.BlockSvg.prototype.width = 0; +BlockSvg.prototype.width = 0; /** * Map from IDs for warnings text to PIDs of functions to apply them. @@ -163,14 +179,14 @@ Blockly.BlockSvg.prototype.width = 0; * @type {Object} * @private */ -Blockly.BlockSvg.prototype.warningTextDb_ = null; +BlockSvg.prototype.warningTextDb_ = null; /** * Constant for identifying rows that are to be rendered inline. * Don't collide with Blockly.inputTypes. * @const */ -Blockly.BlockSvg.INLINE = -1; +BlockSvg.INLINE = -1; /** * ID to give the "collapsed warnings" warning. Allows us to remove the @@ -179,7 +195,7 @@ Blockly.BlockSvg.INLINE = -1; * @type {string} * @const */ -Blockly.BlockSvg.COLLAPSED_WARNING_ID = 'TEMP_COLLAPSED_WARNING_'; +BlockSvg.COLLAPSED_WARNING_ID = 'TEMP_COLLAPSED_WARNING_'; /** * An optional method called when a mutator dialog is first opened. @@ -188,53 +204,52 @@ Blockly.BlockSvg.COLLAPSED_WARNING_ID = 'TEMP_COLLAPSED_WARNING_'; * block with any sub-blocks which are appropriate. This method must also be * coupled with defining a `compose` method for the default mutation dialog * button and UI to appear. - * @type {?function(Blockly.WorkspaceSvg):!Blockly.BlockSvg} + * @type {?function(WorkspaceSvg):!BlockSvg} */ -Blockly.BlockSvg.prototype.decompose; +BlockSvg.prototype.decompose; /** * An optional method called when a mutator dialog saves its content. * This function is called to modify the original block according to new * settings. This method must also be coupled with defining a `decompose` * method for the default mutation dialog button and UI to appear. - * @type {?function(!Blockly.BlockSvg)} + * @type {?function(!BlockSvg)} */ -Blockly.BlockSvg.prototype.compose; +BlockSvg.prototype.compose; /** * An optional method for defining custom block context menu items. * @type {?function(!Array)} */ -Blockly.BlockSvg.prototype.customContextMenu; +BlockSvg.prototype.customContextMenu; /** * An property used internally to reference the block's rendering debugger. - * @type {?Blockly.blockRendering.Debug} + * @type {?BlockRenderingDebug} * @package */ -Blockly.BlockSvg.prototype.renderingDebugger; +BlockSvg.prototype.renderingDebugger; /** * Create and initialize the SVG representation of the block. * May be called more than once. */ -Blockly.BlockSvg.prototype.initSvg = function() { +BlockSvg.prototype.initSvg = function() { if (!this.workspace.rendered) { throw TypeError('Workspace is headless.'); } - for (var i = 0, input; (input = this.inputList[i]); i++) { + for (let i = 0, input; (input = this.inputList[i]); i++) { input.init(); } - var icons = this.getIcons(); - for (var i = 0; i < icons.length; i++) { + const icons = this.getIcons(); + for (let i = 0; i < icons.length; i++) { icons[i].createIcon(); } this.applyColour(); this.pathObject.updateMovable(this.isMovable()); - var svg = this.getSvgRoot(); + const svg = this.getSvgRoot(); if (!this.workspace.options.readOnly && !this.eventsInit_ && svg) { - Blockly.browserEvents.conditionalBind( - svg, 'mousedown', this, this.onMouseDown_); + browserEvents.conditionalBind(svg, 'mousedown', this, this.onMouseDown_); } this.eventsInit_ = true; @@ -247,7 +262,7 @@ Blockly.BlockSvg.prototype.initSvg = function() { * Get the secondary colour of a block. * @return {?string} #RRGGBB string. */ -Blockly.BlockSvg.prototype.getColourSecondary = function() { +BlockSvg.prototype.getColourSecondary = function() { return this.style.colourSecondary; }; @@ -255,7 +270,7 @@ Blockly.BlockSvg.prototype.getColourSecondary = function() { * Get the tertiary colour of a block. * @return {?string} #RRGGBB string. */ -Blockly.BlockSvg.prototype.getColourTertiary = function() { +BlockSvg.prototype.getColourTertiary = function() { return this.style.colourTertiary; }; @@ -264,11 +279,9 @@ Blockly.BlockSvg.prototype.getColourTertiary = function() { * @return {?string} #RRGGBB string. * @deprecated Use style.colourSecondary. (2020 January 21) */ -Blockly.BlockSvg.prototype.getColourShadow = function() { - Blockly.utils.deprecation.warn( - 'BlockSvg.prototype.getColourShadow', - 'January 2020', - 'January 2021', +BlockSvg.prototype.getColourShadow = function() { + deprecation.warn( + 'BlockSvg.prototype.getColourShadow', 'January 2020', 'January 2021', 'style.colourSecondary'); return this.getColourSecondary(); }; @@ -282,25 +295,19 @@ Blockly.BlockSvg.prototype.getColourShadow = function() { * attributes will be defined (#RRGGBB strings). * @deprecated Use style.colourTertiary. (2020 January 21) */ -Blockly.BlockSvg.prototype.getColourBorder = function() { - Blockly.utils.deprecation.warn( - 'BlockSvg.prototype.getColourBorder', - 'January 2020', - 'January 2021', +BlockSvg.prototype.getColourBorder = function() { + deprecation.warn( + 'BlockSvg.prototype.getColourBorder', 'January 2020', 'January 2021', 'style.colourTertiary'); - var colourTertiary = this.getColourTertiary(); - return { - colourBorder: colourTertiary, - colourLight: null, - colourDark: null - }; + const colourTertiary = this.getColourTertiary(); + return {colourBorder: colourTertiary, colourLight: null, colourDark: null}; }; /** * Selects this block. Highlights the block visually and fires a select event * if the block is not already selected. */ -Blockly.BlockSvg.prototype.select = function() { +BlockSvg.prototype.select = function() { if (this.isShadow() && this.getParent()) { // Shadow blocks should not be selected. this.getParent().select(); @@ -309,20 +316,20 @@ Blockly.BlockSvg.prototype.select = function() { if (Blockly.selected == this) { return; } - var oldId = null; + let oldId = null; if (Blockly.selected) { oldId = Blockly.selected.id; // Unselect any previously selected block. - Blockly.Events.disable(); + Events.disable(); try { Blockly.selected.unselect(); } finally { - Blockly.Events.enable(); + Events.enable(); } } - var event = new (Blockly.Events.get(Blockly.Events.SELECTED))(oldId, this.id, - this.workspace.id); - Blockly.Events.fire(event); + const event = + new (Events.get(Events.SELECTED))(oldId, this.id, this.workspace.id); + Events.fire(event); Blockly.selected = this; this.addSelect(); }; @@ -331,50 +338,50 @@ Blockly.BlockSvg.prototype.select = function() { * Unselects this block. Unhighlights the block and fires a select (false) event * if the block is currently selected. */ -Blockly.BlockSvg.prototype.unselect = function() { +BlockSvg.prototype.unselect = function() { if (Blockly.selected != this) { return; } - var event = new (Blockly.Events.get(Blockly.Events.SELECTED))(this.id, null, - this.workspace.id); + const event = + new (Events.get(Events.SELECTED))(this.id, null, this.workspace.id); event.workspaceId = this.workspace.id; - Blockly.Events.fire(event); + Events.fire(event); Blockly.selected = null; this.removeSelect(); }; /** * Block's mutator icon (if any). - * @type {?Blockly.Mutator} + * @type {?Mutator} */ -Blockly.BlockSvg.prototype.mutator = null; +BlockSvg.prototype.mutator = null; /** * Block's comment icon (if any). - * @type {?Blockly.Comment} + * @type {?Comment} * @deprecated August 2019. Use getCommentIcon instead. */ -Blockly.BlockSvg.prototype.comment = null; +BlockSvg.prototype.comment = null; /** * Block's comment icon (if any). - * @type {?Blockly.Comment} + * @type {?Comment} * @private */ -Blockly.BlockSvg.prototype.commentIcon_ = null; +BlockSvg.prototype.commentIcon_ = null; /** * Block's warning icon (if any). - * @type {?Blockly.Warning} + * @type {?Warning} */ -Blockly.BlockSvg.prototype.warning = null; +BlockSvg.prototype.warning = null; /** * Returns a list of mutator, comment, and warning icons. - * @return {!Array} List of icons. + * @return {!Array} List of icons. */ -Blockly.BlockSvg.prototype.getIcons = function() { - var icons = []; +BlockSvg.prototype.getIcons = function() { + const icons = []; if (this.mutator) { icons.push(this.mutator); } @@ -389,21 +396,21 @@ Blockly.BlockSvg.prototype.getIcons = function() { /** * Sets the parent of this block to be a new block or null. - * @param {?Blockly.Block} newParent New parent block. + * @param {?Block} newParent New parent block. * @package * @override */ -Blockly.BlockSvg.prototype.setParent = function(newParent) { - var oldParent = this.parentBlock_; +BlockSvg.prototype.setParent = function(newParent) { + const oldParent = this.parentBlock_; if (newParent == oldParent) { return; } - Blockly.utils.dom.startTextWidthCache(); - Blockly.BlockSvg.superClass_.setParent.call(this, newParent); - Blockly.utils.dom.stopTextWidthCache(); + dom.startTextWidthCache(); + BlockSvg.superClass_.setParent.call(this, newParent); + dom.stopTextWidthCache(); - var svgRoot = this.getSvgRoot(); + const svgRoot = this.getSvgRoot(); // Bail early if workspace is clearing, or we aren't rendered. // We won't need to reattach ourselves anywhere. @@ -411,10 +418,10 @@ Blockly.BlockSvg.prototype.setParent = function(newParent) { return; } - var oldXY = this.getRelativeToSurfaceXY(); + const oldXY = this.getRelativeToSurfaceXY(); if (newParent) { newParent.getSvgRoot().appendChild(svgRoot); - var newXY = this.getRelativeToSurfaceXY(); + const newXY = this.getRelativeToSurfaceXY(); // Move the connections to match the child's new position. this.moveConnections(newXY.x - oldXY.x, newXY.y - oldXY.y); } @@ -434,37 +441,38 @@ Blockly.BlockSvg.prototype.setParent = function(newParent) { * If the block is on the workspace, (0, 0) is the origin of the workspace * coordinate system. * This does not change with workspace scale. - * @return {!Blockly.utils.Coordinate} Object with .x and .y properties in + * @return {!Coordinate} Object with .x and .y properties in * workspace coordinates. */ -Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() { - var x = 0; - var y = 0; +BlockSvg.prototype.getRelativeToSurfaceXY = function() { + let x = 0; + let y = 0; - var dragSurfaceGroup = this.useDragSurface_ ? - this.workspace.getBlockDragSurface().getGroup() : null; + const dragSurfaceGroup = this.useDragSurface_ ? + this.workspace.getBlockDragSurface().getGroup() : + null; - var element = this.getSvgRoot(); + let element = this.getSvgRoot(); if (element) { do { // Loop through this block and every parent. - var xy = Blockly.utils.getRelativeXY(element); + const xy = utils.getRelativeXY(element); x += xy.x; y += xy.y; // If this element is the current element on the drag surface, include // the translation of the drag surface itself. if (this.useDragSurface_ && this.workspace.getBlockDragSurface().getCurrentBlock() == element) { - var surfaceTranslation = + const surfaceTranslation = this.workspace.getBlockDragSurface().getSurfaceTranslation(); x += surfaceTranslation.x; y += surfaceTranslation.y; } element = /** @type {!SVGElement} */ (element.parentNode); } while (element && element != this.workspace.getCanvas() && - element != dragSurfaceGroup); + element != dragSurfaceGroup); } - return new Blockly.utils.Coordinate(x, y); + return new Coordinate(x, y); }; /** @@ -472,20 +480,21 @@ Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() { * @param {number} dx Horizontal offset in workspace units. * @param {number} dy Vertical offset in workspace units. */ -Blockly.BlockSvg.prototype.moveBy = function(dx, dy) { +BlockSvg.prototype.moveBy = function(dx, dy) { if (this.parentBlock_) { throw Error('Block has parent.'); } - var eventsEnabled = Blockly.Events.isEnabled(); + const eventsEnabled = Events.isEnabled(); + let event; if (eventsEnabled) { - var event = new (Blockly.Events.get(Blockly.Events.BLOCK_MOVE))(this); + event = new (Events.get(Events.BLOCK_MOVE))(this); } - var xy = this.getRelativeToSurfaceXY(); + const xy = this.getRelativeToSurfaceXY(); this.translate(xy.x + dx, xy.y + dy); this.moveConnections(dx, dy); if (eventsEnabled) { event.recordNew(); - Blockly.Events.fire(event); + Events.fire(event); } this.workspace.resizeContents(); }; @@ -496,9 +505,8 @@ Blockly.BlockSvg.prototype.moveBy = function(dx, dy) { * @param {number} x The x coordinate of the translation in workspace units. * @param {number} y The y coordinate of the translation in workspace units. */ -Blockly.BlockSvg.prototype.translate = function(x, y) { - this.getSvgRoot().setAttribute('transform', - 'translate(' + x + ',' + y + ')'); +BlockSvg.prototype.translate = function(x, y) { + this.getSvgRoot().setAttribute('transform', 'translate(' + x + ',' + y + ')'); }; /** @@ -507,7 +515,7 @@ Blockly.BlockSvg.prototype.translate = function(x, y) { * Does nothing if useDragSurface_ is false. * @package */ -Blockly.BlockSvg.prototype.moveToDragSurface = function() { +BlockSvg.prototype.moveToDragSurface = function() { if (!this.useDragSurface_) { return; } @@ -515,11 +523,11 @@ Blockly.BlockSvg.prototype.moveToDragSurface = function() { // is equal to the current relative-to-surface position, // to keep the position in sync as it move on/off the surface. // This is in workspace coordinates. - var xy = this.getRelativeToSurfaceXY(); + const xy = this.getRelativeToSurfaceXY(); this.clearTransformAttributes_(); this.workspace.getBlockDragSurface().translateSurface(xy.x, xy.y); // Execute the move on the top-level SVG component - var svg = this.getSvgRoot(); + const svg = this.getSvgRoot(); if (svg) { this.workspace.getBlockDragSurface().setBlocksAndShow(svg); } @@ -527,10 +535,10 @@ Blockly.BlockSvg.prototype.moveToDragSurface = function() { /** * Move a block to a position. - * @param {Blockly.utils.Coordinate} xy The position to move to in workspace units. + * @param {Coordinate} xy The position to move to in workspace units. */ -Blockly.BlockSvg.prototype.moveTo = function(xy) { - var curXY = this.getRelativeToSurfaceXY(); +BlockSvg.prototype.moveTo = function(xy) { + const curXY = this.getRelativeToSurfaceXY(); this.moveBy(xy.x - curXY.x, xy.y - curXY.y); }; @@ -538,11 +546,11 @@ Blockly.BlockSvg.prototype.moveTo = function(xy) { * Move this block back to the workspace block canvas. * Generally should be called at the same time as setDragging_(false). * Does nothing if useDragSurface_ is false. - * @param {!Blockly.utils.Coordinate} newXY The position the block should take on + * @param {!Coordinate} newXY The position the block should take on * on the workspace canvas, in workspace coordinates. * @package */ -Blockly.BlockSvg.prototype.moveOffDragSurface = function(newXY) { +BlockSvg.prototype.moveOffDragSurface = function(newXY) { if (!this.useDragSurface_) { return; } @@ -555,17 +563,17 @@ Blockly.BlockSvg.prototype.moveOffDragSurface = function(newXY) { * Move this block during a drag, taking into account whether we are using a * drag surface to translate blocks. * This block must be a top-level block. - * @param {!Blockly.utils.Coordinate} newLoc The location to translate to, in + * @param {!Coordinate} newLoc The location to translate to, in * workspace coordinates. * @package */ -Blockly.BlockSvg.prototype.moveDuringDrag = function(newLoc) { +BlockSvg.prototype.moveDuringDrag = function(newLoc) { if (this.useDragSurface_) { this.workspace.getBlockDragSurface().translateSurface(newLoc.x, newLoc.y); } else { this.svgGroup_.translate_ = 'translate(' + newLoc.x + ',' + newLoc.y + ')'; - this.svgGroup_.setAttribute('transform', - this.svgGroup_.translate_ + this.svgGroup_.skew_); + this.svgGroup_.setAttribute( + 'transform', this.svgGroup_.translate_ + this.svgGroup_.skew_); } }; @@ -574,14 +582,14 @@ Blockly.BlockSvg.prototype.moveDuringDrag = function(newLoc) { * Used when the block is switching from 3d to 2d transform or vice versa. * @private */ -Blockly.BlockSvg.prototype.clearTransformAttributes_ = function() { +BlockSvg.prototype.clearTransformAttributes_ = function() { this.getSvgRoot().removeAttribute('transform'); }; /** * Snap this block to the nearest grid point. */ -Blockly.BlockSvg.prototype.snapToGrid = function() { +BlockSvg.prototype.snapToGrid = function() { if (!this.workspace) { return; // Deleted block. } @@ -594,18 +602,18 @@ Blockly.BlockSvg.prototype.snapToGrid = function() { if (this.isInFlyout) { return; // Don't move blocks around in a flyout. } - var grid = this.workspace.getGrid(); + const grid = this.workspace.getGrid(); if (!grid || !grid.shouldSnap()) { return; // Config says no snapping. } - var spacing = grid.getSpacing(); - var half = spacing / 2; - var xy = this.getRelativeToSurfaceXY(); - var dx = Math.round((xy.x - half) / spacing) * spacing + half - xy.x; - var dy = Math.round((xy.y - half) / spacing) * spacing + half - xy.y; - dx = Math.round(dx); - dy = Math.round(dy); - if (dx != 0 || dy != 0) { + const spacing = grid.getSpacing(); + const half = spacing / 2; + const xy = this.getRelativeToSurfaceXY(); + const dx = + Math.round(Math.round((xy.x - half) / spacing) * spacing + half - xy.x); + const dy = + Math.round(Math.round((xy.y - half) / spacing) * spacing + half - xy.y); + if (dx || dy) { this.moveBy(dx, dy); } }; @@ -614,12 +622,13 @@ Blockly.BlockSvg.prototype.snapToGrid = function() { * Returns the coordinates of a bounding box describing the dimensions of this * block and any blocks stacked below it. * Coordinate system: workspace coordinates. - * @return {!Blockly.utils.Rect} Object with coordinates of the bounding box. + * @return {!Rect} Object with coordinates of the bounding box. */ -Blockly.BlockSvg.prototype.getBoundingRectangle = function() { - var blockXY = this.getRelativeToSurfaceXY(); - var blockBounds = this.getHeightWidth(); - var left, right; +BlockSvg.prototype.getBoundingRectangle = function() { + const blockXY = this.getRelativeToSurfaceXY(); + const blockBounds = this.getHeightWidth(); + let left; + let right; if (this.RTL) { left = blockXY.x - blockBounds.width; right = blockXY.x; @@ -627,19 +636,18 @@ Blockly.BlockSvg.prototype.getBoundingRectangle = function() { left = blockXY.x; right = blockXY.x + blockBounds.width; } - return new Blockly.utils.Rect( - blockXY.y, blockXY.y + blockBounds.height, left, right); + return new Rect(blockXY.y, blockXY.y + blockBounds.height, left, right); }; /** * Notify every input on this block to mark its fields as dirty. * A dirty field is a field that needs to be re-rendered. */ -Blockly.BlockSvg.prototype.markDirty = function() { - this.pathObject.constants = - (/** @type {!Blockly.WorkspaceSvg} */ (this.workspace)) - .getRenderer().getConstants(); - for (var i = 0, input; (input = this.inputList[i]); i++) { +BlockSvg.prototype.markDirty = function() { + this.pathObject.constants = (/** @type {!WorkspaceSvg} */ (this.workspace)) + .getRenderer() + .getConstants(); + for (let i = 0, input; (input = this.inputList[i]); i++) { input.markDirty(); } }; @@ -648,11 +656,11 @@ Blockly.BlockSvg.prototype.markDirty = function() { * Set whether the block is collapsed or not. * @param {boolean} collapsed True if collapsed. */ -Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) { +BlockSvg.prototype.setCollapsed = function(collapsed) { if (this.collapsed_ == collapsed) { return; } - Blockly.BlockSvg.superClass_.setCollapsed.call(this, collapsed); + BlockSvg.superClass_.setCollapsed.call(this, collapsed); if (!collapsed) { this.updateCollapsed_(); } else if (this.rendered) { @@ -667,12 +675,12 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) { * for that state. * @private */ -Blockly.BlockSvg.prototype.updateCollapsed_ = function() { - var collapsed = this.isCollapsed(); - var collapsedInputName = Blockly.constants.COLLAPSED_INPUT_NAME; - var collapsedFieldName = Blockly.constants.COLLAPSED_FIELD_NAME; +BlockSvg.prototype.updateCollapsed_ = function() { + const collapsed = this.isCollapsed(); + const collapsedInputName = constants.COLLAPSED_INPUT_NAME; + const collapsedFieldName = constants.COLLAPSED_FIELD_NAME; - for (var i = 0, input; (input = this.inputList[i]); i++) { + for (let i = 0, input; (input = this.inputList[i]); i++) { if (input.name != collapsedInputName) { input.setVisible(!collapsed); } @@ -684,31 +692,31 @@ Blockly.BlockSvg.prototype.updateCollapsed_ = function() { return; } - var icons = this.getIcons(); - for (var i = 0, icon; (icon = icons[i]); i++) { + const icons = this.getIcons(); + for (let i = 0, icon; (icon = icons[i]); i++) { icon.setVisible(false); } - var text = this.toString(Blockly.internalConstants.COLLAPSE_CHARS); - var field = this.getField(collapsedFieldName); + const text = this.toString(internalConstants.COLLAPSE_CHARS); + const field = this.getField(collapsedFieldName); if (field) { field.setValue(text); return; } - var input = this.getInput(collapsedInputName) || + const input = this.getInput(collapsedInputName) || this.appendDummyInput(collapsedInputName); - input.appendField(new Blockly.FieldLabel(text), collapsedFieldName); + input.appendField(new FieldLabel(text), collapsedFieldName); }; /** * Open the next (or previous) FieldTextInput. - * @param {!Blockly.Field} start Current field. + * @param {!Field} start Current field. * @param {boolean} forward If true go forward, otherwise backward. */ -Blockly.BlockSvg.prototype.tab = function(start, forward) { - var tabCursor = new Blockly.TabNavigateCursor(); - tabCursor.setCurNode(Blockly.ASTNode.createFieldNode(start)); - var currentNode = tabCursor.getCurNode(); +BlockSvg.prototype.tab = function(start, forward) { + const tabCursor = new TabNavigateCursor(); + tabCursor.setCurNode(ASTNode.createFieldNode(start)); + const currentNode = tabCursor.getCurNode(); if (forward) { tabCursor.next(); @@ -716,9 +724,9 @@ Blockly.BlockSvg.prototype.tab = function(start, forward) { tabCursor.prev(); } - var nextNode = tabCursor.getCurNode(); + const nextNode = tabCursor.getCurNode(); if (nextNode && nextNode !== currentNode) { - var nextField = /** @type {!Blockly.Field} */ (nextNode.getLocation()); + const nextField = /** @type {!Field} */ (nextNode.getLocation()); nextField.showEditor(); // Also move the cursor if we're in keyboard nav mode. @@ -733,8 +741,8 @@ Blockly.BlockSvg.prototype.tab = function(start, forward) { * @param {!Event} e Mouse down event or touch start event. * @private */ -Blockly.BlockSvg.prototype.onMouseDown_ = function(e) { - var gesture = this.workspace && this.workspace.getGesture(e); +BlockSvg.prototype.onMouseDown_ = function(e) { + const gesture = this.workspace && this.workspace.getGesture(e); if (gesture) { gesture.handleBlockStart(e, this); } @@ -744,8 +752,9 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) { * Load the block's help page in a new window. * @package */ -Blockly.BlockSvg.prototype.showHelp = function() { - var url = (typeof this.helpUrl == 'function') ? this.helpUrl() : this.helpUrl; +BlockSvg.prototype.showHelp = function() { + const url = + (typeof this.helpUrl == 'function') ? this.helpUrl() : this.helpUrl; if (url) { window.open(url); } @@ -756,12 +765,12 @@ Blockly.BlockSvg.prototype.showHelp = function() { * @return {?Array} Context menu options or null if no menu. * @protected */ -Blockly.BlockSvg.prototype.generateContextMenu = function() { +BlockSvg.prototype.generateContextMenu = function() { if (this.workspace.options.readOnly || !this.contextMenu) { return null; } - var menuOptions = Blockly.ContextMenuRegistry.registry.getContextMenuOptions( - Blockly.ContextMenuRegistry.ScopeType.BLOCK, {block: this}); + const menuOptions = ContextMenuRegistry.registry.getContextMenuOptions( + ContextMenuRegistry.ScopeType.BLOCK, {block: this}); // Allow the block to add or modify menuOptions. if (this.customContextMenu) { @@ -776,12 +785,12 @@ Blockly.BlockSvg.prototype.generateContextMenu = function() { * @param {!Event} e Mouse event. * @package */ -Blockly.BlockSvg.prototype.showContextMenu = function(e) { - var menuOptions = this.generateContextMenu(); +BlockSvg.prototype.showContextMenu = function(e) { + const menuOptions = this.generateContextMenu(); if (menuOptions && menuOptions.length) { - Blockly.ContextMenu.show(e, menuOptions, this.RTL); - Blockly.ContextMenu.setCurrentBlock(this); + ContextMenu.show(e, menuOptions, this.RTL); + ContextMenu.setCurrentBlock(this); } }; @@ -794,23 +803,23 @@ Blockly.BlockSvg.prototype.showContextMenu = function(e) { * units. * @package */ -Blockly.BlockSvg.prototype.moveConnections = function(dx, dy) { +BlockSvg.prototype.moveConnections = function(dx, dy) { if (!this.rendered) { // Rendering is required to lay out the blocks. // This is probably an invisible block attached to a collapsed block. return; } - var myConnections = this.getConnections_(false); - for (var i = 0; i < myConnections.length; i++) { + const myConnections = this.getConnections_(false); + for (let i = 0; i < myConnections.length; i++) { myConnections[i].moveBy(dx, dy); } - var icons = this.getIcons(); - for (var i = 0; i < icons.length; i++) { + const icons = this.getIcons(); + for (let i = 0; i < icons.length; i++) { icons[i].computeIconLocation(); } // Recurse through all blocks attached under this one. - for (var i = 0; i < this.childBlocks_.length; i++) { + for (let i = 0; i < this.childBlocks_.length; i++) { this.childBlocks_[i].moveConnections(dx, dy); } }; @@ -820,21 +829,21 @@ Blockly.BlockSvg.prototype.moveConnections = function(dx, dy) { * @param {boolean} adding True if adding, false if removing. * @package */ -Blockly.BlockSvg.prototype.setDragging = function(adding) { +BlockSvg.prototype.setDragging = function(adding) { if (adding) { - var group = this.getSvgRoot(); + const group = this.getSvgRoot(); group.translate_ = ''; group.skew_ = ''; - Blockly.common.draggingConnections.push(...this.getConnections_(true)); - Blockly.utils.dom.addClass( + common.draggingConnections.push(...this.getConnections_(true)); + dom.addClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDragging'); } else { - Blockly.common.draggingConnections.length = 0; - Blockly.utils.dom.removeClass( + common.draggingConnections.length = 0; + dom.removeClass( /** @type {!Element} */ (this.svgGroup_), 'blocklyDragging'); } // Recurse through all blocks attached under this one. - for (var i = 0; i < this.childBlocks_.length; i++) { + for (let i = 0; i < this.childBlocks_.length; i++) { this.childBlocks_[i].setDragging(adding); } }; @@ -843,8 +852,8 @@ Blockly.BlockSvg.prototype.setDragging = function(adding) { * Set whether this block is movable or not. * @param {boolean} movable True if movable. */ -Blockly.BlockSvg.prototype.setMovable = function(movable) { - Blockly.BlockSvg.superClass_.setMovable.call(this, movable); +BlockSvg.prototype.setMovable = function(movable) { + BlockSvg.superClass_.setMovable.call(this, movable); this.pathObject.updateMovable(movable); }; @@ -852,10 +861,10 @@ Blockly.BlockSvg.prototype.setMovable = function(movable) { * Set whether this block is editable or not. * @param {boolean} editable True if editable. */ -Blockly.BlockSvg.prototype.setEditable = function(editable) { - Blockly.BlockSvg.superClass_.setEditable.call(this, editable); - var icons = this.getIcons(); - for (var i = 0; i < icons.length; i++) { +BlockSvg.prototype.setEditable = function(editable) { + BlockSvg.superClass_.setEditable.call(this, editable); + const icons = this.getIcons(); + for (let i = 0; i < icons.length; i++) { icons[i].updateEditable(); } }; @@ -865,8 +874,8 @@ Blockly.BlockSvg.prototype.setEditable = function(editable) { * @param {boolean} shadow True if a shadow. * @package */ -Blockly.BlockSvg.prototype.setShadow = function(shadow) { - Blockly.BlockSvg.superClass_.setShadow.call(this, shadow); +BlockSvg.prototype.setShadow = function(shadow) { + BlockSvg.superClass_.setShadow.call(this, shadow); this.applyColour(); }; @@ -876,14 +885,14 @@ Blockly.BlockSvg.prototype.setShadow = function(shadow) { * @param {boolean} insertionMarker True if an insertion marker. * @package */ -Blockly.BlockSvg.prototype.setInsertionMarker = function(insertionMarker) { +BlockSvg.prototype.setInsertionMarker = function(insertionMarker) { if (this.isInsertionMarker_ == insertionMarker) { return; // No change. } this.isInsertionMarker_ = insertionMarker; if (this.isInsertionMarker_) { - this.setColour(this.workspace.getRenderer().getConstants(). - INSERTION_MARKER_COLOUR); + this.setColour( + this.workspace.getRenderer().getConstants().INSERTION_MARKER_COLOUR); this.pathObject.updateInsertionMarker(true); } }; @@ -892,7 +901,7 @@ Blockly.BlockSvg.prototype.setInsertionMarker = function(insertionMarker) { * Return the root node of the SVG or null if none exists. * @return {!SVGGElement} The root SVG node (probably a group). */ -Blockly.BlockSvg.prototype.getSvgRoot = function() { +BlockSvg.prototype.getSvgRoot = function() { return this.svgGroup_; }; @@ -904,76 +913,76 @@ Blockly.BlockSvg.prototype.getSvgRoot = function() { * @param {boolean=} animate If true, show a disposal animation and sound. * @suppress {checkTypes} */ -Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { +BlockSvg.prototype.dispose = function(healStack, animate) { if (!this.workspace) { // The block has already been deleted. return; } - Blockly.Tooltip.dispose(); - Blockly.Tooltip.unbindMouseEvents(this.pathObject.svgPath); - Blockly.utils.dom.startTextWidthCache(); + Tooltip.dispose(); + Tooltip.unbindMouseEvents(this.pathObject.svgPath); + dom.startTextWidthCache(); // Save the block's workspace temporarily so we can resize the // contents once the block is disposed. - var blockWorkspace = this.workspace; + const blockWorkspace = this.workspace; // If this block is being dragged, unlink the mouse events. if (Blockly.selected == this) { this.unselect(); this.workspace.cancelCurrentGesture(); } // If this block has a context menu open, close it. - if (Blockly.ContextMenu.getCurrentBlock() == this) { - Blockly.ContextMenu.hide(); + if (ContextMenu.getCurrentBlock() == this) { + ContextMenu.hide(); } if (animate && this.rendered) { this.unplug(healStack); - Blockly.blockAnimations.disposeUiEffect(this); + blockAnimations.disposeUiEffect(this); } // Stop rerendering. this.rendered = false; // Clear pending warnings. if (this.warningTextDb_) { - for (var n in this.warningTextDb_) { + for (const n in this.warningTextDb_) { clearTimeout(this.warningTextDb_[n]); } this.warningTextDb_ = null; } - var icons = this.getIcons(); - for (var i = 0; i < icons.length; i++) { + const icons = this.getIcons(); + for (let i = 0; i < icons.length; i++) { icons[i].dispose(); } - Blockly.BlockSvg.superClass_.dispose.call(this, !!healStack); + BlockSvg.superClass_.dispose.call(this, !!healStack); - Blockly.utils.dom.removeNode(this.svgGroup_); + dom.removeNode(this.svgGroup_); blockWorkspace.resizeContents(); // Sever JavaScript to DOM connections. this.svgGroup_ = null; - Blockly.utils.dom.stopTextWidthCache(); + dom.stopTextWidthCache(); }; /** * Encode a block for copying. - * @return {?Blockly.ICopyable.CopyData} Copy metadata, or null if the block is + * @return {?ICopyable.CopyData} Copy metadata, or null if the block is * an insertion marker. * @package */ -Blockly.BlockSvg.prototype.toCopyData = function() { +BlockSvg.prototype.toCopyData = function() { if (this.isInsertionMarker_) { return null; } - var xml = /** @type {!Element} */ (Blockly.Xml.blockToDom(this, true)); + const xml = /** @type {!Element} */ (Xml.blockToDom(this, true)); // Copy only the selected block and internal blocks. - Blockly.Xml.deleteNext(xml); + Xml.deleteNext(xml); // Encode start position in XML. - var xy = this.getRelativeToSurfaceXY(); + const xy = this.getRelativeToSurfaceXY(); xml.setAttribute('x', this.RTL ? -xy.x : xy.x); xml.setAttribute('y', xy.y); return { xml: xml, source: this.workspace, - typeCounts: Blockly.utils.getBlockTypeCounts(this, true) + typeCounts: utils.getBlockTypeCounts(this, true) }; }; @@ -981,16 +990,16 @@ Blockly.BlockSvg.prototype.toCopyData = function() { * Updates the colour of the block to match the block's state. * @package */ -Blockly.BlockSvg.prototype.applyColour = function() { +BlockSvg.prototype.applyColour = function() { this.pathObject.applyColour(this); - var icons = this.getIcons(); - for (var i = 0; i < icons.length; i++) { + const icons = this.getIcons(); + for (let i = 0; i < icons.length; i++) { icons[i].applyColour(); } - for (var x = 0, input; (input = this.inputList[x]); x++) { - for (var y = 0, field; (field = input.fieldRow[y]); y++) { + for (let x = 0, input; (input = this.inputList[x]); x++) { + for (let y = 0, field; (field = input.fieldRow[y]); y++) { field.applyColour(); } } @@ -1001,13 +1010,13 @@ Blockly.BlockSvg.prototype.applyColour = function() { * state. * @package */ -Blockly.BlockSvg.prototype.updateDisabled = function() { - var children = this.getChildren(false); +BlockSvg.prototype.updateDisabled = function() { + const children = this.getChildren(false); this.applyColour(); if (this.isCollapsed()) { return; } - for (var i = 0, child; (child = children[i]); i++) { + for (let i = 0, child; (child = children[i]); i++) { if (child.rendered) { child.updateDisabled(); } @@ -1017,9 +1026,9 @@ Blockly.BlockSvg.prototype.updateDisabled = function() { /** * Get the comment icon attached to this block, or null if the block has no * comment. - * @return {?Blockly.Comment} The comment icon attached to this block, or null. + * @return {?Comment} The comment icon attached to this block, or null. */ -Blockly.BlockSvg.prototype.getCommentIcon = function() { +BlockSvg.prototype.getCommentIcon = function() { return this.commentIcon_; }; @@ -1027,16 +1036,17 @@ Blockly.BlockSvg.prototype.getCommentIcon = function() { * Set this block's comment text. * @param {?string} text The text, or null to delete. */ -Blockly.BlockSvg.prototype.setCommentText = function(text) { - if (!Blockly.Comment) { +BlockSvg.prototype.setCommentText = function(text) { + const Comment = goog.module.get('Blockly.Comment'); + if (!Comment) { throw Error('Missing require for Blockly.Comment'); } if (this.commentModel.text == text) { return; } - Blockly.BlockSvg.superClass_.setCommentText.call(this, text); + BlockSvg.superClass_.setCommentText.call(this, text); - var shouldHaveComment = text != null; + const shouldHaveComment = text != null; if (!!this.commentIcon_ == shouldHaveComment) { // If the comment's state of existence is correct, but the text is new // that means we're just updating a comment. @@ -1044,7 +1054,7 @@ Blockly.BlockSvg.prototype.setCommentText = function(text) { return; } if (shouldHaveComment) { - this.commentIcon_ = new Blockly.Comment(this); + this.commentIcon_ = new Comment(this); this.comment = this.commentIcon_; // For backwards compatibility. } else { this.commentIcon_.dispose(); @@ -1064,8 +1074,9 @@ Blockly.BlockSvg.prototype.setCommentText = function(text) { * @param {string=} opt_id An optional ID for the warning text to be able to * maintain multiple warnings. */ -Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) { - if (!Blockly.Warning) { +BlockSvg.prototype.setWarningText = function(text, opt_id) { + const Warning = goog.module.get('Blockly.Warning'); + if (!Warning) { throw Error('Missing require for Blockly.Warning'); } if (!this.warningTextDb_) { @@ -1073,10 +1084,10 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) { // Only runs once per block (and only those with warnings). this.warningTextDb_ = Object.create(null); } - var id = opt_id || ''; + const id = opt_id || ''; if (!id) { // Kill all previous pending processes, this edit supersedes them all. - for (var n in this.warningTextDb_) { + for (const n of Object.keys(this.warningTextDb_)) { clearTimeout(this.warningTextDb_[n]); delete this.warningTextDb_[n]; } @@ -1088,7 +1099,7 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) { if (this.workspace.isDragging()) { // Don't change the warning text during a drag. // Wait until the drag finishes. - var thisBlock = this; + const thisBlock = this; this.warningTextDb_[id] = setTimeout(function() { if (thisBlock.workspace) { // Check block wasn't deleted. delete thisBlock.warningTextDb_[id]; @@ -1101,11 +1112,11 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) { text = null; } - var changedState = false; + let changedState = false; if (typeof text == 'string') { // Bubble up to add a warning on top-most collapsed block. - var parent = this.getSurroundParent(); - var collapsedParent = null; + let parent = this.getSurroundParent(); + let collapsedParent = null; while (parent) { if (parent.isCollapsed()) { collapsedParent = parent; @@ -1113,12 +1124,12 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) { parent = parent.getSurroundParent(); } if (collapsedParent) { - collapsedParent.setWarningText(Blockly.Msg['COLLAPSED_WARNINGS_WARNING'], - Blockly.BlockSvg.COLLAPSED_WARNING_ID); + collapsedParent.setWarningText( + Msg['COLLAPSED_WARNINGS_WARNING'], BlockSvg.COLLAPSED_WARNING_ID); } if (!this.warning) { - this.warning = new Blockly.Warning(this); + this.warning = new Warning(this); changedState = true; } this.warning.setText(/** @type {string} */ (text), id); @@ -1128,9 +1139,9 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) { this.warning.dispose(); changedState = true; } else if (this.warning) { - var oldText = this.warning.getText(); + const oldText = this.warning.getText(); this.warning.setText('', id); - var newText = this.warning.getText(); + const newText = this.warning.getText(); if (!newText) { this.warning.dispose(); } @@ -1146,9 +1157,9 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) { /** * Give this block a mutator dialog. - * @param {?Blockly.Mutator} mutator A mutator dialog instance or null to remove. + * @param {?Mutator} mutator A mutator dialog instance or null to remove. */ -Blockly.BlockSvg.prototype.setMutator = function(mutator) { +BlockSvg.prototype.setMutator = function(mutator) { if (this.mutator && this.mutator !== mutator) { this.mutator.dispose(); } @@ -1168,9 +1179,9 @@ Blockly.BlockSvg.prototype.setMutator = function(mutator) { * Set whether the block is enabled or not. * @param {boolean} enabled True if enabled. */ -Blockly.BlockSvg.prototype.setEnabled = function(enabled) { +BlockSvg.prototype.setEnabled = function(enabled) { if (this.isEnabled() != enabled) { - Blockly.BlockSvg.superClass_.setEnabled.call(this, enabled); + BlockSvg.superClass_.setEnabled.call(this, enabled); if (this.rendered && !this.getInheritedDisabled()) { this.updateDisabled(); } @@ -1182,7 +1193,7 @@ Blockly.BlockSvg.prototype.setEnabled = function(enabled) { * often used to visually mark blocks currently being executed. * @param {boolean} highlighted True if highlighted. */ -Blockly.BlockSvg.prototype.setHighlighted = function(highlighted) { +BlockSvg.prototype.setHighlighted = function(highlighted) { if (!this.rendered) { return; } @@ -1192,18 +1203,18 @@ Blockly.BlockSvg.prototype.setHighlighted = function(highlighted) { /** * Adds the visual "select" effect to the block, but does not actually select * it or fire an event. - * @see Blockly.BlockSvg#select + * @see BlockSvg#select */ -Blockly.BlockSvg.prototype.addSelect = function() { +BlockSvg.prototype.addSelect = function() { this.pathObject.updateSelected(true); }; /** * Removes the visual "select" effect from the block, but does not actually * unselect it or fire an event. - * @see Blockly.BlockSvg#unselect + * @see BlockSvg#unselect */ -Blockly.BlockSvg.prototype.removeSelect = function() { +BlockSvg.prototype.removeSelect = function() { this.pathObject.updateSelected(false); }; @@ -1213,7 +1224,7 @@ Blockly.BlockSvg.prototype.removeSelect = function() { * otherwise. * @package */ -Blockly.BlockSvg.prototype.setDeleteStyle = function(enable) { +BlockSvg.prototype.setDeleteStyle = function(enable) { this.pathObject.updateDraggingDelete(enable); }; @@ -1224,7 +1235,7 @@ Blockly.BlockSvg.prototype.setDeleteStyle = function(enable) { * Get the colour of a block. * @return {string} #RRGGBB string. */ -Blockly.BlockSvg.prototype.getColour = function() { +BlockSvg.prototype.getColour = function() { return this.style.colourPrimary; }; @@ -1232,10 +1243,11 @@ Blockly.BlockSvg.prototype.getColour = function() { * Change the colour of a block. * @param {number|string} colour HSV hue value, or #RRGGBB string. */ -Blockly.BlockSvg.prototype.setColour = function(colour) { - Blockly.BlockSvg.superClass_.setColour.call(this, colour); - var styleObj = this.workspace.getRenderer().getConstants() - .getBlockStyleForColour(this.colour_); +BlockSvg.prototype.setColour = function(colour) { + BlockSvg.superClass_.setColour.call(this, colour); + const styleObj = + this.workspace.getRenderer().getConstants().getBlockStyleForColour( + this.colour_); this.pathObject.setStyle(styleObj.style); this.style = styleObj.style; @@ -1249,9 +1261,9 @@ Blockly.BlockSvg.prototype.setColour = function(colour) { * @param {string} blockStyleName Name of the block style. * @throws {Error} if the block style does not exist. */ -Blockly.BlockSvg.prototype.setStyle = function(blockStyleName) { - var blockStyle = this.workspace.getRenderer() - .getConstants().getBlockStyle(blockStyleName); +BlockSvg.prototype.setStyle = function(blockStyleName) { + const blockStyle = + this.workspace.getRenderer().getConstants().getBlockStyle(blockStyleName); this.styleName_ = blockStyleName; if (blockStyle) { @@ -1274,12 +1286,12 @@ Blockly.BlockSvg.prototype.setStyle = function(blockStyleName) { * block group's , it will render on top of any other blocks. * @package */ -Blockly.BlockSvg.prototype.bringToFront = function() { - var block = this; +BlockSvg.prototype.bringToFront = function() { + let block = this; do { - var root = block.getSvgRoot(); - var parent = root.parentNode; - var childNodes = parent.childNodes; + const root = block.getSvgRoot(); + const parent = root.parentNode; + const childNodes = parent.childNodes; // Avoid moving the block if it's already at the bottom. if (childNodes[childNodes.length - 1] !== root) { parent.appendChild(root); @@ -1294,10 +1306,8 @@ Blockly.BlockSvg.prototype.bringToFront = function() { * @param {(string|Array|null)=} opt_check Statement type or * list of statement types. Null/undefined if any type could be connected. */ -Blockly.BlockSvg.prototype.setPreviousStatement = function(newBoolean, - opt_check) { - Blockly.BlockSvg.superClass_.setPreviousStatement.call(this, newBoolean, - opt_check); +BlockSvg.prototype.setPreviousStatement = function(newBoolean, opt_check) { + BlockSvg.superClass_.setPreviousStatement.call(this, newBoolean, opt_check); if (this.rendered) { this.render(); @@ -1311,9 +1321,8 @@ Blockly.BlockSvg.prototype.setPreviousStatement = function(newBoolean, * @param {(string|Array|null)=} opt_check Statement type or * list of statement types. Null/undefined if any type could be connected. */ -Blockly.BlockSvg.prototype.setNextStatement = function(newBoolean, opt_check) { - Blockly.BlockSvg.superClass_.setNextStatement.call(this, newBoolean, - opt_check); +BlockSvg.prototype.setNextStatement = function(newBoolean, opt_check) { + BlockSvg.superClass_.setNextStatement.call(this, newBoolean, opt_check); if (this.rendered) { this.render(); @@ -1328,8 +1337,8 @@ Blockly.BlockSvg.prototype.setNextStatement = function(newBoolean, opt_check) { * of returned types. Null or undefined if any type could be returned * (e.g. variable get). */ -Blockly.BlockSvg.prototype.setOutput = function(newBoolean, opt_check) { - Blockly.BlockSvg.superClass_.setOutput.call(this, newBoolean, opt_check); +BlockSvg.prototype.setOutput = function(newBoolean, opt_check) { + BlockSvg.superClass_.setOutput.call(this, newBoolean, opt_check); if (this.rendered) { this.render(); @@ -1341,8 +1350,8 @@ Blockly.BlockSvg.prototype.setOutput = function(newBoolean, opt_check) { * Set whether value inputs are arranged horizontally or vertically. * @param {boolean} newBoolean True if inputs are horizontal. */ -Blockly.BlockSvg.prototype.setInputsInline = function(newBoolean) { - Blockly.BlockSvg.superClass_.setInputsInline.call(this, newBoolean); +BlockSvg.prototype.setInputsInline = function(newBoolean) { + BlockSvg.superClass_.setInputsInline.call(this, newBoolean); if (this.rendered) { this.render(); @@ -1354,12 +1363,12 @@ Blockly.BlockSvg.prototype.setInputsInline = function(newBoolean) { * Remove an input from this block. * @param {string} name The name of the input. * @param {boolean=} opt_quiet True to prevent error if input is not present. - * @return {boolean} True if operation succeeds, false if input is not present and opt_quiet is true - * @throws {Error} if the input is not present and - * opt_quiet is not true. + * @return {boolean} True if operation succeeds, false if input is not present + * and opt_quiet is true + * @throws {Error} if the input is not present and opt_quiet is not true. */ -Blockly.BlockSvg.prototype.removeInput = function(name, opt_quiet) { - var removed = Blockly.BlockSvg.superClass_.removeInput.call(this, name, opt_quiet); +BlockSvg.prototype.removeInput = function(name, opt_quiet) { + const removed = BlockSvg.superClass_.removeInput.call(this, name, opt_quiet); if (this.rendered) { this.render(); @@ -1375,10 +1384,8 @@ Blockly.BlockSvg.prototype.removeInput = function(name, opt_quiet) { * @param {number} inputIndex Index of the input to move. * @param {number} refIndex Index of input that should be after the moved input. */ -Blockly.BlockSvg.prototype.moveNumberedInputBefore = function( - inputIndex, refIndex) { - Blockly.BlockSvg.superClass_.moveNumberedInputBefore.call(this, inputIndex, - refIndex); +BlockSvg.prototype.moveNumberedInputBefore = function(inputIndex, refIndex) { + BlockSvg.superClass_.moveNumberedInputBefore.call(this, inputIndex, refIndex); if (this.rendered) { this.render(); @@ -1392,12 +1399,12 @@ Blockly.BlockSvg.prototype.moveNumberedInputBefore = function( * @param {number} type One of Blockly.inputTypes. * @param {string} name Language-neutral identifier which may used to find this * input again. Should be unique to this block. - * @return {!Blockly.Input} The input object created. + * @return {!Input} The input object created. * @protected * @override */ -Blockly.BlockSvg.prototype.appendInput_ = function(type, name) { - var input = Blockly.BlockSvg.superClass_.appendInput_.call(this, type, name); +BlockSvg.prototype.appendInput_ = function(type, name) { + const input = BlockSvg.superClass_.appendInput_.call(this, type, name); if (this.rendered) { this.render(); @@ -1416,7 +1423,7 @@ Blockly.BlockSvg.prototype.appendInput_ = function(type, name) { * @param {boolean} track If true, start tracking. If false, stop tracking. * @package */ -Blockly.BlockSvg.prototype.setConnectionTracking = function(track) { +BlockSvg.prototype.setConnectionTracking = function(track) { if (this.previousConnection) { this.previousConnection.setTracking(track); } @@ -1425,7 +1432,7 @@ Blockly.BlockSvg.prototype.setConnectionTracking = function(track) { } if (this.nextConnection) { this.nextConnection.setTracking(track); - var child = this.nextConnection.targetBlock(); + const child = this.nextConnection.targetBlock(); if (child) { child.setConnectionTracking(track); } @@ -1438,13 +1445,13 @@ Blockly.BlockSvg.prototype.setConnectionTracking = function(track) { return; } - for (var i = 0; i < this.inputList.length; i++) { - var conn = this.inputList[i].connection; + for (let i = 0; i < this.inputList.length; i++) { + const conn = this.inputList[i].connection; if (conn) { conn.setTracking(track); // Pass tracking on down the chain. - var block = conn.targetBlock(); + const block = conn.targetBlock(); if (block) { block.setConnectionTracking(track); } @@ -1457,11 +1464,11 @@ Blockly.BlockSvg.prototype.setConnectionTracking = function(track) { * @param {boolean} all If true, return all connections even hidden ones. * Otherwise, for a non-rendered block return an empty list, and for a * collapsed block don't return inputs connections. - * @return {!Array} Array of connections. + * @return {!Array} Array of connections. * @package */ -Blockly.BlockSvg.prototype.getConnections_ = function(all) { - var myConnections = []; +BlockSvg.prototype.getConnections_ = function(all) { + const myConnections = []; if (all || this.rendered) { if (this.outputConnection) { myConnections.push(this.outputConnection); @@ -1473,7 +1480,7 @@ Blockly.BlockSvg.prototype.getConnections_ = function(all) { myConnections.push(this.nextConnection); } if (all || !this.collapsed_) { - for (var i = 0, input; (input = this.inputList[i]); i++) { + for (let i = 0, input; (input = this.inputList[i]); i++) { if (input.connection) { myConnections.push(input.connection); } @@ -1488,78 +1495,72 @@ Blockly.BlockSvg.prototype.getConnections_ = function(all) { * @param {boolean} ignoreShadows If true,the last connection on a non-shadow * block will be returned. If false, this will follow shadows to find the * last connection. - * @return {?Blockly.RenderedConnection} The last next connection on the stack, + * @return {?RenderedConnection} The last next connection on the stack, * or null. * @package * @override */ -Blockly.BlockSvg.prototype.lastConnectionInStack = function(ignoreShadows) { - return /** @type {Blockly.RenderedConnection} */ ( - Blockly.BlockSvg.superClass_ - .lastConnectionInStack.call(this, ignoreShadows)); +BlockSvg.prototype.lastConnectionInStack = function(ignoreShadows) { + return /** @type {RenderedConnection} */ ( + BlockSvg.superClass_.lastConnectionInStack.call(this, ignoreShadows)); }; /** * 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.RenderedConnection} The matching connection on this block, + * @param {!Block} otherBlock The other block to match against. + * @param {!Connection} conn The other connection to match. + * @return {?RenderedConnection} The matching connection on this block, * or null. * @package * @override */ -Blockly.BlockSvg.prototype.getMatchingConnection = function(otherBlock, conn) { - return /** @type {Blockly.RenderedConnection} */ ( - Blockly.BlockSvg.superClass_.getMatchingConnection.call(this, - otherBlock, conn)); +BlockSvg.prototype.getMatchingConnection = function(otherBlock, conn) { + return /** @type {RenderedConnection} */ ( + BlockSvg.superClass_.getMatchingConnection.call(this, otherBlock, conn)); }; /** * Create a connection of the specified type. * @param {number} type The type of the connection to create. - * @return {!Blockly.RenderedConnection} A new connection of the specified type. + * @return {!RenderedConnection} A new connection of the specified type. * @protected */ -Blockly.BlockSvg.prototype.makeConnection_ = function(type) { - return new Blockly.RenderedConnection(this, type); +BlockSvg.prototype.makeConnection_ = function(type) { + return new RenderedConnection(this, type); }; /** * Bump unconnected blocks out of alignment. Two blocks which aren't actually * connected should not coincidentally line up on screen. */ -Blockly.BlockSvg.prototype.bumpNeighbours = function() { +BlockSvg.prototype.bumpNeighbours = function() { if (!this.workspace) { return; // Deleted block. } if (this.workspace.isDragging()) { return; // Don't bump blocks during a drag. } - var rootBlock = this.getRootBlock(); + const rootBlock = this.getRootBlock(); if (rootBlock.isInFlyout) { return; // Don't move blocks around in a flyout. } // Loop through every connection on this block. - var myConnections = this.getConnections_(false); - for (var i = 0, connection; (connection = myConnections[i]); i++) { - + const myConnections = this.getConnections_(false); + for (let i = 0, connection; (connection = myConnections[i]); i++) { // Spider down from this block bumping all sub-blocks. if (connection.isConnected() && connection.isSuperior()) { connection.targetBlock().bumpNeighbours(); } - var neighbours = - connection.neighbours(Blockly.internalConstants.SNAP_RADIUS); - for (var j = 0, otherConnection; (otherConnection = neighbours[j]); j++) { - + const neighbours = connection.neighbours(internalConstants.SNAP_RADIUS); + for (let j = 0, otherConnection; (otherConnection = neighbours[j]); j++) { // If both connections are connected, that's probably fine. But if // either one of them is unconnected, then there could be confusion. if (!connection.isConnected() || !otherConnection.isConnected()) { // Only bump blocks if they are from different tree structures. if (otherConnection.getSourceBlock().getRootBlock() != rootBlock) { - // Always bump the inferior block. if (connection.isSuperior()) { otherConnection.bumpAwayFrom(connection); @@ -1577,42 +1578,42 @@ Blockly.BlockSvg.prototype.bumpNeighbours = function() { * delay. * @package */ -Blockly.BlockSvg.prototype.scheduleSnapAndBump = function() { - var block = this; +BlockSvg.prototype.scheduleSnapAndBump = function() { + const block = this; // Ensure that any snap and bump are part of this move's event group. - var group = Blockly.Events.getGroup(); + const group = Events.getGroup(); setTimeout(function() { - Blockly.Events.setGroup(group); + Events.setGroup(group); block.snapToGrid(); - Blockly.Events.setGroup(false); - }, Blockly.internalConstants.BUMP_DELAY / 2); + Events.setGroup(false); + }, internalConstants.BUMP_DELAY / 2); setTimeout(function() { - Blockly.Events.setGroup(group); + Events.setGroup(group); block.bumpNeighbours(); - Blockly.Events.setGroup(false); - }, Blockly.internalConstants.BUMP_DELAY); + Events.setGroup(false); + }, internalConstants.BUMP_DELAY); }; /** * Position a block so that it doesn't move the target block when connected. * The block to position is usually either the first block in a dragged stack or * an insertion marker. - * @param {!Blockly.RenderedConnection} sourceConnection The connection on the + * @param {!RenderedConnection} sourceConnection The connection on the * moving block's stack. - * @param {!Blockly.RenderedConnection} targetConnection The connection that + * @param {!RenderedConnection} targetConnection The connection that * should stay stationary as this block is positioned. * @package */ -Blockly.BlockSvg.prototype.positionNearConnection = function(sourceConnection, - targetConnection) { +BlockSvg.prototype.positionNearConnection = function( + sourceConnection, targetConnection) { // We only need to position the new block if it's before the existing one, // otherwise its position is set by the previous block. - if (sourceConnection.type == Blockly.connectionTypes.NEXT_STATEMENT || - sourceConnection.type == Blockly.connectionTypes.INPUT_VALUE) { - var dx = targetConnection.x - sourceConnection.x; - var dy = targetConnection.y - sourceConnection.y; + if (sourceConnection.type == connectionTypes.NEXT_STATEMENT || + sourceConnection.type == connectionTypes.INPUT_VALUE) { + const dx = targetConnection.x - sourceConnection.x; + const dy = targetConnection.y - sourceConnection.y; this.moveBy(dx, dy); } @@ -1620,23 +1621,22 @@ Blockly.BlockSvg.prototype.positionNearConnection = function(sourceConnection, /** * Return the parent block or null if this block is at the top level. - * @return {?Blockly.BlockSvg} The block (if any) that holds the current block. + * @return {?BlockSvg} The block (if any) that holds the current block. * @override */ -Blockly.BlockSvg.prototype.getParent = function() { - return /** @type {!Blockly.BlockSvg} */ ( - Blockly.BlockSvg.superClass_.getParent.call(this)); +BlockSvg.prototype.getParent = function() { + return /** @type {!BlockSvg} */ (BlockSvg.superClass_.getParent.call(this)); }; /** * Return the top-most block in this block's tree. * This will return itself if this block is at the top level. - * @return {!Blockly.BlockSvg} The root block. + * @return {!BlockSvg} The root block. * @override */ -Blockly.BlockSvg.prototype.getRootBlock = function() { - return /** @type {!Blockly.BlockSvg} */ ( - Blockly.BlockSvg.superClass_.getRootBlock.call(this)); +BlockSvg.prototype.getRootBlock = function() { + return /** @type {!BlockSvg} */ ( + BlockSvg.superClass_.getRootBlock.call(this)); }; /** @@ -1644,14 +1644,14 @@ Blockly.BlockSvg.prototype.getRootBlock = function() { * @param {boolean=} opt_bubble If false, just render this block. * If true, also render block's parent, grandparent, etc. Defaults to true. */ -Blockly.BlockSvg.prototype.render = function(opt_bubble) { +BlockSvg.prototype.render = function(opt_bubble) { if (this.renderIsInProgress_) { return; // Don't allow recursive renders. } this.renderIsInProgress_ = true; try { this.rendered = true; - Blockly.utils.dom.startTextWidthCache(); + dom.startTextWidthCache(); if (this.isCollapsed()) { this.updateCollapsed_(); @@ -1660,7 +1660,7 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) { this.updateConnectionLocations_(); if (opt_bubble !== false) { - var parentBlock = this.getParent(); + const parentBlock = this.getParent(); if (parentBlock) { parentBlock.render(true); } else { @@ -1669,7 +1669,7 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) { } } - Blockly.utils.dom.stopTextWidthCache(); + dom.stopTextWidthCache(); this.updateMarkers_(); } finally { this.renderIsInProgress_ = false; @@ -1680,13 +1680,13 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) { * Redraw any attached marker or cursor svgs if needed. * @protected */ -Blockly.BlockSvg.prototype.updateMarkers_ = function() { +BlockSvg.prototype.updateMarkers_ = function() { if (this.workspace.keyboardAccessibilityMode && this.pathObject.cursorSvg) { this.workspace.getCursor().draw(); } if (this.workspace.keyboardAccessibilityMode && this.pathObject.markerSvg) { // TODO(#4592): Update all markers on the block. - this.workspace.getMarker(Blockly.MarkerManager.LOCAL_MARKER).draw(); + this.workspace.getMarker(MarkerManager.LOCAL_MARKER).draw(); } }; @@ -1696,8 +1696,8 @@ Blockly.BlockSvg.prototype.updateMarkers_ = function() { * connection locations. * @private */ -Blockly.BlockSvg.prototype.updateConnectionLocations_ = function() { - var blockTL = this.getRelativeToSurfaceXY(); +BlockSvg.prototype.updateConnectionLocations_ = function() { + const blockTL = this.getRelativeToSurfaceXY(); // Don't tighten previous or output connections because they are inferior // connections. if (this.previousConnection) { @@ -1707,8 +1707,8 @@ Blockly.BlockSvg.prototype.updateConnectionLocations_ = function() { this.outputConnection.moveToOffset(blockTL); } - for (var i = 0; i < this.inputList.length; i++) { - var conn = this.inputList[i].connection; + for (let i = 0; i < this.inputList.length; i++) { + const conn = this.inputList[i].connection; if (conn) { conn.moveToOffset(blockTL); if (conn.isConnected()) { @@ -1731,7 +1731,7 @@ Blockly.BlockSvg.prototype.updateConnectionLocations_ = function() { * block SVG group. * @package */ -Blockly.BlockSvg.prototype.setCursorSvg = function(cursorSvg) { +BlockSvg.prototype.setCursorSvg = function(cursorSvg) { this.pathObject.setCursorSvg(cursorSvg); }; @@ -1741,7 +1741,7 @@ Blockly.BlockSvg.prototype.setCursorSvg = function(cursorSvg) { * block SVG group. * @package */ -Blockly.BlockSvg.prototype.setMarkerSvg = function(markerSvg) { +BlockSvg.prototype.setMarkerSvg = function(markerSvg) { this.pathObject.setMarkerSvg(markerSvg); }; @@ -1752,15 +1752,15 @@ Blockly.BlockSvg.prototype.setMarkerSvg = function(markerSvg) { * properties in workspace units. * @package */ -Blockly.BlockSvg.prototype.getHeightWidth = function() { - var height = this.height; - var width = this.width; +BlockSvg.prototype.getHeightWidth = function() { + let height = this.height; + let width = this.width; // Recursively add size of subsequent blocks. - var nextBlock = this.getNextBlock(); + const nextBlock = this.getNextBlock(); if (nextBlock) { - var nextHeightWidth = nextBlock.getHeightWidth(); - var workspace = /** @type {!Blockly.WorkspaceSvg} */ (this.workspace); - var tabHeight = workspace.getRenderer().getConstants().NOTCH_HEIGHT; + const nextHeightWidth = nextBlock.getHeightWidth(); + const workspace = /** @type {!WorkspaceSvg} */ (this.workspace); + const tabHeight = workspace.getRenderer().getConstants().NOTCH_HEIGHT; height += nextHeightWidth.height - tabHeight; width = Math.max(width, nextHeightWidth.width); } @@ -1773,17 +1773,19 @@ Blockly.BlockSvg.prototype.getHeightWidth = function() { * @param {boolean} add True if highlighting should be added. * @package */ -Blockly.BlockSvg.prototype.fadeForReplacement = function(add) { +BlockSvg.prototype.fadeForReplacement = function(add) { this.pathObject.updateReplacementFade(add); }; /** * Visual effect to show that if the dragging block is dropped it will connect * to this input. - * @param {Blockly.Connection} conn The connection on the input to highlight. + * @param {Connection} conn The connection on the input to highlight. * @param {boolean} add True if highlighting should be added. * @package */ -Blockly.BlockSvg.prototype.highlightShapeForInput = function(conn, add) { +BlockSvg.prototype.highlightShapeForInput = function(conn, add) { this.pathObject.updateShapeForInputHighlight(conn, add); }; + +exports = BlockSvg; diff --git a/tests/deps.js b/tests/deps.js index a54d2acc2..2dceb7137 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -11,7 +11,7 @@ goog.addDependency('../../core/block.js', ['Blockly.Block'], ['Blockly.ASTNode', goog.addDependency('../../core/block_animations.js', ['Blockly.blockAnimations'], ['Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/block_drag_surface.js', ['Blockly.BlockDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/block_dragger.js', ['Blockly.BlockDragger'], ['Blockly.Events', 'Blockly.Events.BlockDrag', 'Blockly.Events.BlockMove', 'Blockly.IBlockDragger', 'Blockly.InsertionMarkerManager', 'Blockly.blockAnimations', 'Blockly.common', 'Blockly.registry', 'Blockly.utils.Coordinate', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/block_svg.js', ['Blockly.BlockSvg'], ['Blockly.ASTNode', 'Blockly.Block', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Events.Selected', 'Blockly.IASTNodeLocationSvg', 'Blockly.IBoundedElement', 'Blockly.ICopyable', 'Blockly.IDraggable', 'Blockly.Msg', 'Blockly.RenderedConnection', 'Blockly.TabNavigateCursor', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Xml', 'Blockly.blockAnimations', 'Blockly.blockRendering.IPathObject', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6'}); +goog.addDependency('../../core/block_svg.js', ['Blockly.BlockSvg'], ['Blockly.ASTNode', 'Blockly.Block', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Events.Selected', 'Blockly.FieldLabel', 'Blockly.IASTNodeLocationSvg', 'Blockly.IBoundedElement', 'Blockly.ICopyable', 'Blockly.IDraggable', 'Blockly.MarkerManager', 'Blockly.Msg', 'Blockly.RenderedConnection', 'Blockly.TabNavigateCursor', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Xml', 'Blockly.blockAnimations', 'Blockly.blockRendering.IPathObject', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/blockly.js', ['Blockly'], ['Blockly.ComponentManager', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.FinishedLoading', 'Blockly.Events.Ui', 'Blockly.Events.UiBase', 'Blockly.Events.VarCreate', 'Blockly.Procedures', 'Blockly.ShortcutRegistry', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.clipboard', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.inject', 'Blockly.inputTypes', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.toolbox']); goog.addDependency('../../core/blockly_options.js', ['Blockly.BlocklyOptions'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/blocks.js', ['Blockly.Blocks'], [], {'lang': 'es6', 'module': 'goog'});