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

[WIP] Sort out cut/copy/paste issues #1023

Closed
wants to merge 4 commits into from
Closed

[WIP] Sort out cut/copy/paste issues #1023

wants to merge 4 commits into from

Conversation

danburzo
Copy link
Contributor

@danburzo danburzo commented Aug 24, 2017

Re: #734 (Work in progress)

References:

Basically I'm swapping the "move into contenteditable div, select it, and let the browser copy the contents" technique with manually setting the clipboard data for text/plain and text/html.

There's an opportunity here to plugin in a Slate HTMLSerializer and PlainSerializer if the author wants to make the clipboard data conform to a certain schema. (There's a discussion about this, I think?) — DONE ✓

What still needs to be done (any help appreciated):

  1. See if anything obvious regresses
  2. Assess the browser support for setData() and whether we can be sure the data has been set. (Otherwise, browsers silently ignoring setData() will not be able to copy anything to the clipboard) — and fall back to the div technique if necessary

@danburzo
Copy link
Contributor Author

danburzo commented Aug 24, 2017

Well, can't test with Browserstack since it messes with the clipboard, but I will take this as a sign the APIs are there since at least 2014, so that's that :)

We just need to do a regression test (Especially interested in IE/Edge) and I think we're good to go.
@mahlero @jwoldan @kumar2013 would you be able to help test this on Windows?

@danburzo
Copy link
Contributor Author

danburzo commented Aug 24, 2017

It seems the chromium issue was marked as WontFix, in which case setData() seems the way to go. One concern I have is whether Webkit, when "canonizing" the text/html content, will wrap things like <td>content</td> in <table><tr></tr></table> and other sorts of normalization prior to placing it in the clipboard — needs to be tested — Update: Tested and it does not generate any wrapping.

@ianstormtaylor
Copy link
Owner

Hey @danburzo I just commented in the original issue. It feels like we're dealing with multiple separate things here in this PR that we should potential detangle from each other.

  1. One is the ability to override the internal pasting with custom serializers. It seems like this is already solvable (although core doesn't give you help with it) by simply adding your own custom onCut/onCopy middleware with a plugin? Using setData here seems like exactly how those plugins would want to do it.

  2. Another is the ability to tweak the data.fragment so that plugins can change the internal pasting behavior without having to re-implement the internal pasting logic themselves.

  3. Another is to fix the behavior of copying HTML content when it is inside a single node in Chrome/Safari? This one seems like the most in need of fixing, and ideally we could find a way that doesn't involve changing much in core?

For (3) I haven't investigated as much as you, so I'm not as sure where the limitations are, but is there no way for us to fix that as currently architected?

Let me know what you think.

@ianstormtaylor
Copy link
Owner

As of #3093 (which was just merged), I believe this issue is no longer applicable, because a lot has changed. I'm going through and closing out any potential issues that are not out of date with the overhaul. Thanks for understanding.

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

Successfully merging this pull request may close these issues.

2 participants