Add setting to disable code block copy buttons in Markdown preview
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
The recently added copy buttons for fenced code blocks in the built-in Markdown preview cannot currently be disabled.
This is problematic for extensions that reuse or extend VS Code's Markdown preview, in particular **Marp for VS Code**. In a Marp presentation, the injected `.code-block-copy-button` becomes part of the rendered slide and appears on every code block. This is presentation content rather than documentation UI, so the button is undesirable and visually intrusive.
**Steps to reproduce**
1. Install Marp for VS Code.
2. Create/open a Marp Markdown presentation containing a fenced code block.
3. Open the Marp preview.
4. A copy button is rendered inside every code block.
There should be a user setting to disable the injected copy buttons, for example:
```JSON
"markdown.preview.codeBlockCopyButton": false
```
Alternatively, there could be an API/contribution mechanism allowing Markdown preview extensions such as Marp to opt out of this feature.
`.code-block-copy-button` is unconditionally injected and there is no configuration setting to disable it.
This appears to have been introduced by the implementation of #322269 / #323609 in the 1.132 milestone.
Contributor guide
Assessment
This issue has not been assessed yet.