Blockly is moving to the Raspberry Pi Foundation on November 10, 2025! Read the
blog
and the
FAQ.
Stay organized with collections
Save and categorize content based on your preferences.
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-24 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-24 UTC."],[],[]]