Skip to main content

Paragraph

The formatting half of Paragraph: style, alignment, spacing, indents, pagination and lists. Import from @reductoai/docx/node, @reductoai/docx/officejs.

Paragraph properties

Paragraph.of()

The handle of element under ctx, made once.

Paragraph.attachToList()

Join an existing list (another paragraph’s list.id) at level.

Paragraph.clear()

Remove the paragraph’s text, keeping the paragraph itself.

Paragraph.closeUp()

Remove direct spacing before this paragraph.

Paragraph.delete()

Paragraph.detachFromList()

Remove this paragraph’s list membership, keeping its text where the marker sat.

Paragraph.endSection()

Extension: end the section at this paragraph’s own mark, so no carrier paragraph is added. The next section starts the way breakType says.

Paragraph.format()

Direct formatting scoped to this exact paragraph, including cells and textboxes.

Paragraph.getComments()

office.js Paragraph.getComments: the comments the whole paragraph’s range holds.

Paragraph.getContentControls()

office.js Paragraph.getContentControls: the whole paragraph’s range, options and all.

Paragraph.getHtml()

As Word: <h1>-<h6> for a heading, the list marker as text, b/i/u/s/sup/sub and links inline.

Paragraph.getNext()

The next paragraph in this scope (body or cell; body-level tables are skipped).

Paragraph.getNextOrNullObject()

The next paragraph, or an OfficeJS null object at the end of this body/cell.

Paragraph.getOoxml()

Paragraph.getPrevious()

The previous paragraph in this scope (body or cell; body-level tables are skipped).

Paragraph.getPreviousOrNullObject()

The previous paragraph, or an OfficeJS null object at the start of this body/cell.

Paragraph.getRange()

Paragraph.getReviewedText()

Paragraph.getText()

Paragraph.getTextRanges()

Paragraph.getTrackedChanges()

office.js Paragraph.getTrackedChanges: every revision INSIDE this w:p, by ELEMENT CONTAINMENT, not the range window — a tracked deletion whose markup lands at the very end of the paragraph still belongs to it.

Paragraph.indent()

Increase direct left indentation by one Word default tab stop (0.5 inch).

Paragraph.indentCharacterWidth()

Move by a signed number of character-grid units.

Paragraph.indentFirstLineCharacterWidth()

Move the first-line indent by a signed number of character-grid units.

Paragraph.insertBreak()

Insert a break before or after this paragraph. Page, Line and Column (an extension) become w:br runs: a page break does not appear in text (read hasPageBreak), a line break reads as “\n”. The four Section* kinds split the paragraph mark and author a real section break. Next stays rejected: OfficeJS deprecated it without a single documented meaning (page break in some hosts, section-on-next-page in others). Ask for Page or SectionNext instead.

Paragraph.insertCanvas()

Insert an empty floating drawing canvas anchored to this paragraph; geometry in points.

Paragraph.insertChart()

Insert an inline chart (extension); data comes from the spec’s literal caches.

Paragraph.insertComment()

Not an OfficeJS Paragraph member, but a named gap beats a bare TypeError.

Paragraph.insertContentControl()

Paragraph.insertDiagram()

Insert an inline SmartArt diagram (extension); the frame is painted from a cache.

Paragraph.insertFileFromBase64()

Insert a .docx’s body at the edge (or in place of the content), with its images, links, styles, numbering, notes and comments. Async here: unlike Word, the file is unpacked on this side.

Paragraph.insertFreeform()

Insert a floating custom-geometry shape (extension): absolute SVG path data in points.

Paragraph.insertGeometricShape()

Insert a floating preset-geometry shape anchored to this paragraph; geometry in points.

Paragraph.insertHorizontalLine()

Insert a horizontal rule (extension; Word’s Insert > Horizontal Line). It takes a whole line and spans the column; returns the range of its one object character.

Paragraph.insertHtml()

Insert a strict named subset of HTML. Before/After author sibling blocks; Start/End place run-level content at this paragraph’s text edges and reject block-level HTML; Replace swaps this paragraph’s text (run-level payload) or the paragraph itself (block-level payload), like insertOoxml.
Insert an external hyperlink; offset is UTF-16 within this paragraph’s text.

Paragraph.insertImage()

Insert an inline image; offset is UTF-16 within this paragraph’s text.

Paragraph.insertInlinePictureFromBase64()

Paragraph.insertLine()

Insert a floating line or connector (extension; PowerPoint’s addLine); points.

Paragraph.insertListItem()

Insert a list item after this paragraph, continuing or starting a list. To append at the end of an existing list, use list.insertParagraph(text, "End").

Paragraph.insertMath()

Extension: TeX math as a native Office Math equation, at insertOoxml’s anchors.

Paragraph.insertOoxml()

Insert a WML fragment or a Word pkg:package payload. Before/After author sibling blocks; Start/End place run-level content at this paragraph’s text edges and reject block-level content. Replace swaps this paragraph’s text in place for a run-level payload (its pPr survives) and replaces the whole paragraph for a block-level one.

