Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class Block implements IASTNodeLocation, IDeletable {
*/
data: string|null = null;

/** Has this block been disposed of? */
/**
* Has this block been disposed of?
* @internal
*/
disposed = false;

/**
Expand Down Expand Up @@ -190,6 +193,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* @deprecated August 2019. Use getCommentText instead.
*/
comment: string|Comment|null = null;
/** @internal */
commentModel: CommentModel;
private readonly xy_: Coordinate;
isInFlyout: boolean;
Expand All @@ -214,7 +218,10 @@ export class Block implements IASTNodeLocation, IDeletable {
/** A bound callback function to use when the parent workspace changes. */
private onchangeWrapper_: ((p1: Abstract) => AnyDuringMigration)|null = null;

/** A count of statement inputs on the block. */
/**
* A count of statement inputs on the block.
* @internal
*/
statementInputCount = 0;
// TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
type!: string;
Expand Down Expand Up @@ -490,6 +497,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* Returns all connections originating from this block.
* @param _all If true, return all connections even hidden ones.
* @return Array of connections.
* @internal
*/
getConnections_(_all: boolean): Connection[] {
const myConnections = [];
Expand Down Expand Up @@ -517,6 +525,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* be returned. If false, this will follow shadows to find the last
* connection.
* @return The last next connection on the stack, or null.
* @internal
*/
lastConnectionInStack(ignoreShadows: boolean): Connection|null {
let nextConnection = this.nextConnection;
Expand Down Expand Up @@ -606,6 +615,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* Return the connection on the first statement input on this block, or null
* if there are none.
* @return The first statement connection or null.
* @internal
*/
getFirstStatementConnection(): Connection|null {
for (let i = 0, input; input = this.inputList[i]; i++) {
Expand Down Expand Up @@ -637,6 +647,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* the top block of the sub stack. If we are nested in a statement input only
* find the top-most nested block. Do not go all the way to the root block.
* @return The top block in a stack.
* @internal
*/
getTopStackBlock(): this {
let block = this;
Expand Down Expand Up @@ -681,6 +692,7 @@ export class Block implements IASTNodeLocation, IDeletable {
/**
* Set parent of this block to be a new block or null.
* @param newParent New parent block.
* @internal
*/
setParent(newParent: this|null) {
if (newParent === this.parentBlock_) {
Expand Down Expand Up @@ -807,6 +819,7 @@ export class Block implements IASTNodeLocation, IDeletable {
/**
* Set whether this block is a shadow block or not.
* @param shadow True if a shadow.
* @internal
*/
setShadow(shadow: boolean) {
this.isShadow_ = shadow;
Expand All @@ -824,6 +837,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* Set whether this block is an insertion marker block or not.
* Once set this cannot be unset.
* @param insertionMarker True if an insertion marker.
* @internal
*/
setInsertionMarker(insertionMarker: boolean) {
this.isInsertionMarker_ = insertionMarker;
Expand Down Expand Up @@ -866,6 +880,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* @param otherBlock The other block to match against.
* @param conn The other connection to match.
* @return The matching connection on this block, or null.
* @internal
*/
getMatchingConnection(otherBlock: Block, conn: Connection): Connection|null {
const connections = this.getConnections_(true);
Expand Down Expand Up @@ -1013,6 +1028,7 @@ export class Block implements IASTNodeLocation, IDeletable {
/**
* Return all variables referenced by this block.
* @return List of variable models.
* @internal
*/
getVarModels(): VariableModel[] {
const vars = [];
Expand All @@ -1036,6 +1052,7 @@ export class Block implements IASTNodeLocation, IDeletable {
* Notification that a variable is renaming but keeping the same ID. If the
* variable is in use on this block, rerender to show the new name.
* @param variable The variable being renamed.
* @internal
*/
updateVarName(variable: VariableModel) {
for (let i = 0, input; input = this.inputList[i]; i++) {
Expand Down
4 changes: 4 additions & 0 deletions core/block_animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let disconnectGroup: Element = null as AnyDuringMigration;
* Play some UI effects (sound, animation) when disposing of a block.
* @param block The block being disposed of.
* @alias Blockly.blockAnimations.disposeUiEffect
* @internal
*/
export function disposeUiEffect(block: BlockSvg) {
const workspace = block.workspace;
Expand Down Expand Up @@ -93,6 +94,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
*/
export function connectionUiEffect(block: BlockSvg) {
const workspace = block.workspace;
Expand Down Expand Up @@ -150,6 +152,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
*/
export function disconnectUiEffect(block: BlockSvg) {
block.workspace.getAudioManager().play('disconnect');
Expand Down Expand Up @@ -202,6 +205,7 @@ function disconnectUiStep(group: SVGElement, magnitude: number, start: Date) {
/**
* Stop the disconnect UI animation immediately.
* @alias Blockly.blockAnimations.disconnectUiStop
* @internal
*/
export function disconnectUiStop() {
if (disconnectGroup) {
Expand Down
5 changes: 4 additions & 1 deletion core/block_dragger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export class BlockDragger implements IBlockDragger {
this.dragIconData_ = initIconData(block);
}

/** Sever all links from this object. */
/**
* Sever all links from this object.
* @internal
*/
dispose() {
this.dragIconData_.length = 0;

Expand Down
41 changes: 38 additions & 3 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,

/**
* An property used internally to reference the block's rendering debugger.
* @internal
*/
renderingDebugger: BlockRenderingDebug|null = null;

Expand Down Expand Up @@ -140,6 +141,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
// Create core elements for the block.
private svgGroup_: SVGGElement;
style: BlockStyle;
/** @internal */
pathObject: IPathObject;
override rendered = false;

Expand Down Expand Up @@ -338,6 +340,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
/**
* Sets the parent of this block to be a new block or null.
* @param newParent New parent block.
* @internal
*/
override setParent(newParent: this|null) {
const oldParent = this.parentBlock_;
Expand Down Expand Up @@ -454,6 +457,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Move this block to its workspace's drag surface, accounting for
* positioning. Generally should be called at the same time as
* setDragging_(true). Does nothing if useDragSurface_ is false.
* @internal
*/
moveToDragSurface() {
if (!this.useDragSurface_) {
Expand Down Expand Up @@ -488,6 +492,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Does nothing if useDragSurface_ is false.
* @param newXY The position the block should take on on the workspace canvas,
* in workspace coordinates.
* @internal
*/
moveOffDragSurface(newXY: Coordinate) {
if (!this.useDragSurface_) {
Expand All @@ -504,6 +509,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* drag surface to translate blocks.
* This block must be a top-level block.
* @param newLoc The location to translate to, in workspace coordinates.
* @internal
*/
moveDuringDrag(newLoc: Coordinate) {
if (this.useDragSurface_) {
Expand Down Expand Up @@ -692,7 +698,10 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
}
}

/** Load the block's help page in a new window. */
/**
* Load the block's help page in a new window.
* @internal
*/
showHelp() {
const url =
typeof this.helpUrl === 'function' ? this.helpUrl() : this.helpUrl;
Expand Down Expand Up @@ -727,6 +736,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
/**
* Show the context menu for this block.
* @param e Mouse event.
* @internal
*/
showContextMenu(e: Event) {
const menuOptions = this.generateContextMenu();
Expand All @@ -744,6 +754,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Also update any attached bubbles.
* @param dx Horizontal offset from current location, in workspace units.
* @param dy Vertical offset from current location, in workspace units.
* @internal
*/
moveConnections(dx: number, dy: number) {
if (!this.rendered) {
Expand All @@ -770,6 +781,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Recursively adds or removes the dragging class to this node and its
* children.
* @param adding True if adding, false if removing.
* @internal
*/
setDragging(adding: boolean) {
if (adding) {
Expand Down Expand Up @@ -812,6 +824,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
/**
* Sets whether this block is a shadow block or not.
* @param shadow True if a shadow.
* @internal
*/
override setShadow(shadow: boolean) {
super.setShadow(shadow);
Expand All @@ -822,6 +835,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Set whether this block is an insertion marker block or not.
* Once set this cannot be unset.
* @param insertionMarker True if an insertion marker.
* @internal
*/
override setInsertionMarker(insertionMarker: boolean) {
if (this.isInsertionMarker_ === insertionMarker) {
Expand Down Expand Up @@ -940,6 +954,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
/**
* Encode a block for copying.
* @return Copy metadata, or null if the block is an insertion marker.
* @internal
*/
toCopyData(): CopyData|null {
if (this.isInsertionMarker_) {
Expand All @@ -958,7 +973,10 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
};
}

/** Updates the colour of the block to match the block's state. */
/**
* Updates the colour of the block to match the block's state.
* @internal
*/
applyColour() {
this.pathObject.applyColour(this);

Expand All @@ -977,6 +995,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
/**
* Updates the color of the block (and children) to match the current disabled
* state.
* @internal
*/
updateDisabled() {
const children = (this.getChildren(false));
Expand Down Expand Up @@ -1187,6 +1206,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
/**
* Update the cursor over this block by adding or removing a class.
* @param enable True if the delete cursor should be shown, false otherwise.
* @internal
*/
setDeleteStyle(enable: boolean) {
this.pathObject.updateDraggingDelete(enable);
Expand Down Expand Up @@ -1250,6 +1270,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* <g> tags do not respect z-index so SVG renders them in the
* order that they are in the DOM. By placing this block first within the
* block group's <g>, it will render on top of any other blocks.
* @internal
*/
bringToFront() {
let block = this;
Expand Down Expand Up @@ -1387,6 +1408,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* tracked_ value to false keeps it from adding itself to the db when it
* gets its first moveTo call, saving expensive ops for later.
* @param track If true, start tracking. If false, stop tracking.
* @internal
*/
setConnectionTracking(track: boolean) {
if (this.previousConnection) {
Expand Down Expand Up @@ -1430,6 +1452,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Otherwise, for a non-rendered block return an empty list, and for a
* collapsed block don't return inputs connections.
* @return Array of connections.
* @internal
*/
override getConnections_(all: boolean): RenderedConnection[] {
const myConnections = [];
Expand Down Expand Up @@ -1461,6 +1484,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* be returned. If false, this will follow shadows to find the last
* connection.
* @return The last next connection on the stack, or null.
* @internal
*/
override lastConnectionInStack(ignoreShadows: boolean): RenderedConnection
|null {
Expand All @@ -1474,6 +1498,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* @param otherBlock The other block to match against.
* @param conn The other connection to match.
* @return The matching connection on this block, or null.
* @internal
*/
override getMatchingConnection(otherBlock: Block, conn: Connection):
RenderedConnection|null {
Expand Down Expand Up @@ -1555,6 +1580,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
/**
* Schedule snapping to grid and bumping neighbours to occur after a brief
* delay.
* @internal
*/
scheduleSnapAndBump() {
const block = this;
Expand All @@ -1581,6 +1607,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* @param sourceConnection The connection on the moving block's stack.
* @param targetConnection The connection that should stay stationary as this
* block is positioned.
* @internal
*/
positionNearConnection(
sourceConnection: RenderedConnection,
Expand All @@ -1596,7 +1623,10 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
}
}

/** @return The first statement connection or null. */
/**
* @return The first statement connection or null.
* @internal
*/
override getFirstStatementConnection(): RenderedConnection|null {
return super.getFirstStatementConnection() as RenderedConnection | null;
}
Expand Down Expand Up @@ -1700,6 +1730,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Add the cursor SVG to this block's SVG group.
* @param cursorSvg The SVG root of the cursor to be added to the block SVG
* group.
* @internal
*/
setCursorSvg(cursorSvg: SVGElement) {
this.pathObject.setCursorSvg(cursorSvg);
Expand All @@ -1709,6 +1740,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Add the marker SVG to this block's SVG group.
* @param markerSvg The SVG root of the marker to be added to the block SVG
* group.
* @internal
*/
setMarkerSvg(markerSvg: SVGElement) {
this.pathObject.setMarkerSvg(markerSvg);
Expand All @@ -1718,6 +1750,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* Returns a bounding box describing the dimensions of this block
* and any blocks stacked below it.
* @return Object with height and width properties in workspace units.
* @internal
*/
getHeightWidth(): {height: number, width: number} {
let height = this.height;
Expand All @@ -1739,6 +1772,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* will be replaced. If a shadow block, it will disappear. Otherwise it will
* bump.
* @param add True if highlighting should be added.
* @internal
*/
fadeForReplacement(add: boolean) {
this.pathObject.updateReplacementFade(add);
Expand All @@ -1749,6 +1783,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg,
* to this input.
* @param conn The connection on the input to highlight.
* @param add True if highlighting should be added.
* @internal
*/
highlightShapeForInput(conn: Connection, add: boolean) {
this.pathObject.updateShapeForInputHighlight(conn, add);
Expand Down
Loading