Provide required information needed to triage your issue
I would like to use Clipboard API to copy text on button click in web Outlook taskpane addin. However, it is currently blocked because the containing iframe doesn't have necessary permissions.
Your Environment
- Platform [PC desktop, Mac, iOS, Office on the web]: Office on the web
- Host [Excel, Word, PowerPoint, etc.]: Outlook
- Operating System: Windows 10
- Browser (if using Office on the web): Google Chrome Version 91.0.4472.124
Expected behavior
The Clipboard API is allowed and I'm able to use it.
Current behavior
The addin is in an iframe without necessary permissions, it is currently impossible to copy text through Clipboard API. After I try to use it, the console writes:
Uncaught (in promise) DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.
The solution would be to add more permissions to the iframe by passing clipboard-write permission to iframe. More info for example here: https://web.dev/async-clipboard/#permissions-policy-integration
Steps to reproduce
- In any react component, write onClick prop:
onClick={() => {navigator.clipboard.writeText(this.state.textToCopy)}}
- Go to pane and try to click on the component
Provide required information needed to triage your issue
I would like to use Clipboard API to copy text on button click in web Outlook taskpane addin. However, it is currently blocked because the containing iframe doesn't have necessary permissions.
Your Environment
Expected behavior
The Clipboard API is allowed and I'm able to use it.
Current behavior
The addin is in an iframe without necessary permissions, it is currently impossible to copy text through Clipboard API. After I try to use it, the console writes:
Uncaught (in promise) DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.The solution would be to add more permissions to the iframe by passing
clipboard-writepermission to iframe. More info for example here: https://web.dev/async-clipboard/#permissions-policy-integrationSteps to reproduce
onClick={() => {navigator.clipboard.writeText(this.state.textToCopy)}}