Stay organized with collections
Save and categorize content based on your preferences.
blockly > clipboard
clipboard namespace
Classes
Functions
Function |
Description |
copy(toCopy, location) |
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. |
getLastCopiedData() |
Gets the copy data for the last item copied. This is useful if you are implementing custom copy/paste behavior. If you want the default behavior, just use the copy and paste methods directly. |
getLastCopiedLocation() |
Gets the location that was last copied from. This is useful if you are implementing custom copy/paste behavior. If you want the default behavior, just use the copy and paste methods directly. |
getLastCopiedWorkspace() |
Gets the workspace that was last copied from. This is useful if you are implementing custom copy/paste behavior and want to paste on the same workspace that was copied from. If you want the default behavior, just use the copy and paste methods directly. |
paste(copyData, workspace, coordinate) |
Paste a pasteable element into the given workspace. This function does not perform any checks to ensure the paste is allowed, e.g. that the workspace is rendered or the block is pasteable. Such checks should be done before calling this function. |
paste() |
Pastes the last copied ICopyable into the last copied-from workspace. |
setLastCopiedData(copyData) |
Sets the last copied item. You should call this method if you implement custom copy behavior, so that other callers are working with the correct data. This method is called automatically if you use the built-in copy method. |
setLastCopiedLocation(location) |
Sets the location that was last copied from. You should call this method if you implement custom copy behavior, so that other callers are working with the correct data. This method is called automatically if you use the built-in copy method. |
setLastCopiedWorkspace(workspace) |
Sets the workspace that was last copied from. You should call this method if you implement custom copy behavior, so that other callers are working with the correct data. This method is called automatically if you use the built-in copy method. |
Interfaces
Namespaces
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."],[[["\u003cp\u003eThe Blockly clipboard namespace provides functionality for copying and pasting elements within the Blockly workspace.\u003c/p\u003e\n"],["\u003cp\u003eIt includes classes like BlockPaster for managing paste operations and functions like paste for inserting copied elements.\u003c/p\u003e\n"],["\u003cp\u003eThe namespace also features a registry for managing clipboard-related components and a TEST_ONLY variable for testing purposes.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can leverage this namespace to implement custom copy-paste behaviors within their Blockly applications, using functionalities exposed through classes, functions, namespaces and variables.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [clipboard](./blockly.clipboard_namespace.md)\n\nclipboard namespace\n\nClasses\n\n| Class | Description |\n|-------------------------------------------------------------------|-------------|\n| [BlockPaster](./blockly.clipboard_namespace.blockpaster_class.md) | |\n\nFunctions\n\n| Function | Description |\n|---------------------------------------------------------------------------------------------|------------------------------------------------------|\n| [paste(copyData, workspace, coordinate)](./blockly.clipboard_namespace.paste_1_function.md) | Paste a pasteable element into the workspace. |\n| [paste()](./blockly.clipboard_namespace.paste_2_function.md) | Pastes the last copied ICopyable into the workspace. |\n\nInterfaces\n\n| Interface | Description |\n|---------------------------------------------------------------------------|-------------|\n| [BlockCopyData](./blockly.clipboard_namespace.blockcopydata_interface.md) | |\n\nNamespaces\n\n| Namespace | Description |\n|-----------------------------------------------------------------|-------------|\n| [registry](./blockly.clipboard_namespace.registry_namespace.md) | |\n\nVariables\n\n| Variable | Description |\n|------------------------------------------------------------------|-------------|\n| [TEST_ONLY](./blockly.clipboard_namespace.test_only_variable.md) | |"]]