Skip to content

Add viewer controller for mermaid (zoom, drag)#36557

Merged
silverwind merged 38 commits intogo-gitea:mainfrom
wxiaoguang:support-mermaid-zoom
Feb 10, 2026
Merged

Add viewer controller for mermaid (zoom, drag)#36557
silverwind merged 38 commits intogo-gitea:mainfrom
wxiaoguang:support-mermaid-zoom

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang commented Feb 8, 2026

Fix #25803

Now the rendered mermaid chart can be dragged or zoomed.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 8, 2026
@wxiaoguang
Copy link
Copy Markdown
Contributor Author

wxiaoguang commented Feb 8, 2026

I didn't spend time on the "button styles". Feel free to make more changes if you'd like to.


image
image

@wxiaoguang wxiaoguang force-pushed the support-mermaid-zoom branch from da7e750 to 015c250 Compare February 8, 2026 10:51
@wxiaoguang wxiaoguang requested a review from Copilot February 8, 2026 10:51
@wxiaoguang wxiaoguang added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 8, 2026
@wxiaoguang wxiaoguang added this to the 1.26.0 milestone Feb 8, 2026

This comment was marked as resolved.

@wxiaoguang wxiaoguang force-pushed the support-mermaid-zoom branch from 015c250 to 5e15e69 Compare February 8, 2026 10:59
@silverwind
Copy link
Copy Markdown
Member

yes these buttons definitely need styling, same style as copy button. and gap between.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 8, 2026
silverwind and others added 3 commits February 10, 2026 04:21
…hover

- Style iframe view-controller buttons to match `.ui.button` by reading
  parent page CSS variables and injecting them into the iframe CSS
- Show buttons only on hover with fade transition, always visible on
  mobile via `@media (hover: none)`
- Add `--transition-fade` CSS variable and use it for both code-copy
  and mermaid view-controller buttons
- Convert code-copy from animation to transition for consistency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: silverwind <me@silverwind.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member

silverwind commented Feb 10, 2026

Button CSS fixed:

Screenshot 2026-02-10 at 04 28 00 Screenshot 2026-02-10 at 04 27 45

silverwind and others added 2 commits February 10, 2026 04:31
Add hover-to-show for mermaid code-copy button and always show all
code-copy buttons on touch devices via @media (hover: none).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member

silverwind commented Feb 10, 2026

One related fix that also affects the copy button: Using @media (hover: none) we detect whether the device supports no hover states (touch devices), which then causes the buttons to always show, this goes for both the copy button and the zoom/reset buttons.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 10, 2026
@silverwind
Copy link
Copy Markdown
Member

silverwind commented Feb 10, 2026

One last topic: I'd like to remove the new css variable in favor of re-using the existing fadeout and fadein keyframe-based animations, checking if it's possible.

@silverwind silverwind self-requested a review February 10, 2026 03:39
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Feb 10, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member

ok think I'm done here now, changes are minimal.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 10, 2026
@silverwind
Copy link
Copy Markdown
Member

silverwind commented Feb 10, 2026

One minor issue but I don't think it would block the merge. On very small diagrams the buttons overlap. Maybe it needs a minimum height:

image

Source code:

```mermaid
flowchart LR
TEST{{"`**Rendering problem**`"}}
```

@silverwind
Copy link
Copy Markdown
Member

Small alignment fix pushed so that the buttons align on right side:

image

@wxiaoguang
Copy link
Copy Markdown
Contributor Author

Feel free to merge if it looks good to you

@silverwind
Copy link
Copy Markdown
Member

One more thing I noticed: when the copy button is hovered, the view-controller hides. It seems tricky to solve, likely requires the view-controller to be moved outside the iframe.

@silverwind
Copy link
Copy Markdown
Member

One more thing I noticed: when the copy button is hovered, the view-controller hides. It seems tricky to solve, likely requires the view-controller to be moved outside the iframe.

Merging now, this is not worth the effort it would take imho.

@silverwind silverwind enabled auto-merge (squash) February 10, 2026 06:33
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 10, 2026
@silverwind
Copy link
Copy Markdown
Member

For reference, here is how the min height looks now:

Screenshot 2026-02-10 at 07 34 13

@silverwind silverwind merged commit 5e57036 into go-gitea:main Feb 10, 2026
24 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 10, 2026
@wxiaoguang wxiaoguang deleted the support-mermaid-zoom branch February 10, 2026 06:48
@wxiaoguang
Copy link
Copy Markdown
Contributor Author

One more thing I noticed: when the copy button is hovered, the view-controller hides. It seems tricky to solve, likely requires the view-controller to be moved outside the iframe.

Fix markup code block layout #36578

silverwind added a commit to silverwind/gitea that referenced this pull request Feb 12, 2026
* origin/main: (34 commits)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  Fix mirror sync parser and fix mirror messages (go-gitea#36504)
  Update JS and PY deps (go-gitea#36576)
  Add viewer controller for mermaid (zoom, drag) (go-gitea#36557)
  Misc typescript tweaks (go-gitea#36523)
  Use full-file highlighting for diff sections (go-gitea#36561)
  fix(diff): reprocess htmx content after loading more files (go-gitea#36568)
  [skip ci] Updated translations via Crowdin
  Add wrap to runner label list (go-gitea#36565)
  fix: add dnf5 command for Fedora in RPM package instructions (go-gitea#36527)
  Enable pagination on GiteaDownloader.getIssueReactions() (go-gitea#36549)
  Refactor merge conan and container auth preserve actions taskID (go-gitea#36560)
  Fix assignee sidebar links and empty placeholder after go-gitea#32465 refactor (go-gitea#36559)
  Fix various version parsing problems (go-gitea#36553)
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 12, 2026
* origin/main: (152 commits)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  Fix mirror sync parser and fix mirror messages (go-gitea#36504)
  Update JS and PY deps (go-gitea#36576)
  Add viewer controller for mermaid (zoom, drag) (go-gitea#36557)
  Misc typescript tweaks (go-gitea#36523)
  Use full-file highlighting for diff sections (go-gitea#36561)
  fix(diff): reprocess htmx content after loading more files (go-gitea#36568)
  [skip ci] Updated translations via Crowdin
  Add wrap to runner label list (go-gitea#36565)
  fix: add dnf5 command for Fedora in RPM package instructions (go-gitea#36527)
  Enable pagination on GiteaDownloader.getIssueReactions() (go-gitea#36549)
  Refactor merge conan and container auth preserve actions taskID (go-gitea#36560)
  Fix assignee sidebar links and empty placeholder after go-gitea#32465 refactor (go-gitea#36559)
  Fix various version parsing problems (go-gitea#36553)
  ...
Sirherobrine23 pushed a commit to Sirherobrine23/gitea that referenced this pull request Mar 4, 2026
Fix go-gitea#25803

Now the rendered mermaid chart can be dragged or zoomed.

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zoom function for mermaid

5 participants