Repository navigation
Releases
v1.31.3
Patch Changes
-
779454c: 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.".
v1.31.2
Patch Changes
- a21644d: 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.
v1.31.1
Patch Changes
- 8e4b50c: 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.
v1.31.0
Minor Changes
- e15dbb2:
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.
v1.30.0
Minor Changes
- 58a2cf0: 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.
v1.29.3
Patch Changes
- df11b47: 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.
v1.29.2
Patch Changes
- 845d335: 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. - d787296:
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.
v1.29.1
Patch Changes
- 2c6e1c5: 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.
v1.29.0
Minor Changes
-
fc9c4ac: 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.
v1.28.0
Minor Changes
- 8d10299: 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.