Skip to content

Commit

Permalink
fix(mermaid): No custom link handling for links in mermaid diagrams
Browse files Browse the repository at this point in the history
This fixes clicking links in mermaid diagrams in Collectives. See the
issue that gets fixed by this for a reproducer.

Fixes: nextcloud/collectives#1135

Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Nov 4, 2024
1 parent eab9cb2 commit 7d380a8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/plugins/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ export function linkClicking() {
click: (view, event) => {
const linkEl = event.target.closest('a')
if (event.button === 0 && linkEl) {
// No special handling in mermaid diagrams to not break links there
if (linkEl.closest('svg[id^="mermaid-view"]')) {
return false
}

event.preventDefault()
if (isLinkToSelfWithHash(linkEl.attributes.href?.value)) {
// Open anchor links directly
Expand Down

0 comments on commit 7d380a8

Please sign in to comment.