Class ClipboardContent
java.lang.Object
com.vaadin.flow.component.clipboard.ClipboardContent
- All Implemented Interfaces:
Serializable
Multi-format payload for
ClipboardBinding.write(com.vaadin.flow.component.clipboard.ClipboardContent). Any combination of
text/plain, text/html and an image source can be set; each
accessor returns null when the corresponding slot is empty.
Use the static factory:
Clipboard.onClick(button).write(ClipboardContent.create().text("Hello")
.html("<b>Hello</b>").image(previewImage));
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClipboardContentcreate()Creates a new empty content builder.@Nullable Action.Input<String> @Nullable Action.Input<?> @Nullable Action.Input<String> Sets the HTML to be written to the clipboard.Sets theimage/pngpayload to a PNG re-encoding of the given component's root<img>element, produced on the client when the trigger fires.<C extends Component & HasValue<?,String>>
ClipboardContenttext(C source) Sets the plain text to be written to the clipboard, taken from thevalueproperty of the given component (typically an input field).Sets the plain text to be written to the clipboard.
-
Method Details
-
create
Creates a new empty content builder.- Returns:
- a new builder
-
text
Sets the plain text to be written to the clipboard.- Parameters:
literal- the value, notnull- Returns:
- this builder
-
text
Sets the plain text to be written to the clipboard, taken from thevalueproperty of the given component (typically an input field). The value is read on the client when the trigger fires.- Type Parameters:
C- component type implementingHasValue<?, String>- Parameters:
source- the component whosevalueproperty should be read, notnull- Returns:
- this builder
-
html
Sets the HTML to be written to the clipboard.- Parameters:
literal- the value, notnull- Returns:
- this builder
-
image
Sets theimage/pngpayload to a PNG re-encoding of the given component's root<img>element, produced on the client when the trigger fires. The source can be any rasterisable image (image/png,image/jpeg,image/svg+xml, ...) with intrinsic dimensions; cross-origin sources needcrossorigin="anonymous"on the<img>plus matching CORS headers, otherwise the canvas is tainted and the write fails.- Parameters:
source- the component whose root<img>should be copied, notnull- Returns:
- this builder
-
getTextInput
- Returns:
- the text input, or
nullif no text was set
-
getHtmlInput
- Returns:
- the html input, or
nullif no html was set
-
getImageInput
- Returns:
- the image input, or
nullif no image was set
-