# Class RichBlocks

java.lang.Object
com.codename1.ui.editor.RichBlocks

public final class RichBlocks extends Object
The per paragraph block attribute model for the pure rich text editor. Each logical line (paragraph, delimited by newlines) has a `BlockAttr` describing its block type (paragraph / heading / preformatted / blockquote), text alignment, list membership and indentation. The model is kept in lockstep with the paragraph structure through `#applyEdit`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `RichBlocks.BlockAttr`
  A single paragraph's block attributes.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ALIGN_CENTER`
  Center alignment.
  `static final int`
  `ALIGN_LEFT`
  Left alignment.
  `static final int`
  `ALIGN_RIGHT`
  Right alignment.
  `static final int`
  `BLOCKQUOTE`
  Block type: a block quote.
  `static final int`
  `H1`
  Block type: heading level 1 through 6 are `H1`..`H1 + 5`.
  `static final int`
  `LIST_NONE`
  Not a list item.
  `static final int`
  `LIST_ORDERED`
  An ordered (numbered) list item.
  `static final int`
  `LIST_UNORDERED`
  An unordered (bulleted) list item.
  `static final int`
  `PARAGRAPH`
  Block type: a normal paragraph.
  `static final int`
  `PRE`
  Block type: preformatted text.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RichBlocks(int paragraphCount)`
  Creates a model with the given paragraph count, all default paragraphs.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `applyEdit(int startParagraph, int removedNewlines, int addedNewlines)`
  Keeps the model in sync with a text edit that changed the paragraph structure.
  `int`
  `count()`
  Returns the number of paragraphs.
  `RichBlocks.BlockAttr`
  `get(int paragraph)`
  Returns the block attributes for the given paragraph (clamped to the valid range).
  `void`
  `reset(int paragraphCount)`
  Resets the model to the given paragraph count, all default paragraphs.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PARAGRAPH

    public static final int PARAGRAPH
    Block type: a normal paragraph.
    See Also:
      - Constant Field Values

  - ### H1

    public static final int H1
    Block type: heading level 1 through 6 are `H1`..`H1 + 5`.
    See Also:
      - Constant Field Values

  - ### PRE

    public static final int PRE
    Block type: preformatted text.
    See Also:
      - Constant Field Values

  - ### BLOCKQUOTE

    public static final int BLOCKQUOTE
    Block type: a block quote.
    See Also:
      - Constant Field Values

  - ### ALIGN_LEFT

    public static final int ALIGN_LEFT
    Left alignment.
    See Also:
      - Constant Field Values

  - ### ALIGN_CENTER

    public static final int ALIGN_CENTER
    Center alignment.
    See Also:
      - Constant Field Values

  - ### ALIGN_RIGHT

    public static final int ALIGN_RIGHT
    Right alignment.
    See Also:
      - Constant Field Values

  - ### LIST_NONE

    public static final int LIST_NONE
    Not a list item.
    See Also:
      - Constant Field Values

  - ### LIST_ORDERED

    public static final int LIST_ORDERED
    An ordered (numbered) list item.
    See Also:
      - Constant Field Values

  - ### LIST_UNORDERED

    public static final int LIST_UNORDERED
    An unordered (bulleted) list item.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### RichBlocks

    public RichBlocks(int paragraphCount)
    Creates a model with the given paragraph count, all default paragraphs.

- ## Method Details

  - ### reset

    public void reset(int paragraphCount)
    Resets the model to the given paragraph count, all default paragraphs.

  - ### count

    public int count()
    Returns the number of paragraphs.

  - ### get

    public RichBlocks.BlockAttr get(int paragraph)
    Returns the block attributes for the given paragraph (clamped to the valid range).

  - ### applyEdit

    public void applyEdit(int startParagraph, int removedNewlines, int addedNewlines)

    Keeps the model in sync with a text edit that changed the paragraph structure.

    ###### Parameters

    - `startParagraph`: the paragraph containing the edit offset

    - `removedNewlines`: number of newlines in the removed text (paragraphs merged away)

    - `addedNewlines`: number of newlines in the inserted text (paragraphs created)