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

Force a text/plain copy to make it easier to work with word processors #77

Closed
wants to merge 1 commit into from

Conversation

julienw
Copy link
Collaborator

@julienw julienw commented Apr 4, 2019

Fixes #46

@julienw
Copy link
Collaborator Author

julienw commented Apr 4, 2019

On my side it seems to fix the problem, but please test it on your side as well!

@sudodoki
Copy link
Owner

sudodoki commented Apr 6, 2019

Not sure about this one, I would prefer to fix #46 by some css (it's a pity mark.style.all = 'unset' doesn't help), or by setting format on clipboard data if there's some mode like plaintext=true arg passed. And just using clipboard.setData as done in https://github.com/sudodoki/copy-to-clipboard/pull/77/files#diff-168726dbe96b3ce427e7fedce31bb0bcL63 is kinda redoing the same effort. I would prefer to rely on execCommand by default. Possibly, #26 might help (switching to textarea) but if we are dealing with html content, something like DOMParser + textContent (as mentioned [here]) might be an answer 🤔

@julienw
Copy link
Collaborator Author

julienw commented Apr 7, 2019

I tried a textarea and it didn't seem to help with this issue, but maybe I did it in a wrong way.

I also tried a white background, and this is mostly OK, except it does a white background on the text when pasting in a colorful document background.

We can also use, if existing, the new api Clipboard.writeText.

But I like the solution I proposed here because:

  • it fixes the problem completely.
  • it is simple
  • It is supported everywhere execCommand is supported. (or so I think)

@julienw
Copy link
Collaborator Author

julienw commented Apr 7, 2019

It is supported everywhere execCommand is supported.

Or rather supported everywhere the copy event is supported.

@julienw
Copy link
Collaborator Author

julienw commented Apr 7, 2019

The root issue, I think, is that chrome copies the default page background. That's why unset: all doesn't work.
I believe this is a bug in Chrome but well... We have to deal with it :)

@julienw
Copy link
Collaborator Author

julienw commented Apr 13, 2019

Also I believe it's important to fix it now because with the other PR I wrote the workaround isn't possible anymore.

@sudodoki
Copy link
Owner

Then I would ask of you to add format as argument (might also require linking to proper values that can be used as format argument, updating readme and updating typing). Does it make sense? In case someone relied on rich text copying. Can you do that, please?

@sudodoki
Copy link
Owner

sudodoki commented May 4, 2019

Closed in favour of #79 Thanks for bringing this up!

@sudodoki sudodoki closed this May 4, 2019
@julienw
Copy link
Collaborator Author

julienw commented May 4, 2019

yeah, I had ideas to implement this, just was too busy, sorry about that :(

But I don't think #79 fixes the original problem in Chrome, actually, as it does nothing if we pass nothing (the default situation), and also I think it won't work properly if somebody passes "text" (as it says the default is), and also it doesn't control how it will look like as HTML.

I have some time now, I can try to rebase on top of that patch and see if I can come up with anything.

@julienw
Copy link
Collaborator Author

julienw commented May 4, 2019

if somebody passes "text"

Ah, I see you changed the README, this makes it better indeed.

I'd still like to propose another possibility, you'll tell me if you like it.
Especially I think the text/html option shouldn't be the default.

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

Successfully merging this pull request may close these issues.

Copied text has a grey background when pasted into gmail or google docs.
2 participants