Class RichBlocks
java.lang.Object
com.codename1.ui.editor.RichBlocks
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 ClassesModifier and TypeClassDescriptionstatic final classA single paragraph's block attributes. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCenter alignment.static final intLeft alignment.static final intRight alignment.static final intBlock type: a block quote.static final intBlock type: heading level 1 through 6 areH1..H1 + 5.static final intNot a list item.static final intAn ordered (numbered) list item.static final intAn unordered (bulleted) list item.static final intBlock type: a normal paragraph.static final intBlock type: preformatted text. -
Constructor Summary
ConstructorsConstructorDescriptionRichBlocks(int paragraphCount) Creates a model with the given paragraph count, all default paragraphs. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyEdit(int startParagraph, int removedNewlines, int addedNewlines) Keeps the model in sync with a text edit that changed the paragraph structure.intcount()Returns the number of paragraphs.get(int paragraph) Returns the block attributes for the given paragraph (clamped to the valid range).voidreset(int paragraphCount) Resets the model to the given paragraph count, all default paragraphs.
-
Field Details
-
PARAGRAPH
public static final int PARAGRAPHBlock type: a normal paragraph.- See Also:
-
H1
public static final int H1Block type: heading level 1 through 6 areH1..H1 + 5.- See Also:
-
PRE
public static final int PREBlock type: preformatted text.- See Also:
-
BLOCKQUOTE
public static final int BLOCKQUOTEBlock type: a block quote.- See Also:
-
ALIGN_LEFT
public static final int ALIGN_LEFTLeft alignment.- See Also:
-
ALIGN_CENTER
public static final int ALIGN_CENTERCenter alignment.- See Also:
-
ALIGN_RIGHT
public static final int ALIGN_RIGHTRight alignment.- See Also:
-
LIST_NONE
public static final int LIST_NONENot a list item.- See Also:
-
LIST_ORDERED
public static final int LIST_ORDEREDAn ordered (numbered) list item.- See Also:
-
LIST_UNORDERED
public static final int LIST_UNORDEREDAn unordered (bulleted) list item.- See Also:
-
-
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
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)
-
-