Repository navigation
fix(muya): make autolinks and bare URLs followable on Cmd/Ctrl-click - #4763
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
linkMouseEvents.ts'sLINK_SELECTORonly listedspan.mu-link,a.mu-reference-link,a.mu-raw-html— nota.mu-auto-link/a.mu-auto-link-extension, sofindLinkWrapper()returned null for autolinks.autoLink.ts/autoLinkExtension.tsrenderers never setdata-raw, so even with the selector fixedgetLinkInfo()would return null and abort.Fix
data-{start,end,raw}on both autolink<a>vnodes (mirroringlink.ts).LINK_SELECTOR.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-clickcontract the desktop shell already consumes is unchanged.Test
New
clickableAutolink.spec.tsboots a real engine and drives the actual click path (renderer → DOM →attachLinkMouseHandlers→ event):<https://example.com>rendersa.mu-auto-linkwithdata-raw+ href; Ctrl-click emitsformat-clickwith the href.https://example.comrendersa.mu-auto-link-extension; Ctrl-click follows it.Full unit suite (1359) and the CommonMark/GFM conformance lock (1347) pass; existing link hover/click tests (43) unaffected.
Fixes #2165