Introduction
Currently, the documentation site successfully provides "Copy" buttons for code blocks tagged with languages like javascript, tsx, and java. However, many critical blocks representing terminal output, shell commands, or environment setup logs (tagged as shell, bash, or text) lack this feature.
Details
In the Environment Setup and Troubleshooting guides, users often need to copy long commands or specific error patterns to compare with their local output.
By "swizzling" the CodeBlock component in the Docusaurus theme, we can ensure that any block with a language tag regardless of whether it's a programming language or a terminal command includes the CopyButton. This would also allow us to add logic to strip the $ or > prompts from the copied text to improve the developer experience.
Discussion points
-
Should we enable the copy button for all code blocks by default, or keep it restricted to a specific list of languages?
-
For shell blocks, should we implement a filter that automatically removes the command prompt symbols ($, >>) from the clipboard content?
-
Are there specific accessibility (a11y) considerations for adding buttons to non-syntax-highlighted text blocks?
Introduction
Currently, the documentation site successfully provides "Copy" buttons for code blocks tagged with languages like javascript, tsx, and java. However, many critical blocks representing terminal output, shell commands, or environment setup logs (tagged as shell, bash, or text) lack this feature.
Details
In the Environment Setup and Troubleshooting guides, users often need to copy long commands or specific error patterns to compare with their local output.
By "swizzling" the CodeBlock component in the Docusaurus theme, we can ensure that any block with a language tag regardless of whether it's a programming language or a terminal command includes the CopyButton. This would also allow us to add logic to strip the $ or > prompts from the copied text to improve the developer experience.
Discussion points
Should we enable the copy button for all code blocks by default, or keep it restricted to a specific list of languages?
For shell blocks, should we implement a filter that automatically removes the command prompt symbols ($, >>) from the clipboard content?
Are there specific accessibility (a11y) considerations for adding buttons to non-syntax-highlighted text blocks?