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()andwrite()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.
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
itemsDictionary<string, Task<string>>optionsClipboardItemOptions
Remarks
NOTE
The
read()andwrite()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
Clipboardinterface.
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
"unspecified","inline"or"attachment".
Remarks
For example, in some contexts an image might be displayed inline, while in others it might be represented as an attachment.
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
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
typestring
Returns
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
typestring
Returns
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.