Interface Clipboard.PasteJs
- All Superinterfaces:
Serializable
- Enclosing class:
Clipboard
How pastes are handled in the browser, as snippets for
JsSnippets.of(Class).
For internal use only. May be renamed or removed in a future release.
-
Method Summary
Modifier and TypeMethodDescriptionA filter that passes a paste only when it does not target a form field: aninput, atextareaor an editable element.readClipboardData(String mimeType) Event data that reads the pasted data of a MIME type.uploadPastedFiles(String urlAttribute) An initializer that uploads the files of each paste on the element to the URL in the given attribute of the element, and returns the function that stops listening.
-
Method Details
-
readClipboardData
@JsExpression("return event.clipboardData?.getData($0) || null;") DomEventData<String> readClipboardData(String mimeType) Event data that reads the pasted data of a MIME type. Optional chaining handles synthetic events without aDataTransfer, and|| nullturns the empty string, which the browser returns for a missing MIME type, intonull.- Parameters:
mimeType- the MIME type to read, such astext/plain- Returns:
- the event data
-
isOutsideEditableField
@JsExpression("return !event.composedPath().some(e => e.tagName\n && (e.tagName === \'INPUT\' || e.tagName === \'TEXTAREA\'\n || e.isContentEditable === true));") DomEventFilter isOutsideEditableField()A filter that passes a paste only when it does not target a form field: aninput, atextareaor an editable element. It walksevent.composedPath(), so it also finds a field inside the open shadow DOM of a web component.- Returns:
- the filter
-
uploadPastedFiles
@JsExpression("const upload = (event) => window.Vaadin.Flow.clipboard\n .uploadPastedFiles(event, this, $0);\nthis.addEventListener(\'paste\', upload);\nreturn () => this.removeEventListener(\'paste\', upload);") JsFunction uploadPastedFiles(String urlAttribute) An initializer that uploads the files of each paste on the element to the URL in the given attribute of the element, and returns the function that stops listening.- Parameters:
urlAttribute- the name of the attribute that holds the upload URL- Returns:
- the initializer function
-