Skip to content

Releases

v1.31.3

Choose a tag to compare

@suprabhat02 suprabhat02 released this 20 Nov 18:53
e07493f

Patch Changes

  • 779454c: Long numbered lists no longer freeze the page. The plain text written alongside rich HTML (by pasteToRich, prepareRich and react-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 a start or value that is not a number is ignored, where it wrote "NaN.".

v1.31.2

Choose a tag to compare

@suprabhat02 suprabhat02 released this 13 Nov 13:06
5b3295b

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

Choose a tag to compare

@suprabhat02 suprabhat02 released this 11 Nov 21:53
9fead23

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> to http://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

Choose a tag to compare

@suprabhat02 suprabhat02 released this 10 Nov 15:04
ca4ed0c

Minor Changes

  • e15dbb2: react-smart-copy/compat: a drop-in replacement for react-copy-to-clipboard. Change the import and keep the JSX: the same props, the same single child cloned with your other props, its own onClick kept, and onCopy(text, result), now with a third argument saying why a copy failed. On the way it drops the blocking window.prompt on failure, writes plain text through the Clipboard API (no styling carried into the paste), and with format: "text/html" writes the HTML and its plain text, where the original wrote only the HTML. onCopy runs 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

Choose a tag to compare

@suprabhat02 suprabhat02 released this 10 Nov 09:11
bed9bea

Minor Changes

  • 58a2cf0: Copy a page as Markdown, cleanly. htmlToMarkdown leaves 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 new ignore option (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

Choose a tag to compare

@suprabhat02 suprabhat02 released this 09 Nov 11:36
8d68fee

Patch Changes

  • df11b47: Line breaks marked aria-hidden are kept. Slack marks every line break that way, and pasting a Slack message with pasteToRich (or copying one with prepareRich or codeFromElement) joined its lines: …/runs/42npm run build. aria-hidden keeps a decoration from screen readers; on a <br> it hides nothing on screen, so the lines now stay apart. Other aria-hidden content is still left out.

v1.29.2

Choose a tag to compare

@suprabhat02 suprabhat02 released this 08 Nov 16:02
b2dca09

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_page came out as https://example.com/my\_page, a link to the wrong address. Plain http(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 °C and = a stay 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. The markdown entry grows by about 0.5 kB.
  • d787296: CopyField and PasteField now use the clipboard of the window they are rendered in. In a pop-out window (window.open plus 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 in copyOptions or pasteOptions still wins. The docs show how to do the same with useCopy and usePaste. Also tested: drag-to-copy registered on a web component's host works for drags that start inside its shadow root.

v1.29.1

Choose a tag to compare

@suprabhat02 suprabhat02 released this 08 Nov 14:20
627b930

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. useCopyInterceptor grows by about 0.25 kB.

v1.29.0

Choose a tag to compare

@suprabhat02 suprabhat02 released this 08 Nov 13:32
b3a3665

Minor Changes

  • fc9c4ac: Copy text the server makes after the click. copy() (and CopyField's value) 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 first await; checked in Chromium, Firefox and WebKit. The source receives the copy's AbortSignal, so reset() 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 an invalid-payload error with the thrown value as its cause; 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.payload is null, so its type is now CopyPayload | null. Code that reads state.payload during copying needs a null check; synchronous sources behave exactly as before. Custom adapters can implement the new optional writeDeferred(text, context) to start their write before the text arrives; without it, the machine waits for the text and calls write.

    useCopy grows by about 0.2 kB.

v1.28.0

Choose a tag to compare

@suprabhat02 suprabhat02 released this 08 Nov 08:33
c89ab94

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 with permission-denied. When that happens, the default adapter now copies text, HTML and JSON through the browser's copy command 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 for useCopy.