Class RichTextEditor

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,T>
com.vaadin.flow.component.AbstractSinglePropertyField<RichTextEditor,String>
com.vaadin.flow.component.richtexteditor.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, HasThemeVariant<RichTextEditorVariant>, com.vaadin.flow.data.value.HasValueChangeMode, Serializable

@Tag("vaadin-rich-text-editor") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.2.4") @NpmPackage(value="@vaadin/rich-text-editor",version="24.2.4") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/rich-text-editor/src/vaadin-rich-text-editor.js") public class RichTextEditor extends com.vaadin.flow.component.AbstractSinglePropertyField<RichTextEditor,String> implements com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.data.value.HasValueChangeMode, HasThemeVariant<RichTextEditorVariant>
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 Classes
    Modifier and Type
    Class
    Description
    static class 
    The internationalization properties for RichTextEditor.

    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

    Constructors
    Constructor
    Description
    Constructs an empty RichTextEditor.
    RichTextEditor(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,String>> listener)
    Constructs an empty RichTextEditor with a value change listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String>
    Gets an instance of HasValue for the editor in the Quill Delta format.
    com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String>
    Gets an instance of HasValue for the editor in the HTML format.
    Deprecated.
    since v24 the RichTextEditor uses the HTML value by default.
    Gets the internationalization object previously set for this component.
    Returns the current value of the text editor in HTML format.
    com.vaadin.flow.data.value.ValueChangeMode
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    void
    Sets the internationalization properties for this component.
    protected void
    setPresentationValue(String newPresentationValue)
     
    void
    Sets the value of this editor in HTML format.
    void
    setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
     

    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(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,String>> listener)
      Constructs an empty RichTextEditor with 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 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

      public void setI18n(RichTextEditor.RichTextEditorI18n i18n)
      Sets the internationalization properties for this component.
      Parameters:
      i18n - the internationalized properties, not null
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • getValueChangeMode

      public com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()

      The default value is ValueChangeMode.ON_CHANGE.

      Specified by:
      getValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
    • setValueChangeMode

      public void setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
      Specified by:
      setValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
    • setValue

      public void setValue(String value)
      Sets the value of this editor in HTML format. If the new value is not equal to getValue(), fires a value change event. Throws NullPointerException, if the value is null.

      Note: Binder will take care of the null 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 an IllegalArgumentException, as it might indicate that the value is in the Delta format. In order to keep using the Delta format, use asDelta(), 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 use asHtml() which does not include this check.

      Specified by:
      setValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,String>,String>
      Overrides:
      setValue in class com.vaadin.flow.component.AbstractField<RichTextEditor,String>
      Parameters:
      value - the new value in HTML format, not null
      See Also:
    • setPresentationValue

      protected void setPresentationValue(String newPresentationValue)
      Overrides:
      setPresentationValue in class com.vaadin.flow.component.AbstractSinglePropertyField<RichTextEditor,String>
    • getValue

      public String 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 interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,String>,String>
      Overrides:
      getValue in class com.vaadin.flow.component.AbstractField<RichTextEditor,String>
      Returns:
      the current value.
      See Also:
    • getHtmlValue

      @Deprecated public String getHtmlValue()
      Deprecated.
      since v24 the RichTextEditor uses the HTML value by default. Use getValue() instead.
      The value of the editor in HTML format.
      Returns:
      the editor value in HTML format
      See Also:
    • asHtml

      public com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String> asHtml()
      Gets an instance of HasValue for the editor in the HTML format. Can be used for binding the value with Binder.

      Note that since v24, the RichTextEditor uses the HTML value by default. Instead of using this wrapper, getValue() and setValue(String) can be used directly, and RichTextEditor 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 using setValue(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 of HasValue for the editor in the Quill Delta format. Can be used for binding the value with Binder.
      Returns:
      an instance of HasValue