zenorocha / clipboard.js

:scissors: Modern copy to clipboard. No Flash. Just 3kb gzipped :clipboard:
https://clipboardjs.com
MIT License
33.96k stars 3.98k forks source link

innerText or Similar Removes Double Spaces #866

Open wbotelhos opened 8 months ago

wbotelhos commented 8 months ago

🐛 Bug Report

Expected Behaviour

Given a <div>Multiple Spaces</div> When I copy the content of it Then I should get Multiple Spaces

Actual Behaviour

Given a <div>Multiple Spaces</div> When I copy the content of it Then I actually get Multiple Spaces

To Reproduce

  1. Add any two or more space for a element content
  2. Execute the copy command
  3. You'll get a squished text

Browsers Affected

  1. Brave
  2. Chrome

Not tested others

Operational System

13.3.1 (a) (22E772610a) Apple M2

Temporary Solutions

Set the text into an attribute like data-clipboard-text instead use a tag content. By the way the browser squish it too, so display the text for a plain user copy is not a cool thing.

Question

Is there any way of add a innerText or innerHTML option?

obetomuniz commented 2 months ago

@wbotelhos, that's a great catch. I'm planning to contribute to some open issues. Soon I will be triaging it and proposing a fix.