Clipboard
Read and write content from and to the clipboard.
System requirements
Please make sure your local environment uses the following application versions before proceeding.
- InDesign v18.5 or higher
- UXP version v7.1 or higher
- Manifest version v5 or higher
Plugins and Scripts
In plugins, you should seek permission for clipboard
access in the manifest.
IMPORTANT: Read about the manifest permissions before you proceed.
In scripts, the permission for clipboard
is fixed. You can ignore the manifest details in the following examples. Learn about these values in the manifest fundamentals section.
Example
JavaScript
manifest
Copied to your clipboardasync function foo() {const clipboard = navigator.clipboard;// Setting content for clipboardclipboard.setContent({ 'text/plain': "Test string to validate clipboard setContent" }).then(() => {console.log("Data successfully set on clipboard");}, (error) => {console.error("Error while setting data on clipboard:", error);});// Reading from clipboard and printingclipboard.getContent().then((result) => {console.log(`Data from clipboard: ${result["text/plain"]}`);}, (error) => {console.error("Error while reading data from clipboard:", error);});}
Copied to your clipboard{"requiredPermissions": {"clipboard": "readAndWrite"}}
Additional notes
- Set the permission to "read" if your script/plugin only intends to read from the clipboard.
Reference material
- Clipboard APIs