Add copy button to graphs/diagrams to copy source

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Collaborate/take over this issue

As discussed in #409451 (comment 1375960637), we should be adding a copy button to the graph/diagrams in order to copy the source code, as we do for Mermaid diagrams.


Implementation Guide

We want to add a "Copy to clipboard" button for all diagrams. We already support if for mermaid diagrams (when you mouse over the diagram you see the icon appear in the upper right corner of the diagram)

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

but we don't for PlantUML

In general, code blocks have this button added in automatically, which was added in Adds copy button to every markdown code block (!75433 - merged).

It wasn't working properly for mermaid diagrams, and was fixed in Fix copy to clipboard for Mermaid diagrams (!83202 - merged).

I don't know exactly where to fix this at the moment - it will require a little more investigation.


original proposal

Proposal

Comments can contain complex diagrams that are impossible to copy/update in another comment without the raw version of the diagram (source code).
Maintainers can edit comments and fetch what they need, but anyone below this permission grade can't, which includes the common Developer role.
Issue descriptions can be edited by Developers, so anything in there can be seen as raw and this issue is focusing on comments only.

We could add a View raw comment link in this comment menu:

Screenshot_2023-05-02_at_11.14.17

For example: I can't suggest an edit to gitlab-web-ide#141 (comment 1367835573) if I wanted to.

Edited Jan 18, 2026 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading