com.vaadin.ui.

Class RichTextArea

    • Constructor Detail

      • RichTextArea

        public RichTextArea()

        Constructs an empty RichTextArea with no caption.

      • RichTextArea

        public RichTextArea​(String caption)

        Constructs an empty RichTextArea with the given caption.

        Parameters:

        caption - the caption for the editor.

      • RichTextArea

        public RichTextArea​(String caption,
                            String value)

        Constructs a new RichTextArea with the given caption and initial text contents.

        Parameters:

        caption - the caption for the editor.

        value - the initial text content of the editor, not null

      • RichTextArea

        public RichTextArea​(HasValue.ValueChangeListener<String> valueChangeListener)

        Constructs a new RichTextArea with a value change listener.

        The listener is called when the value of this TextField is changed either by the user or programmatically.

        Parameters:

        valueChangeListener - the value change listener, not null

        Since:

        8.0

      • RichTextArea

        public RichTextArea​(String caption,
                            HasValue.ValueChangeListener<String> valueChangeListener)

        Constructs a new RichTextArea with the given caption and a value change listener.

        The listener is called when the value of this TextField is changed either by the user or programmatically.

        Parameters:

        caption - the caption for the field

        valueChangeListener - the value change listener, not null

        Since:

        8.0

      • RichTextArea

        public RichTextArea​(String caption,
                            String value,
                            HasValue.ValueChangeListener<String> valueChangeListener)

        Constructs a new RichTextArea with the given caption, initial text contents and a value change listener.

        The listener is called when the value of this RichTextArea is changed either by the user or programmatically.

        Parameters:

        caption - the caption for the field

        value - the value for the field, not null

        valueChangeListener - the value change listener, not null

        Since:

        8.0

    • Method Detail

      • readDesign

        public void readDesign​(org.jsoup.nodes.Element design,
                               DesignContext designContext)

        Description copied from interface: Component

        Reads the component state from the given design.

        The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.

        It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.

        This method must not modify the design.

        Specified by:

        readDesign in interface Component

        Overrides:

        readDesign in class AbstractField<String>

        Parameters:

        design - The element to obtain the state from

        designContext - The DesignContext instance used for parsing the design

      • writeDesign

        public void writeDesign​(org.jsoup.nodes.Element design,
                                DesignContext designContext)

        Description copied from interface: Component

        Writes the component state to the given design.

        The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.

        This method must not modify the component state.

        Specified by:

        writeDesign in interface Component

        Overrides:

        writeDesign in class AbstractField<String>

        Parameters:

        design - The element to write the component state to. Any previous attributes or child nodes are not cleared.

        designContext - The DesignContext instance used for writing the design

      • getState

        protected RichTextAreaState getState()

        Description copied from class: AbstractComponent

        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

        Overrides:

        getState in class AbstractField<String>

        Returns:

        updated component shared state

      • getValue

        public String getValue()

        Description copied from interface: HasValue

        Returns the current value of this object.

        Implementation note: the implementing class should document whether null values may be returned or not.

        Specified by:

        getValue in interface HasValue<String>

        Returns:

        the current value

      • doSetValue

        protected void doSetValue​(String value)

        Description copied from class: AbstractField

        Sets the value of this field. May do sanitization or throw IllegalArgumentException if the value is invalid. Typically saves the value to shared state.

        Specified by:

        doSetValue in class AbstractField<String>

        Parameters:

        value - the new value of the field

      • selectAll

        public void selectAll()

        Selects all text in the rich text area. As a side effect, focuses the rich text area.

        Since:

        6.5

      • addSnippet

        public void addSnippet​(String snippet)

        Add a predefined content snippet to the menu. HTML formatting is allowed. Drop-down menu is visible after the first snippet is added. The title of the snippet is automatically generated from the first 20 characters of the snippet.

        Parameters:

        snippet - snippet text, can be HTML formatted

        Since:

        8.16

      • addSnippet

        public void addSnippet​(String title,
                               String snippet)

        Add a predefined content snippet to the menu. HTML formatting is allowed in the snippet text. Drop down menu is visible after the first snippet is added. This method allows assigning a custom title to the added snippet.

        Parameters:

        title - string to display in drop-down menu

        snippet - snippet text, can be HTML formatted

        Since:

        8.16

      • addSnippet

        public void addSnippet​(Snippet snippet)

        Add a Snippet object to the menu. Drop-down menu is visible after the first snippet is added.

        Parameters:

        snippet - a Snippet object

        Since:

        8.16

      • addSnippets

        public void addSnippets​(String[] snippets)

        Add predefined content snippets to the menu. HTML formatting is allowed. Drop down menu is visible after the first snippet is added. The titles of snippets in the drop-down menu are automatically generated from the first 20 characters of the snippet text.

        Parameters:

        snippets - array of snippet body text, can be HTML formatted

        Since:

        8.16

      • addSnippets

        public void addSnippets​(String[] titles,
                                String[] snippets)

        Add predefined content snippets to the menu. HTML formatting is allowed in the snippet text. Drop-down menu is visible after the first snippet is added. Each snippet is assigned a title from the titles array, or has one automatically generated from the snippet text if the corresponding value in the titles array is null. The array sizes must match exactly.

        Parameters:

        titles - array of strings to display as snippet titles. This array may include nulls, in which case the title is automatically generated from the first 20 characters in the snippet text.

        snippets - array of snippet text, can be HTML formatted

        Since:

        8.16

      • addSnippets

        public void addSnippets​(Collection<Snippet> snippets)

        Add Snippet objects to the menu. Drop-down menu is visible after the first snippet has been added.

        Parameters:

        snippets - a Collection of Snippet objects

        Since:

        8.16

      • clearSnippets

        public void clearSnippets()

        Remove all snippets - this also hides the snippets drop-down unless new snippets are added.

        Since:

        8.16