Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in the console when pasting in a sandboxed iframe and paste does not work #2343

Open
RambabuPatina opened this issue Apr 8, 2024 · 9 comments

Comments

@RambabuPatina
Copy link

Description

The 'Paste to Clipboard' option does not paste and showing errors in the console when pasting in a sandboxed iframe

Steps to Reproduce

  1. Include the editor in a iframe and include virtual keyboard
  2. Copy some text and click on virtual keyboard
  3. Click on 'Paste from clipboard'
Screenshot 2024-04-08 at 5 09 26 PM

Actual Behavior

The paste behaviour does not work and shows errors in the console:

[Violation] Permissions policy violation: The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.
Uncaught (in promise) DOMException: Failed to execute 'readText' on 'Clipboard': The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.
at Object.pasteFromClipboard [as fn]

Expected Behavior

Paste from clipboard should work and No error messages

Environment

MathLive version 0.97.1

macOS/Windows, Chrome/Firefox

@arnog
Copy link
Owner

arnog commented Apr 8, 2024

Does this happen with the current version (0.98.6)?

@RambabuPatina
Copy link
Author

Checked with 0.98.6 version, same issue facing. Do we need additional changes to work in the iframe? Thanks in Advance

@RambabuPatina
Copy link
Author

Hi @arnog , Any clue on the issue?

@arnog
Copy link
Owner

arnog commented Apr 10, 2024

Not yet, and I will need to build a project to try to reproduce the problem before I can debug it.

@rkanumola
Copy link

Any update @arnog ? One of our releases is based on this. Thanks

@arnog
Copy link
Owner

arnog commented Apr 15, 2024

It would help if you had a project to share that reproduces the problem.

@gunnarmein-ts
Copy link
Contributor

@rkanumola are you loading the iframe from the same location as the container doc?

@RambabuPatina
Copy link
Author

@gunnarmein-ts Do you mean location means the domain? The iframe being loaded from other location. I.e the parent document and the iframe domains are different.

@gunnarmein-ts
Copy link
Contributor

This article: https://stackoverflow.com/questions/61401384/can-text-within-an-iframe-be-copied-to-clipboard
mentions: "To use the API in iframes, you need to enable it with Permissions Policy, which defines a mechanism that allows for selectively enabling and disabling various browser features and APIs. Concretely, you need to pass either or both of clipboard-read or clipboard-write, depending on the needs of your app."

<iframe src="index.html" allow="clipboard-read; clipboard-write"></iframe>

Can you try that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants