|
5 | 5 | All notable changes to `@docs.plus/extension-hyperlink` are documented here. |
6 | 6 | This project follows [Semantic Versioning](https://semver.org/) and [Conventional Commits](https://conventionalcommits.org). Section headings (`Added` / `Changed` / `Fixed` / `Security`) intentionally repeat per version, per the [Keep a Changelog](https://keepachangelog.com/) convention. |
7 | 7 |
|
| 8 | +--- |
| 9 | + |
| 10 | +## Migrating from v1.x to v4.x |
| 11 | + |
| 12 | +The last npm-published v1 release was `1.5.2`. Versions `2.x` and `3.x` were internal monorepo refactors and were never published. If you are upgrading from `^1.5.2` directly to `4.x`, the API has been substantially redesigned. This section is the short, actionable diff; the full per-version detail lives under [4.0.0](#400--2026-04-15) (renames + popover contract), [4.1.0](#410--2026-04-15) (XSS hardening + bug fixes), [4.2.0](#420--2026-04-15) (stylesheet + clean-room test harness), and [4.3.0](#430--2026-04-16) (unified href canonicalization). |
| 13 | + |
| 14 | +### What changed at a glance |
| 15 | + |
| 16 | +- **Options renamed** to align with Tiptap conventions |
| 17 | + (`autoHyperlink` → `autolink`, `hyperlinkOnPaste` → `linkOnPaste`). |
| 18 | +- **Commands renamed** with consistent casing |
| 19 | + (`editHyperLinkText` → `editHyperlinkText`, `editHyperLinkHref` → `editHyperlinkHref`). |
| 20 | +- **CSS classes renamed** from camelCase to kebab-case |
| 21 | + (`.hyperlinkCreatePopover` → `.hyperlink-create-popover`, …). |
| 22 | +- **Default stylesheet ships separately** — `import '@docs.plus/extension-hyperlink/styles.css'`. |
| 23 | + v1 inlined CSS via JS; v4 ships a small opt-in CSS file so fully-custom UIs pay zero cost. |
| 24 | +- **Popover contract changed** — `createHyperlink` callback now returns |
| 25 | + `HTMLElement | null` (was `void`); the extension owns positioning, you own content. |
| 26 | +- **Meta key renamed** — `tr.setMeta('preventAutoHyperlink', …)` → `tr.setMeta('preventAutolink', …)`. |
| 27 | +- **Type augmentation fixed** — commands are augmented under `hyperlink:` (was `link:`). |
| 28 | +- **Hardened XSS guards** — `javascript:`, `data:`, and `vbscript:` are now blocked |
| 29 | + at every entry point (parse, paste, input rule, click, popover open). If you |
| 30 | + intentionally stored such URLs, they will now be rejected. |
| 31 | +- **Plausible-host validation** — `validateURL` now rejects typo URLs like |
| 32 | + `https://googlecom` (no TLD dot, not localhost, not an IP literal). |
| 33 | + |
| 34 | +### Code diff |
| 35 | + |
| 36 | +```diff |
| 37 | + Hyperlink.configure({ |
| 38 | +- autoHyperlink: true, |
| 39 | +- hyperlinkOnPaste: true, |
| 40 | ++ autolink: true, |
| 41 | ++ linkOnPaste: true, |
| 42 | + popovers: { |
| 43 | + previewHyperlink: myPreviewFn, |
| 44 | +- createHyperlink: myCreateFn, // was (options) => void |
| 45 | ++ createHyperlink: myCreateFn, // now (options) => HTMLElement | null |
| 46 | + } |
| 47 | + }) |
| 48 | + |
| 49 | + // Commands |
| 50 | +-editor.commands.editHyperLinkText('New Text') |
| 51 | +-editor.commands.editHyperLinkHref('https://example.com') |
| 52 | ++editor.commands.editHyperlinkText('New Text') |
| 53 | ++editor.commands.editHyperlinkHref('https://example.com') |
| 54 | + |
| 55 | + // Meta key in transactions |
| 56 | +-tr.setMeta('preventAutoHyperlink', true) |
| 57 | ++tr.setMeta('preventAutolink', true) |
| 58 | +``` |
| 59 | + |
| 60 | +```css |
| 61 | +/* CSS selectors */ |
| 62 | +- .hyperlinkCreatePopover { … } |
| 63 | +- .hyperlinkPreviewPopover { … } |
| 64 | +- .hyperlinkEditPopover { … } |
| 65 | +- .buttonsWrapper { … } |
| 66 | +- .inputsWrapper { … } |
| 67 | +- .textWrapper { … } |
| 68 | +- .hrefWrapper { … } |
| 69 | +- .backButton { … } |
| 70 | +- .btn_applyModal { … } |
| 71 | ++ .hyperlink-create-popover { … } |
| 72 | ++ .hyperlink-preview-popover { … } |
| 73 | ++ .hyperlink-edit-popover { … } |
| 74 | ++ .buttons-wrapper { … } |
| 75 | ++ .inputs-wrapper { … } |
| 76 | ++ .text-wrapper { … } |
| 77 | ++ .href-wrapper { … } |
| 78 | ++ .back-button { … } |
| 79 | ++ .apply-button { … } |
| 80 | +``` |
| 81 | + |
| 82 | +```ts |
| 83 | +// Popover types — no more hand-rolled types |
| 84 | +import type { |
| 85 | + PreviewHyperlinkOptions, |
| 86 | + CreateHyperlinkOptions |
| 87 | +} from '@docs.plus/extension-hyperlink' |
| 88 | +``` |
| 89 | + |
| 90 | +### One-shot rename script |
| 91 | + |
| 92 | +For the rename-only changes, run this in your project root and commit the diff: |
| 93 | + |
| 94 | +```bash |
| 95 | +rg -l "autoHyperlink|hyperlinkOnPaste|editHyperLinkText|editHyperLinkHref|preventAutoHyperlink|hyperlinkCreatePopover|hyperlinkPreviewPopover|hyperlinkEditPopover|buttonsWrapper|inputsWrapper|textWrapper|hrefWrapper|backButton|btn_applyModal" \ |
| 96 | + | xargs sed -i.bak \ |
| 97 | + -e 's/autoHyperlink/autolink/g' \ |
| 98 | + -e 's/hyperlinkOnPaste/linkOnPaste/g' \ |
| 99 | + -e 's/editHyperLinkText/editHyperlinkText/g' \ |
| 100 | + -e 's/editHyperLinkHref/editHyperlinkHref/g' \ |
| 101 | + -e 's/preventAutoHyperlink/preventAutolink/g' \ |
| 102 | + -e 's/hyperlinkCreatePopover/hyperlink-create-popover/g' \ |
| 103 | + -e 's/hyperlinkPreviewPopover/hyperlink-preview-popover/g' \ |
| 104 | + -e 's/hyperlinkEditPopover/hyperlink-edit-popover/g' \ |
| 105 | + -e 's/buttonsWrapper/buttons-wrapper/g' \ |
| 106 | + -e 's/inputsWrapper/inputs-wrapper/g' \ |
| 107 | + -e 's/textWrapper/text-wrapper/g' \ |
| 108 | + -e 's/hrefWrapper/href-wrapper/g' \ |
| 109 | + -e 's/backButton/back-button/g' \ |
| 110 | + -e 's/btn_applyModal/apply-button/g' |
| 111 | +``` |
| 112 | + |
| 113 | +The rename script handles the mechanical changes. The semantic changes that |
| 114 | +require code review — popover contract returning `HTMLElement | null`, the |
| 115 | +new `styles.css` import, and the stricter URL validation — are not safely |
| 116 | +automatable. Read the [4.0.0](#400--2026-04-15) and [4.1.0](#410--2026-04-15) |
| 117 | +sections to confirm those before shipping the upgrade. |
| 118 | + |
| 119 | +### Need help? |
| 120 | + |
| 121 | +Open an issue at <https://github.com/docs-plus/docs.plus/issues> with the |
| 122 | +label `extension-hyperlink` + `migration` and a snippet of the v1 config |
| 123 | +you're upgrading from. |
| 124 | + |
| 125 | +--- |
| 126 | + |
8 | 127 | ## [4.3.0] — 2026-04-16 |
9 | 128 |
|
10 | 129 | ### Added |
|
0 commit comments