Comments (5)
To use the new api but still support older browsers i'm using this implementation. But might be good to add this to copy-to-clipboard.
async onClick() {
try {
await navigator.clipboard.writeText(shareUrl);
} catch {
// Otherwise we use copy-to-clipboard library that tries to use execCommand which is deprecated in modern browsers
// when browser does not allow clipboard copy it will show a modal with the link in it
copy(shareUrl);
}
}
from copy-to-clipboard.
I think a downside of this is it looks like you can only copy text, and can't specify the format. Am I incorrect here?
from copy-to-clipboard.
writeText
is only for text. For other formats, there is write
.
from copy-to-clipboard.
I guess with this API available, this module is pretty much obsolete, so one option could be to not support it, letting this module exist only as a "legacy solution".
from copy-to-clipboard.
I guess with this API available, this module is pretty much obsolete, so one option could be to not support it, letting this module exist only as a "legacy solution".
the new clipboard API just works on HTTPS or localhost. In some usage scenarios, such as intranet environments without domain name resolution and custom certificates, the new API is not available.
from copy-to-clipboard.
Related Issues (20)
- 哥们,你的 options 的 format 必须传值才走复制的代码,format 传为 text/plain,你下个版本修复下? HOT 5
- Disable prompt on error HOT 4
- TypeError: reselectPrevious is not a function HOT 4
- IE11 format: 'text/html' results in empty clipboard HOT 1
- Option to support text/html and text/plain in parallel when one or the other is available. HOT 2
- execCommand is now obsolete HOT 2
- Safari when copy is made async HOT 1
- Copied text/html content not getting pasted in code editor, slack, etc. HOT 4
- reselectPrevious is not a function HOT 1
- Deprecated? HOT 1
- npm audit: 16 vulnerabilities HOT 3
- Screen readers should not narrate copied text HOT 3
- Platform parsing will soon break on Chrome
- Copy incorrectly if my text contains "\r\n" when using firefox HOT 3
- Copy to clipboard doesn't work in fullscreen mode HOT 1
- not es-module compliant HOT 2
- Seemed wrong preventDefault?
- Does it support copy image/png?
- CDN source dead
- Safari 17 Throws error NotFoundError: The object can not be found here.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from copy-to-clipboard.