Repository navigation
Description
Part of #769. Depends on #774: without PURE annotations the saving is 0.
Summary
Hosts that draw their own link popovers still ship the three prebuilt forms (preview, edit, create). The docs.plus pad and chat composer pass all three slots (apps/webapp/.../getHyperlinkPopoverConfig.ts), so that code is dead in the webapp. This issue adds HyperlinkBase, the same mark without the prebuilt forms. Hyperlink stays as it is and keeps its fallback. It is the only byte cut from the review that reaches the docs.plus webapp.
Review numbers (2026-11-12, prototype on top of PURE sites 1-2; this issue takes its own before and after)
| Row | Hyperlink today |
With HyperlinkBase |
|---|---|---|
| The webapp-like app pays (min / gzip) | 54,947 / 19,144 B | −6,108 / −1,809 B |
| A StarterKit app pays | 70,854 / 25,213 B | −6,710 / −2,018 B |
The full Hyperlink after the change |
— | +285 / +87 B in a StarterKit app (the fallback moves into storage) |
Why the first prototype was wrong
Tiptap configure deep-merges options. A prototype that put the prebuilt factories into option defaults broke two promises:
- README lines 25 and 94, and
docs/api.mdlines 151 and 199, say an opener uses the prebuilt form when its popover slot isnull. - It also broke the no-options case: the click gate (
src/interactions/createLinkContext.ts:35,src/interactions/clickHandler.ts:61) andopenPreviewAtSelection.ts:30read the option slots, so a link click andMod-kinside a link opened a preview where 2.3.0 does not. - In a 24-cell matrix (4 configs × 6 actions), it differed from 2.3.0 in 8 cells.
Fix (the shippable shape; 24 of 24 cells match 2.3.0 in the review)
export const HyperlinkBase = /* @__PURE__ */ Mark.create(...), with the option defaults stillnull.export const Hyperlink = /* @__PURE__ */ HyperlinkBase.extend({ addStorage() { return { ...this.parent!(), prebuiltPopovers: { previewHyperlink, editHyperlink, createHyperlink } } } }).- Add optional
prebuiltPopoverstoHyperlinkStorage. - Add
getPrebuiltPopovers(editor)insrc/openers/getHyperlinkOptions.ts. It readseditor.storage.hyperlink?.prebuiltPopovers ?? {}. openPreviewHyperlink.ts:15,openEditHyperlink.ts:19andopenCreateHyperlink.ts:22usepopovers.x ?? getPrebuiltPopovers(editor).x, and drop their direct popover imports.- Never put the factories into option defaults.
- Docs: README lines 25 and 94;
docs/api.mdlines 16, 151 and 199; the JSDoc atsrc/commands/surface.ts:28. Each says the fallback belongs to the fullHyperlinkonly. Add one README paragraph: chooseHyperlinkBasewhen you pass your own popovers; chooseHyperlinkotherwise. - Webapp switch (
TipTap.tsx:230,useTiptapEditor.ts:180) in a separate commit after the extension release.
Residual risk: an addStorage override that rebuilds the storage without this.parent() loses the fallback. Name it in the CHANGELOG.
Benchmark
| Field | Value |
|---|---|
| Metric | Package bench byte rows with the app importing HyperlinkBase; the webapp's own route table after the switch. |
| Before | Take it after #774 lands. Post it as a Measured comment. |
| After | not measured yet |
| Confounds | #774, #776. |
| Condition | esbuild minify, ESM, browser, Bun zlib level 9, exact. Webapp: build:ci route table. |
| How to run | Package bench; extend bytes.ts with a HyperlinkBase app case. Webapp: build:ci. |
| Pass rule | The webapp-like case drops at least 1,500 B gzip; the full Hyperlink costs at most +120 B gzip. |
| Guard | The UX contract below. |
| Owner | Agent in the repo: code, tests, docs, bench. Maintainer: the release, and the phone checks after the webapp switch. |
| Claim | "Hosts with their own link forms ship about 1.8 kB gzip less." |
UX contract
- A jsdom matrix for
HyperlinkandHyperlinkBase. Configs: no options,configure({}), all slotsnull, the README Quickstart. Actions: click a link,Mod-koutside and inside a link (real keydown), each opener.Hyperlinkmatches 2.3.0 in all 24 cells. -
HyperlinkBasewithnullslots opens nothing, and the openers returnfalse. The Quickstart opens everything. - Before the webapp switch, list every opener call and slot the webapp fills: toolbar,
Mod-k, link click, hovercard edit, chat composer, phone docked controls. - After the switch, on desktop and in mobile emulation: create, preview and edit open as before. On iOS emulation, the first
Mod-k(or the toolbar link button) opens the create form and the keyboard in the same tap. -
dist/index.d.tsdiff shows additions only.
Acceptance checks
- One fallback test each in
src/openers/__tests__/openPreviewHyperlink.test.ts,openEditHyperlink.test.tsandopenCreateHyperlink.test.ts, for both marks. Sabotage proof. -
bun run test:unit, typecheck, the full package Cypress suite. - README Quickstart (
examples/vanilla) runs unchanged;scripts/extension-preflight.shpasses. - CHANGELOG
Addedline (minor version).
Out of scope
- Removing the fallback from
Hyperlink(a major). - Feature factories for hovercard, pasteTitle and linkIcon (deferred to the product 3.0 major).
Activity
HMarzban commentedon Nov 12, 2026
Bytes on top of #774 (2026-11-12, scratch prototype)
Same build setup as the #774 comment. StarterKit app, min / gzip B:
Raw data (
<wf3>= the maintainer's local workflow folderwf3/, kept outside the repo):<wf3>/v-e4-pure-build/results/bytes-AhmmOn-s5c-s5cbase-BaseS5b.json(s5b rows) ande4-pure-build/results/bytes-*.json(without #774). Re-run:cd <wf3>/v-e4-pure-build && NODE_ENV=production bun build.ts BaseS5b && bun bytes.ts BaseS5b.HMarzban commentedon Nov 13, 2026
Built (2026-11-13). Not committed yet. The webapp is not switched.
Shape.
createHyperlinkMark(prebuilt), builds both marks.HyperlinkBase = createHyperlinkMark({}).Hyperlink = createHyperlinkMark({ preview, edit, create }).storage.prebuiltPopovers, an optional field, so an existingaddStorageoverride still type-checks.can()resolve a slot through one helper: the configured slot, else the prebuilt form.Behaviour.
Hyperlink, nothing changes. Openers fall back to the prebuilt forms, andeditor.can().openCreateHyperlinkPopover()staystrue. A 24-cell matrix matched the@docs.plus/[email protected]source.HyperlinkBasewith empty slots, nothing opens.openPreviewHyperlinkandopenCreateHyperlinkreturnfalse, andcan()returnsfalse.openEditHyperlinkstill returnsvoid, soindex.d.tsgains only additions.Mod-koutside a link is left to the browser. The README says so.extendwhoseaddStorageskipsthis.parent()loses the fallback. The CHANGELOG says so.Bytes.
Hyperlink,configure({})Hyperlink, three own slotsHyperlinkBase,configure({})HyperlinkBase, three own slotsHyperlinkBasewith three slots, againstHyperlinkwith three slots before, must save at least 1,500 B gzip. It saves 6,623 B minified and 1,982 B gzip: pass.Hyperlinkmay cost at most +120 B gzip. It costs +250 / +90 B, and +250 / +71 B with three slots: pass.Tests and gates.
can().can()check makes it fail.Still owed.
docs/popovers.md:94. It still says every opener falls back.HMarzban commentedon Nov 13, 2026
Webapp switched to
HyperlinkBase(2026-11-13, not committed yet)The pad (
TipTap.tsx) and the chat composer (useTiptapEditor.ts) now loadHyperlinkBase. Every option is unchanged.Slot audit.
getHyperlinkPopoverConfigandgetHyperlinkPopoverConfigAtInvokereturn three non-null slots on every branch: pad desktop, pad mobile and composer mobile. History and/editorget the samepopovers. Click andMod-kread the slot directly. No path relies on the prebuilt fallback, so nothing changes at runtime.Route table, local
build:ci(Next 15.5.28, n = 1, exact kB; the only difference between the two builds is the switch):/first load/[...slugs]first load_appfirst loadThe after build holds none of the prebuilt form strings ("Please enter link text", the
hyperlink-*-popoverclasses).Browser checks.
next dev: all 8editor/hyperlink/*specs,document/hyperlink-icon-prefill,editor/slash/slash-menuandchatroom/composer-link-keys: 89 of 89 pass. The chat spec needs--config baseUrl=http://localhost:3001.The webapp CHANGELOG lists the switch under
[Unreleased].feat(extension-hyperlink): add HyperlinkBase and ruled autolink fixes
perf(webapp): load HyperlinkBase in the pad and composer
HMarzban commentedon Nov 16, 2026
iOS check, 2026-11-16: not valid; a real iPhone is still owed.
iPhone 18 Pro(iOS 27.0), Safari, signed out, a production scratch pad atb7888dce1. The pad loaded, and the pencil opened edit mode with the keyboard and the mobile toolbar.HMarzban commentedon Nov 16, 2026
iOS check, 2026-11-16: pass.
iPhone 18 Pro(iOS 27.0), Safari, signed out, production pad atb7888dce1..comkey).The change is
f52630eedand13cd8ab27, live since3d90636a9. Release credit v2.3.8. Closing as done.