Open LiuRhoRamen opened 2 years ago
yes, that's an issue I have observed as well. Using textarea introduces other issues. Did you try using alternative copy packages?
Yeah, I've found sindresorhus/copy-text-to-clipboard which use textarea, but I'm not sure if it will cause some other issues that you mentioned. Also I've found there's a new api called navigator.clipboard that can be used in modern browsers.
I need to copy text which contains "\r\n". when using firefox, I found that the "\r\n" inside the copied text turned to be "\n\n". After reading the source code, I found the problem is the use of
Selection
. (Maybe it's a bug of Firefox)Heres a simple example to explain the problem: https://jsfiddle.net/LiuRhoRamen/mo1zfxvb/7/
Maybe It's better to create a
textarea
, call .select() method and do the copy?