No access to clipboard

I want to copy an image blob into clipboard with the api navigator.clipboard.write. It works fine in chrome, but got an uncaught error like this:

​ Uncaught Error: Clipboard access not supported for 3P plugins with manifest version upto 4. Valid manifest entry required from manifest version 5.
    at new e.exports (uxp://uxp-internal/domjs_scripts.js:2)
    at U.get clipboard [as clipboard] (uxp://uxp-internal/domjs_scripts.js:2)
    at Object.get clipboard [as clipboard] (uxp://uxp-internal/pluginmanager_scripts.js:2)
    at <anonymous>:1:11

How can I solve this promble please?

my code looks like this:

        async function CopyImage() {
        // const blob = await getImageBlobFromUrl(src);
        const blob = Base642Blob();
        const item = new ClipboardItem({[blob.type]: blob});
        try{
          await navigator.clipboard.write([item]);
        }catch (error) {
          console.log(error);
        }

You need to update your manifest to v5.
https://developer.adobe.com/photoshop/uxp/2022/guides/uxp_guide/uxp-misc/manifest-v5/

It works, Thank you veryyyyy much! But I ran into another problems:
​ Uncaught UxpRuntimeError: Refusing to load event handler tag as executable code. Code generation is disabled in plugins
What should I do please?

If you’re using webpack, you can (for dev purposes), add allowCodeGenerationFromStrings: true to your requiredPermissions section in the manifest, and the error should go away.

2 Likes

thanks I will try it out