Copy to clipboard on Code Block

Hey, as the title says I think it would be very helpful to display a button to copy to clipboard on code blocks.
Sample usage would be of course copying and pasting to a terminal…
I don’t think that would need to be enabled by default but could be under a toggle in settings for people who need it.
EDIT: Forgot to mention that my personal opinion is that having the possibility to enable the button is a lot better the Right Click->Copy Code Block. I don’t know, maybe you can poll this feature somehow :slight_smile:

8 Likes

Hi there,

Many thanks for taking the time to leave a post with some feedback for us here.

I can see that this is your first time posting on the forum, so welcome to the community!

Regarding the above, may I just ask are you wanting to copy the code block format? or just the text from it?

If it’s the latter, you can right click and “copy code” or use the Command+C and Command + V to copy and paste.

If you mean copying the code block format, i’ll pass on this suggestion to the development team to consider when moving forward.

Hello,
As you can see in the following screenshot taken from a GitHub rendered markdown file, when hovering the code block a button appears. On click the text is copied to the clipboard for easy pasting into a terminal for example. I think the user experience is greatly improved having something similar, as I found that, right clicking and finding the entry in the menu to copy the code block not too good.

Ah, I see what you mean.

Thank you for the additional explanation and image.

I’ll pass on the suggestion to the development team to consider :slight_smile:

3 Likes

Please add my +1 vote on that feature request :slightly_smiling_face:

Add my vote too, specifically for iPadOS to have this. It seems like such a common feature in forums, as well as some coding websites like GitHub. Anyways, please add this.

Yes I’ll add my vote too. I think it would be essential to be able to quickly copy the contents of a code block (without the backticks and language identifier; just the contents) on all platforms. I think there’s already a ‘Copy Code Block’ option in Mac’s Menubar but it’s not available on iOS and iPadOS.

Vote has been added :slight_smile:

Vote has been added :slight_smile:

Thank you for your feedback, your vote has been added :slight_smile:

Any updates on whether this would be a feature that would be added?

An alternative would be to have an option to setup a shortcut to copy code block instead of having to right click and then select Copy Code Block.

1 Like

We are not convinced about having a permanent button on the code block UI is the way to go.

I’ll discuss adding Copy Code to the Edit menu to facilitate adding custom macOS shortcuts.

1 Like

We already have a way to copy code blocks using the contextual menu. I’m thinking that the copy button should be visible only when hovering the code block as it is done in a lot of other apps. Having that option in the Edit menu is not good UX from my point of view.

2 Likes

On seconds thoughts, shortcuts would potentially be faster/easier than having to click a button. Thanks for putting it in consideration.

FWIW, a small copy icon in the corner of a code block on hover that copies the code without moving the cursor or selecting text & expanding the code markdown would be far better user experience for Bear 2.

Current Bear 2 beta copy code experience:

Bear 2 Copy Code

  • Right-click on code block, selects whatever text is under the mouse when right-clicking and expands the code block markdown, making for a clunky user experience.

GitHub copy code experience:

GitHub Copy Code

  • Hover, click, and you’re done. Cursor doesn’t move and code block doesn’t shift as you’re trying to copy it.

Honestly, the latter approach is more consistent with Bear 2’s beautiful only-show-markdown-when-you-need-it approach. :slight_smile:

6 Likes

@trix180 and @TedwardBear please consider my +1 on this as well. The implementation shown by @Burke looks really good and imo works well with your design language. Personally I am finding the code copy mechanism for 2.0 way too janky as anytime clicking on the code block cause the backticks to pop back up again and the thing jumps around on the screen, even if I go to copy via right click. Bear being a markdown editor and having legacy of supporting code blocks so well, I think we can do better here.

1 Like