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

How to add a copy button to a code block? #2411

Open
1 task done
yzxh24 opened this issue Dec 10, 2024 · 9 comments
Open
1 task done

How to add a copy button to a code block? #2411

yzxh24 opened this issue Dec 10, 2024 · 9 comments
Labels
question Further information is requested

Comments

@yzxh24
Copy link

yzxh24 commented Dec 10, 2024

Is there an existing issue for this?

The question

Hi all, I would like to ask if I add a copy button to the top right corner of the code block so that I can quickly copy the code inside, similar to the picture below:
image

@yzxh24 yzxh24 added the question Further information is requested label Dec 10, 2024
@EchoEllet
Copy link
Collaborator

The code block is not customizable, but it's possible to replace it with another widget, possibly a code highlighter / viewer that already has a copy button.

@yzxh24

This comment has been minimized.

@EchoEllet
Copy link
Collaborator

Yes, the screenshot in my question was generated from CustomBlockEmbed in the documentation.
However, there are two issues I can't deal with when using CustomBlockEmbed:

Please refer to #2146, and consider using the experimental property customLeadingBlockBuilder instead of CustomBlockEmbed to override the built-in code block instead of implementing a new custom embed.

allows to pass an Iterable? parameter, but it doesn't seem to be working correctly at the moment, I'm still trying to find out why

Could you provide a minimal example code? The toPlainText() extracts plain text without attributes or rich output. What are you using it for?

@yzxh24

This comment has been minimized.

@CatHood0

This comment has been minimized.

@EchoEllet

This comment has been minimized.

@CatHood0

This comment has been minimized.

@CatHood0

This comment has been minimized.

@EchoEllet

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants