Skip to main content
Partas

Clipboard

Designed to make reading and writing to the MDN clipboard API easy.

ClipboardItem

type ClipboardItem = interface

A interface to the MDN clipboard API ClipboardItem interface.

See newClipboardItem for creating a new ClipboardItem.

member presentationStyle: PresentationStyle with get

See PresentationStyle.

member types: string[] with get
member getType(``type``: string): JS.Promise<obj>

The getType method retrieves the data of a specific MIME type from the ClipboardItem. It returns a promise that resolves to the data object. Errors if the MIME type is not found.

PresentationStyle

type PresentationStyle = StringEnum
| Attachment
| Inline
| Unspecified

newClipboardItem

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

newClipboardItem is a wrapper method around creating new ClipboardItem objects. It takes a MIME type and data object, returning a new ClipboardItem.

readClipboard

let readClipboard(): JS.Promise<ClipboardItem[]>

Async read from the clipboard, returning a promise that resolves to an array of ClipboardItem.

writeClipboard

let writeClipboard(input: string): unit
let writeClipboard(input: ClipboardItem[]): unit

Writes to the clipboard.

See newClipboardItem for creating a new ClipboardItem.

note

The writing method is asynchronous, use the apostraphised version of the method to interact with the returned Promise.

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

Writes to the clipboard asynchronously.

createClipboard

The result of the createClipboard function can either be destructured with F# features using the apostraphe version or used with named access via the ClipboardResult interface.

let createClipboard(
?data: Accessor<string | ClipboardItem[]>,
?deferInitial: bool
): ClipboardResult
Apostraphised Version
let createClipboard'(
?data: Accessor<string | ClipboardItem[]>,
?deferInitial: bool
):
SolidResource<CliboardItem[]> *
(unit -> unit) *
(string -> JS.Promise<unit>)

Provides full facilities for reading and writing to the clipboard.

Can write to the clipboard using either the returned write method of the ClipboardResult, or through the input signal. It wraps the clipboard async API with a Solid resource to make pulling from the clipboard easy.

ClipboardResult

type ClipboardResult = interface

A result type for the createClipboard function, which provides named access to the returned array values.

member resourceItems: SolidResource<ClipboardItem[]>
member refetch: (unit -> unit)
member write: (string -> JS.Promise<unit>)

Last updated: 7/13/25, 12:35 PM

PartasBuilt using the Partas.SolidStart SolidBase template
Community
githubdiscord