Skip to content
Document Authoring DA  API Docs v1.10.0
npmGitHub

BlockLevelContainer

BlockLevelContainer:

Container for block-level elements (paragraphs and tables).

BlockLevelContainer is implemented by Body and TableCell, providing methods to manage block-level content within these containers.

Adding paragraphs and tables:

const body = draft.body();
const paragraph = body.addParagraph(); // Append paragraph at end
const table = body.addTable(0); // Insert table at start

Accessing and removing elements:

const elements = body.blocklevels();
const removed = body.removeElement(0);

replaceText: ReplaceTextSignature

Searches and replaces text within this container. See ReplaceTextSignature.

blocklevels(): BlockLevel[]

Returns all block-level elements in this container.

BlockLevel[]


addParagraph(index?): Paragraph

Adds a new paragraph. If index is provided, inserts at that position; otherwise appends to the end.

number

Paragraph


addTable(index?): Table

Adds a new table. If index is provided, inserts at that position; otherwise appends to the end.

number

Table


removeElement(index): BlockLevel | undefined

Removes the element at the specified index. Returns the removed element, or undefined if index is out of bounds.

number

BlockLevel | undefined