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.HasLabel, 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.1.3")
    @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, com.vaadin.flow.component.HasLabel
    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 Delta format. The setValue and getValue methods deal with the default Delta format, but it is also possible to get and set the value as an HTML string using rte.asHtml().getValue(), rte.asHtml().setValue() and getHtmlValue().

    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)
      Constructs a RichTextEditor with the initial value
      RichTextEditor​(String initialValue, 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 and an initial value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.vaadin.flow.component.HasValue<com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,​String> asHtml()
      Gets an instance of HasValue for binding the html value of the editor with Binder.
      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()
      Returns the current value of the text editor in Delta format.
      com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()
      void setI18n​(RichTextEditor.RichTextEditorI18n i18n)
      Sets the internationalization properties for this component.
      void setValue​(String value)
      Sets the value of this editor.
      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, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, 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.HasLabel

        getLabel, setLabel
      • 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

        public RichTextEditor​(String initialValue)
        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

        public RichTextEditor​(String initialValue,
                              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 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

        public void setValue​(String value)
        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

        public String getValue()
        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 binding the html value of the editor with Binder.
        Returns:
        an instance of HasValue