BlockLevelContainer
BlockLevelContainer:
{}Container for block-level elements (paragraphs and tables).
Remarks
Section titled “Remarks”BlockLevelContainer is implemented by Body and TableCell, providing
methods to manage block-level content within these containers.
Examples
Section titled “Examples”Adding paragraphs and tables:
const body = draft.body();const paragraph = body.addParagraph(); // Append paragraph at endconst table = body.addTable(0); // Insert table at startAccessing and removing elements:
const elements = body.blocklevels();const removed = body.removeElement(0);Properties
Section titled “Properties”replaceText
Section titled “replaceText”replaceText:
ReplaceTextSignature
Searches and replaces text within this container. See ReplaceTextSignature.
Methods
Section titled “Methods”blocklevels()
Section titled “blocklevels()”blocklevels():
BlockLevel[]
Returns all block-level elements in this container.
Returns
Section titled “Returns”addParagraph()
Section titled “addParagraph()”addParagraph(
index?):Paragraph
Adds a new paragraph. If index is provided, inserts at that position; otherwise appends to the end.
Parameters
Section titled “Parameters”index?
Section titled “index?”Returns
Section titled “Returns”addTable()
Section titled “addTable()”addTable(
index?):Table
Adds a new table. If index is provided, inserts at that position; otherwise appends to the end.
Parameters
Section titled “Parameters”index?
Section titled “index?”Returns
Section titled “Returns”removeElement()
Section titled “removeElement()”removeElement(
index):BlockLevel|undefined
Removes the element at the specified index. Returns the removed element, or undefined if index is out of bounds.