Class ClipboardAccess
Index
Constructors
Methods
Constructors
constructor
- new
Clipboard (): ClipboardAccessAccess Returns ClipboardAccess
Methods
Static
readText
- read
Text (activeWindow?): Promise<string> Uses
navigator.clipboard
if available to read text from the clipboard.Note: Always returns
undefined
whennavigator.clipboard
is not available or the clipboard contains the empty string.Parameters
Optional
activeWindow: WindowOptional active current window.
Returns Promise<string>
The current clipboard text or undefined.
Static
writeText
- write
Text (text, activeWindow?): Promise<boolean> Uses
navigator.clipboard
if available then falls back todocument.execCommand('copy')
if available to copy the given text to the clipboard.Parameters
- text: string
Text to copy to the browser clipboard.
Optional
activeWindow: WindowOptional active current window.
Returns Promise<boolean>
Copy successful.
- text: string
Provides access to the Clipboard API for reading / writing text strings. This requires a secure context.
Note:
writeText
will attempt to use the olderexecCommand
if available whennavigator.clipboard
is not available.