copyFromUrl
Copies a document fetched from a URL onto the clipboard when its host button is pressed.
import { copyFromUrl } from "@sdxc/ui/docs";Usage
Fetches href with Accept: text/markdown, text/plain on every press and writes the
body to the clipboard, then dispatches a ui:copy CopyEvent. A failed fetch or
write writes failedLabel into the button's [role="status"] element for four seconds.
Signature
copyFromUrl(href: string, failedLabel?: string): MixinDescriptor<HTMLButtonElement>Returns a mixin descriptor for the copy button's mix prop.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
href | string | Yes | URL of the text to copy, such as the page's .md twin. |
failedLabel | string | No | What a screen reader announces when the copy fails. |
Examples
<button type="button" mix={[copyFromUrl("/docs/install.md", t("copyFailed")), copyFeedback(t("copied"))]}>
{t("copyPage")}
<span role="status" mix={[visuallyHidden()]} />
</button>