Repository navigation
Description
Part of #769. Decision first; code only if the ruling changes today's behaviour. Found while fixing #770.
Summary
Pressing Enter inside a link splits it into two paragraphs. Today the first half loses its link, and the second half keeps a link to the old target. Upstream @tiptap/extension-link keeps both halves linked. Neither is clearly right, so the maintainer rules.
Reproduce
Content <p><a href="https://example.com">example.com</a></p>, caret after exam, press Enter.
| Behaviour | Result |
|---|---|
| Today (and with the #770 fix) | <p>exam</p><p><a href="https://example.com">ple.com</a></p> |
Upstream @tiptap/extension-link 3.32.2 |
both exam and ple.com linked to https://example.com |
Why today's result: the strip pass sees the text change (the '\n' between blocks makes a split count as a change). exam alone is not a URL, so it loses the link. ple.com alone is a URL, so it keeps its link to https://example.com.
Decision needed (maintainer)
Ruling 2 of the review:
- A (recommended). Keep today's behaviour. It is rare, and the Hyperlink: keep the whole link when part of it is formatted #770 fix already keeps it. Close this issue with the ruling.
- B. Match upstream: keep both halves linked to the old target.
- C. Remove the link from both halves when neither half is the old URL.
Fix (only for B or C)
The strip pass in extensions/extension-hyperlink/src/interactions/autolink.ts (lines 43-73). For B, treat a block split of one link as a mark-preserving change. For C, compare each half with the old href, not with detect.
Benchmark
| Field | Value |
|---|---|
| Metric | A new behaviour case enter inside a link in scripts/bench/behaviour.ts, with the ruled result as "want". |
| Before | Today's result above. |
| After | not measured yet |
| Confounds | #770, #772. |
| Condition | jsdom on Bun. |
| How to run | NODE_ENV=production bun scripts/bench/run.ts |
| Pass rule | The case passes; every other case still passes. |
| Guard | Undo of the Enter restores one whole link in one step. |
| Owner | Maintainer: the ruling. Agent in the repo: the case, and code for B or C. |
| Claim | None. |
Acceptance checks
- The ruling recorded in this issue.
- The behaviour case added with the ruled result (even for A, to pin it).
- For B or C: unit tests with sabotage proof, the full package Cypress suite, a pad check.
Activity
HMarzban commentedon Nov 12, 2026
Ruling 2 evidence (2026-11-12)
Condition: jsdom 26.1.0, Bun 1.4.4, Tiptap core and StarterKit 3.32.2. Upstream is
@tiptap/extension-link3.32.2. Enter goes throughhandleKeyDown. Results are deterministic, n = 1 per case, and a verifier re-ran them byte-identical.¶marks a new paragraph, and[text]is a linked run.example.com, 3ex ¶ [ample.com][ex] ¶ [ample.com]ex ¶ ample.comex ¶ ample.comexample.com, 5exam ¶ [ple.com][exam] ¶ [ple.com]exam ¶ ple.comexam ¶ ple.comexample.com, 8example ¶ [.com][example] ¶ [.com]example ¶ .comexample ¶ .comexample.com, 10example.c ¶ [om][example.c] ¶ [om]example.c ¶ omexample.c ¶ omclick here, 3/5/8/10example.com→https://other.example/x, 3/5/8/10exam ¶ [ple.com])*C-urlonly is not one of the listed options. It applies C only when the old link text is a URL.
Findings.
ple.com→https://example.com) in 6 of 20 cases. B also links non-URL pieces such as[ex]and[example.c]to the old target. C dropsclick herelabels in 4 of 4. Every C reading drops a custom href in 4 of 4..com(pos 8) andom(pos 10) stay linked although neither is a URL. So the reason in this issue's body is not accurate.autolink.ts:54, and it equals upstream on every case.Recommendation: B. It never removes a link the user made, it does not depend on the caret position, and it matches upstream. Its cost: both halves point at the old target, even pieces such as
[ex]. Today has the same mismatch on one half. Shipped code for any C reading must use ungateddetect, not gatedforWrite.Not run: Cypress, a pad check, Yjs undo.
Raw data (
<wf3>= the maintainer's local workflow folderwf3/, kept outside the repo):<wf3>/e2-enter-in-link/matrix.tsvand the verifier'sverify-e2/. Re-run:cd <wf3>/e2-enter-in-link && POS=1,3,5,8,10 bun harness.ts <today|upstream|B|C> out.json, withC_URL_ONLY=1orC_LITERAL=1for the C readings.HMarzban commentedon Nov 13, 2026
Ruled: option B (maintainer, 2026-11-13)
Enter inside a link keeps both halves linked to the old target, as upstream
@tiptap/extension-link3.32.2 does. It never removes a link the user made, and it is the same at every caret position.Accepted cost: a half that is not a URL on its own (for example
exam) stays linked to the old target. Today one half already has this mismatch.Pin the result with a unit test, and add an
enter inside a linkcase toscripts/bench/behaviour.ts. One undo after the Enter must still restore one whole link.HMarzban commentedon Nov 13, 2026
Built: option B (2026-11-13). Not committed yet.
Enter inside a link now keeps both halves linked to the old target, as in
@tiptap/extension-link3.32.2. The strip pass inautolink.tsno longer adds a block separator when it compares the text. So a block split counts as the same text.Unit tests. There are 20 new cases in
autolink.test.ts.example.com, aclick herelabel, a link with a bold part, and a custom href.Live check (y-undo).
example.com, then press Enter afterexam. Result:[exam] ¶ [ple.com], both linked tohttps://example.com.Bench.
dist/index.js.Accepted cost. A half that is not a URL on its own keeps the old href.
Not run: iOS Safari, Android Chrome, two peers, Enter in a list item, and the
see example.comprefix case.feat(extension-hyperlink): add HyperlinkBase and ruled autolink fixes
perf(webapp): load HyperlinkBase in the pad and composer
HMarzban commentedon Nov 16, 2026
Production check, 2026-11-16. docs.plus at
b7888dce1(deployed 2026-11-15). Chrome on macOS, signed in. One scratch pad, never/demo. Each result was read from the editor DOM after the action. n = 1.visit example.org, put the caret afterexam, press Enterexamandple.org, both linked tohttps://example.orgexample.orgAll three acceptance checks are met: the ruling (option B), the behaviour case (0/1 to 1/1), and 20 unit cases with sabotage proof (12 of 20 fail on the old line). The fix is
f52630eed, live since3d90636a9(2026-11-13) and still inb7888dce1. Release credit v2.3.8. Closing as done.