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

Utils: Is it possible to provide one copyToClipboard utils or component by using the new API? #8842

Open
adamzhang1932 opened this issue Jun 24, 2024 · 0 comments

Comments

@adamzhang1932
Copy link

Is your feature request related to a problem or use case? Please describe.
The old API document.execCommand might be deprecated in the future.
A component or utils which can read/write/clear the clipboard easily by using the new API and old API would be nice.

Describe the solution you'd like
As we know, there are some description and implements here.
https://w3c.github.io/clipboard-apis/
https://web.dev/articles/async-clipboard
https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand

And the pseudocode might be here(just one small suggestion):

// If new clipboard api is not supported, then downgrade to the old api.
if (new Clipboard API is supported) {
   copyByNewAPI().then(function () {
	successCallback();
    }, function () {
	copyByOldAPI();
    });
} else {
   copyByOldAPI();
}

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.
And what application do you work on? Infor SunSystems

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

No branches or pull requests

1 participant