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.data.value.HasValueChangeMode, Serializable

    @Tag("vaadin-rich-text-editor")
    @NpmPackage(value="@vaadin/polymer-legacy-adapter",
                version="23.3.0")
    @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js")
    public class RichTextEditor
    extends GeneratedVaadinRichTextEditor<RichTextEditor,​String>
    implements com.vaadin.flow.component.HasSize, com.vaadin.flow.data.value.HasValueChangeMode, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, com.vaadin.flow.component.CompositionNotifier
    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 Quill Delta format. The setValue and getValue methods use the delta format by default.

    Note that the default use of the delta format has been deprecated in 23.3, and from 24 onwards, the component will use the HTML format as default. To keep using the delta format, use asDelta(), RichTextEditor.AsDelta.getValue() and RichTextEditor.AsDelta.setValue(String).

    To get and set the value in HTML format, use asHtml, RichTextEditor.AsHtml.getValue() and RichTextEditor.AsHtml.setValue(String).

    Author:
    Vaadin Ltd
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  RichTextEditor.RichTextEditorI18n
      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
      RichTextEditor()
      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.
      RichTextEditor​(String initialValue)
      Deprecated.
      Since 23.3, this API is deprecated in order to maintain API consistency.
      RichTextEditor​(String initialValue, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,​String>> listener)
      Deprecated.
      Since 23.3, this API is deprecated in order to maintain API consistency.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addThemeVariants​(RichTextEditorVariant... variants)
      Adds theme variants to the component.
      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.
      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.
      String getHtmlValue()
      The value of the editor presented as an HTML string.
      RichTextEditor.RichTextEditorI18n getI18n()
      Gets the internationalization object previously set for this component.
      String getValue()
      Deprecated.
      since 23.3, from 24 onwards the value will be in HTML format.
      com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()
      void removeThemeVariants​(RichTextEditorVariant... variants)
      Removes theme variants from the component.
      void setI18n​(RichTextEditor.RichTextEditorI18n i18n)
      Sets the internationalization properties for this component.
      void setValue​(String value)
      Deprecated.
      since 23.3, from 24 onwards the value will be in HTML format.
      void setValueChangeMode​(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)  
      • Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

        getSynchronizationRegistration, hasValidValue, setPresentationValue, 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, onAttach, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
      • 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.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 Detail

      • RichTextEditor

        public RichTextEditor()
        Constructs an empty RichTextEditor.
      • RichTextEditor

        @Deprecated
        public RichTextEditor​(String initialValue)
        Deprecated.
        Since 23.3, this API is deprecated in order to maintain API consistency. Use setValue(String) instead.
        Constructs a RichTextEditor with the initial value
        Parameters:
        initialValue - the initial value in Delta format, not null
        See Also:
        AbstractField.setValue(Object)
      • 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)
      • RichTextEditor

        @Deprecated
        public RichTextEditor​(String initialValue,
                              com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<RichTextEditor,​String>> listener)
        Deprecated.
        Since 23.3, this API is deprecated in order to maintain API consistency. Use setValue(String) instead.
        Constructs an empty RichTextEditor with a value change listener and an initial value.
        Parameters:
        initialValue - the initial value
        listener - the value change listener
        See Also:
        AbstractField.setValue(Object), AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
    • Method Detail

      • getI18n

        public RichTextEditor.RichTextEditorI18n 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
      • 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

        @Deprecated
        public void setValue​(String value)
        Deprecated.
        since 23.3, from 24 onwards the value will be in HTML format. Use asDelta() instead.
        Sets the value of this editor. Should be in Delta 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.

        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 Delta format, not null
        See Also:
        asHtml(), RichTextEditor.AsHtml.setValue(String)
      • getValue

        @Deprecated
        public String getValue()
        Deprecated.
        since 23.3, from 24 onwards the value will be in HTML format. Use asDelta() instead.
        Returns the current value of the text editor in Delta 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(), asHtml(), RichTextEditor.AsHtml.getValue()
      • getHtmlValue

        public String getHtmlValue()
        The value of the editor presented as an HTML string.

        This represents the value currently set on the client side. If you have just set the value on the server side using setValue(String) or RichTextEditor.AsHtml.setValue(String) then the value returned from this method will not yet correspond to the newly set value until the next server round trip.

        Returns:
        the sanitized htmlValue property from the web component or null if it is not available.
        See Also:
        getValue(), asHtml(), RichTextEditor.AsHtml.getValue()
      • 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.
        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