Skip to content

fix(muya): make autolinks and bare URLs followable on Cmd/Ctrl-click - #4763

Merged
Jocs merged 1 commit into
developfrom
fix/2165-clickable-autolinks
Jun 27, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/2165-clickable-autolinks

Conversation

@Jocs

@Jocs Jocs commented Jun 27, 2026

Copy link
Copy Markdown
Member

Summary

CommonMark autolinks (<https://example.com>) and GFM bare-URL autolinks (https://example.com) rendered as anchors but could not be followed — Cmd/Ctrl-clicking them did nothing, while regular [text](url) links opened.

Root cause (two gaps):

  1. linkMouseEvents.ts's LINK_SELECTOR only listed span.mu-link, a.mu-reference-link, a.mu-raw-html — not a.mu-auto-link / a.mu-auto-link-extension, so findLinkWrapper() returned null for autolinks.
  2. The autoLink.ts / autoLinkExtension.ts renderers never set data-raw, so even with the selector fixed getLinkInfo() would return null and abort.

Fix

  • Set data-{start,end,raw} on both autolink <a> vnodes (mirroring link.ts).
  • Add the two autolink classes to LINK_SELECTOR.
  • Keep autolinks follow-only: isPopoverTarget() returns false for them, so the edit/unlink hover popover doesn't appear (there's no [](…) source to rewrite, and the URL re-autolinks on the next render). The existing modifier-click → format-click contract the desktop shell already consumes is unchanged.

Test

New clickableAutolink.spec.ts boots a real engine and drives the actual click path (renderer → DOM → attachLinkMouseHandlers → event):

  • <https://example.com> renders a.mu-auto-link with data-raw + href; Ctrl-click emits format-click with the href.
  • bare https://example.com renders a.mu-auto-link-extension; Ctrl-click follows it.
  • a plain (non-modifier) click does not emit.
  • hovering an autolink does not open the edit/unlink popover.

Full unit suite (1359) and the CommonMark/GFM conformance lock (1347) pass; existing link hover/click tests (43) unaffected.

Fixes #2165

CommonMark autolinks (`<https://x.com>`) and GFM bare-URL autolinks render as
`a.mu-auto-link` / `a.mu-auto-link-extension`, but those classes were missing
from linkMouseEvents' LINK_SELECTOR and the renderers never set `data-raw`, so
`getLinkInfo` returned null and a modifier-click never emitted `format-click` —
the link could not be opened. Set `data-{start,end,raw}` on both autolink
anchors and add their classes to the selector. They stay follow-only: the
edit/unlink hover popover is suppressed for autolinks (there is no `[](…)`
source to rewrite, and the URL re-autolinks on the next render).

Fixes #2165

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Jocs
Jocs merged commit fc3699d into develop Jun 27, 2026
7 checks passed
@Jocs
Jocs deleted the fix/2165-clickable-autolinks branch June 27, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make it easy to follow a link

1 participant