-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add "Copy Block Data" button #22
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As outlined in the GitHub issue for this feature, there are three different options available for adding this functionality in Gutenberg. I have opted for the oldest (and now deprecated ClipboardButton component). This does come with it the disadvantage of a depreaction notice but that seems a small price to pay for backwards compatibility. Initially, I inteneded to use the most modern solution useCopyToClipboard (adding in Gutenberg 10.3.0, WordPress core 5.8.x), my thinking being that since we were importing this hook from the latest version of the package, it would work despite running on an older version of Gutenberg. import { useCopyToClipboard } from '@wordpress/compose'; Nope - this fails with with the following error TypeError _wordpress_composer__WEBPACK_IMPORTED_MODULE_1__.useCopyToClipboard is not a function This only deepens my confusion around importing packages vs destructuring them from the "wp" global as discussed in https://salferrarello.com/wordpress-gutenberg-import-versus-destructuring-global-wp/ At this point I could add a conditional and provide two (or more) sets of code to create this copy functionality to ensure I don't throw any deprecation notices or I can use this older (but fully functional technique) and be done with it. Resolves #17
Next step is to pull in the code from #21 so we can conditionally use that when |
2bfdd80
to
68d3642
Compare
Closed
When useCopyToClipboard is present, use ModernCopyButton and when it is not present, use LegacyCopyButton.
68d3642
to
14453a9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #17