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

Safari paste handling and Clipboard API #4998

Closed
dylans opened this issue May 19, 2022 · 8 comments · Fixed by #5362
Closed

Safari paste handling and Clipboard API #4998

dylans opened this issue May 19, 2022 · 8 comments · Fixed by #5362

Comments

@dylans
Copy link
Collaborator

dylans commented May 19, 2022

Description

A recent Safari update seems to have blocked all of Slate's attempts to append our syntax tree to application/x-slate-fragment. Previously this worked but would exclude files.

Sandbox/Steps

Any slate example shows an empty application/x-slate-fragment when pasting.

Expectation

We can control what gets pasted. Currently we're falling back to HTML which isn't great for void elements that have behavior not contained in html.

Environment

  • Slate Version: Any
  • Operating System: macOS, probably iOS
  • Browser: Safari

Context

We probably need to switch to the newer clipboard api for Safari, though it's annoying in that it asks for user approval. See various links in #4465 (comment)

@dylans dylans changed the title Safari paste handling Safari paste handling and Clipboard API May 19, 2022
@IMSupperkaka
Copy link

same problem

@jdmanabat
Copy link

Currently, we are having an issue when pasting bullet and number lists in Safari. Do you think it's related to this?

@dylans
Copy link
Collaborator Author

dylans commented Jun 8, 2022

Currently, we are having an issue when pasting bullet and number lists in Safari. Do you think it's related to this?

What type of issue?

@jdmanabat
Copy link

jdmanabat commented Jun 8, 2022

Currently, we are having an issue when pasting bullet and number lists in Safari. Do you think it's related to this?

What type of issue?

When pasting the copied bullet or numbered lists the HTML tags are removed.

Screen Shot 2022-06-09 at 10 00 54 AM

@Nikhil22
Copy link

When I paste plain text with line breaks in Safari, Slate does not honor the line breaks. End result is all one block of text.

@dylans
Copy link
Collaborator Author

dylans commented Jan 18, 2023

Safari has progressively made the old copy/paste API less usable, a strong to push to use the newer API (which requires user consent). We need to implement that in 2023 to solve a number of problems with copy/paste in Safari.

@Nikhil22
Copy link

@dylans Sounds good. If you or the team need any help, I'm happy to contribute in any way I can.

@12joan
Copy link
Contributor

12joan commented Mar 2, 2023

The Clipboard API doesn't require prompting for permission when writing to the clipboard from an event handler, only when reading it outside of a paste event. However, it won't work for copying application/x-slate-fragment data in Safari, since all major browsers only allow a limited set of data types when writing with Clipbard.write(). See https://webkit.org/blog/10855/.

I don't think there are any APIs that allow us to copy application/x-slate-fragment in Safari.

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

Successfully merging a pull request may close this issue.

5 participants