Table of Contents

Class ClipboardItem

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The ClipboardItem interface of the Clipboard API represents a single item format, used when reading or writing clipboard data using Read(ClipboardUnsanitizedFormats) and Write(List<ClipboardItem>) respectively.

[Value("ClipboardItem")]
public class ClipboardItem
Inheritance
ClipboardItem
Inherited Members

Remarks

The ClipboardItem interface enables developers to use a single type to represent a range of different data formats.

NOTE

The read() and write() methods can be used to work with text strings and arbitrary data items represented by Blob instances. However, if you are solely working with text, it is more convenient to use the ReadText() and WriteText(string) methods.

-Clipboard API
-Image support for Async Clipboard article

See also on MDN

Constructors

ClipboardItem()

public ClipboardItem()

ClipboardItem(Dictionary<string, Task<string>>, ClipboardItemOptions)

The ClipboardItem() constructor creates a new ClipboardItem object, which represents data to be stored or retrieved via the Clipboard API Write(List<ClipboardItem>) and Read(ClipboardUnsanitizedFormats) methods, respectively.

public ClipboardItem(Dictionary<string, Task<string>> items, ClipboardItemOptions options = null)

Parameters

items Dictionary<string, Task<string>>
options ClipboardItemOptions

Remarks

NOTE

The read() and write() methods can be used to work with text strings and arbitrary data items represented by Blob instances. However, if you are solely working with text, it is more convenient to use the ReadText() and WriteText(string) methods.

NOTE

Image format support varies by browser. See the browser compatibility table for the Clipboard interface.

-Clipboard API
-Image support for Async Clipboard article

See also on MDN

Properties

PresentationStyle

The read-only presentationStyle property of the ClipboardItem interface returns a string indicating how an item should be presented.

[Value("presentationStyle")]
public PresentationStyle PresentationStyle { get; }

Property Value

PresentationStyle

One of either &quot;unspecified&quot;, &quot;inline&quot; or &quot;attachment&quot;.

Remarks

For example, in some contexts an image might be displayed inline, while in others it might be represented as an attachment.

-Clipboard API
-Image support for Async Clipboard article

See also on MDN

Types

The read-only types property of the ClipboardItem interface returns an {{jsxref("Array")}} of {{Glossary("MIME type", 'MIME types')}} available within the ClipboardItem.

[Value("types")]
public string[] Types { get; }

Property Value

string[]

An Array of available {{Glossary("MIME type", 'MIME types')}}.

Remarks

Methods

GetType(string)

The getType() method of the ClipboardItem interface returns a {{jsxref("Promise")}} that resolves with a Blob of the requested {{Glossary("MIME type")}} or an error if the MIME type is not found.

[Value("getType")]
public Task<Blob> GetType(string type)

Parameters

type string

Returns

Task<Blob>

A {{jsxref("Promise")}} that resolves with a Blob object.

Remarks

Supports(string)

The supports() static method of the ClipboardItem interface returns true if the given MIME type is supported by the clipboard, and false otherwise.

[Value("supports")]
public static bool Supports(string type)

Parameters

type string

Returns

bool

true if the given MIME type is supported by the clipboard, false otherwise.

Remarks

Note that the Clipboard API mandates support for plain text, HTML and PNG files.
The supports() method will always return true for these MIME types, so testing them is unnecessary.

-Clipboard API
-Image support for Async Clipboard article

See also on MDN