blockly > clipboard > copy

clipboard.copy() function

Copy a copyable item, and record its data and the workspace it was copied from.

This function does not perform any checks to ensure the copy should be allowed, e.g. to ensure the block is deletable. Such checks should be done before calling this function.

Note that if the copyable item is not an ISelectable or its workspace property is not a WorkspaceSvg, the copy will be successful, but there will be no saved workspace data. This will impact the ability to paste the data unless you explictily pass a workspace into the paste method.

Signature:

export declare function copy<T extends ICopyData>(toCopy: ICopyable<T>, location?: Coordinate): T | null;

Parameters

Parameter Type Description
toCopy ICopyable<T> item to copy.
location Coordinate (Optional) location to save as a potential paste location.

Returns:

T | null

the copied data if copy was successful, otherwise null.