vuepress / ecosystem

Official plugins and themes for VuePress2
https://ecosystem.vuejs.press
MIT License
20 stars 26 forks source link

feat: optimize the code block copy #152

Closed pengzhanbo closed 1 month ago

pengzhanbo commented 1 month ago

Before submitting the PR, please make sure you do the following

What is the purpose of this pull request?

Description

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 9185613900

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
plugins/plugin-prismjs/src/node/prismjsPlugin.ts 0 1 0.0%
<!-- Total: 24 25 96.0% -->
Files with Coverage Reduction New Missed Lines %
plugins/plugin-prismjs/src/node/prismjsPlugin.ts 1 4.35%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 9161313702: 1.5%
Covered Lines: 1048
Relevant Lines: 1617

💛 - Coveralls
Mister-Hope commented 1 month ago

Also, I did not find any thing about vp-copy-ignore class in current codes, so what's this option for?

When users are using twosplash, can we still provide the correct content?

Mister-Hope commented 1 month ago

BTW, I still dislike this PR change, as it splits a whole copy-code functionality inside 2 plugins, and users do not benefit from it in most cases.

The only thing it improves is removing a delay option, but the docs will confuse both the developers and the users. The ideal situation is that every theme should have a highlighter built-in, and if it does not bundle the copy code plugin, then users might get greatly confused when reading the copy code plugin docs.

We don't need any SSG render or SEO with the copy button actually, we just need a client side a11y support.

The things I actually concern is that can the 2 highlighter plugin provide a client side transformer, guiding the copy code plugin to make some transform to get the correct code.

pengzhanbo commented 1 month ago

Also, I did not find any thing about vp-copy-ignore class in current codes, so what's this option for?

When users are using twosplash, can we still provide the correct content?

For example, using twoslash will inject additional content into the code block, and you can also add a class name vp-copy-ignore to this additional content to prevent it from being copied. You can think of vp-copy-ignore as a preset. I have considered making ignore an optional configuration.