-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add Copy Button to Code Block #70019
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
Conversation
|
There are currently two blockers with this PR:
|
|
I don't think this improves UX in the editor, but it introduces more lines of code to maintain. The "Select All" command works just fine in textarea and contenteditable fields, unlike @t-hamano, what do you think? |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
Thanks for the ping! Personally, I am against adding new functionality to the Code block. A PR has also been submitted to add line numbers, but I left my thoughts there. See #68465 (comment) |
|
Thanks @Mamaduka and @t-hamano for sharing your views! 💯
I agree with the same, but as on now I couldn't find a plugin that would do this, so we can probably think about implementing this |
|
Sure, the feature can be part of a custom plugin, and if the user really needs a separate copy, they can install the plugin. That's the beauty of WordPress. Not every feature needs to be part of the core. I'm going to close this and the associated issue as "won't fix". Thanks again for contributing, @Rishit30G! |
|
Hey I have lately become hooked on using ChatGPT for developing code that I need. So with a lot of help I made this tutorial. I add code for line numbers and a copy button to the Code block. |
What?
Closes #70018
Why?
This PR is intended to add the copy button to the code block
How?
This PR adds the
<Button>component in the code code block with the necessaryicon,onClick,labelanddisabledprop for it to behave like Copy Button along with anotice.Testing Instructions
Screenshots or screencast
Screen.Recording.2025-04-30.at.1.25.34.PM.mov