Skip to content

Clipboard

Bindings for @solid-primitives/clipboard, which wraps the browser's clipboard API.

ClipboardItem

type ClipboardItem =
    member presentationStyle: PresentationStyle // Attachment | Inline | Unspecified
    member types: string[]
    member getType(``type``: string): JS.Promise<obj>

let newClipboardItem(``type``: string, data: obj): ClipboardItem

getType resolves to the item's data for one MIME type, and rejects if the item has none.

readClipboard and writeClipboard

let readClipboard(): JS.Promise<ClipboardItem[]>
let writeClipboard(input: string | ClipboardItem[]): unit
let writeClipboard'(input: string | ClipboardItem[]): JS.Promise<unit>

Writing is asynchronous. Use the version with an apostrophe when you need the returned Promise.

createClipboard

let createClipboard(?data: Accessor<string | ClipboardItem[]>, ?deferInitial: bool): ClipboardResult

type ClipboardResult =
    member resourceItems: SolidResource<ClipboardItem[]>
    member refetch: unit -> unit
    member write: string -> JS.Promise<unit>

Write with write or through the data signal; reads come back as the resource. createClipboard' returns the same three values as a tuple.

Edit this page