code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.39k stars 135 forks source link

Ability to copy just highlighted code #351

Closed rachelnabors closed 1 year ago

rachelnabors commented 1 year ago

We have the copy button for the entire chunk of code, but I want to let learners copy just the code that is highlighted. Is this possible/in progress?

pomber commented 1 year ago

I was waiting for someone to ask for this one.

How do you think it should work for inline highlights? Do you mean highlighted using focus or using mark?

image

rachelnabors commented 1 year ago

This code:

image

Would add a copy button just to

? Enter a name for the project reactamplified
The following configuration will be applied:
pomber commented 1 year ago

I'll add this one soon

pomber commented 1 year ago

I added the copy button to the mark annotation (when you target one or more lines) but it's hidden by default. You need to display it with CSS:

.ch-code-multiline-mark:hover .ch-code-button {
  display: block;
}

Demo

github-actions[bot] commented 1 year ago

:rocket: Issue was released in v0.8.3 :rocket: