chore: remove redundant fileoverview from ts

This commit is contained in:
Maribeth Bottorff
2022-08-16 16:11:00 -07:00
parent 8556a22fd6
commit 169959bc08
253 changed files with 1079 additions and 1440 deletions
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The class representing one block.
*/
/**
* The class representing one block.
* @class
+8 -4
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Methods animating a block on connection and disconnection.
*/
/**
* Methods animating a block on connection and disconnection.
*
* @namespace Blockly.blockAnimations
*/
import * as goog from '../closure/goog/goog.js';
@@ -37,6 +34,7 @@ let disconnectGroup: SVGElement|null = null;
/**
* Play some UI effects (sound, animation) when disposing of a block.
*
* @param block The block being disposed of.
* @alias Blockly.blockAnimations.disposeUiEffect
* @internal
@@ -59,6 +57,7 @@ export function disposeUiEffect(block: BlockSvg) {
* Animate a cloned block and eventually dispose of it.
* This is a class method, not an instance method since the original block has
* been destroyed and is no longer accessible.
*
* @param clone SVG element to animate and dispose of.
* @param rect Starting rect of the clone.
* @param rtl True if RTL, false if LTR.
@@ -87,6 +86,7 @@ function disposeUiStep(
/**
* Play some UI effects (sound, ripple) after a connection has been established.
*
* @param block The block being connected.
* @alias Blockly.blockAnimations.connectionUiEffect
* @internal
@@ -124,6 +124,7 @@ export function connectionUiEffect(block: BlockSvg) {
/**
* Expand a ripple around a connection.
*
* @param ripple Element to animate.
* @param start Date of animation's start.
* @param scale Scale of workspace.
@@ -142,6 +143,7 @@ function connectionUiStep(ripple: SVGElement, start: Date, scale: number) {
/**
* Play some UI effects (sound, animation) when disconnecting a block.
*
* @param block The block being disconnected.
* @alias Blockly.blockAnimations.disconnectUiEffect
* @internal
@@ -167,6 +169,7 @@ export function disconnectUiEffect(block: BlockSvg) {
/**
* Animate a brief wiggle of a disconnected block.
*
* @param group SVG element to animate.
* @param magnitude Maximum degrees skew (reversed for RTL).
* @param start Date of animation's start.
@@ -190,6 +193,7 @@ function disconnectUiStep(group: SVGElement, magnitude: number, start: Date) {
/**
* Stop the disconnect UI animation immediately.
*
* @alias Blockly.blockAnimations.disconnectUiStop
* @internal
*/
-9
View File
@@ -4,15 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A class that manages a surface for dragging blocks. When a
* block drag is started, we move the block (and children) to a separate DOM
* element that we move around using translate3d. At the end of the drag, the
* blocks are put back in into the SVG they came from. This helps
* performance by avoiding repainting the entire SVG on every mouse move
* while dragging blocks.
*/
/**
* A class that manages a surface for dragging blocks. When a
* block drag is started, we move the block (and children) to a separate DOM
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Methods for dragging a block visually.
*/
/**
* Methods for dragging a block visually.
* @class
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Methods for graphically rendering a block as SVG.
*/
/**
* Methods for graphically rendering a block as SVG.
* @class
+28 -11
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The top level namespace used to access the Blockly library.
*/
/**
* The top level namespace used to access the Blockly library.
*
* @namespace Blockly
*/
import * as goog from '../closure/goog/goog.js';
@@ -186,6 +183,7 @@ import {ZoomControls} from './zoom_controls.js';
* buildCompressed gulp task.
* For local builds, you can pass --define='Blockly.VERSION=X.Y.Z' to the
* compiler to override this constant.
*
* @define {string}
* @alias Blockly.VERSION
*/
@@ -290,6 +288,7 @@ export const TOOLBOX_AT_RIGHT = toolbox.Position.RIGHT;
* See workspace.resizeContents to resize the workspace when the contents
* change (e.g. when a block is added or removed).
* Record the height/width of the SVG image.
*
* @param workspace Any workspace in the SVG.
* @see Blockly.common.svgResize
* @alias Blockly.svgResize
@@ -298,6 +297,7 @@ export const svgResize = common.svgResize;
/**
* Close tooltips, context menus, dropdown selections, etc.
*
* @param opt_onlyClosePopups Whether only popups should be closed.
* @see Blockly.WorkspaceSvg.hideChaff
* @alias Blockly.hideChaff
@@ -310,6 +310,7 @@ export function hideChaff(opt_onlyClosePopups?: boolean) {
* Returns the main workspace. Returns the last used main workspace (based on
* focus). Try not to use this function, particularly if there are multiple
* Blockly instances on a page.
*
* @see Blockly.common.getMainWorkspace
* @alias Blockly.getMainWorkspace
*/
@@ -317,6 +318,7 @@ export const getMainWorkspace = common.getMainWorkspace;
/**
* Returns the currently selected copyable object.
*
* @alias Blockly.common.getSelected
*/
export const getSelected = common.getSelected;
@@ -324,6 +326,7 @@ export const getSelected = common.getSelected;
/**
* Define blocks from an array of JSON block definitions, as might be generated
* by the Blockly Developer Tools.
*
* @param jsonArray An array of JSON block definitions.
* @see Blockly.common.defineBlocksWithJsonArray
* @alias Blockly.defineBlocksWithJsonArray
@@ -335,6 +338,7 @@ export const defineBlocksWithJsonArray = common.defineBlocksWithJsonArray;
* dropDownDiv, and Tooltip are rendered into the first time `Blockly.inject`
* is called.
* This method is a NOP if called after the first ``Blockly.inject``.
*
* @param container The container element.
* @see Blockly.common.setParentContainer
* @alias Blockly.setParentContainer
@@ -343,8 +347,9 @@ export const setParentContainer = common.setParentContainer;
/**
* Returns the dimensions of the specified SVG image.
*
* @param svg SVG image.
* @return Contains width and height properties.
* @returns Contains width and height properties.
* @deprecated Use workspace.setCachedParentSvgSize. (2021 March 5)
* @see Blockly.WorkspaceSvg.setCachedParentSvgSize
* @alias Blockly.svgSize
@@ -354,6 +359,7 @@ export const svgSize = svgMath.svgSize;
/**
* Size the workspace when the contents change. This also updates
* scrollbars accordingly.
*
* @param workspace The workspace to resize.
* @deprecated Use workspace.resizeContents. (2021 December)
* @see Blockly.WorkspaceSvg.resizeContents
@@ -369,6 +375,7 @@ export const resizeSvgContents = resizeSvgContentsLocal;
/**
* Copy a block or workspace comment onto the local clipboard.
*
* @param toCopy Block or Workspace Comment to be copied.
* @deprecated Use Blockly.clipboard.copy(). (2021 December)
* @see Blockly.clipboard.copy
@@ -383,7 +390,8 @@ export function copy(toCopy: ICopyable) {
/**
* Paste a block or workspace comment on to the main workspace.
* @return True if the paste was successful, false otherwise.
*
* @returns True if the paste was successful, false otherwise.
* @deprecated Use Blockly.clipboard.paste(). (2021 December)
* @see Blockly.clipboard.paste
* @alias Blockly.paste
@@ -397,6 +405,7 @@ export function paste(): boolean {
/**
* Duplicate this block and its children, or a workspace comment.
*
* @param toDuplicate Block or Workspace Comment to be copied.
* @deprecated Use Blockly.clipboard.duplicate(). (2021 December)
* @see Blockly.clipboard.duplicate
@@ -411,8 +420,9 @@ export function duplicate(toDuplicate: ICopyable) {
/**
* Is the given string a number (includes negative and decimals).
*
* @param str Input string.
* @return True if number, false otherwise.
* @returns True if number, false otherwise.
* @deprecated Use Blockly.utils.string.isNumber(str). (2021 December)
* @see Blockly.utils.string.isNumber
* @alias Blockly.isNumber
@@ -426,8 +436,9 @@ export function isNumber(str: string): boolean {
/**
* Convert a hue (HSV model) into an RGB hex triplet.
*
* @param hue Hue on a colour wheel (0-360).
* @return RGB code, e.g. '#5ba65b'.
* @returns RGB code, e.g. '#5ba65b'.
* @deprecated Use Blockly.utils.colour.hueToHex(). (2021 December)
* @see Blockly.utils.colour.hueToHex
* @alias Blockly.hueToHex
@@ -444,11 +455,12 @@ export function hueToHex(hue: number): string {
* of the active touch stream.
* Use this for events that are not part of a multi-part gesture (e.g.
* mouseover for tooltips).
*
* @param node Node upon which to listen.
* @param name Event name to listen to (e.g. 'mousedown').
* @param thisObject The value of 'this' in the function.
* @param func Function to call when event is triggered.
* @return Opaque data that can be passed to unbindEvent_.
* @returns Opaque data that can be passed to unbindEvent_.
* @deprecated Use Blockly.browserEvents.bind(). (December 2021)
* @see Blockly.browserEvents.bind
* @alias Blockly.bindEvent_
@@ -464,9 +476,10 @@ export function bindEvent_(
/**
* Unbind one or more events event from a function call.
*
* @param bindData Opaque data from bindEvent_.
* This list is emptied during the course of calling this function.
* @return The function call.
* @returns The function call.
* @deprecated Use Blockly.browserEvents.unbind(). (December 2021)
* @see browserEvents.unbind
* @alias Blockly.unbindEvent_
@@ -483,6 +496,7 @@ export function unbindEvent_(bindData: browserEvents.Data): Function {
* touch stream.
* Use this for events that either start or continue a multi-part gesture (e.g.
* mousedown or mousemove, which may be part of a drag or click).
*
* @param node Node upon which to listen.
* @param name Event name to listen to (e.g. 'mousedown').
* @param thisObject The value of 'this' in the function.
@@ -493,7 +507,7 @@ export function unbindEvent_(bindData: browserEvents.Data): Function {
* @param opt_noPreventDefault True if triggering on this event should prevent
* the default handler. False by default. If opt_noPreventDefault is
* provided, opt_noCaptureIdentifier must also be provided.
* @return Opaque data that can be passed to unbindEvent_.
* @returns Opaque data that can be passed to unbindEvent_.
* @deprecated Use Blockly.browserEvents.conditionalBind(). (December 2021)
* @see browserEvents.conditionalBind
* @alias Blockly.bindEventWithChecks_
@@ -523,6 +537,7 @@ export const COLLAPSED_FIELD_NAME = constants.COLLAPSED_FIELD_NAME;
* String for use in the "custom" attribute of a category in toolbox XML.
* This string indicates that the category should be dynamically populated with
* variable blocks.
*
* @alias Blockly.VARIABLE_CATEGORY_NAME
*/
export const VARIABLE_CATEGORY_NAME: string = Variables.CATEGORY_NAME;
@@ -531,6 +546,7 @@ export const VARIABLE_CATEGORY_NAME: string = Variables.CATEGORY_NAME;
* String for use in the "custom" attribute of a category in toolbox XML.
* This string indicates that the category should be dynamically populated with
* variable blocks.
*
* @alias Blockly.VARIABLE_DYNAMIC_CATEGORY_NAME
*/
export const VARIABLE_DYNAMIC_CATEGORY_NAME: string =
@@ -539,6 +555,7 @@ export const VARIABLE_DYNAMIC_CATEGORY_NAME: string =
* String for use in the "custom" attribute of a category in toolbox XML.
* This string indicates that the category should be dynamically populated with
* procedure blocks.
*
* @alias Blockly.PROCEDURE_CATEGORY_NAME
*/
export const PROCEDURE_CATEGORY_NAME: string = Procedures.CATEGORY_NAME;
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Object that defines user-specified options for the workspace.
*/
/**
* Object that defines user-specified options for the workspace.
* @namespace Blockly.BlocklyOptions
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A mapping of block type names to block prototype objects.
*/
/**
* A mapping of block type names to block prototype objects.
* @namespace Blockly.blocks
+24 -11
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Browser event handling.
*/
/**
* Browser event handling.
*
* @namespace Blockly.browserEvents
*/
import * as goog from '../closure/goog/goog.js';
@@ -22,6 +19,7 @@ import * as userAgent from './utils/useragent.js';
/**
* Blockly opaque event data used to unbind events when using
* `bind` and `conditionalBind`.
*
* @alias Blockly.browserEvents.Data
*/
export type Data = [EventTarget, string, (e: Event) => void][];
@@ -45,6 +43,7 @@ const PAGE_MODE_MULTIPLIER = 125;
* touch stream.
* Use this for events that either start or continue a multi-part gesture (e.g.
* mousedown or mousemove, which may be part of a drag or click).
*
* @param node Node upon which to listen.
* @param name Event name to listen to (e.g. 'mousedown').
* @param thisObject The value of 'this' in the function.
@@ -55,13 +54,17 @@ const PAGE_MODE_MULTIPLIER = 125;
* @param opt_noPreventDefault True if triggering on this event should prevent
* the default handler. False by default. If opt_noPreventDefault is
* provided, opt_noCaptureIdentifier must also be provided.
* @return Opaque data that can be passed to unbindEvent_.
* @returns Opaque data that can be passed to unbindEvent_.
* @alias Blockly.browserEvents.conditionalBind
*/
export function conditionalBind(
node: EventTarget, name: string, thisObject: Object|null, func: Function,
opt_noCaptureIdentifier?: boolean, opt_noPreventDefault?: boolean): Data {
let handled = false;
/**
*
* @param e
*/
function wrapFunc(e: Event) {
const captureIdentifier = !opt_noCaptureIdentifier;
// Handle each touch point separately. If the event was a mouse event, this
@@ -119,16 +122,21 @@ export function conditionalBind(
* of the active touch stream.
* Use this for events that are not part of a multi-part gesture (e.g.
* mouseover for tooltips).
*
* @param node Node upon which to listen.
* @param name Event name to listen to (e.g. 'mousedown').
* @param thisObject The value of 'this' in the function.
* @param func Function to call when event is triggered.
* @return Opaque data that can be passed to unbindEvent_.
* @returns Opaque data that can be passed to unbindEvent_.
* @alias Blockly.browserEvents.bind
*/
export function bind(
node: EventTarget, name: string, thisObject: Object|null,
func: Function): Data {
/**
*
* @param e
*/
function wrapFunc(e: Event) {
if (thisObject) {
func.call(thisObject, e);
@@ -179,9 +187,10 @@ export function bind(
/**
* Unbind one or more events event from a function call.
*
* @param bindData Opaque data from bindEvent_.
* This list is emptied during the course of calling this function.
* @return The function call.
* @returns The function call.
* @alias Blockly.browserEvents.unbind
*/
export function unbind(bindData: Data): (e: Event) => void {
@@ -201,8 +210,9 @@ export function unbind(bindData: Data): (e: Event) => void {
/**
* Returns true if this event is targeting a text input widget?
*
* @param e An event.
* @return True if text input.
* @returns True if text input.
* @alias Blockly.browserEvents.isTargetInput
*/
export function isTargetInput(e: Event): boolean {
@@ -230,8 +240,9 @@ export function isTargetInput(e: Event): boolean {
/**
* Returns true this event is a right-click.
*
* @param e Mouse event.
* @return True if right-click.
* @returns True if right-click.
* @alias Blockly.browserEvents.isRightButton
*/
export function isRightButton(e: MouseEvent): boolean {
@@ -246,10 +257,11 @@ export function isRightButton(e: MouseEvent): boolean {
/**
* Returns the converted coordinates of the given mouse event.
* The origin (0,0) is the top-left corner of the Blockly SVG.
*
* @param e Mouse event.
* @param svg SVG element.
* @param matrix Inverted screen CTM to use.
* @return Object with .x and .y properties.
* @returns Object with .x and .y properties.
* @alias Blockly.browserEvents.mouseToSvg
*/
export function mouseToSvg(
@@ -266,8 +278,9 @@ export function mouseToSvg(
/**
* Returns the scroll delta of a mouse event in pixel units.
*
* @param e Mouse event.
* @return Scroll delta object with .x and .y properties.
* @returns Scroll delta object with .x and .y properties.
* @alias Blockly.browserEvents.getScrollDeltaPixels
*/
export function getScrollDeltaPixels(e: WheelEvent): {x: number, y: number} {
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Object representing a UI bubble.
*/
/**
* Object representing a UI bubble.
* @class
+9 -6
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Methods for dragging a bubble visually.
*/
/**
* Methods for dragging a bubble visually.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -37,6 +34,7 @@ import type {WorkspaceSvg} from './workspace_svg.js';
* Class for a bubble dragger. It moves things on the bubble canvas around the
* workspace when they are being dragged by a mouse or touch. These can be
* block comments, mutators, warnings, or workspace comments.
*
* @alias Blockly.BubbleDragger
*/
export class BubbleDragger {
@@ -71,6 +69,7 @@ export class BubbleDragger {
/**
* Start dragging a bubble. This includes moving it to the drag surface.
*
* @internal
*/
startBubbleDrag() {
@@ -93,6 +92,7 @@ export class BubbleDragger {
/**
* Execute a step of bubble dragging, based on the given event. Update the
* display accordingly.
*
* @param e The most recent move event.
* @param currentDragDeltaXY How far the pointer has moved from the position
* at the start of the drag, in pixel units.
@@ -123,8 +123,9 @@ export class BubbleDragger {
/**
* Whether ending the drag would delete the bubble.
*
* @param dragTarget The drag target that the bubblee is currently over.
* @return Whether dropping the bubble immediately would delete the block.
* @returns Whether dropping the bubble immediately would delete the block.
*/
private shouldDelete_(dragTarget: IDragTarget|null): boolean {
if (dragTarget) {
@@ -148,6 +149,7 @@ export class BubbleDragger {
/**
* Finish a bubble drag and put the bubble back on the workspace.
*
* @param e The mouseup/touchend event.
* @param currentDragDeltaXY How far the pointer has moved from the position
* at the start of the drag, in pixel units.
@@ -210,8 +212,9 @@ export class BubbleDragger {
* correction for mutator workspaces.
* This function does not consider differing origins. It simply scales the
* input's x and y values.
*
* @param pixelCoord A coordinate with x and y values in CSS pixel units.
* @return The input coordinate divided by the workspace scale.
* @returns The input coordinate divided by the workspace scale.
*/
private pixelsToWorkspaceUnits_(pixelCoord: Coordinate): Coordinate {
const result = new Coordinate(
+8 -7
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Utilities for bumping objects back into worksapce bounds.
*/
/**
* Utilities for bumping objects back into worksapce bounds.
*
* @namespace Blockly.bumpObjects
*/
import * as goog from '../closure/goog/goog.js';
@@ -32,11 +29,12 @@ import type {WorkspaceSvg} from './workspace_svg.js';
/**
* Bumps the given object that has passed out of bounds.
*
* @param workspace The workspace containing the object.
* @param scrollMetrics Scroll metrics
* in workspace coordinates.
* @param object The object to bump.
* @return True if block was bumped.
* @returns True if block was bumped.
* @alias Blockly.bumpObjects.bumpIntoBounds
*/
function bumpObjectIntoBounds(
@@ -86,8 +84,9 @@ export const bumpIntoBounds = bumpObjectIntoBounds;
/**
* Creates a handler for bumping objects when they cross fixed bounds.
*
* @param workspace The workspace to handle.
* @return The event handler.
* @returns The event handler.
* @alias Blockly.bumpObjects.bumpIntoBoundsHandler
*/
export function bumpIntoBoundsHandler(workspace: WorkspaceSvg):
@@ -134,10 +133,11 @@ export function bumpIntoBoundsHandler(workspace: WorkspaceSvg):
/**
* Extracts the object from the given event.
*
* @param workspace The workspace the event originated
* from.
* @param e An event containing an object.
* @return The extracted
* @returns The extracted
* object.
*/
function extractObjectFromEvent(
@@ -165,6 +165,7 @@ function extractObjectFromEvent(
/**
* Bumps the top objects in the given workspace into bounds.
*
* @param workspace The workspace.
* @alias Blockly.bumpObjects.bumpTopObjectsIntoBounds
*/
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Blockly's internal clipboard for managing copy-paste.
*/
/**
* Blockly's internal clipboard for managing copy-paste.
* @namespace Blockly.clipboard
+21 -8
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Object representing a code comment.
*/
/**
* Object representing a code comment.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -44,6 +41,7 @@ import * as userAgent from './utils/useragent.js';
/**
* Class for a comment.
*
* @alias Blockly.Comment
*/
export class Comment extends Icon {
@@ -94,6 +92,7 @@ export class Comment extends Icon {
/**
* Draw the comment icon.
*
* @param group The icon group.
*/
protected override drawIcon_(group: Element) {
@@ -125,7 +124,8 @@ export class Comment extends Icon {
/**
* Create the editor for the comment's bubble.
* @return The top-level node of the editor.
*
* @returns The top-level node of the editor.
*/
private createEditor_(): SVGElement {
/* Create the editor. Here's the markup that will be generated in
@@ -171,7 +171,10 @@ export class Comment extends Icon {
});
this.onChangeWrapper_ = browserEvents.conditionalBind(
textarea, 'change', this,
/** @param _e Unused event parameter. */
/**
* @param this
* @param _e Unused event parameter.
*/
function(this: Comment, _e: Event) {
if (this.cachedText_ !== this.model_.text) {
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))!
@@ -181,7 +184,10 @@ export class Comment extends Icon {
});
this.onInputWrapper_ = browserEvents.conditionalBind(
textarea, 'input', this,
/** @param _e Unused event parameter. */
/**
* @param this
* @param _e Unused event parameter.
*/
function(this: Comment, _e: Event) {
this.model_.text = textarea.value;
});
@@ -238,6 +244,7 @@ export class Comment extends Icon {
/**
* Show or hide the comment bubble.
*
* @param visible True if the bubble should be visible.
*/
override setVisible(visible: boolean) {
@@ -280,6 +287,7 @@ export class Comment extends Icon {
/**
* Show a non-editable bubble.
*
* @suppress {checkTypes} Suppress `this` type mismatch.
*/
private createNonEditableBubble_() {
@@ -292,6 +300,7 @@ export class Comment extends Icon {
/**
* Dispose of the bubble.
*
* @suppress {checkTypes} Suppress `this` type mismatch.
*/
private disposeBubble_() {
@@ -323,6 +332,7 @@ export class Comment extends Icon {
*
* Bring the comment to the top of the stack when clicked on. Also cache the
* current text so it can be used to fire a change event.
*
* @param _e Mouse up event.
*/
private startEdit_(_e: Event) {
@@ -337,7 +347,8 @@ export class Comment extends Icon {
/**
* Get the dimensions of this comment's bubble.
* @return Object with width and height properties.
*
* @returns Object with width and height properties.
*/
getBubbleSize(): Size {
return this.model_.size;
@@ -345,6 +356,7 @@ export class Comment extends Icon {
/**
* Size this comment's bubble.
*
* @param width Width of the bubble.
* @param height Height of the bubble.
*/
@@ -359,6 +371,7 @@ export class Comment extends Icon {
/**
* Update the comment's view to match the model.
*
* @internal
*/
updateText() {
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Common functions used both internally and externally, but which
* must not be at the top level to avoid circular dependencies.
*/
/**
* Common functions used both internally and externally, but which
* must not be at the top level to avoid circular dependencies.
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Manager for all items registered with the workspace.
*/
/**
* Manager for all items registered with the workspace.
* @class
+7 -6
View File
@@ -4,16 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview All the values that we expect developers to be able to change
* before injecting Blockly. Changing these values during run time is not
* generally recommended.
*/
/**
* All the values that we expect developers to be able to change
* before injecting Blockly. Changing these values during run time is not
* generally recommended.
*
* @namespace Blockly.config
*/
import * as goog from '../closure/goog/goog.js';
@@ -43,6 +38,7 @@ const DEFAULT_SNAP_RADIUS = 28;
export const config: Config = {
/**
* Number of pixels the mouse must move before a drag starts.
*
* @alias Blockly.config.dragRadius
*/
dragRadius: 5,
@@ -50,17 +46,20 @@ export const config: Config = {
* Number of pixels the mouse must move before a drag/scroll starts from the
* flyout. Because the drag-intention is determined when this is reached, it
* is larger than dragRadius so that the drag-direction is clearer.
*
* @alias Blockly.config.flyoutDragRadius
*/
flyoutDragRadius: 10,
/**
* Maximum misalignment between connections for them to snap together.
*
* @alias Blockly.config.snapRadius
*/
snapRadius: DEFAULT_SNAP_RADIUS,
/**
* Maximum misalignment between connections for them to snap together.
* This should be the same as the snap radius.
*
* @alias Blockly.config.connectingSnapRadius
*/
connectingSnapRadius: DEFAULT_SNAP_RADIUS,
@@ -69,11 +68,13 @@ export const config: Config = {
* to a new connection. The current previewed connection is considered to be
* this much closer to the matching connection on the block than it actually
* is.
*
* @alias Blockly.config.currentConnectionPreference
*/
currentConnectionPreference: 8,
/**
* Delay in ms between trigger and bumping unconnected block out of alignment.
*
* @alias Blockly.config.bumpDelay
*/
bumpDelay: 250,
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Components for creating connections between blocks.
*/
/**
* Components for creating connections between blocks.
* @class
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview An object that encapsulates logic for checking whether a
* potential connection is safe and valid.
*/
/**
* An object that encapsulates logic for checking whether a
* potential connection is safe and valid.
+18 -13
View File
@@ -4,16 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A database of all the rendered connections that could
* possibly be connected to (i.e. not collapsed, etc).
* Sorted by y coordinate.
*/
/**
* A database of all the rendered connections that could
* possibly be connected to (i.e. not collapsed, etc).
* Sorted by y coordinate.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -32,6 +27,7 @@ import type {Coordinate} from './utils/coordinate.js';
* Database of connections.
* Connections are stored in order of their vertical component. This way
* connections in an area may be looked up quickly using a binary search.
*
* @alias Blockly.ConnectionDB
*/
export class ConnectionDB {
@@ -46,6 +42,7 @@ export class ConnectionDB {
/**
* Add a connection to the database. Should not already exist in the database.
*
* @param connection The connection to be added.
* @param yPos The y position used to decide where to insert the connection.
* @internal
@@ -60,9 +57,10 @@ export class ConnectionDB {
*
* Starts by doing a binary search to find the approximate location, then
* linearly searches nearby for the exact connection.
*
* @param conn The connection to find.
* @param yPos The y position used to find the index of the connection.
* @return The index of the connection, or -1 if the connection was not found.
* @returns The index of the connection, or -1 if the connection was not found.
*/
private findIndexOfConnection_(conn: RenderedConnection, yPos: number):
number {
@@ -99,8 +97,9 @@ export class ConnectionDB {
/**
* Finds the correct index for the given y position.
*
* @param yPos The y position used to decide where to insert the connection.
* @return The candidate index.
* @returns The candidate index.
*/
private calculateIndexForYPos_(yPos: number): number {
if (!this.connections_.length) {
@@ -124,6 +123,7 @@ export class ConnectionDB {
/**
* Remove a connection from the database. Must already exist in DB.
*
* @param connection The connection to be removed.
* @param yPos The y position used to find the index of the connection.
* @throws {Error} If the connection cannot be found in the database.
@@ -139,9 +139,10 @@ export class ConnectionDB {
/**
* Find all nearby connections to the given connection.
* Type checking does not apply, since this function is used for bumping.
*
* @param connection The connection whose neighbours should be returned.
* @param maxRadius The maximum radius to another connection.
* @return List of connections.
* @returns List of connections.
*/
getNeighbours(connection: RenderedConnection, maxRadius: number):
RenderedConnection[] {
@@ -167,8 +168,9 @@ export class ConnectionDB {
* Computes if the current connection is within the allowed radius of
* another connection. This function is a closure and has access to outside
* variables.
*
* @param yIndex The other connection's index in the database.
* @return True if the current connection's vertical distance from the other
* @returns True if the current connection's vertical distance from the other
* connection is less than the allowed radius.
*/
function checkConnection_(yIndex: number): boolean {
@@ -199,10 +201,11 @@ export class ConnectionDB {
/**
* Is the candidate connection close to the reference connection.
* Extremely fast; only looks at Y distance.
*
* @param index Index in database of candidate connection.
* @param baseY Reference connection's Y value.
* @param maxRadius The maximum radius to another connection.
* @return True if connection is in range.
* @returns True if connection is in range.
*/
private isInYRange_(index: number, baseY: number, maxRadius: number):
boolean {
@@ -211,11 +214,12 @@ export class ConnectionDB {
/**
* Find the closest compatible connection to this connection.
*
* @param conn The connection searching for a compatible mate.
* @param maxRadius The maximum radius to another connection.
* @param dxy Offset between this connection's location in the database and
* the current location (as a result of dragging).
* @return Contains two properties: 'connection' which is either another
* @returns Contains two properties: 'connection' which is either another
* connection or null, and 'radius' which is the distance.
*/
searchForClosest(
@@ -273,9 +277,10 @@ export class ConnectionDB {
/**
* Initialize a set of connection DBs for a workspace.
*
* @param checker The workspace's connection checker, used to decide if
* connections are valid during a drag.
* @return Array of databases.
* @returns Array of databases.
*/
static init(checker: IConnectionChecker): ConnectionDB[] {
// Create four databases, one for each connection type.
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview An enum for the possible types of connections.
*/
/**
* An enum for the possible types of connections.
* @namespace Blockly.ConnectionType
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Blockly constants.
*/
/**
* Blockly constants.
* @namespace Blockly.constants
+23 -10
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Functionality for the right-click context menus.
*/
/**
* Functionality for the right-click context menus.
*
* @namespace Blockly.ContextMenu
*/
import * as goog from '../closure/goog/goog.js';
@@ -46,7 +43,8 @@ const dummyOwner = {};
/**
* Gets the block the context menu is currently attached to.
* @return The block the context menu is attached to.
*
* @returns The block the context menu is attached to.
* @alias Blockly.ContextMenu.getCurrentBlock
*/
export function getCurrentBlock(): Block|null {
@@ -55,6 +53,7 @@ export function getCurrentBlock(): Block|null {
/**
* Sets the block the context menu is currently attached to.
*
* @param block The block the context menu is attached to.
* @alias Blockly.ContextMenu.setCurrentBlock
*/
@@ -69,6 +68,7 @@ let menu_: Menu|null = null;
/**
* Construct the menu based on the list of options and show the menu.
*
* @param e Mouse event.
* @param options Array of menu options.
* @param rtl True if RTL, false if LTR.
@@ -96,9 +96,10 @@ export function show(
/**
* Create the context menu object and populate it with the given options.
*
* @param options Array of menu options.
* @param rtl True if RTL, false if LTR.
* @return The menu that will be shown on right click.
* @returns The menu that will be shown on right click.
*/
function populate_(
options: (ContextMenuOption|LegacyContextMenuOption)[],
@@ -134,6 +135,7 @@ function populate_(
/**
* Add the menu to the page and position it correctly.
*
* @param menu The menu to add and position.
* @param e Mouse event for the right click that is making the context
* menu appear.
@@ -170,6 +172,7 @@ function position_(menu: Menu, e: Event, rtl: boolean) {
/**
* Create and render the menu widget inside Blockly's widget div.
*
* @param menu The menu to add to the widget div.
*/
function createWidget_(menu: Menu) {
@@ -188,6 +191,7 @@ function createWidget_(menu: Menu) {
}
/**
* Halts the propagation of the event without doing anything else.
*
* @param e An event.
*/
function haltPropagation(e: Event) {
@@ -198,6 +202,7 @@ function haltPropagation(e: Event) {
/**
* Hide the context menu.
*
* @alias Blockly.ContextMenu.hide
*/
export function hide() {
@@ -207,6 +212,7 @@ export function hide() {
/**
* Dispose of the menu.
*
* @alias Blockly.ContextMenu.dispose
*/
export function dispose() {
@@ -219,9 +225,10 @@ export function dispose() {
/**
* Create a callback function that creates and configures a block,
* then places the new block next to the original.
*
* @param block Original block.
* @param xml XML representation of new block.
* @return Function that creates a block.
* @returns Function that creates a block.
* @alias Blockly.ContextMenu.callbackFactory
*/
export function callbackFactory(block: Block, xml: Element): Function {
@@ -253,9 +260,10 @@ export function callbackFactory(block: Block, xml: Element): Function {
/**
* Make a context menu option for deleting the current workspace comment.
*
* @param comment The workspace comment where the
* right-click originated.
* @return A menu option,
* @returns A menu option,
* containing text, enabled, and a callback.
* @alias Blockly.ContextMenu.commentDeleteOption
* @internal
@@ -276,9 +284,10 @@ export function commentDeleteOption(comment: WorkspaceCommentSvg):
/**
* Make a context menu option for duplicating the current workspace comment.
*
* @param comment The workspace comment where the
* right-click originated.
* @return A menu option,
* @returns A menu option,
* containing text, enabled, and a callback.
* @alias Blockly.ContextMenu.commentDuplicateOption
* @internal
@@ -297,10 +306,11 @@ export function commentDuplicateOption(comment: WorkspaceCommentSvg):
/**
* Make a context menu option for adding a comment on the workspace.
*
* @param ws The workspace where the right-click
* originated.
* @param e The right-click mouse event.
* @return A menu option, containing text, enabled, and a callback.
* @returns A menu option, containing text, enabled, and a callback.
* @suppress {strictModuleDepCheck,checkTypes} Suppress checks while workspace
* comments are not bundled in.
* @alias Blockly.ContextMenu.workspaceCommentOption
@@ -310,6 +320,9 @@ export function workspaceCommentOption(
ws: WorkspaceSvg, e: Event): ContextMenuOption {
// Helper function to create and position a comment correctly based on the
// location of the mouse event.
/**
*
*/
function addWsComment() {
const comment = new WorkspaceCommentSvg(
ws, Msg['WORKSPACE_COMMENT_DEFAULT_TEXT'],
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Registers default context menu items.
*/
/**
* Registers default context menu items.
* @namespace Blockly.ContextMenuItems
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Registry for context menu option items.
*/
/**
* Registry for context menu option items.
* @class
+4 -4
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Inject Blockly's CSS synchronously.
*/
/**
* Inject Blockly's CSS synchronously.
*
* @namespace Blockly.Css
*/
import * as goog from '../closure/goog/goog.js';
@@ -24,6 +21,7 @@ let injected = false;
/**
* Add some CSS to the blob that will be injected later. Allows optional
* components such as fields and the toolbox to store separate CSS.
*
* @param cssContent Multiline CSS string or an array of single lines of CSS.
* @alias Blockly.Css.register
*/
@@ -49,6 +47,7 @@ export function register(cssContent: string|string[]) {
* a) It loads synchronously and doesn't force a redraw later.
* b) It speeds up loading by not blocking on a separate HTTP transfer.
* c) The CSS content may be made dynamic depending on init options.
*
* @param hasCss If false, don't inject CSS (providing CSS becomes the
* document's responsibility).
* @param pathToMedia Path from page to the Blockly media directory.
@@ -79,6 +78,7 @@ export function inject(hasCss: boolean, pathToMedia: string) {
/**
* The CSS content for Blockly.
*
* @alias Blockly.Css.content
*/
let content = `
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The abstract class for a component that can delete a block or
* bubble that is dropped on top of it.
*/
/**
* The abstract class for a component that can delete a block or
* bubble that is dropped on top of it.
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Wrapper functions around JS functions for showing
* alert/confirmation dialogs.
*/
/**
* Wrapper functions around JS functions for showing alert/confirmation dialogs.
* @namespace Blockly.dialog
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The abstract class for a component with custom behaviour when a
* block or bubble is dragged over or dropped on top of it.
*/
/**
* The abstract class for a component with custom behaviour when a
* block or bubble is dragged over or dropped on top of it.
-5
View File
@@ -5,11 +5,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A div that floats on top of the workspace, for drop-down menus.
* The drop-down can be kept inside the workspace, animate in/out, etc.
*/
/**
* A div that floats on top of the workspace, for drop-down menus.
* @class
+1 -4
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of actions in Blockly's editor.
*/
/**
* Events fired as a result of actions in Blockly's editor.
*
* @namespace Blockly.Events
*/
import * as goog from '../../closure/goog/goog.js';
+10 -8
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Abstract class for events fired as a result of actions in
* Blockly's editor.
*/
/**
* Abstract class for events fired as a result of actions in
* Blockly's editor.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -25,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Abstract class for an event.
*
* @alias Blockly.Events.Abstract
*/
export abstract class Abstract {
@@ -57,7 +54,8 @@ export abstract class Abstract {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
toJson(): AnyDuringMigration {
const json = {'type': this.type};
@@ -69,6 +67,7 @@ export abstract class Abstract {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
fromJson(json: AnyDuringMigration) {
@@ -78,7 +77,8 @@ export abstract class Abstract {
/**
* Does this event record any change of state?
* @return True if null, false if something changed.
*
* @returns True if null, false if something changed.
*/
isNull(): boolean {
return false;
@@ -86,6 +86,7 @@ export abstract class Abstract {
/**
* Run an event.
*
* @param _forward True if run forward, false if run backward (undo).
*/
run(_forward: boolean) {}
@@ -93,7 +94,8 @@ export abstract class Abstract {
/**
* Get workspace the event belongs to.
* @return The workspace the event belongs to.
*
* @returns The workspace the event belongs to.
* @throws {Error} if workspace is null.
* @internal
*/
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Base class for all types of block events.
*/
/**
* Base class for all types of block events.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -22,6 +19,7 @@ import {Abstract as AbstractEvent} from './events_abstract.js';
/**
* Abstract class for a block event.
*
* @alias Blockly.Events.BlockBase
*/
export class BlockBase extends AbstractEvent {
@@ -46,7 +44,8 @@ export class BlockBase extends AbstractEvent {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -56,6 +55,7 @@ export class BlockBase extends AbstractEvent {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
+10 -7
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a block change event.
*/
/**
* Class for a block change event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -26,6 +23,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a block change event.
*
* @alias Blockly.Events.BlockChange
*/
export class BlockChange extends BlockBase {
@@ -63,7 +61,8 @@ export class BlockChange extends BlockBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -78,6 +77,7 @@ export class BlockChange extends BlockBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -90,7 +90,8 @@ export class BlockChange extends BlockBase {
/**
* Does this event record any change of state?
* @return False if something changed.
*
* @returns False if something changed.
*/
override isNull(): boolean {
return this.oldValue === this.newValue;
@@ -98,6 +99,7 @@ export class BlockChange extends BlockBase {
/**
* Run a change event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
@@ -157,8 +159,9 @@ export class BlockChange extends BlockBase {
/**
* Returns the extra state of the given block (either as XML or a JSO,
* depending on the block's definition).
*
* @param block The block to get the extra state of.
* @return A stringified version of the extra state of the given block.
* @returns A stringified version of the extra state of the given block.
* @internal
*/
static getExtraBlockState_(block: BlockSvg): string {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a block creation event.
*/
/**
* Class for a block creation event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -26,6 +23,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a block creation event.
*
* @alias Blockly.Events.BlockCreate
*/
export class BlockCreate extends BlockBase {
@@ -61,7 +59,8 @@ export class BlockCreate extends BlockBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -76,6 +75,7 @@ export class BlockCreate extends BlockBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -90,6 +90,7 @@ export class BlockCreate extends BlockBase {
/**
* Run a creation event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a block delete event.
*/
/**
* Class for a block delete event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -26,6 +23,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a block deletion event.
*
* @alias Blockly.Events.BlockDelete
*/
export class BlockDelete extends BlockBase {
@@ -70,7 +68,8 @@ export class BlockDelete extends BlockBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -86,6 +85,7 @@ export class BlockDelete extends BlockBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -102,6 +102,7 @@ export class BlockDelete extends BlockBase {
/**
* Run a deletion event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a block drag.
*/
/**
* Events fired as a block drag.
* @class
+10 -7
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a block move event.
*/
/**
* Class for a block move event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -32,6 +29,7 @@ interface BlockLocation {
/**
* Class for a block move event. Created before the move.
*
* @alias Blockly.Events.BlockMove
*/
export class BlockMove extends BlockBase {
@@ -71,7 +69,8 @@ export class BlockMove extends BlockBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -93,6 +92,7 @@ export class BlockMove extends BlockBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -119,7 +119,8 @@ export class BlockMove extends BlockBase {
/**
* Returns the parentId and input if the block is connected,
* or the XY location if disconnected.
* @return Collection of location info.
*
* @returns Collection of location info.
*/
private currentLocation_(): BlockLocation {
const workspace = this.getEventWorkspace_();
@@ -142,7 +143,8 @@ export class BlockMove extends BlockBase {
/**
* Does this event record any change of state?
* @return False if something changed.
*
* @returns False if something changed.
*/
override isNull(): boolean {
return this.oldParentId === this.newParentId &&
@@ -152,6 +154,7 @@ export class BlockMove extends BlockBase {
/**
* Run a move event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of bubble open.
*/
/**
* Events fired as a result of bubble open.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -24,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a bubble open event.
*
* @alias Blockly.Events.BubbleOpen
*/
export class BubbleOpen extends UiBase {
@@ -57,7 +55,8 @@ export class BubbleOpen extends UiBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -69,6 +68,7 @@ export class BubbleOpen extends UiBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of UI click in Blockly's editor.
*/
/**
* Events fired as a result of UI click in Blockly's editor.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -24,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a click event.
*
* @alias Blockly.Events.Click
*/
export class Click extends UiBase {
@@ -59,7 +57,8 @@ export class Click extends UiBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -72,6 +71,7 @@ export class Click extends UiBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Base class for comment events.
*/
/**
* Base class for comment events.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -27,6 +24,7 @@ import * as eventUtils from './utils.js';
/**
* Abstract class for a comment event.
*
* @alias Blockly.Events.CommentBase
*/
export class CommentBase extends AbstractEvent {
@@ -62,7 +60,8 @@ export class CommentBase extends AbstractEvent {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -74,6 +73,7 @@ export class CommentBase extends AbstractEvent {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -83,6 +83,7 @@ export class CommentBase extends AbstractEvent {
/**
* Helper function for Comment[Create|Delete]
*
* @param event The event to run.
* @param create if True then Create, if False then Delete
*/
+8 -6
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for comment change event.
*/
/**
* Class for comment change event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -24,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a comment change event.
*
* @alias Blockly.Events.CommentChange
*/
export class CommentChange extends CommentBase {
@@ -60,7 +58,8 @@ export class CommentChange extends CommentBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -71,6 +70,7 @@ export class CommentChange extends CommentBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -81,7 +81,8 @@ export class CommentChange extends CommentBase {
/**
* Does this event record any change of state?
* @return False if something changed.
*
* @returns False if something changed.
*/
override isNull(): boolean {
return this.oldContents_ === this.newContents_;
@@ -89,6 +90,7 @@ export class CommentChange extends CommentBase {
/**
* Run a change event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for comment creation event.
*/
/**
* Class for comment creation event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -25,6 +22,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a comment creation event.
*
* @alias Blockly.Events.CommentCreate
*/
export class CommentCreate extends CommentBase {
@@ -52,7 +50,8 @@ export class CommentCreate extends CommentBase {
// TODO (#1266): "Full" and "minimal" serialization.
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -62,6 +61,7 @@ export class CommentCreate extends CommentBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -71,6 +71,7 @@ export class CommentCreate extends CommentBase {
/**
* Run a creation event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for comment deletion event.
*/
/**
* Class for comment deletion event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -24,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a comment deletion event.
*
* @alias Blockly.Events.CommentDelete
*/
export class CommentDelete extends CommentBase {
@@ -49,7 +47,8 @@ export class CommentDelete extends CommentBase {
// TODO (#1266): "Full" and "minimal" serialization.
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -58,6 +57,7 @@ export class CommentDelete extends CommentBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -66,6 +66,7 @@ export class CommentDelete extends CommentBase {
/**
* Run a creation event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+9 -6
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for comment move event.
*/
/**
* Class for comment move event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -25,6 +22,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a comment move event. Created before the move.
*
* @alias Blockly.Events.CommentMove
*/
export class CommentMove extends CommentBase {
@@ -83,6 +81,7 @@ export class CommentMove extends CommentBase {
/**
* Override the location before the move. Use this if you don't create the
* event until the end of the move, but you know the original location.
*
* @param xy The location before the move, in workspace coordinates.
*/
setOldCoordinate(xy: Coordinate) {
@@ -92,7 +91,8 @@ export class CommentMove extends CommentBase {
// TODO (#1266): "Full" and "minimal" serialization.
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -109,6 +109,7 @@ export class CommentMove extends CommentBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -126,7 +127,8 @@ export class CommentMove extends CommentBase {
/**
* Does this event record any change of state?
* @return False if something changed.
*
* @returns False if something changed.
*/
override isNull(): boolean {
return Coordinate.equals(this.oldCoordinate_, this.newCoordinate_);
@@ -134,6 +136,7 @@ export class CommentMove extends CommentBase {
/**
* Run a move event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of a marker move.
*/
/**
* Events fired as a result of a marker move.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -26,6 +23,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a marker move event.
*
* @alias Blockly.Events.MarkerMove
*/
export class MarkerMove extends UiBase {
@@ -72,7 +70,8 @@ export class MarkerMove extends UiBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -85,6 +84,7 @@ export class MarkerMove extends UiBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of element select action.
*/
/**
* Events fired as a result of element select action.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -23,6 +20,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a selected event.
*
* @alias Blockly.Events.Selected
*/
export class Selected extends UiBase {
@@ -55,7 +53,8 @@ export class Selected extends UiBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -66,6 +65,7 @@ export class Selected extends UiBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of a theme update.
*/
/**
* Events fired as a result of a theme update.
* @class
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of selecting an item on the toolbox.
*/
/**
* Events fired as a result of selecting an item on the toolbox.
* @class
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of trashcan flyout open and close.
*/
/**
* Events fired as a result of trashcan flyout open and close.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -23,6 +20,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a trashcan open event.
*
* @alias Blockly.Events.TrashcanOpen
*/
export class TrashcanOpen extends UiBase {
@@ -47,7 +45,8 @@ export class TrashcanOpen extends UiBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -57,6 +56,7 @@ export class TrashcanOpen extends UiBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
+5 -6
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview (Deprecated) Events fired as a result of UI actions in
* Blockly's editor.
*/
/**
* (Deprecated) Events fired as a result of UI actions in
* Blockly's editor.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -26,6 +22,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a UI event.
*
* @deprecated December 2020. Instead use a more specific UI event.
* @alias Blockly.Events.Ui
*/
@@ -60,7 +57,8 @@ export class Ui extends UiBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -76,6 +74,7 @@ export class Ui extends UiBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
+2 -5
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Base class for events fired as a result of UI actions in
* Blockly's editor.
*/
/**
* Base class for events fired as a result of UI actions in
* Blockly's editor.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -26,6 +22,7 @@ import {Abstract as AbstractEvent} from './events_abstract.js';
* editing to work (e.g. scrolling the workspace, zooming, opening toolbox
* categories).
* UI events do not undo or redo.
*
* @alias Blockly.Events.UiBase
*/
export class UiBase extends AbstractEvent {
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Abstract class for a variable event.
*/
/**
* Abstract class for a variable event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -22,6 +19,7 @@ import {Abstract as AbstractEvent} from './events_abstract.js';
/**
* Abstract class for a variable event.
*
* @alias Blockly.Events.VarBase
*/
export class VarBase extends AbstractEvent {
@@ -46,7 +44,8 @@ export class VarBase extends AbstractEvent {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -56,6 +55,7 @@ export class VarBase extends AbstractEvent {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a variable creation event.
*/
/**
* Class for a variable creation event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -24,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a variable creation event.
*
* @alias Blockly.Events.VarCreate
*/
export class VarCreate extends VarBase {
@@ -52,7 +50,8 @@ export class VarCreate extends VarBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -63,6 +62,7 @@ export class VarCreate extends VarBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -73,6 +73,7 @@ export class VarCreate extends VarBase {
/**
* Run a variable creation event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Classes for all types of variable events.
*/
/**
* Classes for all types of variable events.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -24,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a variable deletion event.
*
* @alias Blockly.Events.VarDelete
*/
export class VarDelete extends VarBase {
@@ -52,7 +50,8 @@ export class VarDelete extends VarBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -63,6 +62,7 @@ export class VarDelete extends VarBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -73,6 +73,7 @@ export class VarDelete extends VarBase {
/**
* Run a variable deletion event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+6 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a variable rename event.
*/
/**
* Class for a variable rename event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -24,6 +21,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a variable rename event.
*
* @alias Blockly.Events.VarRename
*/
export class VarRename extends VarBase {
@@ -53,7 +51,8 @@ export class VarRename extends VarBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -64,6 +63,7 @@ export class VarRename extends VarBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
@@ -74,6 +74,7 @@ export class VarRename extends VarBase {
/**
* Run a variable rename event.
*
* @param forward True if run forward, false if run backward (undo).
*/
override run(forward: boolean) {
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Events fired as a result of a viewport change.
*/
/**
* Events fired as a result of a viewport change.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -23,6 +20,7 @@ import * as eventUtils from './utils.js';
/**
* Class for a viewport change event.
*
* @alias Blockly.Events.ViewportChange
*/
export class ViewportChange extends UiBase {
@@ -72,7 +70,8 @@ export class ViewportChange extends UiBase {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = super.toJson();
@@ -85,6 +84,7 @@ export class ViewportChange extends UiBase {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Helper methods for events that are fired as a result of
* actions in Blockly's editor.
*/
/**
* Helper methods for events that are fired as a result of
* actions in Blockly's editor.
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a finished loading workspace event.
*/
/**
* Class for a finished loading workspace event.
*
* @class
*/
import * as goog from '../../closure/goog/goog.js';
@@ -27,6 +24,7 @@ import * as eventUtils from './utils.js';
* Used to notify the developer when the workspace has finished loading (i.e
* domToWorkspace).
* Finished loading events do not record undo or redo.
*
* @alias Blockly.Events.FinishedLoading
*/
export class FinishedLoading extends AbstractEvent {
@@ -56,7 +54,8 @@ export class FinishedLoading extends AbstractEvent {
/**
* Encode the event as JSON.
* @return JSON representation.
*
* @returns JSON representation.
*/
override toJson(): AnyDuringMigration {
const json = {
@@ -73,6 +72,7 @@ export class FinishedLoading extends AbstractEvent {
/**
* Decode the JSON event.
*
* @param json JSON representation.
*/
override fromJson(json: AnyDuringMigration) {
-7
View File
@@ -4,13 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Extensions are functions that help initialize blocks, usually
* adding dynamic behavior such as onchange handlers and mutators. These
* are applied using Block.applyExtension(), or the JSON "extensions"
* array attribute.
*/
/**
* Extensions are functions that help initialize blocks, usually
* adding dynamic behavior such as onchange handlers and mutators. These
+88 -35
View File
@@ -4,16 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Field. Used for editable titles, variables, etc.
* This is an abstract class that defines the UI on the block. Actual
* instances would be FieldTextInput, FieldDropdown, etc.
*/
/**
* Field. Used for editable titles, variables, etc.
* This is an abstract class that defines the UI on the block. Actual
* instances would be FieldTextInput, FieldDropdown, etc.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -58,6 +53,7 @@ import * as Xml from './xml.js';
/**
* Abstract class for an editable field.
*
* @alias Blockly.Field
*/
export abstract class Field implements IASTNodeLocationSvg,
@@ -140,6 +136,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Has this field been disposed of?
*
* @internal
*/
disposed = false;
@@ -169,12 +166,14 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* The prefix field.
*
* @internal
*/
prefixField: string|null = null;
/**
* The suffix field.
*
* @internal
*/
suffixField: string|null = null;
@@ -233,6 +232,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Process the configuration map passed to the field.
*
* @param config A map of options used to configure the field. See the
* individual field's documentation for a list of properties this
* parameter supports.
@@ -247,6 +247,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Attach this field to a block.
*
* @param block The block containing this field.
*/
setSourceBlock(block: Block) {
@@ -258,7 +259,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Get the renderer constant provider.
* @return The renderer constant provider.
*
* @returns The renderer constant provider.
*/
getConstants(): ConstantProvider|null {
if (!this.constants_ && this.sourceBlock_ && !this.sourceBlock_.disposed &&
@@ -272,7 +274,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Get the block this field is attached to.
* @return The block containing this field.
*
* @returns The block containing this field.
*/
getSourceBlock(): Block {
return this.sourceBlock_;
@@ -281,6 +284,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Initialize everything to render this field. Override
* methods initModel and initView rather than this method.
*
* @final
* @internal
*/
@@ -304,6 +308,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Create the block UI for this field.
*
* @internal
*/
initView() {
@@ -314,6 +319,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Initializes the model of the field after it has been installed on a block.
* No-op by default.
*
* @internal
*/
initModel() {}
@@ -368,6 +374,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Sets the field's value based on the given XML element. Should only be
* called by Blockly.Xml.
*
* @param fieldElement The element containing info about the field's state.
* @internal
*/
@@ -377,9 +384,10 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Serializes this field's value to XML. Should only be called by Blockly.Xml.
*
* @param fieldElement The element to populate with info about the field's
* state.
* @return The element containing info about the field's state.
* @returns The element containing info about the field's state.
* @internal
*/
toXml(fieldElement: Element): Element {
@@ -390,10 +398,11 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Saves this fields value as something which can be serialized to JSON.
* Should only be called by the serialization system.
*
* @param _doFullSerialization If true, this signals to the field that if it
* normally just saves a reference to some state (eg variable fields) it
* should instead serialize the full state of the thing being referenced.
* @return JSON serializable state.
* @returns JSON serializable state.
* @internal
*/
saveState(_doFullSerialization?: boolean): AnyDuringMigration {
@@ -407,6 +416,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Sets the field's state based on the given state value. Should only be
* called by the serialization system.
*
* @param state The state we want to apply to the field.
* @internal
*/
@@ -421,9 +431,10 @@ export abstract class Field implements IASTNodeLocationSvg,
* Returns a stringified version of the XML state, if it should be used.
* Otherwise this returns null, to signal the field should use its own
* serialization.
*
* @param callingClass The class calling this method.
* Used to see if `this` has overridden any relevant hooks.
* @return The stringified version of the XML state, or null.
* @returns The stringified version of the XML state, or null.
*/
protected saveLegacyState(callingClass: AnyDuringMigration): string|null {
if (callingClass.prototype.saveState === this.saveState &&
@@ -442,10 +453,11 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Loads the given state using either the old XML hooks, if they should be
* used. Returns true to indicate loading has been handled, false otherwise.
*
* @param callingClass The class calling this method.
* Used to see if `this` has overridden any relevant hooks.
* @param state The state to apply to the field.
* @return Whether the state was applied or not.
* @returns Whether the state was applied or not.
*/
loadLegacyState(callingClass: AnyDuringMigration, state: AnyDuringMigration):
boolean {
@@ -461,6 +473,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Dispose of all DOM objects and events belonging to this editable field.
*
* @internal
*/
dispose() {
@@ -497,6 +510,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Set whether this field's value can be changed using the editor when the
* source block is editable.
*
* @param enabled True if enabled.
*/
setEnabled(enabled: boolean) {
@@ -507,7 +521,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Check whether this field's value can be changed using the editor when the
* source block is editable.
* @return Whether this field is enabled.
*
* @returns Whether this field is enabled.
*/
isEnabled(): boolean {
return this.enabled_;
@@ -515,7 +530,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Check whether this field defines the showEditor_ function.
* @return Whether this field is clickable.
*
* @returns Whether this field is clickable.
*/
isClickable(): boolean {
return this.enabled_ && !!this.sourceBlock_ &&
@@ -527,7 +543,8 @@ export abstract class Field implements IASTNodeLocationSvg,
* Check whether this field is currently editable. Some fields are never
* EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on
* non-editable blocks or be currently disabled.
* @return Whether this field is currently enabled, editable and on an
*
* @returns Whether this field is currently enabled, editable and on an
* editable block.
*/
isCurrentlyEditable(): boolean {
@@ -538,7 +555,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Check whether this field should be serialized by the XML renderer.
* Handles the logic for backwards compatibility and incongruous states.
* @return Whether this field should be serialized or not.
*
* @returns Whether this field should be serialized or not.
*/
isSerializable(): boolean {
let isSerializable = false;
@@ -558,7 +576,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Gets whether this editable field is visible or not.
* @return True if visible.
*
* @returns True if visible.
*/
isVisible(): boolean {
return this.visible_;
@@ -567,6 +586,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Sets whether this editable field is visible or not. Should only be called
* by input.setVisible.
*
* @param visible True if visible.
* @internal
*/
@@ -602,7 +622,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Gets the validation function for editable fields, or null if not set.
* @return Validation function, or null.
*
* @returns Validation function, or null.
*/
getValidator(): Function|null {
return this.validator_;
@@ -611,7 +632,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Gets the group element for this editable field.
* Used for measuring the size and for positioning.
* @return The group element.
*
* @returns The group element.
*/
getSvgRoot(): SVGGElement {
return this.fieldGroup_;
@@ -620,6 +642,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Updates the field to match the colour/style of the block. Should only be
* called by BlockSvg.applyColour().
*
* @internal
*/
applyColour() {}
@@ -641,6 +664,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Calls showEditor_ when the field is clicked if the field is clickable.
* Do not override.
*
* @param opt_e Optional mouse event that triggered the field to open, or
* undefined if triggered programmatically.
* @final
@@ -655,6 +679,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* A developer hook to create an editor for the field. This is no-op by
* default, and must be overriden to create an editor.
*
* @param _e Optional mouse event that triggered the field to open, or
* undefined if triggered programmatically.
*/
@@ -663,6 +688,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Updates the size of the field based on the text.
*
* @param opt_margin margin to use when positioning the text element.
*/
protected updateSize_(opt_margin?: number) {
@@ -694,6 +720,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Position a field's text element after a size change. This handles both LTR
* and RTL positioning.
*
* @param xOffset x offset to use when positioning the text element.
* @param contentWidth The content width.
*/
@@ -749,7 +776,8 @@ export abstract class Field implements IASTNodeLocationSvg,
* Returns the height and width of the field.
*
* This should *in general* be the only place render_ gets called from.
* @return Height and width.
*
* @returns Height and width.
*/
getSize(): Size {
if (!this.isVisible()) {
@@ -773,7 +801,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Returns the bounding box of the rendered field, accounting for workspace
* scaling.
* @return An object with top, bottom, left, and right in pixels relative to
*
* @returns An object with top, bottom, left, and right in pixels relative to
* the top left corner of the page (window coordinates).
* @internal
*/
@@ -816,7 +845,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Get the text from this field to display on the block. May differ from
* ``getText`` due to ellipsis, and other formatting.
* @return Text to display.
*
* @returns Text to display.
*/
protected getDisplayText_(): string {
let text = this.getText();
@@ -841,7 +871,8 @@ export abstract class Field implements IASTNodeLocationSvg,
* Get the text from this field.
* Override getText_ to provide a different behavior than simply casting the
* value to a string.
* @return Current text.
*
* @returns Current text.
* @final
*/
getText(): string {
@@ -859,7 +890,8 @@ export abstract class Field implements IASTNodeLocationSvg,
* Override if the text representation of the value of this field
* is not just a string cast of its value.
* Return null to resort to a string cast.
* @return Current text or null.
*
* @returns Current text or null.
*/
protected getText_(): string|null {
return null;
@@ -870,6 +902,7 @@ export abstract class Field implements IASTNodeLocationSvg,
* rerender this field and adjust for any sizing changes.
* Other fields on the same block will not rerender, because their sizes have
* already been recorded.
*
* @internal
*/
markDirty() {
@@ -884,6 +917,7 @@ export abstract class Field implements IASTNodeLocationSvg,
* rerender this field and adjust for any sizing changes.
* Other fields on the same block will not rerender, because their sizes have
* already been recorded.
*
* @internal
*/
forceRerender() {
@@ -899,6 +933,7 @@ export abstract class Field implements IASTNodeLocationSvg,
* Used to change the value of the field. Handles validation and events.
* Subclasses should override doClassValidation_ and doValueUpdate_ rather
* than this method.
*
* @param newValue New value.
* @final
*/
@@ -954,9 +989,10 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Process the result of validation.
*
* @param newValue New value.
* @param validatedValue Validated value.
* @return New value, or an Error object.
* @returns New value, or an Error object.
*/
private processValidation_(
newValue: AnyDuringMigration,
@@ -976,7 +1012,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Get the current value of the field.
* @return Current value.
*
* @returns Current value.
*/
getValue(): AnyDuringMigration {
return this.value_;
@@ -985,8 +1022,9 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Used to validate a value. Returns input by default. Can be overridden by
* subclasses, see FieldDropdown.
*
* @param opt_newValue The value to be validated.
* @return The validated value, same as input by default.
* @returns The validated value, same as input by default.
*/
protected doClassValidation_(opt_newValue?: AnyDuringMigration):
AnyDuringMigration {
@@ -999,6 +1037,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Used to update the value of a field. Can be overridden by subclasses to do
* custom storage of values/updating of external things.
*
* @param newValue The value to be saved.
*/
protected doValueUpdate_(newValue: AnyDuringMigration) {
@@ -1010,6 +1049,7 @@ export abstract class Field implements IASTNodeLocationSvg,
* Used to notify the field an invalid value was input. Can be overridden by
* subclasses, see FieldTextInput.
* No-op by default.
*
* @param _invalidValue The input value that was determined to be invalid.
*/
protected doValueInvalid_(_invalidValue: AnyDuringMigration) {}
@@ -1017,6 +1057,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Handle a mouse down event on a field.
*
* @param e Mouse down event.
*/
protected onMouseDown_(e: Event) {
@@ -1031,6 +1072,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Sets the tooltip for this field.
*
* @param newTip The text for the tooltip, a function that returns the text
* for the tooltip, a parent object whose tooltip will be used, or null to
* display the tooltip of the parent block. To not display a tooltip pass
@@ -1051,7 +1093,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Returns the tooltip text for this field.
* @return The tooltip text for this field.
*
* @returns The tooltip text for this field.
*/
getTooltip(): string {
const clickTarget = this.getClickTarget_();
@@ -1066,7 +1109,8 @@ export abstract class Field implements IASTNodeLocationSvg,
* The element to bind the click handler to. If not set explicitly, defaults
* to the SVG root of the field. When this element is
* clicked on an editable field, the editor will open.
* @return Element to bind click handler to.
*
* @returns Element to bind click handler to.
*/
protected getClickTarget_(): Element {
return this.clickTarget_ || this.getSvgRoot();
@@ -1075,7 +1119,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Return the absolute coordinates of the top-left corner of this field.
* The origin (0,0) is the top-left corner of the page body.
* @return Object with .x and .y properties.
*
* @returns Object with .x and .y properties.
*/
protected getAbsoluteXY_(): Coordinate {
return style.getPageOffset(this.getClickTarget_() as SVGRectElement);
@@ -1085,7 +1130,8 @@ export abstract class Field implements IASTNodeLocationSvg,
* Whether this field references any Blockly variables. If true it may need
* to be handled differently during serialization and deserialization.
* Subclasses may override this.
* @return True if this field has any variable references.
*
* @returns True if this field has any variable references.
* @internal
*/
referencesVariables(): boolean {
@@ -1095,6 +1141,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Refresh the variable name referenced by this field if this field references
* variables.
*
* @internal
*/
refreshVariableName() {}
@@ -1103,7 +1150,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Search through the list of inputs and their fields in order to find the
* parent input of a field.
* @return The input that the field belongs to.
*
* @returns The input that the field belongs to.
* @internal
*/
getParentInput(): Input {
@@ -1128,7 +1176,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Returns whether or not we should flip the field in RTL.
* @return True if we should flip in RTL.
*
* @returns True if we should flip in RTL.
*/
getFlipRtl(): boolean {
return false;
@@ -1136,7 +1185,8 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Returns whether or not the field is tab navigable.
* @return True if the field is tab navigable.
*
* @returns True if the field is tab navigable.
*/
isTabNavigable(): boolean {
return false;
@@ -1144,8 +1194,9 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Handles the given keyboard shortcut.
*
* @param _shortcut The shortcut to be handled.
* @return True if the shortcut has been handled, false otherwise.
* @returns True if the shortcut has been handled, false otherwise.
*/
onShortcut(_shortcut: KeyboardShortcut): boolean {
return false;
@@ -1153,6 +1204,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Add the cursor SVG to this fields SVG group.
*
* @param cursorSvg The SVG root of the cursor to be added to the field group.
* @internal
*/
@@ -1170,6 +1222,7 @@ export abstract class Field implements IASTNodeLocationSvg,
/**
* Add the marker SVG to this fields SVG group.
*
* @param markerSvg The SVG root of the marker to be added to the field group.
* @internal
*/
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Angle input field.
*/
/**
* Angle input field.
* @class
+20 -11
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Checkbox field. Checked or not checked.
*/
/**
* Checkbox field. Checked or not checked.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -26,6 +23,7 @@ import type {Sentinel} from './utils/sentinel.js';
/**
* Class for a checkbox field.
*
* @alias Blockly.FieldCheckbox
*/
export class FieldCheckbox extends Field {
@@ -84,6 +82,7 @@ export class FieldCheckbox extends Field {
/**
* Configure the field based on the given map of options.
*
* @param config A map of options to configure the field based on.
*/
protected override configure_(config: FieldCheckboxConfig) {
@@ -93,7 +92,8 @@ export class FieldCheckbox extends Field {
/**
* Saves this field's value.
* @return The boolean value held by this field.
*
* @returns The boolean value held by this field.
* @internal
*/
override saveState(): AnyDuringMigration {
@@ -106,6 +106,7 @@ export class FieldCheckbox extends Field {
/**
* Create the block UI for this checkbox.
*
* @internal
*/
override initView() {
@@ -128,6 +129,7 @@ export class FieldCheckbox extends Field {
/**
* Set the character used for the check mark.
*
* @param character The character to use for the check mark, or null to use
* the default.
*/
@@ -143,8 +145,9 @@ export class FieldCheckbox extends Field {
/**
* Ensure that the input value is valid ('TRUE' or 'FALSE').
*
* @param opt_newValue The input value.
* @return A valid value ('TRUE' or 'FALSE), or null if invalid.
* @returns A valid value ('TRUE' or 'FALSE), or null if invalid.
*/
protected override doClassValidation_(opt_newValue?: AnyDuringMigration):
string|null {
@@ -159,6 +162,7 @@ export class FieldCheckbox extends Field {
/**
* Update the value of the field, and update the checkElement.
*
* @param newValue The value to be saved. The default validator guarantees
* that this is a either 'TRUE' or 'FALSE'.
*/
@@ -172,7 +176,8 @@ export class FieldCheckbox extends Field {
/**
* Get the value of this field, either 'TRUE' or 'FALSE'.
* @return The value of this field.
*
* @returns The value of this field.
*/
override getValue(): string {
return this.value_ ? 'TRUE' : 'FALSE';
@@ -180,7 +185,8 @@ export class FieldCheckbox extends Field {
/**
* Get the boolean value of this field.
* @return The boolean value of this field.
*
* @returns The boolean value of this field.
*/
getValueBoolean(): boolean {
return this.value_ as boolean;
@@ -188,7 +194,8 @@ export class FieldCheckbox extends Field {
/**
* Get the text of this field. Used when the block is collapsed.
* @return Text representing the value of this field ('true' or 'false').
*
* @returns Text representing the value of this field ('true' or 'false').
*/
override getText(): string {
return String(this.convertValueToBool_(this.value_));
@@ -199,8 +206,9 @@ export class FieldCheckbox extends Field {
*
* Converts 'TRUE' to true and 'FALSE' to false correctly, everything else
* is cast to a boolean.
*
* @param value The value to convert.
* @return The converted value.
* @returns The converted value.
*/
private convertValueToBool_(value: AnyDuringMigration): boolean {
if (typeof value === 'string') {
@@ -212,8 +220,9 @@ export class FieldCheckbox extends Field {
/**
* Construct a FieldCheckbox from a JSON arg object.
*
* @param options A JSON object with options (checked).
* @return The new field instance.
* @returns The new field instance.
* @nocollapse
* @internal
*/
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Colour input field.
*/
/**
* Colour input field.
* @class
+29 -14
View File
@@ -4,16 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Dropdown input field. Used for editable titles and variables.
* In the interests of a consistent UI, the toolbox shares some functions and
* properties with the context menu.
*/
/**
* Dropdown input field. Used for editable titles and variables.
* In the interests of a consistent UI, the toolbox shares some functions and
* properties with the context menu.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -37,6 +32,7 @@ import * as userAgent from './utils/useragent.js';
/**
* Class for an editable dropdown field.
*
* @alias Blockly.FieldDropdown
*/
export class FieldDropdown extends Field {
@@ -86,12 +82,14 @@ export class FieldDropdown extends Field {
/**
* The prefix field label, of common words set after options are trimmed.
*
* @internal
*/
override prefixField: string|null = null;
/**
* The suffix field label, of common words set after options are trimmed.
*
* @internal
*/
override suffixField: string|null = null;
@@ -156,6 +154,7 @@ export class FieldDropdown extends Field {
/**
* Sets the field's value based on the given XML element. Should only be
* called by Blockly.Xml.
*
* @param fieldElement The element containing info about the field's state.
* @internal
*/
@@ -168,6 +167,7 @@ export class FieldDropdown extends Field {
/**
* Sets the field's value based on the given state.
*
* @param state The state to apply to the dropdown field.
* @internal
*/
@@ -183,6 +183,7 @@ export class FieldDropdown extends Field {
/**
* Create the block UI for this dropdown.
*
* @internal
*/
override initView() {
@@ -208,7 +209,8 @@ export class FieldDropdown extends Field {
/**
* Whether or not the dropdown should add a border rect.
* @return True if the dropdown field should add a border rect.
*
* @returns True if the dropdown field should add a border rect.
*/
protected shouldAddBorderRect_(): boolean {
return !this.getConstants()!.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW ||
@@ -249,6 +251,7 @@ export class FieldDropdown extends Field {
/**
* Create a dropdown menu under the text.
*
* @param opt_e Optional mouse event that triggered the field to open, or
* undefined if triggered programmatically.
*/
@@ -343,6 +346,7 @@ export class FieldDropdown extends Field {
/**
* Handle an action in the dropdown menu.
*
* @param menuItem The MenuItem selected within menu.
*/
private handleMenuActionEvent_(menuItem: MenuItem) {
@@ -352,6 +356,7 @@ export class FieldDropdown extends Field {
/**
* Handle the selection of an item in the dropdown menu.
*
* @param menu The Menu component clicked.
* @param menuItem The MenuItem selected within menu.
*/
@@ -411,7 +416,7 @@ export class FieldDropdown extends Field {
}
/**
* @return True if the option list is generated by a function.
* @returns True if the option list is generated by a function.
* Otherwise false.
*/
isOptionListDynamic(): boolean {
@@ -420,9 +425,10 @@ export class FieldDropdown extends Field {
/**
* Return a list of the options for this dropdown.
*
* @param opt_useCache For dynamic options, whether or not to use the cached
* options or to re-generate them.
* @return A non-empty array of option tuples:
* @returns A non-empty array of option tuples:
* (human-readable text or image, language-neutral name).
* @throws {TypeError} If generated options are incorrectly structured.
*/
@@ -442,8 +448,9 @@ export class FieldDropdown extends Field {
/**
* Ensure that the input value is a valid language-neutral option.
*
* @param opt_newValue The input value.
* @return A valid language-neutral option, or null if invalid.
* @returns A valid language-neutral option, or null if invalid.
*/
protected override doClassValidation_(opt_newValue?: AnyDuringMigration):
string|null {
@@ -470,6 +477,7 @@ export class FieldDropdown extends Field {
/**
* Update the value of this dropdown field.
*
* @param newValue The value to be saved. The default validator guarantees
* that this is one of the valid dropdown options.
*/
@@ -485,6 +493,7 @@ export class FieldDropdown extends Field {
/**
* Updates the dropdown arrow to match the colour/style of the block.
*
* @internal
*/
override applyColour() {
@@ -526,6 +535,7 @@ export class FieldDropdown extends Field {
/**
* Renders the selected option, which must be an image.
*
* @param imageJson Selected option that must be an image.
*/
private renderSelectedImage_(imageJson: ImageProperties) {
@@ -613,9 +623,10 @@ export class FieldDropdown extends Field {
/**
* Position a drop-down arrow at the appropriate location at render-time.
*
* @param x X position the arrow is being rendered at, in px.
* @param y Y position the arrow is being rendered at, in px.
* @return Amount of space the arrow is taking up, in px.
* @returns Amount of space the arrow is taking up, in px.
*/
private positionSVGArrow_(x: number, y: number): number {
if (!this.svgArrow_) {
@@ -636,7 +647,8 @@ export class FieldDropdown extends Field {
* Use the `getText_` developer hook to override the field's text
* representation. Get the selected option text. If the selected option is an
* image we return the image alt text.
* @return Selected option text.
*
* @returns Selected option text.
*/
protected override getText_(): string|null {
if (!this.selectedOption_) {
@@ -651,8 +663,9 @@ export class FieldDropdown extends Field {
/**
* Construct a FieldDropdown from a JSON arg object.
*
* @param options A JSON object with options (options).
* @return The new field instance.
* @returns The new field instance.
* @nocollapse
* @internal
*/
@@ -671,11 +684,12 @@ export class FieldDropdown extends Field {
/**
* Use the calculated prefix and suffix lengths to trim all of the options in
* the given array.
*
* @param options Array of option tuples:
* (human-readable text or image, language-neutral name).
* @param prefixLength The length of the common prefix.
* @param suffixLength The length of the common suffix
* @return A new array with all of the option text trimmed.
* @returns A new array with all of the option text trimmed.
*/
static applyTrim_(
options: AnyDuringMigration[][], prefixLength: number,
@@ -730,6 +744,7 @@ FieldDropdown.ARROW_CHAR = userAgent.ANDROID ? '\u25BC' : '\u25BE';
/**
* Validates the data structure to be processed as an options list.
*
* @param options The proposed dropdown options.
* @throws {TypeError} If proposed options are incorrectly structured.
*/
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Image field. Used for pictures, icons, etc.
*/
/**
* Image field. Used for pictures, icons, etc.
* @class
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Non-editable, non-serializable text field. Used for titles,
* labels, etc.
*/
/**
* Non-editable, non-serializable text field. Used for titles,
* labels, etc.
+4 -7
View File
@@ -4,16 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Non-editable, serializable text field. Behaves like a
* normal label but is serialized to XML. It may only be
* edited programmatically.
*/
/**
* Non-editable, serializable text field. Behaves like a
* normal label but is serialized to XML. It may only be
* edited programmatically.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -26,6 +21,7 @@ import * as parsing from './utils/parsing.js';
/**
* Class for a non-editable, serializable text field.
*
* @alias Blockly.FieldLabelSerializable
*/
export class FieldLabelSerializable extends FieldLabel {
@@ -59,8 +55,9 @@ export class FieldLabelSerializable extends FieldLabel {
/**
* Construct a FieldLabelSerializable from a JSON arg object,
* dereferencing any string table references.
*
* @param options A JSON object with options (text, and class).
* @return The new field instance.
* @returns The new field instance.
* @nocollapse
* @internal
*/
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Text Area field.
*/
/**
* Text Area field.
* @class
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Number input field
*/
/**
* Number input field
* @class
+7 -7
View File
@@ -4,16 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Fields can be created based on a JSON definition. This file
* contains methods for registering those JSON definitions, and building the
* fields based on JSON.
*/
/**
* Fields can be created based on a JSON definition. This file
* contains methods for registering those JSON definitions, and building the
* fields based on JSON.
*
* @namespace Blockly.fieldRegistry
*/
import * as goog from '../closure/goog/goog.js';
@@ -28,6 +23,7 @@ import * as registry from './registry.js';
* Registers a field type.
* fieldRegistry.fromJson uses this registry to
* find the appropriate field type.
*
* @param type The field type name as used in the JSON definition.
* @param fieldClass The field class containing a fromJson function that can
* construct an instance of the field.
@@ -41,6 +37,7 @@ export function register(type: string, fieldClass: IRegistrableField) {
/**
* Unregisters the field registered with the given type.
*
* @param type The field type name as used in the JSON definition.
* @alias Blockly.fieldRegistry.unregister
*/
@@ -52,9 +49,10 @@ export function unregister(type: string) {
* Construct a Field from a JSON arg object.
* Finds the appropriate registered field by the type name as registered using
* fieldRegistry.register.
*
* @param options A JSON object with a type and options specific to the field
* type.
* @return The new field instance or null if a field wasn't found with the given
* @returns The new field instance or null if a field wasn't found with the given
* type name
* @alias Blockly.fieldRegistry.fromJson
* @internal
@@ -65,6 +63,8 @@ export function fromJson(options: AnyDuringMigration): Field|null {
/**
* Private version of fromJson for stubbing in tests.
*
* @param options
*/
function fromJsonInternal(options: AnyDuringMigration): Field|null {
const fieldObject =
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Text input field.
*/
/**
* Text input field.
* @class
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Variable input field.
*/
/**
* Variable input field.
* @class
+69 -25
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Flyout tray containing blocks which may be created.
*/
/**
* Flyout tray containing blocks which may be created.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -46,6 +43,7 @@ enum FlyoutItemType {
/**
* Class for a flyout.
*
* @alias Blockly.Flyout
*/
export abstract class Flyout extends DeleteArea implements IFlyout {
@@ -58,14 +56,16 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
* Determine if a drag delta is toward the workspace, based on the position
* and orientation of the flyout. This is used in determineDragIntention_ to
* determine if a new block should be created or if the flyout should scroll.
*
* @param currentDragDeltaXY How far the pointer has
* moved from the position at mouse down, in pixel units.
* @return True if the drag is toward the workspace.
* @returns True if the drag is toward the workspace.
*/
abstract isDragTowardWorkspace(currentDragDeltaXY: Coordinate): boolean;
/**
* Sets the translation of the flyout to match the scrollbars.
*
* @param xyRatio Contains a y property which is a float
* between 0 and 1 specifying the degree of scrolling and a
* similar x property.
@@ -74,6 +74,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Lay out the blocks in the flyout.
*
* @param contents The blocks and buttons to lay
* out.
* @param gaps The visible gaps between blocks.
@@ -82,6 +83,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Scroll the flyout.
*
* @param e Mouse wheel scroll event.
*/
protected abstract wheel_(e: WheelEvent): void;
@@ -94,13 +96,15 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Calculates the x coordinate for the flyout position.
* @return X coordinate.
*
* @returns X coordinate.
*/
abstract getX(): number;
/**
* Calculates the y coordinate for the flyout position.
* @return Y coordinate.
*
* @returns Y coordinate.
*/
abstract getY(): number;
@@ -118,6 +122,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
RTL: boolean;
/**
* Whether the flyout should be laid out horizontally or not.
*
* @internal
*/
horizontalLayout: boolean = false;
@@ -163,6 +168,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* The target workspace.
*
* @internal
*/
targetWorkspace!: WorkspaceSvg;
@@ -277,6 +283,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* A map from blocks to the rects which are beneath them to act as input
* targets.
*
* @internal
*/
this.rectMap_ = new WeakMap();
@@ -304,9 +311,10 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
* Creates the flyout's DOM. Only needs to be called once. The flyout can
* either exist as its own SVG element or be a g element nested inside a
* separate SVG element.
*
* @param tagName The type of tag to
* put the flyout in. This should be <svg> or <g>.
* @return The flyout's SVG group.
* @returns The flyout's SVG group.
*/
createDom(tagName: string|Svg<SVGSVGElement>|Svg<SVGGElement>): SVGElement {
/*
@@ -331,6 +339,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Initializes the flyout.
*
* @param targetWorkspace The workspace in which to
* create new blocks.
*/
@@ -382,6 +391,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Dispose of this flyout.
* Unlink from all DOM elements to prevent memory leaks.
*
* @suppress {checkTypes}
*/
dispose() {
@@ -405,7 +415,8 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Get the width of the flyout.
* @return The width of the flyout.
*
* @returns The width of the flyout.
*/
getWidth(): number {
return this.width_;
@@ -413,7 +424,8 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Get the height of the flyout.
* @return The width of the flyout.
*
* @returns The width of the flyout.
*/
getHeight(): number {
return this.height_;
@@ -422,7 +434,8 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Get the scale (zoom level) of the flyout. By default,
* this matches the target workspace scale, but this can be overridden.
* @return Flyout workspace scale.
*
* @returns Flyout workspace scale.
*/
getFlyoutScale(): number {
return this.targetWorkspace.scale;
@@ -430,7 +443,8 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Get the workspace inside the flyout.
* @return The workspace inside the flyout.
*
* @returns The workspace inside the flyout.
* @internal
*/
getWorkspace(): WorkspaceSvg {
@@ -439,7 +453,8 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Is the flyout visible?
* @return True if visible.
*
* @returns True if visible.
*/
isVisible(): boolean {
return this.isVisible_;
@@ -449,6 +464,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
* Set whether the flyout is visible. A value of true does not necessarily
* mean that the flyout is shown. It could be hidden because its container is
* hidden.
*
* @param visible True if visible.
*/
setVisible(visible: boolean) {
@@ -467,6 +483,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Set whether this flyout's container is visible.
*
* @param visible Whether the container is visible.
*/
setContainerVisible(visible: boolean) {
@@ -498,6 +515,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Update the view based on coordinates calculated in position().
*
* @param width The computed width of the flyout's SVG group
* @param height The computed height of the flyout's SVG group.
* @param x The computed x origin of the flyout's SVG group.
@@ -560,6 +578,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Show and populate the flyout.
*
* @param flyoutDef Contents to display
* in the flyout. This is either an array of Nodes, a NodeList, a
* toolbox definition, or a string with the name of the dynamic category.
@@ -583,6 +602,10 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
// IE 11 is an incompetent browser that fails to fire mouseout events.
// When the mouse is over the background, deselect all blocks.
/**
*
* @param this
*/
function deselectAll(this: Flyout) {
const topBlocks = this.workspace_.getTopBlocks(false);
for (let i = 0, block; block = topBlocks[i]; i++) {
@@ -615,9 +638,10 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Create the contents array and gaps array necessary to create the layout for
* the flyout.
*
* @param parsedContent The array
* of objects to show in the flyout.
* @return The list of contents and gaps needed to lay out the flyout.
* @returns The list of contents and gaps needed to lay out the flyout.
*/
private createFlyoutInfo_(parsedContent: toolbox.FlyoutItemInfoArray):
{contents: FlyoutItem[], gaps: number[]} {
@@ -673,8 +697,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Gets the flyout definition for the dynamic category.
*
* @param categoryName The name of the dynamic category.
* @return The definition of the
* @returns The definition of the
* flyout in one of its many forms.
*/
private getDynamicCategoryContents_(categoryName: string):
@@ -694,9 +719,10 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Creates a flyout button or a flyout label.
*
* @param btnInfo The object holding information about a button or a label.
* @param isLabel True if the button is a label, false otherwise.
* @return The object used to display the button in the
* @returns The object used to display the button in the
* flyout.
*/
private createButton_(btnInfo: toolbox.ButtonOrLabelInfo, isLabel: boolean):
@@ -710,8 +736,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Create a block from the xml and permanently disable any blocks that were
* defined as disabled.
*
* @param blockInfo The info of the block.
* @return The block created from the blockInfo.
* @returns The block created from the blockInfo.
*/
private createFlyoutBlock_(blockInfo: toolbox.BlockInfo): BlockSvg {
let block;
@@ -745,8 +772,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Returns a block from the array of recycled blocks with the given type, or
* undefined if one cannot be found.
*
* @param blockType The type of the block to try to recycle.
* @return The recycled block, or undefined if
* @returns The recycled block, or undefined if
* one could not be recycled.
*/
private getRecycledBlock_(blockType: string): BlockSvg|undefined {
@@ -762,6 +790,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Adds a gap in the flyout based on block info.
*
* @param blockInfo Information about a block.
* @param gaps The list of gaps between items in the flyout.
* @param defaultGap The default gap between one element and the
@@ -783,6 +812,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Add the necessary gap in the flyout for a separator.
*
* @param sepInfo The object holding
* information about a separator.
* @param gaps The list gaps between items in the flyout.
@@ -848,8 +878,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Returns whether the given block can be recycled or not.
*
* @param _block The block to check for recyclability.
* @return True if the block can be recycled. False otherwise.
* @returns True if the block can be recycled. False otherwise.
*/
protected blockIsRecyclable_(_block: BlockSvg): boolean {
// By default, recycling is disabled.
@@ -860,6 +891,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
* Puts a previously created block into the recycle bin and moves it to the
* top of the workspace. Used during large workspace swaps to limit the number
* of new DOM elements we need to create.
*
* @param block The block to recycle.
*/
private recycleBlock_(block: BlockSvg) {
@@ -870,6 +902,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Add listeners to a block that has been added to the flyout.
*
* @param root The root node of the SVG group the block is in.
* @param block The block to add listeners for.
* @param rect The invisible rectangle under the block that acts
@@ -893,8 +926,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Handle a mouse-down on an SVG block in a non-closing flyout.
*
* @param block The flyout block to copy.
* @return Function to call when block is clicked.
* @returns Function to call when block is clicked.
*/
private blockMouseDown_(block: BlockSvg): Function {
const flyout = this;
@@ -909,6 +943,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Mouse down on the flyout background. Start a vertical scroll drag.
*
* @param e Mouse down event.
*/
private onMouseDown_(e: MouseEvent) {
@@ -921,8 +956,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Does this flyout allow you to create a new instance of the given block?
* Used for deciding if a block can be "dragged out of" the flyout.
*
* @param block The block to copy from the flyout.
* @return True if you can create a new instance of the block, false
* @returns True if you can create a new instance of the block, false
* otherwise.
* @internal
*/
@@ -932,8 +968,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Create a copy of this block on the workspace.
*
* @param originalBlock The block to copy from the flyout.
* @return The newly created block.
* @returns The newly created block.
* @throws {Error} if something went wrong with deserialization.
* @internal
*/
@@ -978,6 +1015,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Initialize the given button: move it to the correct location,
* add listeners, etc.
*
* @param button The button to initialize and place.
* @param x The x position of the cursor during this layout pass.
* @param y The y position of the cursor during this layout pass.
@@ -996,14 +1034,17 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Create and place a rectangle corresponding to the given block.
*
* @param block The block to associate the rect to.
* @param x The x position of the cursor during this layout pass.
* @param y The y position of the cursor during this layout pass.
* @param blockHW The height and width of
* the block.
* @param blockHW.height
* @param index The index into the mats list where this rect should
* be placed.
* @return Newly created SVG element for the rectangle behind
* @param blockHW.width
* @returns Newly created SVG element for the rectangle behind
* the block.
*/
protected createRect_(
@@ -1031,6 +1072,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Move a rectangle to sit exactly behind a block, taking into account tabs,
* hats, and any other protrusions we invent.
*
* @param rect The rectangle to move directly behind the block.
* @param block The block the rectangle should be behind.
*/
@@ -1079,7 +1121,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
}
/**
* @return True if this flyout may be scrolled with a scrollbar or
* @returns True if this flyout may be scrolled with a scrollbar or
* by dragging.
* @internal
*/
@@ -1090,8 +1132,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Copy a block from the flyout to the workspace and position it correctly.
*
* @param oldBlock The flyout block to copy.
* @return The new block in the main workspace.
* @returns The new block in the main workspace.
*/
private placeNewBlock_(oldBlock: BlockSvg): BlockSvg {
const targetWorkspace = this.targetWorkspace;
@@ -1113,6 +1156,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
/**
* Positions a block on the target workspace.
*
* @param oldBlock The flyout block being copied.
* @param block The block to posiiton.
*/
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class for a button in the flyout.
*/
/**
* Class for a button in the flyout.
* @class
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Horizontal flyout tray containing blocks which may be created.
*/
/**
* Horizontal flyout tray containing blocks which may be created.
* @class
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Calculates and reports flyout workspace metrics.
*/
/**
* Calculates and reports flyout workspace metrics.
* @class
+16 -8
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Layout code for a vertical variant of the flyout.
*/
/**
* Layout code for a vertical variant of the flyout.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -35,6 +32,7 @@ import * as WidgetDiv from './widgetdiv.js';
/**
* Class for a flyout.
*
* @alias Blockly.VerticalFlyout
*/
export class VerticalFlyout extends Flyout {
@@ -54,8 +52,11 @@ export class VerticalFlyout extends Flyout {
/**
* Sets the translation of the flyout to match the scrollbars.
*
* @param xyRatio Contains a y property which is a float between 0 and 1
* specifying the degree of scrolling and a similar x property.
* @param xyRatio.x
* @param xyRatio.y
*/
protected override setMetrics_(xyRatio: {x: number, y: number}) {
if (!this.isVisible()) {
@@ -78,7 +79,8 @@ export class VerticalFlyout extends Flyout {
/**
* Calculates the x coordinate for the flyout position.
* @return X coordinate.
*
* @returns X coordinate.
*/
override getX(): number {
if (!this.isVisible()) {
@@ -126,7 +128,8 @@ export class VerticalFlyout extends Flyout {
/**
* Calculates the y coordinate for the flyout position.
* @return Y coordinate.
*
* @returns Y coordinate.
*/
override getY(): number {
// Y is always 0 since this is a vertical flyout.
@@ -155,6 +158,7 @@ export class VerticalFlyout extends Flyout {
/**
* Create and set the path for the visible boundaries of the flyout.
*
* @param width The width of the flyout, not including the rounded corners.
* @param height The height of the flyout, not including rounded corners.
*/
@@ -190,6 +194,7 @@ export class VerticalFlyout extends Flyout {
/**
* Scroll the flyout.
*
* @param e Mouse wheel scroll event.
*/
protected override wheel_(e: WheelEvent) {
@@ -215,6 +220,7 @@ export class VerticalFlyout extends Flyout {
/**
* Lay out the blocks in the flyout.
*
* @param contents The blocks and buttons to lay out.
* @param gaps The visible gaps between blocks.
*/
@@ -264,9 +270,10 @@ export class VerticalFlyout extends Flyout {
* Determine if a drag delta is toward the workspace, based on the position
* and orientation of the flyout. This is used in determineDragIntention_ to
* determine if a new block should be created or if the flyout should scroll.
*
* @param currentDragDeltaXY How far the pointer has moved from the position
* at mouse down, in pixel units.
* @return True if the drag is toward the workspace.
* @returns True if the drag is toward the workspace.
* @internal
*/
override isDragTowardWorkspace(currentDragDeltaXY: Coordinate): boolean {
@@ -287,7 +294,8 @@ export class VerticalFlyout extends Flyout {
/**
* Returns the bounding rectangle of the drag target area in pixel units
* relative to viewport.
* @return The component's bounding box. Null if drag target area should be
*
* @returns The component's bounding box. Null if drag target area should be
* ignored.
*/
override getClientRect(): Rect|null {
-5
View File
@@ -4,11 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Utility functions for generating executable code from
* Blockly code.
*/
/**
* Utility functions for generating executable code from
* Blockly code.
+48 -18
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The class representing an in-progress gesture, usually a drag
* or a tap.
*/
/**
* The class representing an in-progress gesture, usually a drag
* or a tap.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -50,6 +46,7 @@ import type {WorkspaceSvg} from './workspace_svg.js';
// TODO: Consider touchcancel/pointercancel.
/**
* Class for one gesture.
*
* @alias Blockly.Gesture
*/
export class Gesture {
@@ -190,6 +187,7 @@ export class Gesture {
/**
* Sever all links from this object.
*
* @internal
*/
dispose() {
@@ -215,6 +213,7 @@ export class Gesture {
/**
* Update internal state based on an event.
*
* @param e The most recent mouse or touch event.
*/
private updateFromEvent_(e: Event) {
@@ -234,9 +233,10 @@ export class Gesture {
/**
* DO MATH to set currentDragDeltaXY_ based on the most recent mouse position.
*
* @param currentXY The most recent mouse/pointer position, in pixel units,
* with (0, 0) at the window's top left corner.
* @return True if the drag just exceeded the drag radius for the first time.
* @returns True if the drag just exceeded the drag radius for the first time.
*/
private updateDragDelta_(currentXY: Coordinate): boolean {
this.currentDragDeltaXY_ =
@@ -263,7 +263,8 @@ export class Gesture {
* gesture. If a block should be dragged from the flyout this function creates
* the new block on the main workspace and updates targetBlock_ and
* startWorkspace_.
* @return True if a block is being dragged from the flyout.
*
* @returns True if a block is being dragged from the flyout.
*/
private updateIsDraggingFromFlyout_(): boolean {
if (!this.targetBlock_) {
@@ -300,7 +301,8 @@ export class Gesture {
* the drag radius is exceeded. It should be called no more than once per
* gesture. If a bubble should be dragged this function creates the necessary
* BubbleDragger and starts the drag.
* @return True if a bubble is being dragged.
*
* @returns True if a bubble is being dragged.
*/
private updateIsDraggingBubble_(): boolean {
if (!this.startBubble_) {
@@ -319,7 +321,8 @@ export class Gesture {
* gesture. If a block should be dragged, either from the flyout or in the
* workspace, this function creates the necessary BlockDragger and starts the
* drag.
* @return True if a block is being dragged.
*
* @returns True if a block is being dragged.
*/
private updateIsDraggingBlock_(): boolean {
if (!this.targetBlock_) {
@@ -411,6 +414,7 @@ export class Gesture {
/**
* Start a gesture: update the workspace to indicate that a gesture is in
* progress and bind mousemove and mouseup handlers.
*
* @param e A mouse down or touch start event.
* @internal
*/
@@ -471,6 +475,7 @@ export class Gesture {
/**
* Bind gesture events.
*
* @param e A mouse down or touch start event.
* @internal
*/
@@ -486,6 +491,7 @@ export class Gesture {
/**
* Handle a mouse move or touch move event.
*
* @param e A mouse move or touch move event.
* @internal
*/
@@ -505,6 +511,7 @@ export class Gesture {
/**
* Handle a mouse up or touch end event.
*
* @param e A mouse up or touch end event.
* @internal
*/
@@ -548,6 +555,7 @@ export class Gesture {
/**
* Cancel an in-progress gesture. If a workspace or block drag is in
* progress, end the drag at the most recent location.
*
* @internal
*/
cancel() {
@@ -572,6 +580,7 @@ export class Gesture {
/**
* Handle a real or faked right-click event by showing a context menu.
*
* @param e A mouse move or touch move event.
* @internal
*/
@@ -596,6 +605,7 @@ export class Gesture {
/**
* Handle a mousedown/touchstart event on a workspace.
*
* @param e A mouse down or touch start event.
* @param ws The workspace the event hit.
* @internal
@@ -613,6 +623,7 @@ export class Gesture {
/**
* Fires a workspace click event.
*
* @param ws The workspace that a user clicks on.
*/
private fireWorkspaceClick_(ws: WorkspaceSvg) {
@@ -622,6 +633,7 @@ export class Gesture {
/**
* Handle a mousedown/touchstart event on a flyout.
*
* @param e A mouse down or touch start event.
* @param flyout The flyout the event hit.
* @internal
@@ -638,6 +650,7 @@ export class Gesture {
/**
* Handle a mousedown/touchstart event on a block.
*
* @param e A mouse down or touch start event.
* @param block The block the event hit.
* @internal
@@ -654,6 +667,7 @@ export class Gesture {
/**
* Handle a mousedown/touchstart event on a bubble.
*
* @param e A mouse down or touch start event.
* @param bubble The bubble the event hit.
* @internal
@@ -711,6 +725,7 @@ export class Gesture {
/**
* Execute a workspace click. When in accessibility mode shift clicking will
* move the cursor.
*
* @param _e A mouse up or touch end event.
*/
private doWorkspaceClick_(_e: Event) {
@@ -741,6 +756,7 @@ export class Gesture {
/**
* Record the field that a gesture started on.
*
* @param field The field the gesture started on.
* @internal
*/
@@ -757,6 +773,7 @@ export class Gesture {
/**
* Record the bubble that a gesture started on
*
* @param bubble The bubble the gesture started on.
* @internal
*/
@@ -769,6 +786,7 @@ export class Gesture {
/**
* Record the block that a gesture started on, and set the target block
* appropriately.
*
* @param block The block the gesture started on.
* @internal
*/
@@ -788,6 +806,7 @@ export class Gesture {
* Record the block that a gesture targets, meaning the block that will be
* dragged if this turns into a drag. If this block is a shadow, that will be
* its first non-shadow parent.
*
* @param block The block the gesture targets.
*/
private setTargetBlock_(block: BlockSvg) {
@@ -802,6 +821,7 @@ export class Gesture {
/**
* Record the workspace that a gesture started on.
*
* @param ws The workspace the gesture started on.
*/
private setStartWorkspace_(ws: WorkspaceSvg) {
@@ -812,6 +832,7 @@ export class Gesture {
/**
* Record the flyout that a gesture started on.
*
* @param flyout The flyout the gesture started on.
*/
private setStartFlyout_(flyout: IFlyout) {
@@ -828,7 +849,8 @@ export class Gesture {
/**
* Whether this gesture is a click on a bubble. This should only be called
* when ending a gesture (mouse up, touch end).
* @return Whether this gesture was a click on a bubble.
*
* @returns Whether this gesture was a click on a bubble.
*/
private isBubbleClick_(): boolean {
// A bubble click starts on a bubble and never escapes the drag radius.
@@ -839,7 +861,8 @@ export class Gesture {
/**
* Whether this gesture is a click on a block. This should only be called
* when ending a gesture (mouse up, touch end).
* @return Whether this gesture was a click on a block.
*
* @returns Whether this gesture was a click on a block.
*/
private isBlockClick_(): boolean {
// A block click starts on a block, never escapes the drag radius, and is
@@ -852,7 +875,8 @@ export class Gesture {
/**
* Whether this gesture is a click on a field. This should only be called
* when ending a gesture (mouse up, touch end).
* @return Whether this gesture was a click on a field.
*
* @returns Whether this gesture was a click on a field.
*/
private isFieldClick_(): boolean {
const fieldClickable =
@@ -864,7 +888,8 @@ export class Gesture {
/**
* Whether this gesture is a click on a workspace. This should only be called
* when ending a gesture (mouse up, touch end).
* @return Whether this gesture was a click on a workspace.
*
* @returns Whether this gesture was a click on a workspace.
*/
private isWorkspaceClick_(): boolean {
const onlyTouchedWorkspace =
@@ -878,7 +903,8 @@ export class Gesture {
* Whether this gesture is a drag of either a workspace or block.
* This function is called externally to block actions that cannot be taken
* mid-drag (e.g. using the keyboard to delete the selected blocks).
* @return True if this gesture is a drag of a workspace or block.
*
* @returns True if this gesture is a drag of a workspace or block.
* @internal
*/
isDragging(): boolean {
@@ -890,7 +916,8 @@ export class Gesture {
* Whether this gesture has already been started. In theory every mouse down
* has a corresponding mouse up, but in reality it is possible to lose a
* mouse up, leaving an in-process gesture hanging.
* @return Whether this gesture was a click on a workspace.
*
* @returns Whether this gesture was a click on a workspace.
* @internal
*/
hasStarted(): boolean {
@@ -900,7 +927,8 @@ export class Gesture {
/**
* Get a list of the insertion markers that currently exist. Block drags have
* 0, 1, or 2 insertion markers.
* @return A possibly empty list of insertion marker blocks.
*
* @returns A possibly empty list of insertion marker blocks.
* @internal
*/
getInsertionMarkers(): BlockSvg[] {
@@ -913,7 +941,8 @@ export class Gesture {
/**
* Gets the current dragger if an item is being dragged. Null if nothing is
* being dragged.
* @return The dragger that is currently in use or null if no drag is in
*
* @returns The dragger that is currently in use or null if no drag is in
* progress.
*/
getCurrentDragger(): WorkspaceDragger|BubbleDragger|IBlockDragger|null {
@@ -929,7 +958,8 @@ export class Gesture {
/**
* Is a drag or other gesture currently in progress on any workspace?
* @return True if gesture is occurring.
*
* @returns True if gesture is occurring.
*/
static inProgress(): boolean {
const workspaces = common.getAllWorkspaces();
+13 -9
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Object for configuring and updating a workspace grid in
* Blockly.
*/
/**
* Object for configuring and updating a workspace grid in
* Blockly.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -25,6 +21,7 @@ import {GridOptions} from './blockly_options.js';
/**
* Class for a workspace's grid.
*
* @alias Blockly.Grid
*/
export class Grid {
@@ -64,7 +61,8 @@ export class Grid {
/**
* Whether blocks should snap to the grid, based on the initial configuration.
* @return True if blocks should snap, false otherwise.
*
* @returns True if blocks should snap, false otherwise.
* @internal
*/
shouldSnap(): boolean {
@@ -73,7 +71,8 @@ export class Grid {
/**
* Get the spacing of the grid points (in px).
* @return The spacing of the grid points.
*
* @returns The spacing of the grid points.
* @internal
*/
getSpacing(): number {
@@ -83,7 +82,8 @@ export class Grid {
/**
* Get the ID of the pattern element, which should be randomized to avoid
* conflicts with other Blockly instances on the page.
* @return The pattern ID.
*
* @returns The pattern ID.
* @internal
*/
getPatternId(): string {
@@ -92,6 +92,7 @@ export class Grid {
/**
* Update the grid with a new scale.
*
* @param scale The new workspace scale.
* @internal
*/
@@ -118,6 +119,7 @@ export class Grid {
/**
* Set the attributes on one of the lines in the grid. Use this to update the
* length and stroke width of the grid lines.
*
* @param line Which line to update.
* @param width The new stroke size (in px).
* @param x1 The new x start position of the line (in px).
@@ -140,6 +142,7 @@ export class Grid {
/**
* Move the grid to a new x and y position, and make sure that change is
* visible.
*
* @param x The new x position of the grid (in px).
* @param y The new y position of the grid (in px).
* @internal
@@ -157,10 +160,11 @@ export class Grid {
/**
* Create the DOM for the grid described by options.
*
* @param rnd A random ID to append to the pattern's ID.
* @param gridOptions The object containing grid configuration.
* @param defs The root SVG element for this workspace's defs.
* @return The SVG element for the grid pattern.
* @returns The SVG element for the grid pattern.
* @internal
*/
static createDom(rnd: string, gridOptions: GridOptions, defs: SVGElement):
+12 -7
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Object representing an icon on a block.
*/
/**
* Object representing an icon on a block.
*
* @class
*/
import * as goog from '../closure/goog/goog.js';
@@ -27,6 +24,7 @@ import * as svgMath from './utils/svg_math.js';
/**
* Class for an icon.
*
* @alias Blockly.Icon
*/
export abstract class Icon {
@@ -100,7 +98,8 @@ export abstract class Icon {
/**
* Is the associated bubble visible?
* @return True if the bubble is visible.
*
* @returns True if the bubble is visible.
*/
isVisible(): boolean {
return !!this.bubble_;
@@ -108,6 +107,7 @@ export abstract class Icon {
/**
* Clicking on the icon toggles if the bubble is visible.
*
* @param e Mouse click event.
*/
protected iconClick_(e: MouseEvent) {
@@ -129,6 +129,7 @@ export abstract class Icon {
/**
* Notification that the icon has moved. Update the arrow accordingly.
*
* @param xy Absolute location in workspace coordinates.
*/
setIconLocation(xy: Coordinate) {
@@ -156,7 +157,8 @@ export abstract class Icon {
/**
* Returns the center of the block's icon relative to the surface.
* @return Object with x and y properties in workspace coordinates.
*
* @returns Object with x and y properties in workspace coordinates.
*/
getIconLocation(): Coordinate|null {
return this.iconXY_;
@@ -166,7 +168,8 @@ export abstract class Icon {
* Get the size of the icon as used for rendering.
* This differs from the actual size of the icon, because it bulges slightly
* out of its row rather than increasing the height of its row.
* @return Height and width.
*
* @returns Height and width.
*/
getCorrectedSize(): Size {
// TODO (#2562): Remove getCorrectedSize.
@@ -175,6 +178,7 @@ export abstract class Icon {
/**
* Draw the icon.
*
* @param _group The icon group.
*/
protected drawIcon_(_group: Element) {}
@@ -182,6 +186,7 @@ export abstract class Icon {
/**
* Show or hide the icon.
*
* @param _visible True if the icon should be visible.
*/
setVisible(_visible: boolean) {}
+13 -7
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Functions for injecting Blockly into a web page.
*/
/**
* Functions for injecting Blockly into a web page.
*
* @namespace Blockly.inject
*/
import * as goog from '../closure/goog/goog.js';
@@ -40,9 +37,10 @@ import {WorkspaceSvg} from './workspace_svg.js';
/**
* Inject a Blockly editor into the specified container element (usually a div).
*
* @param container Containing element, or its ID, or a CSS selector.
* @param opt_options Optional dictionary of options.
* @return Newly created main workspace.
* @returns Newly created main workspace.
* @alias Blockly.inject
*/
export function inject(
@@ -101,9 +99,10 @@ export function inject(
/**
* Create the SVG image.
*
* @param container Containing element.
* @param options Dictionary of options.
* @return Newly created SVG image.
* @returns Newly created SVG image.
*/
function createDom(container: Element, options: Options): Element {
// Sadly browsers (Chrome vs Firefox) are currently inconsistent in laying
@@ -152,11 +151,12 @@ function createDom(container: Element, options: Options): Element {
/**
* Create a main workspace and add it to the SVG.
*
* @param svg SVG element with pattern defined.
* @param options Dictionary of options.
* @param blockDragSurface Drag surface SVG for the blocks.
* @param workspaceDragSurface Drag surface SVG for the workspace.
* @return Newly created main workspace.
* @returns Newly created main workspace.
*/
function createMainWorkspace(
svg: Element, options: Options, blockDragSurface: BlockDragSurfaceSvg,
@@ -206,6 +206,7 @@ function createMainWorkspace(
/**
* Initialize Blockly with various handlers.
*
* @param mainWorkspace Newly created main workspace.
*/
function init(mainWorkspace: WorkspaceSvg) {
@@ -275,6 +276,7 @@ function init(mainWorkspace: WorkspaceSvg) {
/**
* Handle a key-down on SVG drawing surface. Does nothing if the main workspace
* is not visible.
*
* @param e Key down event.
*/
// TODO (https://github.com/google/blockly/issues/1998) handle cases where there
@@ -340,6 +342,7 @@ function bindDocumentEvents() {
/**
* Load sounds for the given workspace.
*
* @param pathToMedia The path to the media directory.
* @param workspace The workspace to load sounds for.
*/
@@ -369,6 +372,9 @@ function loadSounds(pathToMedia: string, workspace: WorkspaceSvg) {
// Bind temporary hooks that preload the sounds.
const soundBinds: AnyDuringMigration[] = [];
/**
*
*/
function unbindSounds() {
while (soundBinds.length) {
browserEvents.unbind(soundBinds.pop());
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Object representing an input (value, statement, or dummy).
*/
/**
* Object representing an input (value, statement, or dummy).
* @class
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview An enum for the possible types of inputs.
*/
/**
* An enum for the possible types of inputs.
* @namespace Blockly.inputTypes
-4
View File
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class that controls updates to connections during drags.
*/
/**
* Class that controls updates to connections during drags.
* @class
+2 -4
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for an AST node location.
*/
/**
* The interface for an AST node location.
*
* @namespace Blockly.IASTNodeLocation
*/
import * as goog from '../../closure/goog/goog.js';
@@ -18,6 +15,7 @@ goog.declareModuleId('Blockly.IASTNodeLocation');
/**
* An AST node location interface.
*
* @alias Blockly.IASTNodeLocation
*/
export interface IASTNodeLocation {}
+4 -4
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for an AST node location SVG.
*/
/**
* The interface for an AST node location SVG.
*
* @namespace Blockly.IASTNodeLocationSvg
*/
import * as goog from '../../closure/goog/goog.js';
@@ -20,17 +17,20 @@ import type {IASTNodeLocation} from './i_ast_node_location.js';
/**
* An AST node location SVG interface.
*
* @alias Blockly.IASTNodeLocationSvg
*/
export interface IASTNodeLocationSvg extends IASTNodeLocation {
/**
* Add the marker SVG to this node's SVG group.
*
* @param markerSvg The SVG root of the marker to be added to the SVG group.
*/
setMarkerSvg(markerSvg: SVGElement|null): void;
/**
* Add the cursor SVG to this node's SVG group.
*
* @param cursorSvg The SVG root of the cursor to be added to the SVG group.
*/
setCursorSvg(cursorSvg: SVGElement|null): void;
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for an AST node location that has an associated
* block.
*/
/**
* The interface for an AST node location that has an associated
* block.
*
* @namespace Blockly.IASTNodeLocationWithBlock
*/
import * as goog from '../../closure/goog/goog.js';
@@ -27,12 +23,14 @@ import type {Block} from '../block.js';
/**
* An AST node location that has an associated block.
*
* @alias Blockly.IASTNodeLocationWithBlock
*/
export interface IASTNodeLocationWithBlock extends IASTNodeLocation {
/**
* Get the source block associated with this node.
* @return The source block.
*
* @returns The source block.
*/
getSourceBlock(): Block;
}
+3 -5
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for a component that is automatically hidden
* when WorkspaceSvg.hideChaff is called.
*/
/**
* The interface for a component that is automatically hidden
* when WorkspaceSvg.hideChaff is called.
*
* @namespace Blockly.IAutoHideable
*/
import * as goog from '../../closure/goog/goog.js';
@@ -22,11 +18,13 @@ import type {IComponent} from './i_component.js';
/**
* Interface for a component that can be automatically hidden.
*
* @alias Blockly.IAutoHideable
*/
export interface IAutoHideable extends IComponent {
/**
* Hides the component. Called in WorkspaceSvg.hideChaff.
*
* @param onlyClosePopups Whether only popups should be closed.
* Flyouts should not be closed if this is true.
*/
+7 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for a block dragger.
*/
/**
* The interface for a block dragger.
*
* @namespace Blockly.IBlockDragger
*/
import * as goog from '../../closure/goog/goog.js';
@@ -27,11 +24,13 @@ goog.declareModuleId('Blockly.IBlockDragger');
/**
* A block dragger interface.
*
* @alias Blockly.IBlockDragger
*/
export interface IBlockDragger {
/**
* Start dragging a block. This includes moving it to the drag surface.
*
* @param currentDragDeltaXY How far the pointer has moved from the position
* at mouse down, in pixel units.
* @param healStack Whether or not to heal the stack after disconnecting.
@@ -41,6 +40,7 @@ export interface IBlockDragger {
/**
* Execute a step of block dragging, based on the given event. Update the
* display accordingly.
*
* @param e The most recent move event.
* @param currentDragDeltaXY How far the pointer has moved from the position
* at the start of the drag, in pixel units.
@@ -49,6 +49,7 @@ export interface IBlockDragger {
/**
* Finish a block drag and put the block back on the workspace.
*
* @param e The mouseup/touchend event.
* @param currentDragDeltaXY How far the pointer has moved from the position
* at the start of the drag, in pixel units.
@@ -58,7 +59,8 @@ export interface IBlockDragger {
/**
* Get a list of the insertion markers that currently exist. Drags have 0, 1,
* or 2 insertion markers.
* @return A possibly empty list of insertion marker blocks.
*
* @returns A possibly empty list of insertion marker blocks.
*/
getInsertionMarkers(): BlockSvg[];
+5 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for a bounded element.
*/
/**
* The interface for a bounded element.
*
* @namespace Blockly.IBoundedElement
*/
import * as goog from '../../closure/goog/goog.js';
@@ -23,18 +20,21 @@ goog.declareModuleId('Blockly.IBoundedElement');
/**
* A bounded element interface.
*
* @alias Blockly.IBoundedElement
*/
export interface IBoundedElement {
/**
* Returns the coordinates of a bounded element describing the dimensions of
* the element. Coordinate system: workspace coordinates.
* @return Object with coordinates of the bounded element.
*
* @returns Object with coordinates of the bounded element.
*/
getBoundingRectangle(): Rect;
/**
* Move the element by a relative offset.
*
* @param dx Horizontal offset in workspace units.
* @param dy Vertical offset in workspace units.
*/
+11 -6
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for a bubble.
*/
/**
* The interface for a bubble.
*
* @namespace Blockly.IBubble
*/
import * as goog from '../../closure/goog/goog.js';
@@ -30,19 +27,22 @@ import type {IDraggable} from './i_draggable.js';
/**
* A bubble interface.
*
* @alias Blockly.IBubble
*/
export interface IBubble extends IDraggable, IContextMenu {
/**
* Return the coordinates of the top-left corner of this bubble's body
* relative to the drawing surface's origin (0,0), in workspace units.
* @return Object with .x and .y properties.
*
* @returns Object with .x and .y properties.
*/
getRelativeToSurfaceXY(): Coordinate;
/**
* Return the root node of the bubble's SVG group.
* @return The root SVG node of the bubble's group.
*
* @returns The root SVG node of the bubble's group.
*/
getSvgRoot(): SVGElement;
@@ -50,12 +50,14 @@ export interface IBubble extends IDraggable, IContextMenu {
* Set whether auto-layout of this bubble is enabled. The first time a bubble
* is shown it positions itself to not cover any blocks. Once a user has
* dragged it to reposition, it renders where the user put it.
*
* @param enable True if auto-layout should be enabled, false otherwise.
*/
setAutoLayout(enable: boolean): void;
/**
* Sets whether or not this bubble is being dragged.
*
* @param adding True if dragging, false otherwise.
*/
setDragging(dragging: boolean): void;
@@ -63,6 +65,7 @@ export interface IBubble extends IDraggable, IContextMenu {
/**
* Move this bubble during a drag, taking into account whether or not there is
* a drag surface.
*
* @param dragSurface The surface that carries rendered items during a drag,
* or null if no drag surface is in use.
* @param newLoc The location to translate to, in workspace coordinates.
@@ -72,6 +75,7 @@ export interface IBubble extends IDraggable, IContextMenu {
/**
* Move the bubble to the specified location in workspace coordinates.
*
* @param x The x position to move to.
* @param y The y position to move to.
*/
@@ -79,6 +83,7 @@ export interface IBubble extends IDraggable, IContextMenu {
/**
* Update the style of this bubble when it is dragged over a delete area.
*
* @param enable True if the bubble is about to be deleted, false otherwise.
*/
setDeleteStyle(enable: boolean): void;
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for a collapsible toolbox item.
*/
/**
* The interface for a collapsible toolbox item.
*
* @namespace Blockly.ICollapsibleToolboxItem
*/
import * as goog from '../../closure/goog/goog.js';
@@ -26,18 +23,21 @@ import type {IToolboxItem} from './i_toolbox_item.js';
/**
* Interface for an item in the toolbox that can be collapsed.
*
* @alias Blockly.ICollapsibleToolboxItem
*/
export interface ICollapsibleToolboxItem extends ISelectableToolboxItem {
/**
* Gets any children toolbox items. (ex. Gets the subcategories)
* @return The child toolbox items.
*
* @returns The child toolbox items.
*/
getChildToolboxItems(): IToolboxItem[];
/**
* Whether the toolbox item is expanded to show its child subcategories.
* @return True if the toolbox item shows its children, false if it is
*
* @returns True if the toolbox item shows its children, false if it is
* collapsed.
*/
isExpanded(): boolean;
+2 -5
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Interface for a workspace component that can be registered with
* the ComponentManager.
*/
/**
* Interface for a workspace component that can be registered with
* the ComponentManager.
*
* @namespace Blockly.IComponent
*/
import * as goog from '../../closure/goog/goog.js';
@@ -21,6 +17,7 @@ goog.declareModuleId('Blockly.IComponent');
/**
* The interface for a workspace component that can be registered with the
* ComponentManager.
*
* @alias Blockly.IComponent
*/
export interface IComponent {
+14 -11
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for an object that encapsulates logic for
* checking whether a potential connection is safe and valid.
*/
/**
* The interface for an object that encapsulates logic for
* checking whether a potential connection is safe and valid.
*
* @namespace Blockly.IConnectionChecker
*/
import * as goog from '../../closure/goog/goog.js';
@@ -29,18 +25,20 @@ goog.declareModuleId('Blockly.IConnectionChecker');
/**
* Class for connection type checking logic.
*
* @alias Blockly.IConnectionChecker
*/
export interface IConnectionChecker {
/**
* Check whether the current connection can connect with the target
* connection.
*
* @param a Connection to check compatibility with.
* @param b Connection to check compatibility with.
* @param isDragging True if the connection is being made by dragging a block.
* @param opt_distance The max allowable distance between the connections for
* drag checks.
* @return Whether the connection is legal.
* @returns Whether the connection is legal.
*/
canConnect(
a: Connection|null, b: Connection|null, isDragging: boolean,
@@ -49,12 +47,13 @@ export interface IConnectionChecker {
/**
* Checks whether the current connection can connect with the target
* connection, and return an error code if there are problems.
*
* @param a Connection to check compatibility with.
* @param b Connection to check compatibility with.
* @param isDragging True if the connection is being made by dragging a block.
* @param opt_distance The max allowable distance between the connections for
* drag checks.
* @return Connection.CAN_CONNECT if the connection is legal, an error code
* @returns Connection.CAN_CONNECT if the connection is legal, an error code
* otherwise.
*/
canConnectWithReason(
@@ -63,10 +62,11 @@ export interface IConnectionChecker {
/**
* Helper method that translates a connection error code into a string.
*
* @param errorCode The error code.
* @param a One of the two connections being checked.
* @param b The second of the two connections being checked.
* @return A developer-readable error string.
* @returns A developer-readable error string.
*/
getErrorMessage(errorCode: number, a: Connection|null, b: Connection|null):
string;
@@ -74,9 +74,10 @@ export interface IConnectionChecker {
/**
* Check that connecting the given connections is safe, meaning that it would
* not break any of Blockly's basic assumptions (e.g. no self connections).
*
* @param a The first of the connections to check.
* @param b The second of the connections to check.
* @return An enum with the reason this connection is safe or unsafe.
* @returns An enum with the reason this connection is safe or unsafe.
*/
doSafetyChecks(a: Connection|null, b: Connection|null): number;
@@ -84,18 +85,20 @@ export interface IConnectionChecker {
* Check whether this connection is compatible with another connection with
* respect to the value type system. E.g. square_root("Hello") is not
* compatible.
*
* @param a Connection to compare.
* @param b Connection to compare against.
* @return True if the connections share a type.
* @returns True if the connections share a type.
*/
doTypeChecks(a: Connection, b: Connection): boolean;
/**
* Check whether this connection can be made by dragging.
*
* @param a Connection to compare.
* @param b Connection to compare against.
* @param distance The maximum allowable distance between connections.
* @return True if the connection is allowed during a drag.
* @returns True if the connection is allowed during a drag.
*/
doDragChecks(a: RenderedConnection, b: RenderedConnection, distance: number):
boolean;
+2 -4
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for an object that supports a right-click.
*/
/**
* The interface for an object that supports a right-click.
*
* @namespace Blockly.IContextMenu
*/
import * as goog from '../../closure/goog/goog.js';
@@ -20,6 +17,7 @@ goog.declareModuleId('Blockly.IContextMenu');
export interface IContextMenu {
/**
* Show the context menu for this object.
*
* @param e Mouse event.
*/
showContextMenu(e: Event): void;
+3 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for an object that is copyable.
*/
/**
* The interface for an object that is copyable.
*
* @namespace Blockly.ICopyable
*/
import * as goog from '../../closure/goog/goog.js';
@@ -23,7 +20,8 @@ import type {ISelectable} from './i_selectable.js';
export interface ICopyable extends ISelectable {
/**
* Encode for copying.
* @return Copy metadata.
*
* @returns Copy metadata.
* @internal
*/
toCopyData(): CopyData|null;
+4 -5
View File
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for an object that is deletable.
*/
/**
* The interface for an object that is deletable.
*
* @namespace Blockly.IDeletable
*/
import * as goog from '../../closure/goog/goog.js';
@@ -18,12 +15,14 @@ goog.declareModuleId('Blockly.IDeletable');
/**
* The interface for an object that can be deleted.
*
* @alias Blockly.IDeletable
*/
export interface IDeletable {
/**
* Get whether this object is deletable or not.
* @return True if deletable.
*
* @returns True if deletable.
*/
isDeletable(): boolean;
}
+4 -6
View File
@@ -4,14 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The interface for a component that can delete a block or bubble
* that is dropped on top of it.
*/
/**
* The interface for a component that can delete a block or bubble
* that is dropped on top of it.
*
* @namespace Blockly.IDeleteArea
*/
import * as goog from '../../closure/goog/goog.js';
@@ -29,6 +25,7 @@ import type {IDraggable} from './i_draggable.js';
/**
* Interface for a component that can delete a block or bubble that is dropped
* on top of it.
*
* @alias Blockly.IDeleteArea
*/
export interface IDeleteArea extends IDragTarget {
@@ -37,9 +34,10 @@ export interface IDeleteArea extends IDragTarget {
* this area.
* This method should check if the element is deletable and is always called
* before onDragEnter/onDragOver/onDragExit.
*
* @param element The block or bubble currently being dragged.
* @param couldConnect Whether the element could could connect to another.
* @return Whether the element provided would be deleted if dropped on this
* @returns Whether the element provided would be deleted if dropped on this
* area.
*/
wouldDelete(element: IDraggable, couldConnect: boolean): boolean;

Some files were not shown because too many files have changed in this diff Show More