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 <[email protected]>
  • Loading branch information
mejo- committed Oct 30, 2024
1 parent ed138a8 commit 4cd57d6
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 @@ -158,6 +158,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 4cd57d6

Please sign in to comment.