Skip to content

Add copy actions to workshop code blocks#5

Merged
jamesmontemagno merged 6 commits into
mainfrom
copilot/add-copy-buttons-to-code-blocks
Mar 19, 2026
Merged

Add copy actions to workshop code blocks#5
jamesmontemagno merged 6 commits into
mainfrom
copilot/add-copy-buttons-to-code-blocks

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 19, 2026

Workshop docs code blocks did not provide a quick way to copy commands or snippets. This change adds inline copy actions to rendered markdown code blocks in the GitHub Pages step viewer.

  • Code block enhancements

    • injects a copy button into each rendered pre > code block after markdown is parsed
    • copies the exact block contents, preserving multi-line snippets
    • avoids duplicate button injection when content is re-rendered
  • Clipboard behavior

    • uses the async Clipboard API when available
    • falls back to the legacy copy path when clipboard access is unavailable or denied
    • surfaces transient UI states for success and failure
  • UI + accessibility

    • styles the button to match the existing docs theme
    • reserves space within code blocks so the control does not overlap content
    • updates aria-label and announces state changes for assistive technologies
<pre><code>cd socops
./mvnw test</code></pre>

After render, the viewer augments the block with an inline Copy control and updates the label to Copied! or Failed based on the clipboard result.

Copilot AI and others added 6 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-java/sessions/fbe0f93a-28f4-47a7-ba04-4a263cfd3017
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-java/sessions/fbe0f93a-28f4-47a7-ba04-4a263cfd3017
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-java/sessions/fbe0f93a-28f4-47a7-ba04-4a263cfd3017
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-java/sessions/fbe0f93a-28f4-47a7-ba04-4a263cfd3017
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-java/sessions/fbe0f93a-28f4-47a7-ba04-4a263cfd3017
Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com>
Agent-Logs-Url: https://github.com/copilot-dev-days/agent-lab-java/sessions/fbe0f93a-28f4-47a7-ba04-4a263cfd3017
@jamesmontemagno jamesmontemagno marked this pull request as ready for review March 19, 2026 22:57
@jamesmontemagno jamesmontemagno merged commit ce966cf into main Mar 19, 2026
@jamesmontemagno jamesmontemagno deleted the copilot/add-copy-buttons-to-code-blocks branch March 19, 2026 22:58
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