(e: MouseEvent)
| 563 | const root = ref.current; |
| 564 | if (!root) return; |
| 565 | const onClick = (e: MouseEvent): void => { |
| 566 | const target = e.target as HTMLElement; |
| 567 | const copyButton = target.closest<HTMLButtonElement>( |
| 568 | CODE_COPY_BUTTON_SELECTOR, |
| 569 | ); |
| 570 | if (copyButton) { |
| 571 | e.preventDefault(); |
| 572 | e.stopPropagation(); |
| 573 | copyCodeBlockToClipboard(copyButton); |
| 574 | return; |
| 575 | } |
| 576 | const foldButton = target.closest<HTMLButtonElement>( |
| 577 | CODE_FOLD_BUTTON_SELECTOR, |
| 578 | ); |
| 579 | if (foldButton) { |
| 580 | e.preventDefault(); |
| 581 | e.stopPropagation(); |
| 582 | toggleCodeBlockFold(foldButton); |
| 583 | return; |
| 584 | } |
| 585 | |
| 586 | const expandButton = target.closest( |
| 587 | ".zen-diagram-expand", |
| 588 | ) as HTMLButtonElement | null; |
| 589 | if (expandButton) { |
| 590 | e.preventDefault(); |
| 591 | const host = expandButton.closest<HTMLElement>( |
| 592 | "[data-zen-diagram-kind][data-zen-diagram-source]", |
| 593 | ); |
| 594 | const kind = host?.dataset.zenDiagramKind as |
| 595 | | ExpandedDiagramKind |
| 596 | | undefined; |
| 597 | const source = host?.dataset.zenDiagramSource; |
| 598 | if (host && kind && source) setExpandedDiagram({ kind, source }); |
| 599 | return; |
| 600 | } |
| 601 | const anchor = target.closest("a") as HTMLAnchorElement | null; |
| 602 | if (!anchor) return; |
| 603 | if (anchor.classList.contains("wikilink")) { |
| 604 | e.preventDefault(); |
| 605 | const path = anchor.dataset.resolvedPath; |
| 606 | if (path) { |
| 607 | // Scroll to the #heading when the link carries one. (#196) |
| 608 | const headingAnchor = wikilinkHeadingAnchor(anchor.dataset.wikilink ?? ""); |
| 609 | if (headingAnchor) void openWikilinkHeading(path, headingAnchor); |
| 610 | else void selectNoteRef.current(path); |
| 611 | } else if (anchor.dataset.databaseCsv) { |
| 612 | void useStore.getState().openDatabase(anchor.dataset.databaseCsv); |
| 613 | } |
| 614 | return; |
| 615 | } |
| 616 | if (anchor.classList.contains("hashtag")) { |
| 617 | e.preventDefault(); |
| 618 | const tag = anchor.getAttribute("data-tag"); |
| 619 | if (tag) void useStore.getState().openTagView(tag); |
| 620 | return; |
| 621 | } |
| 622 | // A standard Markdown link to another note — `[text](path/to/Note.md)` — |
no test coverage detected