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

feat: allow explicitly mark code element as .vp-copy-ignore #3360

Merged
merged 2 commits into from Dec 20, 2023

Conversation

antfu
Copy link
Member

@antfu antfu commented Dec 19, 2023

When we enabled TwoSlash, it injected some elements to provide the type information inline. It works great until you copy the code (you can try on https://shikiji.netlify.app/packages/twoslash).

I didn't find a good and agnostic way to opt-out elements from being printed in .textContent, so I guess actually removing those elements before grabbing the content might be a more solid idea.

I picked a kinda natural selector, .vp-copy-ignore, so in Shikiji integration, I could provide an option for users to inset that class. On another pov, I am not sure how much VitePress would be interested in document the usage of twoslash or even ship it as a feature.

@brc-dd brc-dd merged commit 93122ee into main Dec 20, 2023
7 checks passed
@brc-dd brc-dd deleted the feat/copy-ignore branch December 20, 2023 04:20
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants