Skip to content

Add copy controls to docs code blocks#4

Merged
jamesmontemagno merged 8 commits intomainfrom
copilot/add-copy-buttons-to-code-blocks
Mar 19, 2026
Merged

Add copy controls to docs code blocks#4
jamesmontemagno merged 8 commits intomainfrom
copilot/add-copy-buttons-to-code-blocks

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 19, 2026

The docs viewer renders workshop markdown without any way to quickly copy sample commands or code. This adds per-block copy controls with lightweight feedback so readers can grab snippets directly from the rendered guide.

  • Code block actions

    • Injects a copy button into each rendered markdown pre > code block after marked.parse()
    • Copies the block’s text content, not HTML, so shell commands and code paste cleanly
    • Avoids duplicate controls when the viewer re-initializes
  • Clipboard handling

    • Uses the Clipboard API when available
    • Falls back to an off-screen textarea + execCommand('copy') path for older or restricted contexts
    • Keeps the fallback encapsulated in the docs viewer script
  • User feedback + styling

    • Adds inline state feedback: CopyCopied! / Failed
    • Styles the control to match the existing docs theme
    • Reserves space in the code block header so the button does not overlap content
<pre>
  <code>uv run pytest</code>
  <button class="code-copy-btn">Copy</button>
</pre>

Copilot AI and others added 8 commits March 19, 2026 22:50
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-python/sessions/f398ad34-4328-47f8-b47a-52157fb85dc3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants