@blockly/continuous-toolbox
Version:
A Blockly plugin that adds a continous-scrolling style toolbox and flyout
72 lines • 2.45 kB
TypeScript
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Blockly from 'blockly/core';
/**
* A block inflater that caches and reuses blocks to improve performance.
*/
export declare class RecyclableBlockFlyoutInflater extends Blockly.BlockFlyoutInflater {
/**
* Whether or not block recycling is enabled.
*/
recyclingEnabled: boolean;
/**
* Map from block type to block instance.
*/
private recycledBlocks;
/**
* Custom function to use for checking whether or not blocks can be recycled.
*/
recycleEligibilityChecker?: (block: Blockly.Block) => boolean;
/**
* Creates a new block from the given block definition.
*
* @param blockDefinition The definition to create a block from.
* @param workspace The workspace to create the block on.
* @returns The newly created block.
*/
createBlock(blockDefinition: Blockly.utils.toolbox.BlockInfo, workspace: Blockly.WorkspaceSvg): Blockly.BlockSvg;
/**
* Returns the type of a block from an XML or JSON block definition.
*
* @param blockDefinition The block definition to parse.
* @returns The block type.
*/
private getTypeFromDefinition;
/**
* 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;
/**
* Returns a block from the cache 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.
* @returns The recycled block, or undefined if one could not be recycled.
*/
private getRecycledBlock;
/**
* Returns whether the given block can be recycled or not.
*
* @param block The block to check for recyclability.
* @returns True if the block can be recycled. False otherwise.
*/
protected blockIsRecyclable(block: Blockly.Block): boolean;
/**
* Disposes of the provided block.
*
* @param item The block to dispose of.
*/
disposeItem(item: Blockly.FlyoutItem): void;
/**
* Clears the cache of recycled blocks.
*/
emptyRecycledBlocks(): void;
}
//# sourceMappingURL=RecyclableBlockFlyoutInflater.d.ts.map