com.vaadin.flow.component.richtexteditor.
Class RichTextEditor
All Implemented Interfaces:
AttachNotifier
, CompositionNotifier
, DetachNotifier
, HasElement
, HasEnabled
, HasSize
, HasStyle
, HasTheme
, HasValue<AbstractField.ComponentValueChangeEvent<RichTextEditor,
, HasValueAndElement<AbstractField.ComponentValueChangeEvent<RichTextEditor,
, InputNotifier
, KeyNotifier
, HasThemeVariant<RichTextEditorVariant>
, HasValueChangeMode
, Serializable
Rich Text Editor is an input field for entering rich text. It allows you to format and style your text using boldface, italics, headings, lists, images, links etc.
The value of the rich text editor is in the HTML format. The
setValue
and getValue
methods
use the HTML format by default.
To get and set the value in the
Quill Delta format, use
asDelta()
, HasValue.getValue()
and
HasValue.setValue(String)
.
Author:
Vaadin Ltd
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The internationalization properties for
RichTextEditor
.Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
AbstractField.ComponentValueChangeEvent<C extends Component,
V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
-
Field Summary
Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty
RichTextEditor
.RichTextEditor
(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<RichTextEditor, String>> listener) Constructs an empty
RichTextEditor
with a value change listener. -
Method Summary
Modifier and TypeMethodDescriptionasDelta()
Gets an instance of
HasValue
for the editor in the Quill Delta format.asHtml()
Gets an instance of
HasValue
for the editor in the HTML format.Gets an unmodifiable list of colors in HEX format used by the text color picker and background color picker controls of the text editor.
Deprecated.
since v24 the RichTextEditor uses the HTML value by default.getI18n()
Gets the internationalization object previously set for this component.
getValue()
Returns the current value of the text editor in HTML format.
Gets current value change mode of the component.
protected void
onAttach
(AttachEvent attachEvent) Called when the component is attached to a UI.
void
setColorOptions
(List<String> colorOptions) Sets the list of colors in HEX format to use by the text color picker and background color picker controls of the text editor.
void
Sets the internationalization object for this component.
protected void
setPresentationValue
(String newPresentationValue) Updates the presentation of this field to display the provided value.
void
Sets the value of this editor in HTML format.
void
setValueChangeMode
(ValueChangeMode valueChangeMode) Sets new value change mode for the component.
Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setSynchronizedEvent
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, isEmpty, setModelValue, valueEquals
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
Methods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValue
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
Methods inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
getValueChangeTimeout, setValueChangeTimeout
Methods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListener
Methods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Constructor Details
-
RichTextEditor
public RichTextEditor()Constructs an empty
RichTextEditor
. -
RichTextEditor
public RichTextEditor(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<RichTextEditor, String>> listener) Constructs an empty
RichTextEditor
with a value change listener.Parameters:
listener
- the value change listenerSee Also:
-
-
Method Details
-
getI18n
Gets the internationalization object previously set for this component.
NOTE: Updating the instance that is returned from this method will not update the component if not set again using
setI18n(RichTextEditorI18n)
Returns:
the i18n object or
null
if no i18n object has been set -
setI18n
Sets the internationalization object for this component.
Parameters:
i18n
- the i18n object, notnull
-
onAttach
Description copied from class:
Component
Called when the component is attached to a UI.
This method is invoked before the
Make sure to callAttachEvent
is fired for the component.super.onAttach
when overriding this method. -
getValueChangeMode
Gets current value change mode of the component.
The default value is
ValueChangeMode.ON_CHANGE
.Specified by:
getValueChangeMode
in interfaceHasValueChangeMode
Returns:
current value change mode of the component, or
null
if the value is not synchronized -
setValueChangeMode
Description copied from interface:
HasValueChangeMode
Sets new value change mode for the component.
Specified by:
setValueChangeMode
in interfaceHasValueChangeMode
Parameters:
valueChangeMode
- new value change mode, ornull
to disable the value synchronization -
setValue
Sets the value of this editor in HTML format. If the new value is not equal to
getValue()
, fires a value change event. ThrowsNullPointerException
, if the value is null.Note:
Binder
will take care of thenull
conversion when integrates with the editor, as long as no new converter is defined.Since v24, this method only accepts values in the HTML format, whereas in v23 and earlier this method would accept values in the Delta format. In order to prevent data corruption, passing a value that starts with either
[
or{
will now throw anIllegalArgumentException
, as it might indicate that the value is in the Delta format. In order to keep using the Delta format, useasDelta()
, which allows setting, retrieving, and binding the value using Binder, in the Delta format. In order to pass an HTML value starting with either characters, either wrap the value in a valid HTML tag, such as<p>
, or useasHtml()
which does not include this check.Specified by:
setValue
in interfaceHasValue<AbstractField.ComponentValueChangeEvent<RichTextEditor,
String>, String> Overrides:
setValue
in classAbstractField<RichTextEditor,
String> Parameters:
value
- the new value in HTML format, notnull
See Also:
-
setPresentationValue
Description copied from class:
AbstractField
Updates the presentation of this field to display the provided value. Subclasses should override this method to show the value to the user. This is typically done by setting an element property or by applying changes to child components.
If
AbstractField.setModelValue(Object, boolean)
is called from within this method, the value of the last invocation will be used as the model value instead of the value passed to this method. In this caseAbstractField.setPresentationValue(Object)
will not be called again. Changing the provided value might be useful if the provided value is sanitized.See
AbstractField
for an overall description on the difference between model values and presentation values.Overrides:
setPresentationValue
in classAbstractSinglePropertyField<RichTextEditor,
String> Parameters:
newPresentationValue
- the new value to show -
getValue
Returns the current value of the text editor in HTML format. By default, the empty editor will return an empty string.
Specified by:
getValue
in interfaceHasValue<AbstractField.ComponentValueChangeEvent<RichTextEditor,
String>, String> Overrides:
getValue
in classAbstractField<RichTextEditor,
String> Returns:
the current value.
See Also:
-
getHtmlValue
Deprecated.since v24 the RichTextEditor uses the HTML value by default. UsegetValue()
instead.The value of the editor in HTML format.
Returns:
the editor value in HTML format
See Also:
-
getColorOptions
Gets an unmodifiable list of colors in HEX format used by the text color picker and background color picker controls of the text editor.
Returns
null
by default, which means the web component shows a default color palette.Returns:
an unmodifiable list of colors options
Since:
24.5
-
setColorOptions
Sets the list of colors in HEX format to use by the text color picker and background color picker controls of the text editor.
Parameters:
colorOptions
- the list of colors to set, not nullSince:
24.5
-
asHtml
Gets an instance of
HasValue
for the editor in the HTML format. Can be used for binding the value withBinder
.Note that since v24, the RichTextEditor uses the HTML value by default. Instead of using this wrapper,
getValue()
andsetValue(String)
can be used directly, andRichTextEditor
can be used for binding the HTML value using Binder. This method is not intended to be deprecated as it keeps the legacy behavior that allows passing values starting with either[
or{
, which is not allowed when usingsetValue(String)
.Returns:
an instance of
HasValue
-
asDelta
Gets an instance of
HasValue
for the editor in the Quill Delta format. Can be used for binding the value withBinder
.Returns:
an instance of
HasValue
-