Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8361872

RichTextArea: provide mechanism for CSS styling of highlights

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • jfx25
    • javafx
    • None
    • source
    • minimal
    • Newly added methods may conflict with similarly named methods declared in the classes that extend RichParagraph (incubator).
    • Java API
    • JDK

      Summary

      Adds the (missing) API to style the rich text paragraph highlights with CSS.

      Problem

      RichTextParagraph.Builder class provides two sets of APIs to style the text: using explicit attributes and using CSS styles, except for the highlights.

      Solution

      The solution entails adding the missing methods:

      • RichParagraph.Builder.addHighlight(int start, int end, String ... styles)
      • RichParagraph.Builder.addWavyUnderline(int start, int end, String ... styles)

      Specification

      jfx.incubator.scene.control.richtext.model.RichParagraph.java

          +        /**
          +         * Adds a wavy underline (typically used as a spell checker indicator) with the specified style name(s).
          +         * <p>
          +         * The corresponding styles should define CSS properties applicable to {@link javafx.scene.shape.Path}.
          +         *
          +         * @param start the start offset
          +         * @param length the end offset
          +         * @param css the style name(s)
          +         * @return this {@code Builder} instance
          +         * @since 25
          +         */
          +        public Builder addWavyUnderline(int start, int length, String ... css)
      
                   /**
          +         * Adds a highlight with the specified style name(s).
          +         * Use translucent colors to enable multiple highlights in the same region of text.
          +         * <p>
          +         * The corresponding styles should define CSS properties applicable to {@link javafx.scene.shape.Path}.
          +         *
          +         * @param start the start offset
          +         * @param length the end offset
          +         * @param css the style name(s)
          +         * @return this {@code Builder} instance
          +         * @since 25
          +         */
          +        public Builder addHighlight(int start, int length, String ... css)
      
      
                   /**
                    * Appends a text segment styled with the stylesheet style names.
          +         * The corresponding styles should define CSS properties applicable to {@link javafx.scene.text.Text}.
                    *
                    * @param text non-null text string
                    * @param css array of style names, cannot be null
                    * @return this {@code Builder} instance
                    */
                   public Builder addWithStyleNames(String text, String ... css)
      
                   /**
                    * Appends a text segment styled with both the inline style and the stylesheet style names.
          +         * The corresponding styles should define CSS properties applicable to {@link javafx.scene.text.Text}.
                    *
                    * @param text non-null text string
                    * @param style direct style (such as {@code -fx-fill:red;}), or null
                    * @param css array of style names
                    * @return this {@code Builder} instance
                    */
                   public Builder addWithInlineAndStyleNames(String text, String style, String ... css)
      
                   /**
                    * Appends a text segment styled with the stylesheet style names.
          +         * The corresponding styles should define CSS properties applicable to {@link javafx.scene.text.Text}.
                    *
                    * @param text non-null text string
                    * @param style the inline style (example {@code "-fx-fill:red;"}), or null
                    * @return this {@code Builder} instance
                    */
                   public Builder addWithInlineStyle(String text, String style)

      jfx.incubator.scene.control.richtext.model.SimpleViewOnlyStyledModel.java

               /**
          +     * Adds a highlight of the given color to the specified range within the last paragraph,
          +     * with the specified style name(s).
          +     *
          +     * @param start the start offset
          +     * @param length the length of the highlight
          +     * @param css the highlight style name(s)
          +     * @return this model instance
          +     * @since 25
          +     */
          +    public SimpleViewOnlyStyledModel highlight(int start, int length, String ... css)
      
          +    /**
          +     * Adds a wavy underline (typically used as a spell checker indicator)
          +     * to the specified range within the last paragraph, with the specified style name(s).
          +     *
          +     * @param start the start offset
          +     * @param length the length of the highlight
          +     * @param css the highlight style name(s)
          +     * @return this model instance
          +     * @since 25
          +     */
          +    public SimpleViewOnlyStyledModel addWavyUnderline(int start, int length, String ... css)

            angorya Andy Goryachev
            angorya Andy Goryachev
            Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: