Class RichTextEditor
- All Implemented Interfaces:
AttachNotifier
,CompositionNotifier
,DetachNotifier
,HasElement
,HasEnabled
,HasSize
,HasStyle
,HasTheme
,HasValue<AbstractField.ComponentValueChangeEvent<RichTextEditor,
,String>, String> HasValueAndElement<AbstractField.ComponentValueChangeEvent<RichTextEditor,
,String>, String> InputNotifier
,KeyNotifier
,HasThemeVariant<RichTextEditorVariant>
,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
Modifier and TypeClassDescriptionstatic class
The internationalization properties forRichTextEditor
.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
ConstructorDescriptionConstructs an emptyRichTextEditor
.RichTextEditor
(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<RichTextEditor, String>> listener) Constructs an emptyRichTextEditor
with a value change listener. -
Method Summary
Modifier and TypeMethodDescriptionasDelta()
Gets an instance ofHasValue
for the editor in the Quill Delta format.asHtml()
Gets an instance ofHasValue
for the editor in the HTML format.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
Sets the internationalization properties 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 emptyRichTextEditor
. -
RichTextEditor
public RichTextEditor(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<RichTextEditor, String>> listener) Constructs an emptyRichTextEditor
with a value change listener.- Parameters:
listener
- the value change listener- See Also:
-
-
Method Details
-
getI18n
Gets the internationalization object previously set for this component.Note: updating the object content that is gotten from this method will not update the lang on the component if not set back using
setI18n(RichTextEditorI18n)
- Returns:
- the i18n object. It will be
null
, If the i18n properties weren't set.
-
setI18n
Sets the internationalization properties for this component.- Parameters:
i18n
- the internationalized properties, notnull
-
onAttach
Description copied from class:Component
Called when the component is attached to a UI.The default implementation does nothing.
This method is invoked before the
AttachEvent
is fired for the component. -
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 togetValue()
, 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:
-
asHtml
Gets an instance ofHasValue
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 ofHasValue
for the editor in the Quill Delta format. Can be used for binding the value withBinder
.- Returns:
- an instance of
HasValue
-