Paragraph.insertParagraph()

Insert a sibling paragraph after or before this one, as Office.js does: the new paragraph keeps this one’s style, numbering and paragraph formatting. “After” hands it this paragraph’s mark and types with the last character’s format; “Before” uses the first character’s. format: "plain" starts from document defaults. On a table cell’s last paragraph, “After” goes where Word puts it: before the next paragraph in document order (the next row’s cell, or after the table), with that paragraph’s formatting. To add a paragraph in the same cell, use getRange("End").insertText("\n" + text, "End").

Paragraph.insertPictureFromBase64()

Insert a floating picture anchored to this paragraph; geometry in points.

Paragraph.insertScene()

Insert one floating group of preset shapes and connectors (an org tree, a flow); points.

Paragraph.insertTable()

Insert a table after or before this body paragraph; values fills cells row-major. Cells are born PLAIN: the table style owns their appearance, so no run formatting is cloned from the anchor paragraph. Pass format: "clone" to seed cell text from the anchor instead.

Paragraph.insertText()

Insert into this paragraph’s own text. "Replace" swaps the whole paragraph text in place — on a blank paragraph that is the fill-the-blank primitive. Newlines split into sibling paragraphs cloned from this one. Returns the range covering the inserted text (its first line, if several).

Paragraph.insertTextBox()

Insert a floating textbox anchored to this paragraph; geometry is in points.

Paragraph.insertTextEffect()

Insert legacy WordArt: the text stretched over a box (extension; VBA’s Shapes.AddTextEffect, which Word’s text watermark uses). Returns the range of its one object character.

Paragraph.moveTo()

Move this paragraph (through options.through, a later sibling, for a multi-paragraph clause) before or after another paragraph. With change tracking on the move is recorded as Word’s Moved From / Moved To pair. Returns the paragraph now at the destination.

Paragraph.next()

Return the paragraph count siblings forward in the same parent scope.

Paragraph.openOrCloseUp()

Toggle direct space-before between zero and twelve points.

Paragraph.openUp()

Set direct space-before to twelve points.

Paragraph.outdent()

Remove one Word default tab-stop level, stopping at the left margin.

Paragraph.outlineDemote()

Apply the next heading style; Heading 9 demotes to Normal body text.

Paragraph.outlineDemoteToBody()

Demote the paragraph to body text by applying Normal.

Paragraph.outlinePromote()

Apply the previous heading style; body text promotes to Heading 9.

Paragraph.previous()

Return the paragraph count siblings backward in the same parent scope.

Paragraph.reset()

Remove direct paragraph formatting while retaining style, list, and section identity.

Paragraph.set()

Paragraph.setLineSpacing()

Rule and value in one write: Exactly / AtLeast take the pitch in points, Multiple a count of lines.

Paragraph.space1()

Paragraph.space1Pt5()

Paragraph.space2()

Paragraph.split()

Office.js Paragraph.split: the paragraph’s text cut after each delimiter.

Paragraph.startNewList()

Make this paragraph the first item of a new list; pass list.id to attachToList. format is a raw OOXML w:numFmt token, one of: bullet, decimal, decimalZero, lowerLetter, upperLetter, lowerRoman, upperRoman, hebrew1, hebrew2, none. For the OfficeJS ListNumbering spellings, and to change one level after the fact, use list.setLevelNumbering.

Paragraph.tabHangingIndent()

Set a hanging indent measured in Word’s default half-inch tab stops.

Paragraph.tabIndent()

Set the left indent measured in Word’s default half-inch tab stops. Not implemented. These Office.js members throw: getAnnotations, insertAnnotations, joinList, resetAdvanceTo, select, selectNumber, separateList.

ParagraphCollection

OfficeJS-flavored live collection: items is recomputed on every access. Import from @reductoai/docx/node, @reductoai/docx/officejs.

ParagraphCollection properties

ParagraphCollection.add()

Insert a new blank paragraph immediately before range.

ParagraphCollection.at()

ParagraphCollection.closeUp()

ParagraphCollection.decreaseSpacing()

ParagraphCollection.getFirst()

ParagraphCollection.getFirstOrNullObject()

OfficeJS null-object variant; inspect isNullObject before other members.

ParagraphCollection.getItem()

OfficeJS spelling of at().

ParagraphCollection.getLast()

ParagraphCollection.getLastOrNullObject()

OfficeJS null-object variant; inspect isNullObject before other members.

ParagraphCollection.increaseSpacing()

ParagraphCollection.indent()

ParagraphCollection.indentCharacterWidth()

ParagraphCollection.indentFirstLineCharacterWidth()

ParagraphCollection.openOrCloseUp()

ParagraphCollection.openUp()

ParagraphCollection.outdent()

ParagraphCollection.outlineDemote()

ParagraphCollection.outlineDemoteToBody()

ParagraphCollection.outlinePromote()

ParagraphCollection.space1()

ParagraphCollection.space1Pt5()

ParagraphCollection.space2()

ParagraphCollection.tabHangingIndent()

ParagraphCollection.tabIndent()