vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.33k stars 1.83k forks source link

useCopyCode Documentation #3734

Closed donnimsipa closed 3 weeks ago

donnimsipa commented 3 weeks ago

Describe the bug

The Vitepress documentation lacks proper guidance on the usage of useCopyCode hook, which is essential for implementing copy-to-clipboard functionality in code blocks.

Reproduction

  1. Navigate to the Vitepress documentation site.
  2. Look for documentation related to useCopyCode hook or copy-to-clipboard functionality.
  3. Observe the absence of clear instructions or examples on how to use useCopyCode.

Expected behavior

The Vitepress documentation should provide comprehensive guidance, including usage examples and explanations, for the useCopyCode hook, enabling users to easily implement copy-to-clipboard functionality in their projects.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 Intel(R) Pentium(R) CPU N4200 @ 1.10GHz
    Memory: 2.03 GB / 7.83 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.65)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    vitepress: ^1.0.0-rc.45 => 1.0.0-rc.45

Additional context

No response

Validations

brc-dd commented 3 weeks ago

It’s not meant to be used externally and is tied to the DOM we generate for code fences. So, in a blank theme the copy code button should still work without any additional steps. What is your use case?

It is not a hook exactly. It just adds an event listener and is not customizable. Why would want to use it manually?

donnimsipa commented 3 weeks ago

I want to create something similar to useCopyCode directly within 'Custom Containers', but it seems that it's not feasible based on your explanation. Thank you for responding, and I will create a 'code' within 'Custom Containers' so that the 'copy code' appears instead of directly creating a copy button in 'Custom Containers'