Class RichTextEditor
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.CompositionNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,,String>, String> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,,String>, String> com.vaadin.flow.component.InputNotifier,com.vaadin.flow.component.KeyNotifier,com.vaadin.flow.component.shared.HasThemeVariant<RichTextEditorVariant>,com.vaadin.flow.data.value.HasValueChangeMode,Serializable
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 classThe internationalization properties forRichTextEditor.Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object> Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Field Summary
Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyRichTextEditor.RichTextEditor(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor, String>> listener) Constructs an emptyRichTextEditorwith a value change listener. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String> asDelta()Gets an instance ofHasValuefor the editor in the Quill Delta format.com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String> asHtml()Gets an instance ofHasValuefor 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.com.vaadin.flow.data.value.ValueChangeModebooleanisEmpty()Returns whether the value is considered to be empty.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) voidsetColorOptions(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.voidSets the internationalization object for this component.protected voidsetPresentationValue(String newPresentationValue) voidSets the value of this editor in HTML format.voidsetValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode) Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, setModelValue, valueEqualsMethods 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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariantsMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisibleMethods inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
getValueChangeTimeout, setValueChangeTimeoutMethods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListenerMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Constructor Details
-
RichTextEditor
public RichTextEditor()Constructs an emptyRichTextEditor. -
RichTextEditor
public RichTextEditor(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor, String>> listener) Constructs an emptyRichTextEditorwith a value change listener.- Parameters:
listener- the value change listener- See Also:
-
AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
-
-
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
nullif no i18n object has been set
-
setI18n
Sets the internationalization object for this component.- Parameters:
i18n- the i18n object, notnull
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
getValueChangeMode
public com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()The default value is
ValueChangeMode.ON_CHANGE.- Specified by:
getValueChangeModein interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
setValueChangeMode
public void setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode) - Specified by:
setValueChangeModein interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
setValue
Sets the value of this editor in HTML format. If the new value is not equal togetValue(), fires a value change event. ThrowsNullPointerException, if the value is null.Note:
Binderwill take care of thenullconversion 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:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,String>, String> - Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<RichTextEditor,String> - Parameters:
value- the new value in HTML format, notnull- See Also:
-
asDelta()HasValue.setValue(String)
-
setPresentationValue
- Overrides:
setPresentationValuein classcom.vaadin.flow.component.AbstractSinglePropertyField<RichTextEditor,String>
-
isEmpty
public boolean isEmpty()Returns whether the value is considered to be empty.As the editor's HTML value always contains a minimal markup, this does not check if the value is an empty string. Instead, this method considers the value to not be empty if the user has added some content, which can be:
- Text, whitespaces or line breaks
- An image
Note that a single empty HTML tag, such as a heading, blockquote, etc., is not considered as content.
- Specified by:
isEmptyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,String>, String> - Overrides:
isEmptyin classcom.vaadin.flow.component.AbstractField<RichTextEditor,String> - Returns:
trueif considered empty;falseif not
-
getValue
Returns the current value of the text editor in HTML format. By default, the empty editor will return an empty string.- Specified by:
getValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,String>, String> - Overrides:
getValuein classcom.vaadin.flow.component.AbstractField<RichTextEditor,String> - Returns:
- the current value.
- See Also:
-
asDelta()HasValue.getValue()
-
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
nullby 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 null- Since:
- 24.5
-
asHtml
public com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String> asHtml()Gets an instance ofHasValuefor 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, andRichTextEditorcan 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
public com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String> asDelta()Gets an instance ofHasValuefor the editor in the Quill Delta format. Can be used for binding the value withBinder.- Returns:
- an instance of
HasValue
-