Releases
Every release is published to npm with provenance, and each GitHub release holds the exact tarball with its Sigstore attestation. Versions follow semantic versioning.
1.31.3
Section titled “1.31.3”Released November 20, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”-
Long numbered lists no longer freeze the page. The plain text written alongside rich HTML (by
pasteToRich,prepareRichandreact-smart-copy/compat) found each numbered item’s place by scanning its whole list again, so a list of n items cost n²: an 8,000-item Word list took 7 seconds in Chrome, and 20,000 items over three minutes in tests. Each list is now numbered once, in linear time (116 ms for those 8,000 items).The numbers are also the ones a browser shows, checked against Chromium: an item after
<li value="9">is 10 (it was counted from the list’s start),<ol reversed>counts down, and astartorvaluethat is not a number is ignored, where it wrote “NaN.”.
1.31.2
Section titled “1.31.2”Released November 13, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Releases are now published from GitHub Actions through npm trusted publishing, so no long-lived npm token is stored anywhere and every version carries provenance tied to this repository and its release workflow. The package code is unchanged.
1.31.1
Section titled “1.31.1”Released November 11, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- A URL in text becomes a Markdown autolink only when its host is letters, digits, hyphens and dots, as real hosts are. A host such as
x.y=is valid to the URL standard, but renderers read it differently: markdown-it linked<http://x.y=:1>tohttp://x.y:1=, so the link went somewhere other than its text. Such URLs are now kept as text, as other unusual addresses already were. Found by the randomized round-trip tests.
1.31.0
Section titled “1.31.0”Released November 10, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”react-smart-copy/compat: a drop-in replacement forreact-copy-to-clipboard. Change the import and keep the JSX: the same props, the same single child cloned with your other props, its ownonClickkept, andonCopy(text, result), now with a third argument saying why a copy failed. On the way it drops the blockingwindow.prompton failure, writes plain text through the Clipboard API (no styling carried into the paste), and withformat: "text/html"writes the HTML and its plain text, where the original wrote only the HTML.onCopyruns when the copy is written, still reports after a menu closes and unmounts it, and the whole component works on plain HTTP and in embedded apps. The migration guide lists each difference; the component is checked with a real click in Chromium, Firefox and WebKit.
1.30.0
Section titled “1.30.0”Released November 10, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”- Copy a page as Markdown, cleanly.
htmlToMarkdownleaves out heading permalinks: the#,¶or “Section titled” link that Starlight, Docusaurus, VitePress, MkDocs, Sphinx and GitHub put inside or beside every heading, so a copied page or a pasted docs section no longer reads## Options¶. A heading whose whole text is a link keeps it. A newignoreoption (a CSS selector) leaves out demos, ads or widgets, and[data-copy-ignore]is now always left out, as it is in the rest of the library. The Markdown guide has a tested “Copy a page as Markdown” recipe, and the docs site has the button on every page.
1.29.3
Section titled “1.29.3”Released November 9, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Line breaks marked
aria-hiddenare kept. Slack marks every line break that way, and pasting a Slack message withpasteToRich(or copying one withprepareRichorcodeFromElement) joined its lines:…/runs/42npm run build.aria-hiddenkeeps a decoration from screen readers; on a<br>it hides nothing on screen, so the lines now stay apart. Otheraria-hiddencontent is still left out.
1.29.2
Section titled “1.29.2”Released November 8, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Markdown: URLs in pasted text no longer turn into broken links on GitHub. GitHub links a bare URL and keeps the backslash escapes inside it, so text such as
https://example.com/my_pagecame out ashttps://example.com/my\_page, a link to the wrong address. Plainhttp(s)addresses are now written as autolinks (<https://example.com/my_page>), which every renderer follows exactly, and a link whose text is its own address is written the same way. URL-like text that is not a plain address is kept from being linked at all. Escaping is also tighter, matching CommonMark: underscores inside words (snake_case),0.75,#hashtag,-5 °Cand= astay as written, while a line such as:-that GitHub reads as a table delimiter row is now escaped. The property tests now check every output with GitHub’s reference parser (micromark with GFM) as well as markdown-it. Themarkdownentry grows by about 0.5 kB. CopyFieldandPasteFieldnow use the clipboard of the window they are rendered in. In a pop-out window (window.openplus a React portal), they used the opener’s clipboard, which only works while the opener’s document has focus, and the click happened in the pop-out. An adapter you pass incopyOptionsorpasteOptionsstill wins. The docs show how to do the same withuseCopyandusePaste. Also tested: drag-to-copy registered on a web component’s host works for drags that start inside its shadow root.
1.29.1
Section titled “1.29.1”Released November 8, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Copy interceptors now work with web components. A scope registered around a component (Shoelace, Ionic, Lightning and similar build their cards and inputs in shadow DOM) used to miss text selected inside it and, worse, an input inside it: a redaction scope around a component’s API-key field silently let the key through. The interceptor now follows the copy event’s composed path to the real field, matches scopes through shadow roots, and reads selections that Safari and Chromium fold onto the component’s host through
getComposedRanges, nested components included. Closed shadow roots stay private, and a selection that starts outside a component and ends inside it is left to the browser.useCopyInterceptorgrows by about 0.25 kB.
1.29.0
Section titled “1.29.0”Released November 8, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Copy text the server makes after the click.
copy()(andCopyField’svalue) now accepts an async function, such as one that creates a share link:copy(async ({ signal }) => (await fetch(url, { signal })).text()). The write starts during the click with a promise of the text, so it works in Safari, which ends the click at the firstawait; checked in Chromium, Firefox and WebKit. The source receives the copy’sAbortSignal, soreset()or unmounting also cancels the request, and text that arrives after that is never written. It may resolve to text or JSON. A rejected request is aninvalid-payloaderror with the thrown value as itscause; if the write fails after the text arrived,retry()writes it again without asking the server.Type change: while an async source is still producing its text,
CopyingState.payloadisnull, so its type is nowCopyPayload | null. Code that readsstate.payloadduringcopyingneeds a null check; synchronous sources behave exactly as before. Custom adapters can implement the new optionalwriteDeferred(text, context)to start their write before the text arrives; without it, the machine waits for the text and callswrite.useCopygrows by about 0.2 kB.
1.28.0
Section titled “1.28.0”Released November 8, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”- Copy works in embedded apps. A Microsoft Teams tab, a SharePoint web part, a Storybook canvas or any app in a cross-origin iframe without
allow="clipboard-write"has its async clipboard writes refused by Chromium (NotAllowedError), so copy buttons there failed withpermission-denied. When that happens, the default adapter now copies text, HTML and JSON through the browser’scopycommand while the click is still fresh, as it already does on plain HTTP. When the command cannot help (an image,legacyFallback: false, an aborted copy), the browser’s own error stands, classified as before. No size change foruseCopy.
1.27.1
Section titled “1.27.1”Released November 7, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Faster with large inputs, measured in real browsers. Pasting a 10,000-row table from Google Sheets is about 40% faster (in Chromium, 410 ms to 235 ms): cells holding one text node, nearly all of a spreadsheet’s, are read without the general walk, and the table parser no longer strips event handler attributes from a document whose nodes never leave it. Copying on plain HTTP no longer lays out the whole payload: a megabyte goes from about 107 ms to 4 ms. Results are unchanged; a property test checks the fast path against the general one.
1.27.0
Section titled “1.27.0”Released November 5, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Copy now works where the async Clipboard API does not: on plain-HTTP pages (intranet tools, internal dashboards on an IP address) and in webviews without
navigator.clipboard, text, HTML and JSON are copied through the browser’scopycommand, asreact-copy-to-clipboarddoes. The payload is written exactly through thecopyevent: nothing is added to the visible page, the user’s selection and focus are restored, and page copy handlers and interceptors do not rewrite it. HTML is copied as HTML whereClipboardItemis missing, instead of being reduced to text. Images still need HTTPS. Copies that used to fail withinsecure-contextorunsupportednow succeed; passlegacyFallback: falsetocreateBrowserClipboardAdapterto keep the old behaviour.useCopygrows by about 0.7 kB.New docs page: Migrating, from react-copy-to-clipboard, copy-to-clipboard, react-use and
navigator.clipboard, with every snippet run as a test.
1.26.1
Section titled “1.26.1”Released November 4, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Capture and image: when an image from another site blocks the canvas (the browser’s
SecurityError), the failure now says so (CORS), and it is no longer reported as retryable. Trying again cannot change what the other site’s server says, so a “Try again” button for it could never work. The error type is stillblob-generation-failed, so nothing that switches on it breaks.
1.26.0
Section titled “1.26.0”Released November 4, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”- Clipboard permission:
readClipboardPermission,watchClipboardPermission(inreact-smart-copy/core) and theuseClipboardPermissionhook tell you whether the browser will let the page read or write the clipboard, so a blocked paste button can say what to do instead of failing. The state isgranted,prompt,deniedorunsupported; Firefox and Safari have no such permission to query and sayunsupported, which is not a refusal. It never reads the clipboard and never shows a prompt.
1.25.1
Section titled “1.25.1”Released November 2, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Native copy: a selection that only reaches the edge of a scope no longer gives that scope the copy. Triple-clicking a paragraph ends at the start of the next block, so a higher-priority scope right below (a redaction zone, say) used to take the copy and the paragraph lost its attribution. A scope now takes a selection only when it selects something of it: text, or an image or other embedded element. Redaction is not weakened: selecting even one character of a scope still gives it the copy.
1.25.0
Section titled “1.25.0”Released November 2, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Consistent limits, and a way to test against real clipboards.
parseNumber,parseAddressesandextractOtptake amaxLengthoption, like the other text parsers. Their limits are now namedDEFAULT_NUMBER_MAX_LENGTH,DEFAULT_ADDRESS_LIST_MAX_LENGTHandDEFAULT_OTP_MAX_LENGTH;NUMBER_MAX_LENGTH,ADDRESS_LIST_MAX_LENGTHandOTP_SCAN_LENGTHstay as deprecated aliases until 2.0.parseAddressesnow acceptsmaxAddresses: Infinity, as every other limit does.- New docs: the Clipboard Inspector, which shows every format a paste holds and saves it as a capture for bug reports; the API conventions; and the proposal for a future 2.0.
- The test suite has a corpus harness for real clipboard captures: each capture is run through every converter and held to a reviewed result. The corpus starts empty; captures made with the Inspector are what fill it.
1.24.1
Section titled “1.24.1”Released October 28, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”-
Production hardening.
extractOtpis about four times faster on long text: keywords are found once per message instead of once per number. At its 100,000-character limit, hostile input now takes about 15 ms instead of 60 ms. A keyword cut off at the edge of the 60-character window no longer counts as a whole word.- Every export’s type is written out (
isolatedDeclarations), so the public API never depends on what TypeScript infers. The published declarations are unchanged apart from naming:CopyField,PasteFieldandFILE_TYPEShave the same types, written explicitly. - The npm page shows the whole README again. npm cuts READMEs at 64 KiB, and it had grown past that. The README is now a 15 kB overview that links to the docs.
- The docs have a new guide, Performance and limits: bundle costs, every parser’s input limits, and the linear-time guarantee. Two docs examples that called
useCopyInterceptorwith the wrong arguments are fixed.
1.24.0
Section titled “1.24.0”Released October 25, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
react-smart-copy/email: lists of e-mail recipients, pasted and copied the way mail programs do.parseAddresses(text)reads the lists people paste from Outlook, Gmail, Apple Mail, contact cards and spreadsheets:- entries separated by commas, semicolons, line breaks or tabs;
- bare addresses,
Name <address>, quoted names with escapes, Outlook’s unquotedLima, Ana <ana@example.com>,address (Name),mailto:links, and names in the spreadsheet cells around an address.
- Each address is checked:
- its local part, a domain that can exist, and length limits;
- invisible and direction-changing characters are turned away;
- domains that mix Latin with Cyrillic or Greek letters are flagged
lookalike.
- Duplicates are dropped, without case, and invalid entries come back with a reason. International domains are given in ASCII for storing and in Unicode for showing.
domainsrestricts a list to the domains you allow. pasteAddresses(event, { onAddresses })is a paste handler for recipient fields; what was not an address stays in the field to be corrected.parseAddress,formatAddressandaddressesPayloadhandle one address and write lists back. Names are quoted as mail needs, and can never end a mail header.
1.23.0
Section titled “1.23.0”Released October 24, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
react-smart-copy/number: numbers and amounts, pasted and copied exactly in any locale’s format.parseNumber(text, { locale })reads one number from pasted text:- group separators
,.'and spaces (no-break and narrow ones too), in groups of three or lakh and crore grouping; wrong grouping givesnull; - the decimal separator the text shows is one; only a lone
1,234or1.234is settled bylocale, and flaggedambiguous; -,+,−, a trailing minus and accounting brackets; currency symbols and ISO codes before or after;%and‰; scientific notation; digits of any script.- It gives
value, andexactas a decimal string with every digit as written, for money.
- group separators
pasteAsNumber(event)inserts the number the way the field takes it:exactin<input type="number">, the locale’s format in text fields with undo intact. Pastes that are not numbers are turned away.formatNumberandnumberPayloadwrite a number, bigint or exact decimal string for any locale, grouped or not, rounded tofractionDigitswithout float error.numberSymbols(locale)gives a locale’s separators and grouping.
1.22.0
Section titled “1.22.0”Released October 23, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
react-smart-copy/otpanduseOtpField: one-time codes, pasted and autofilled the way people expect.useOtpField(React entry) andcreateOtpField(framework-agnostic) wire a row of single-character boxes:- typing moves to the next box; Backspace, Delete, the arrow keys, Home and End work as people expect;
- pasting a code, or a whole SMS holding one, into any box fills them all;
- SMS autofill on iOS and Android, through
autocomplete="one-time-code"on the first box; - the WebOTP API with
webOtp: true, cancelled when the boxes are detached or the code is typed; - an accessible name on every box, the numeric keyboard for numeric codes, and no autocorrect.
extractOtp(text)finds the code in an SMS or an e-mail: a code on its own, an origin-bound line (@example.com #482913, refused for anotherdomain), or a number next to a word that names it, in twenty languages and with digits of any script. Prices, dates, times, phone numbers, order numbers and anything in a URL or an e-mail address are left alone. Linear time, first 100,000 characters.normalizeOtpTextreads digits of any script, and full-width characters, as ASCII.
1.21.0
Section titled “1.21.0”Released October 22, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
react-smart-copy/secrets: keep API keys, tokens, private keys, passwords, card numbers and IBANs out of pastes and copies.scanSecrets(text)finds:- keys and tokens of AWS, GitHub, GitLab, Slack, Stripe, Google, npm, PyPI, SendGrid, Twilio and Azure, and JSON Web Tokens, by their documented formats;
- PEM and OpenSSH private keys;
- passwords in URLs and connection strings;
- card numbers (Luhn and brand ranges) and IBANs (mod-97 and country lengths);
- random-looking values assigned to secret names.
- Each finding has a kind, a confidence and a masked preview, never the secret. Every pattern runs in linear time.
redactSecrets(text)replaces each secret, by default with[redacted <label>].pasteWithoutSecrets(event)redacts (undo intact) or blocks pastes that hold secrets.secretRedactor()is auseCopyInterceptortransform that redacts secrets in what people copy from your page.- Works on servers too.
1.20.0
Section titled “1.20.0”Released October 21, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
react-smart-copy/files: take pasted and dropped files and folders safely.acceptFiles(source, options)takes a paste or drop event (DOM or React), aDataTransfer, aFileListor a list of files. It walks dropped folders withinmaxFiles,maxFileBytes,maxTotalBytesandmaxDepth, and accepts or rejects each file with areasonand a message that names the file by its safe name. Withdigest: true, each file gets a SHA-256 and repeated files are rejected asduplicate.- Types come from content, never from names or claimed types: more than 50 formats are recognised by their signatures, including Office and OpenDocument files told apart inside their ZIP.
acceptworks like<input accept>, judged by content. Each accepted file’suploadis the same bytes, with the safe name and the detected type. - Risky files are rejected by default: programs and scripts, HTML and SVG (active content), Office files with macros, content that contradicts the extension, double extensions (
invoice.pdf.exe), and hidden characters in names (photo\u202Egpj.exe).blockchooses which risks reject. inspectFile,detectFileType,safeFileNameandmatchesAcceptare exported as building blocks. Everything works on servers too (Node 18+).
1.19.1
Section titled “1.19.1”Released October 20, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- New documentation site: a page for every feature, each with its live demo, plus search, a Releases page and guides, at https://suprabhat02.github.io/react-smart-copy/. Links to the old single page still work. The README’s option tables now name their notes column. No change to the library’s code.
1.19.0
Section titled “1.19.0”Released October 20, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Paste into rich-text editors:
pasteToRichandpasteAsRichinreact-smart-copy/rich. What Google Docs, Word, Outlook, Gmail and web pages put on the clipboard becomes clean, semantic HTML for TipTap, ProseMirror, Lexical, Quill or acontenteditableelement.- Formatting set by CSS becomes
<strong>,<em>,<u>,<s>,<code>,<sup>and<sub>, and CSS wins over tags, as in the browser (Google Docs’ non-bold<b>wrapper stays non-bold). Every style, class and id is left out, so the paste takes the editor’s look. - Word’s list paragraphs become nested lists with their numbering. Docs’ paragraphs in list items and lists nested beside their items are put right. Mail layout tables become their content; data tables keep their sections, merged cells and captions. Code blocks keep their lines and indentation.
- The output is canonical: the same content always gives the same HTML, and cleaning it again changes nothing.
- The same sanitizer as
prepareRich: allowlisted elements and attributes, absolute, scheme-checked URLs. Google and Outlook Safe Links redirects are unwrapped. Relative links resolve only againstbase.removedreports scripts, embeds, and unsafe links and images. formatslimits the output to what the editor holds, keeping all of the text: a heading becomes a bold paragraph, a list item a paragraph after its marker, a table its cells.pasteAsRich(event)inserts into acontenteditableelement with undo intact, and leaves plain-text pastes to the browser. Plain text throughpasteToRichbecomes paragraphs, without a DOM.- Property-tested against generated Docs, Word, mail and hostile HTML: only allowlisted markup, nothing for DOMPurify to remove, every visible character kept with the formats it showed, and a fixpoint.
Also: link and image removal reports read the URL scheme as the URL parser does, so
java	script:is reported asjavascript.Also, across
markdown,code,link,tableandrich, pasted HTML is now parsed by one internal routine that removes event handler attributes as soon as it has parsed them, so no node of the inert document carries one. - Formatting set by CSS becomes
1.18.0
Section titled “1.18.0”Released October 20, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
One shared core for every entry point. Before, each entry point (
react-smart-copy,/core,/rich,/markdown, …) bundled its own copy of the copy and paste core. Now that code ships once, indist/chunks/, and each entry point imports it.- Smaller apps: an app that uses several entry points loads the core once. An app using five of them is 24.6 kB instead of 25.5 kB (minified and brotlied). The minified JavaScript is 18% smaller, and the npm package shrinks from 4.2 MB to 3.0 MB unpacked.
- One
CopyFailureclass: a failure from any entry point is aninstanceoftheCopyFailureexported byreact-smart-copyandreact-smart-copy/core. Before, each entry point had its own class, soinstanceoffailed across them (isCopyFailure()always worked, and still does). - Nothing to change in your code: the entry points, their exports and their types are the same, and each entry point alone is the same size as before. Only the React entry is a client module (
"use client"); the build now checks that no other entry point reaches React, so server code can import them.
1.17.2
Section titled “1.17.2”Released October 20, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”-
- A
CopyFailurethrown by your owndecodeorencodehook inreact-smart-copy/imageis passed on as it is, even when it comes from another entry point (such asreact-smart-copy/core), which bundles its own copy of the class. It was wrapped in a new error before.react-smart-copy/codeuses the same brand check. A lint rule now keepsinstanceof CopyFailureout of the library. - Support, now checked on every change: TypeScript 5.0 and later (the published types are type-checked on 5.0 and 7), and Node.js 18, 20, 22 and 24 (every entry point of the packed package, through
importandrequire). - Each GitHub release now holds the npm tarball and a Sigstore attestation of it (
gh attestation verify). - Docs: the README states the supported TypeScript and Node.js versions, and the roadmap marks 1.17 shipped and lists 1.18 and 1.19. The docs site has a canonical URL.
- A
1.17.1
Section titled “1.17.1”Released October 19, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”-
Fix
formatColorfor greys from other colour spaces inhslandhwb: white fromcolor(display-p3 1 1 1)was written ashsl(240 NaN% 100%), and greys from Lab or OKLCH came out with a made-up hue and saturation (lab(100 0 0)ashsl(120 50% 100%)). Greys are nowhsl(0 0% …)andhwb(0 …); real tints keep their hue, however faint.Also hardening, with no other change in behaviour:
- Colour conversions are typed end to end: three-component vectors no longer need casts, so the compiler checks every step.
- 100% test coverage now comes from deterministic tests alone, and the property tests run separately, so coverage never depends on a random seed. Colour property tests now draw edge values (0, 0.5, 1) often, and check that no format ever writes
NaNand that greys stay grey. - Stricter TypeScript settings (
noPropertyAccessFromIndexSignature,noUnusedLocals,noUnusedParameters), and type tests forreact-smart-copy/capture.
1.17.0
Section titled “1.17.0”Released October 19, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/rich: copy styled content so it pastes as it looks in Gmail, Outlook, Apple Mail, Google Docs, Word, Notion and Slack.richPayload(element)for a copy button, andrichTransform()foruseCopyInterceptor, so Ctrl/⌘+C of a selection is portable too.prepareRichreturns{ html, text, removed, truncated }.- Only allowlisted elements and attributes are kept. Scripts, event handlers, embeds, SVG, media, forms and controls are left out, and so are hidden and
data-copy-ignorecontent.removedlists what was left out and why. - Styles are inline, from what the reader sees (computed styles), and only where they change. Layout CSS is never copied.
- Every colour (
oklch(),color(), translucentrgb()) becomes opaque hex. Withcolors: "readable"(the default), light text from a dark theme takes the destination’s colour. - Links and images get absolute, scheme-checked URLs. Images get their displayed size.
data:images are opt-in. - Table rows sit in table bodies and blocks stay out of paragraphs, so nothing moves when the paste is parsed.
- Readable plain text: bullets, numbers, tab-separated table cells.
- Property-tested against hostile HTML: DOMPurify finds nothing to remove, and running the output through again changes nothing. Computed styles are checked end to end in Chromium, Firefox and WebKit.
Also: every property test file now has a 60-second timeout, so heavy runs no longer time out on busy CI runners.
1.16.0
Section titled “1.16.0”Released October 19, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/color: copy and paste colours in every CSS format.colorPayload(color, { format })copies a colour as hex,rgb(),hsl(),hwb(),oklch(),oklab(),lab(),lch()orcolor(display-p3 …). Docs, Notion, Slack and mail also get a small swatch (swatch: falseturns it off).parseColorreads every CSS Color 4 notation: hex, the 148 named colours,rgb()andhsl()in both syntaxes,hwb(),lab(),lch(),oklab(),oklch(), andcolor()insrgb,srgb-linear,display-p3,xyz,xyz-d65andxyz-d50. It returnsnullfor anything else and never throws.formatColorwrites any of the formats. The default precision brings every 8-bit colour back exactly; this was checked on 836,056 colours. Colours outside sRGB are gamut-mapped as CSS Color 4 specifies (chroma reduced in OKLCH, hue kept);gamut: "clip"clips them instead.inGamutandtoGamutare exported too.readColorreads a pasted colour, including declarations copied from developer tools (color: #3b82f6;).pasteAsColorinserts any pasted colour in a field’s format and keeps the browser’s undo.contrastRatioandcontrastLevel: WCAG 2 contrast for normal and large text, never rounded up.- Accuracy is property-tested against culori, and checked against the browser’s own CSS parser in Chromium, Firefox and WebKit.
1.15.0
Section titled “1.15.0”Released October 19, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add sharing: one button that opens the share sheet on phones and tablets and copies a titled link everywhere else.
useShare(fromreact-smart-copy) returnsshare,status(idle,sharing,shared,copiedorerror) andmethod.methodis"native"or"copy", so the button can say “Share…” or “Copy link”. It is"copy"during server rendering, then follows the device.react-smart-copy/share(framework-agnostic):shareOrCopy(content, options)never rejects. It resolves toshared,copied(with its reason:preferred,unsupportedorfallback),cancelledorerrorwith a typedCopyError. Closing the share sheet iscancelled: never an error, and never a surprise copy. AlsoshareMethodanddescribeShareError.mode:"auto"(default) uses the share sheet on touch-first devices,"native"uses it wherever available, and"copy"always copies. When the share sheet fails, the link is copied instead (fallback: falsereports the error instead).- Links are checked like everything in
react-smart-copy/link: safe schemes only, credentials removed, tracking parameters removed withclean: true, titles cleaned. Files go only to a share sheet that accepts them. react-smart-copy/linkconstants are now marked pure, so bundles that don’t use them drop them.
1.14.1
Section titled “1.14.1”Released October 19, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”react-smart-copy/markdown: inline code in a table cell that holds a backslash before a pipe (such asa\|b) no longer breaks the table on GitHub and other GFM renderers. GFM splits table cells before it reads code spans, so a pipe after an odd number of backslashes cannot be written inside one code span. The code is now split around such a pipe, and the cell keeps its exact text. Every other pipe stays inside the code. Table output is now tested against micromark, the reference GFM parser, as well as markdown-it.
1.14.0
Section titled “1.14.0”Released October 19, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/link: copy links that paste well everywhere and link to a passage of a page.linkPayloadcopies a titled<a>link and the URL, so Slack, Google Docs, Notion, Teams and mail paste the title as a link and editors paste the URL. Plain text can be the URL, the title, both, or Markdown.{ target: "drag" }addstext/uri-listandtext/x-moz-urlforuseDragCopy.- Every URL is resolved and checked: only
https:,http:,mailto:andtel:by default (neverjavascript:ordata:), user names and passwords removed, international domains in punycode. Titles are cleaned of hidden and reordering characters, capped, and escaped. cleanLinkUrlandclean: trueremove tracking parameters (utm_*,fbclid,gclid,msclkidand more) and keep everything else.textFragmentUrlandselectionLinkmake links that scroll to and highlight a passage (#:~:text=), with each term inside one block and context added when the passage repeats.readLinkreads the one link a paste or drop holds, with its title.pasteAsLinkturns selected text into a link when a URL is pasted over it, keeping the browser’s undo.- No dependencies, about 4 kB;
linkPayloadalone is about 1.8 kB. Works on the server with abase.
The README’s drag-to-copy example now uses
linkPayload, which escapes the title and checks the URL.
1.13.2
Section titled “1.13.2”Released October 18, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Documentation only: the README now says the library is tested in Chromium, Firefox and WebKit on every change, and how to run those tests. No code changes.
1.13.1
Section titled “1.13.1”Released October 18, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”react-smart-copy/image: every metadata check now reads only its own segment, chunk or Exif block. Before this, an empty JPEG APP2 segment could be classified from the bytes after it, so a malformed file kept a segment on the first strip and dropped it on the second. Fuzz tests found it. They now run five times as many cases in CI, and the case is a regression test.
1.13.0
Section titled “1.13.0”Released October 18, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/image: get pasted and dropped images ready to upload, private and small.prepareImage(file, options?): removes metadata and fits the image tomaxWidth,maxHeight,maxPixelsandmaxBytes. It re-encodes only when it has to. When only the metadata goes, every pixel stays the same. For a byte budget it searches for the highest JPEG or WebP quality that fits (down tominQuality), then reduces the size.type: 'auto'keeps PNG screenshots lossless while they fit, then moves to WebP or JPEG. When a limit can’t be met, it is atoo-largeerror, never an oversized file. Large reductions are drawn in halving steps.stripMetadata(file, options?): lossless metadata removal for JPEG, PNG, WebP and GIF. It removes Exif (camera, dates, serial numbers), the GPS location, embedded thumbnails, XMP, IPTC, comments, PNG text, multi-picture and depth images (MPF), content credentials (C2PA) and data appended after the image (motion photos). It keeps the colour profile, and the orientation in a 26-byte Exif block, so photos stay upright. Works on the server.readImageInfo(file): format, size, orientation, animation and the metadata a file carries, read from its bytes. This includes AVIF and HEIC, whose Exif and GPS are found through their item tables. It never decodes the picture and never trusts the file name or the claimed type.- Safe with hostile files: sizes are checked against
maxInputPixelsbefore decoding (decompression bombs), every parser read is bounded by its own box or chunk, and fuzz tests feed random and mutated files to every parser. Animations keep every frame by default (animated: 'keep' | 'first-frame' | 'reject'). Every failure is a typed error, andsignalandtimeoutMscancel the work. removedis read back from the output, not assumed (some encoders add their own colour profile), and an injectableenvironmenttakes a custom decoder or a test double.
Also: the published
react-smart-copy/codebundle no longer contains its lookalike table as raw Cyrillic and Greek letters (the build had turned the escapes into characters), so security scanners don’t flag the package itself. Every release is now checked by the package’s owninspectCodefor hidden, reordering, control and lookalike characters before it is published.
1.12.0
Section titled “1.12.0”Released October 18, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/code: copy code the way developers expect, paste it safely.codePayload(source, options?): a copy payload for a string or a rendered, highlighted code block. It holds plain text for editors and terminals, plus monospaced HTML with the block’s syntax colours for Google Docs, Word, Slack, Teams and mail. Line-number gutters,user-select: noneandaria-hiddenparts, hidden parts, buttons anddata-copy-ignoreare left out.codeFromElementreturns just the text.- Terminal and REPL sessions copy as their commands (
prompt: 'auto'): bash/zsh, PowerShell, cmd, Python, IPython and Node prompts, or your own pattern. Continued commands stay whole (a trailing backslash, a heredoc, an open quote), and output is dropped.diff: 'after' | 'before'copies one side of a unified diff, andlineNumbers: trueremoves typed line numbers that count up. Shared indentation and trailing whitespace are removed and line endings normalised.normalizeCodeexposes all of this, and also works on the server. pasteAsCode(event, options?): a paste handler for code fields. It fixes curly quotes, dashes, no-break spaces and invisible characters, dedents, and indents each line to the cursor. The browser’s undo stays intact.onPastesees every finding and can cancel.pasteToCode(result)servesusePaste, CodeMirror and Monaco.inspectCode(text)finds code that runs differently from how it reads, with line, column and Unicode name: Trojan Source bidi overrides (CVE-2021-42574), invisible identifiers (Hangul fillers), hidden tag characters, runs of variation selectors, Cyrillic and Greek lookalikes in Latin words, control characters, unusual spaces and typographic punctuation. Joiners in Arabic, Persian, Indic and emoji, and full-width punctuation in CJK text, are left alone.cleanCode(text)applies safe replacements until nothing fixable is left, and never guesses a letter.- Pasted code is never cut: past
maxLengthit is atoo-largeerror, or a native paste withpasteAsCode. HTML is parsed inertly.
insertTextnow lives in one shared module and is exported from both/markdownand/code.
1.11.0
Section titled “1.11.0”Released October 17, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/markdown: paste rich content as Markdown.pasteAsMarkdown(event, options?): a paste handler for a<textarea>or text<input>(onPaste={pasteAsMarkdown}). Rich pastes from Google Docs, Word, Notion, GitHub, web pages and mail are inserted as Markdown at the cursor. The browser’s undo still works, with the paste as its own step,inputevents fire so React state follows, andmaxlengthis respected. Plain-text pastes, which are usually Markdown already, and code from editors are left to the browser.htmlToMarkdown(source, options?): HTML string or DOM node to CommonMark with GFM tables, strikethrough and task lists. Handles Google Docs (CSS-only bold and italic, the non-bold<b>wrapper, sibling-nested lists, redirect links), Word (mso-listlists), mail layout tables and code editors.pasteToMarkdown(result, options?),insertText(field, text)andescapeMarkdown(text)for custom flows, includingusePasteandPasteField.- Correct by construction: every emphasis delimiter is checked with CommonMark’s own pairing algorithm before it is kept, so text always renders as the same text. Property tests with a CommonMark parser check this.
- Secure by default: inert parsing (no scripts, no requests), no raw HTML in the output, links limited to
http:,https:andmailto:, images as alt text unlessimages: 'keep', and explicitmaxLength,maxNodesandmaxDepthlimits reported throughtruncated.
1.10.0
Section titled “1.10.0”Released October 17, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/structured: typed, versioned, validated application data on the clipboard.defineClipFormat({ id, version, schema, migrate, encode, text, html })defines a format. The schema can be any Standard Schema (Zod, Valibot, ArkType, Effect Schema) or a plain validator function, and the value type is inferred from it.clipPayload(format, value)builds a payload forcopy(), auseCopyInterceptortransform or auseDragCopysource. It carries the data three ways: a web custom format (web application/vnd.<id>+json), a custom clipboard type, and a hidden envelope in the HTML, plus readable text and HTML for other apps. Every browser and paste path gets at least one.readClip(source, format)/readClipSyncread the data from aPasteResult, aDataTransferor a payload, and returnok,absent,invalidorunsupported-version. They never throw for clipboard content.clipAccept(...formats)returns theacceptlist forusePasteandPasteField.- Security: carriers are size-checked before they are parsed (
maxBytes, default 8 MiB), own__proto__keys are dropped, migrations run before the schema validates, and copying rejects valuesJSON.stringifywould silently change (NaN,BigInt,Map,Set, functions).
Core additions, all backward compatible:
multipayload items acceptoptional: true. An optional item is written only whenClipboardItem.supports()confirms its type, and is skipped otherwise instead of failing the copy.- Copy and drag events skip web custom formats, which only the async Clipboard API can write.
acceptaccepts web custom formats ('web application/vnd.acme+json'), and+jsontypes arrive as strings. Wildcards never match either kind, so they must be listed exactly, asimage/svg+xmlalready had to be.- New helpers
normalizeClipboardTypeandisWebCustomFormat.
Released October 14, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
react-smart-copy/table: spreadsheet-ready copy and paste for tables.- Copy:
tablePayload(data)returns anhtmlpayload, an HTML<table>plus tab-separated text, forcopy(),useCopyInterceptoranduseDragCopy. Rows paste as cells in Excel, Google Sheets, Numbers and LibreOffice, and as a table in Docs, Word and Notion. Numbers, bigints, booleans and dates stay typed; strings stay text, so leading zeros survive (preserveText). Text that would run as a formula is neutralised by default, following OWASP’s CSV Injection guidance (formulaGuard). - Sources:
fromRowsfor your own objects (type-checked column keys),fromAgGridfor AG Grid v31+ (Community and Enterprise),fromTanStackTablefor TanStack Table v8 and v9 in any framework, andfromTableElementfor any rendered<table>. No dependency on any grid library. - Paste:
parseTablereads the HTML that Excel, Google Sheets, Word and web pages put on the clipboard (merged cells, line breaks, hidden rows) and falls back to tab-separated text, also on the server.toRecordsmaps a pasted range onto typed records by header, with aliases, and reports missing columns and parse errors. Explicit limits for rows, columns, cells and input length, reported throughtruncated.
Also: a
CopyFailurethrown inside acopy()source, a drag source or a copy transform now keeps its own error type (for exampletoo-large) instead of becoming a genericinvalid-payload. - Copy:
Patch changes
Section titled “Patch changes”- Docs: the README roadmap now lists the
react-smart-copy/testingsubpackage under 1.6, the version it shipped in.
Released October 12, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Docs: the npm README now links the GitHub repository for stars and names the package author, and
package.jsoncarries the author’s name and site.
Released October 10, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
useDragCopy— a headless React hook that makes any element draggable and populates itsDataTransferwith structured data ondragstart.Features:
- Structured payloads —
text,html(with plain-text fallback),json, andmulti(arbitrary MIME types). - Zero Clipboard API — works in every browser that supports HTML5 drag-and-drop.
- Always-fresh source — the
sourcecallback reads the latest props/state on every drag, never stale closures. enabledprop — removedraggableand the listener without unmounting; status resets toidle.effectAllowed— controls the browser drag cursor and permitted drop effects.onDragStartprop path — stable callback for use inside render-prop components or when the native listener alone isn’t enough.- SSR-safe — no DOM access during server rendering;
draggableis never set on the server. - Framework-agnostic core —
applyDragCopyandregisterDragCopyare also exported fromreact-smart-copy/core.
const { ref } = useDragCopy({source: () => ({ kind: 'html', html: '<b>Hello</b>', text: 'Hello' }),effectAllowed: 'copy',});return <div ref={ref}>Drag me</div>; - Structured payloads —
Released October 9, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”- Docs: README footer now reads “Made with ❤️ from 🇮🇳”. No code changes.
Released October 9, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”-
Copy interception:
selection.textnow matches what the browser itself would copyCopySelection.textwas built fromRange#toString(), which returns raw DOM text. In real browsers that meant source indentation, line breaks from your markup and visually hidden text leaked into rewritten copies, so an attribution transform produced messier text than a plain Ctrl/⌘+C. It is now read fromSelection#toString(), which follows the rendered layout.htmlandfragmentare unchanged.
Released October 9, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Control what native copy puts on the clipboard:
useCopyInterceptorUntil now every copy the library handled started from a button. The copies people make most often are native: select, then Ctrl/⌘+C, Ctrl/⌘+X or the context menu. Those can now be rewritten, redacted or blocked inside any element.
const { ref } = useCopyInterceptor<HTMLElement>({transform: ({ text }) => `${text}\n\nSource: ${location.href}`,});return <article ref={ref}>…</article>;The transform receives the selection (
text,html, a detachedfragmentsafe to mutate, thefieldfor inputs, andkind) and returns a string or a text/HTML/JSON/multi payload to write instead,falseto block the copy, or nothing to leave it alone.- Works everywhere, no prompt. Writes go through the copy event’s
clipboardData, so there is no permission request and no HTTPS requirement. Only strings can be written this way: image payloads andasynctransforms are compile errors. - Fails closed. A transform that throws or returns something unwritable blocks the copy
and reports
onError, the safe default for redaction.failureMode: "native"lets the original copy through instead. - Cuts behave like cuts. In inputs and
contenteditable, the selection is still removed after your content is written, through the browser’s editing path (undo works, React seesinput). A blocked cut deletes nothing. - Deterministic overlap. One document listener serves every scope. When a selection
touches several, exactly one handles it: highest
priority, then innermost, then document order. The winner sees the whole selection, so a high-priority redaction scope masks content copied across it and its neighbours. - Framework-agnostic core.
registerCopyInterceptor(element, options)andinterceptCopyEvent(event, options)inreact-smart-copy/core;readCopySelection(event)for custom handlers.
Tree-shaken:
useCopy,usePaste,CopyFieldandPasteFieldare unchanged in size.useCopyInterceptoron its own is 2.28 kB (min + brotli).Not a security boundary: users can still screenshot or open dev tools. It guards against accidental copying of sensitive values.
- Works everywhere, no prompt. Writes go through the copy event’s
Released October 8, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Section titled “react-smart-copy/testing — test utilities subpackage”react-smart-copy/testing— test utilities subpackageA new
react-smart-copy/testingentry point ships three utilities that make consumer test suites resilient to future API additions:
Section titled “createPasteResult(init?)”createPasteResult(init?)Builds a complete, self-consistent
PasteResultfrom partial input. Every field has a sensible default (null,[],'clipboard'), so adding a required field in a future release will not break existing test code.import { createPasteResult } from 'react-smart-copy/testing';// Builds items, imageFiles, etc. automaticallyconst result = createPasteResult({ text: 'hello', source: 'clipboard' });When
itemsis omitted it is derived fromtext,html, andimages;imageFilesis always computed from the intersection ofimagesandfiles, exactly as the machine does.
Section titled “createMockPasteAdapter()”createMockPasteAdapter()Returns a controllable
PasteAdapterbacked by a result queue. Queue entries are consumed in FIFO order; an empty queue rejects with'no-content'.import { createMockPasteAdapter, createPasteResult } from 'react-smart-copy/testing';import { createPasteMachine } from 'react-smart-copy/core';const mock = createMockPasteAdapter();mock.queueResult(createPasteResult({ text: 'hello' }));mock.queueError(createCopyError('permission-denied', 'blocked'));const machine = createPasteMachine({ adapter: mock.adapter });await machine.paste(); // → { status: 'read', result: … }expect(mock.readCount()).toBe(1);Pass
mock.adapterasadapterincreatePasteMachineoptions or inusePaste’sadapterprop.
Section titled “createMockClipboardAdapter()”createMockClipboardAdapter()Returns a controllable
ClipboardAdapterbacked by a success/error queue. Captures the last payload the machine sent so you can assert on it.import { createMockClipboardAdapter } from 'react-smart-copy/testing';import { createCopyMachine } from 'react-smart-copy/core';const mock = createMockClipboardAdapter();mock.queueSuccess();const machine = createCopyMachine({ adapter: mock.adapter });await machine.copy('hello');expect(mock.lastPayload()).toEqual({ kind: 'text', value: 'hello' });Re-exports
Section titled “Re-exports”react-smart-copy/testingalso re-exports the types most often needed in test files:CopyFailure,CopyError,CopyPayload,PasteAdapter,PasteReadResult,PasteResult,PasteSource,PasteItem, andClipboardAdapter, so a single import path covers both the utilities and their types.Why now?
Section titled “Why now?”v1.3.0 added
imageFilesand v1.4.0 addedsource: 'drop'toPasteResult. Both releases required consumers to update hand-written result literals in their tests.createPasteResultabsorbs future additions at the library level so that upgrading a minor release never touches test code.Bundle size
Section titled “Bundle size”683 B brotli (zero browser globals; works in Node, jsdom, and Deno).
Released October 7, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Drag-and-drop through the paste pipeline.
-
New: drops are pastes. A dropped file or text selection goes through the same
acceptlist,maxBytes/maxItemslimits and image byte-checks as a paste, and resolves withresult.source === 'drop'. Dropped image files arrive inresult.imageFileswith their names. -
New:
PasteField.Zoneaccepts drops by default. It setsdata-drag-overwhile an accepted drag is over it and announcesmessages.dropped(“Dropped content added”). If you override onlypasted, for example to translate it, that message is used for drops too. Passdroppable={false}to keep the 1.3 behaviour. Your ownonDragEnter/onDragOver/onDragLeave/onDrophandlers run first, and callingpreventDefault()in one takes over. -
New in
usePaste:dropTargetProps: spread it onto one element.isDragOver.dropEvent.
Drops are kept separate from
targetProps, so a textarea that only spreadstargetPropskeeps its native text drop. -
New in core:
machine.dropEvent(event).canAcceptDrag(dataTransfer, options): decides from the item kinds and types a browser exposes while dragging. A file whose type is hidden until the drop counts as a maybe.- The
PasteDropEventLike,DataTransferItemLikeandPasteDropTargetPropstypes.
-
Safe in real browsers:
- Every
dragoveron the target is claimed. Drags the field doesn’t accept getdropEffect: 'none', so a rejected file is cancelled instead of being opened in place of your page. - Drags aimed at an
<input>,<textarea>or editable region nested inside the target keep their native behaviour. Inside a target that is itself editable, every drop is still checked againstacceptand the limits. - The drop effect respects the source’s
effectAllowed. - The drag-over state clears on any drop or
dragend, and when the pointer leaves for an element outside the target, so it can’t get stuck.
- Every
-
New:
describePasteError(error, source?). Passstate.sourceto word drop failures as drops (“The dropped content is too large.”).messages.errorreceives the source as its second argument. -
Changed: the developer-facing
no-contentmessage now says “content” instead of “clipboard”, since it covers drops too. -
Docs: the README already said
PasteField.Zoneaccepts drops, which wasn’t true until this release. -
Tests: 459 at 100% coverage, with drag behaviour also checked in Chromium against the docs site.
-
Size (brotli):
Bundle 1.4.0 1.3.0 usePaste4.29 kB 3.79 kB PasteField7.03 kB 6.37 kB core 6.05 kB 5.86 kB useCopy,CopyField+CopyGroup, captureunchanged
Heads-up for TypeScript users. Everything is additive, but:
- Exhaustive switches on the source.
PasteSourcegains'drop', so an exhaustiveswitchoverresult.sourceorstate.sourceneeds the new case. - Hand-built objects. If you build these types by hand, for example in test mocks, add the new members:
UsePasteResult(and soPasteFieldContextValue) gainsdropEvent,dropTargetPropsandisDragOver.PasteMachinegainsdropEvent.
- Messages.
PasteFieldMessagesgains an optionaldropped.errormay receive a secondsourceargument, and existing one-argument functions still fit.
-
Released October 7, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Lifecycle callbacks, consistent
maxBytes, andPasteResult.imageFiles.-
New:
onCancel(reason).useCopy,usePaste,createCopyMachineandcreatePasteMachineacceptonCancel, called once when an in-flight operation is cancelled:'reset','disconnect'(unmount), or for paste'superseded'(a paste event replaced a Clipboard API read). It is not called when nothing was in flight, so React Strict Mode’s extra mount/unmount is silent. The newCopyCancelReasonandPasteCancelReasontypes are exported. (The callback is namedonCancelrather thanonReleaseso it isn’t confused withCopyGroup’s internal hand-off.) -
New:
onReset(). Called whenreset()moves a copy or paste out of a non-idle state. Whenreset()cancels work,onCancel('reset')runs first, thenonReset(). It is not called for the automaticresetAfterMstimer or aCopyGrouphand-off. -
New:
PasteResult.imageFiles. These are the entries offilesthat were verified as images. They keep their file names (retyped from their bytes when needed) and can go straight intoFormData. Clipboard API image blobs, which have no names, stay inimagesonly. The paste machine derivesimageFilesfrom every adapter’s result, so the field is always consistent. -
Changed:
maxBytescounts UTF-8 bytes on every paste path. Before this release, paste events andreadText()measured strings in UTF-16 code units, whilenavigator.clipboard.read()chargedBlob.size. The same text could therefore pass on one path and fail on another. Strings are now measured as they would be encoded, without allocating a copy. Non-ASCII text counts more than before:'日本'is 6 bytes, not 2. If you set a tightmaxBytesfor CJK or emoji-heavy content, check your limit. -
Changed: if a custom adapter (typically untyped JavaScript) resolves a result without
imagesorfiles, the paste now ends in anerrorstate. Before, the incomplete object was stored as a successful read. -
Tests: 427 at 100% coverage, including type-level tests for the new API.
-
Size (brotli):
Bundle 1.3.0 1.2.0 useCopy3.42 kB 3.37 kB usePaste3.79 kB 3.59 kB PasteField6.37 kB 6.18 kB CopyField+CopyGroup5.55 kB 5.51 kB core 5.86 kB 5.66 kB capture 3.54 kB unchanged
Heads-up for TypeScript users. No runtime behaviour you rely on is removed, but:
- Building results by hand.
PasteResultgains a requiredimageFiles. If you buildPasteResultobjects by hand, for example in test mocks oronPastefixtures, addimageFiles: []. - Custom adapters.
PasteAdapter.read()now resolvesPasteReadResult, which isPasteResultwithoutimageFiles. Existing adapters that return a fullPasteResultkeep compiling. - Reading adapters directly. If you store
createBrowserPasteAdapter().read()in a variable typedPasteResult, change it toPasteReadResult. - Options types.
UseCopyOptions,UsePasteOptionsand the machine options gain the optionalonResetandonCancel.
-
Released October 6, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Paste retry, cancellation and
PasteField.Preview.- New: paste
retry().usePasteandcreatePasteMachinegainretry(),canRetryand amaxRetriesoption (default 3), matching the copy side. After a retryable failure of the Paste button (permission denied, page not focused, timeout),retry()reads the clipboard again; past the cap it fails withmax-retries-exceeded. Keyboard-paste failures reportnot-retryable, because the event’s data is gone once it has been handled.canRetryPasteState()is exported for vanilla use, andPasteField.Triggerrender props now includecanRetry. - New: cancellation. Every copy and paste gets an
AbortSignalthat fires onreset(), on unmount, or when a newer paste supersedes it, and never after the operation has finished. Late results were already ignored; now the work itself stops. Lazy image sources and custom adapters receive it as an optional last argument (OperationContext),captureSource/captureImagestop rasterising (combined with anysignalyou pass, without leaking listeners on browsers lackingAbortSignal.any), and the browser paste adapter stops reading further clipboard items. Existing adapters and sources keep working unchanged. - Changed: cancelled operations resolve
{ status: 'ignored', reason: 'cancelled' }. If a copy or paste fails after you cancelled it (reset, unmount, superseded), the promise you awaited now resolvesignored/cancelledinstead oferror, andonErroris not called. Code that shows a toast forstatus === 'error'no longer reports failures for work the user walked away from. - New:
PasteField.Preview. Shows what was pasted: text (truncated atmaxTextLength), image thumbnails withimageAlttext, and non-image file names. It never renders pasted HTML. Object URLs are revoked when the result changes and on unmount. Pass a function child to render{ result, imageUrls }yourself, andplaceholderfor the empty state. - Fix:
useCopy().canRetrynow readsmaxRetriesfrom the effective options, the same ones the machine uses. - Docs: the README’s
PasteFieldexample passedonPastetoPasteField.Root, which has no such prop. It now goes inpasteOptions. - Tests: 398 at 100% coverage, including StrictMode runs of
CopyGroupandPasteField.Preview, and type-level tests for the paste API. - Size (brotli):
PasteFieldwithPreview6.18 kB (was 5.40),usePaste3.59 kB (was 3.16),useCopy3.37 kB (was 3.22),CopyField+CopyGroup5.51 kB (was 5.37), core 5.66 kB (was 5.47), capture 3.54 kB (was 3.41).
Heads-up for TypeScript users. All changes are additive, but if you build these types by hand (for example in test mocks), you’ll need the new members:
PasteErrorStategainssourceandretryCountPasteMachinegainsretry;UsePasteResult(and soPasteFieldContextValue) gainsretryandcanRetryPasteFieldTriggerRenderPropsgainscanRetryPasteIgnoredReasongains'nothing-to-retry','not-retryable'and'cancelled';CopyIgnoredReasongains'cancelled'. An exhaustiveswitchover ignored reasons needs the new cases.
- New: paste
Released October 6, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”-
Accessibility fixes for
PasteFieldandCopyField. No API changes; no bundle growth.- Fix:
PasteField.Zoneaccessible name. The zone set botharia-labelandaria-labelledby, andaria-labelledbywins, so a customzoneLabelmessage oraria-labelprop was silently ignored. The zone is now named byaria-labelonly (“Paste area for Notes”). Passaria-labelledbyyourself if you want to name it from another element. - Fix: reduced motion in
PasteField.Trigger. The default label crossfade now respectsprefers-reduced-motion, matchingCopyField.Trigger. Both triggers now share one label component. - New:
aria-busyon triggers.CopyField.TriggerandPasteField.Triggersetaria-busy="true"while a copy or paste is in flight, so screen readers know the action is in progress. The button is still neverdisabled, so focus stays put. - New:
aria-keyshortcutsonPasteField.Zone. Defaults to"Control+V Meta+V"so screen-reader users hear how to paste. Override it with your ownaria-keyshortcutsprop. - Docs:
maxRetriesJSDoc now states that0disables retry andInfinityallows unlimited retries.
- Fix:
Released October 3, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Add
PasteFieldcompound component — a headless, fully accessible paste UI that mirrorsCopyFieldfor the paste side.New exports
PasteField— compound component withRoot,Label,Status,Zone,Triggersub-componentsusePasteField()— context hook for building custom sub-components insidePasteField.RootdefaultPasteFieldMessages— the default English messages objectusePasteDisplayStatus— flicker-free presentation hook for paste status (suppresses thereadingflash on fast pastes)DEFAULT_PASTE_PENDING_DELAY_MS/DEFAULT_PASTE_MIN_PENDING_MS— exported timing constants
PasteFieldhighlightsPasteField.Zone— a<div role="region">that accepts keyboardpasteevents and drag-and-drop, focusable by default (tabIndex=0)PasteField.Status— displays a human-readable label per paste status (idle → "Ready",reading → "Reading…",read → "Pasted",error → "Error")PasteField.Trigger— button that calls the Clipboard API; supports render-function children for full control- All parts carry
data-state(real),data-display-state(flicker-free), anddata-revealedattributes for CSS styling - Built-in
<LiveRegion>announces success and error messages to screen readers - Full SSR support,
alwaysVisibleprop, custommessagesoverrides,pendingDelayMs/minPendingMstiming controls - 44 new tests; 350 tests total, 100% coverage maintained
Released October 2, 2026. On npm and GitHub
Major changes
Section titled “Major changes”-
v1.0.0 — production-ready release
Full SSR safety audit across every hook and core module, verified with 10 dedicated SSR tests in a Node environment (no
window). Hardened against prototype pollution inCopyFieldkind labels and clipboard adapter multi-format record creation. Comprehensive WCAG 2.1 AA accessibility audit confirmed compliance across all 10 relevant criteria. Performance and bundle size at peak — zero runtime dependencies, tree-shaking annotations throughout, frozen singletons, proper memoization. 302 tests at 100% coverage across statements, branches, functions, and lines. Package integrity verified withpublint --strictand@arethetypeswrong/cli.
Released October 2, 2026. On npm and GitHub
Patch changes
Section titled “Patch changes”-
Security & accessibility hardening — all improvements are backwards-compatible.
Security
Section titled “Security”- ReDoS fix: SVG attribute reading now uses pre-compiled
RegExpobjects instead of runtime-constructed ones — eliminates catastrophic backtracking risk on untrusted SVG markup - Resource leak fix:
withDeadline(SVG/DOM capture) now aborts its internalAbortControlleron task completion, stopping downstream cooperative work from running after the result is already settled - Async source guard: passing an async function (returning a
Promise) as the copy source now fails immediately with a clearinvalid-payloaderror instead of silently breaking the user-gesture window required for clipboard writes
Accessibility (WCAG)
Section titled “Accessibility (WCAG)”- Live region role:
LiveRegionnow usesrole="status"for all politeness levels instead ofrole="alert"for assertive —role="alert"interrupts any sentence currently being spoken, which is inappropriate for copy feedback (WCAG 4.1.3) - Mount-safe announcements: the live region no longer writes its initial message as React children — it writes imperatively via a ref after mount, preventing spurious announcements on SSR hydration and strict-mode double-mounts in JAWS / NVDA
- Non-text payload labels:
CopyField.Valuenow renders a human-readable description for non-text payloads so screen-reader users know what will be copied:html→ “Rich text”,image→ “Image”,json→ “JSON data”,multi→ “Mixed content” - Accessible name guard:
CopyField.Triggernow guarantees a non-emptyaria-labeleven if a customtriggerLabelmessage returns an empty string
Robustness
Section titled “Robustness”- Ghost state eliminated: in
PasteMachine, option-resolution errors now transition directly toerrorwithout briefly passing throughreading— observers no longer see a spurious intermediate state
Performance
Section titled “Performance”useMediaQuerycaching: theMediaQueryListobject is now cached in a ref and reused across renders;matchMedia()is called only when the query string changes, avoiding repeated parse/layout work on every render
- ReDoS fix: SVG attribute reading now uses pre-compiled
Released September 30, 2026. On npm and GitHub
Minor changes
Section titled “Minor changes”-
Paste, copy groups and image capture.
usePaste: read the clipboard with the same honest state machine asuseCopy(idle → reading → read | error). Supports a Paste button (paste()) and keyboard paste with no permission prompt (targetPropsorlistenOnDocument). Strict by default: plain text only unless youacceptmore, images verified from their bytes, SVG never matched by wildcards,maxBytes/maxItemsenforced before decoding. Framework-agnosticcreatePasteMachineandcreateBrowserPasteAdapterinreact-smart-copy/core.<CopyGroup>: only oneuseCopy/CopyFieldinside shows “Copied” at a time. Built oncreateCopyCoordinator(), also usable from vanillacreateCopyMachine({ coordinator }).react-smart-copy/capture(new, opt-in entry, zero dependencies):svgToPngBlob,captureElement,captureSourceandcaptureImageto copy an<svg>or any element as a verified PNG, with pixel limits, timeouts andAbortSignalsupport.- Fix (React 18): a fast
CopyFieldcopy could stay on “Copied” instead of auto-resetting, becauseuseDisplayStatusupdated state during render, which disturbsuseSyncExternalStoreon React 18. - Fix: an image copy is no longer reported as copied when a lax clipboard implementation resolves without reading an image source that failed.
toCopyError(cause, operation)now produces read-specific messages and classifiesAbortError/TimeoutError. NewdescribePasteError().
Heads-up:
CopyErrorTypegainsno-content,too-large,timeoutandaborted. If you keep an exhaustiveRecord<CopyErrorType, string>of translations, add these four keys.
Released September 24, 2026. On npm and GitHub
Initial release
Section titled “Initial release”useCopy: an honest copy state machine (idle → copying → copied | error) with retry, auto-reset and stable function identities.copy()never rejects; it resolves to an outcome you can branch on.CopyField: headless compound component (Root,Label,Value,Trigger) with reveal on hover, focus and touch, a screen-reader announcement, and a stable-width trigger label.- Payloads: plain text, rich HTML with a required plain-text fallback, JSON, and PNG image blobs, as a typed discriminated union.
useDisplayStatus: flicker-free rendering status, so “Copying…” never flashes for a one-frame copy.useRevealOnInteractionandLiveRegionfor building your own accessible copy rows.react-smart-copy/core: framework-agnosticcreateCopyMachineand the browser clipboard adapter.- Typed errors with
describeCopyError(). SSR-safe, zero runtime dependencies, dual ESM and CommonJS builds.