Interface Clipboard.PasteJs

All Superinterfaces:
Serializable
Enclosing class:
Clipboard

@JsDefinition public static interface Clipboard.PasteJs extends Serializable
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 Type
    Method
    Description
    A filter that passes a paste only when it does not target a form field: an input, a textarea or an editable element.
    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 a DataTransfer, and || null turns the empty string, which the browser returns for a missing MIME type, into null.
      Parameters:
      mimeType - the MIME type to read, such as text/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: an input, a textarea or an editable element. It walks event.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