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

InlineText

InlineText:

Represents a text segment with consistent formatting within a paragraph.

InlineText is the most common inline element type, representing actual text content with uniform formatting properties. A paragraph’s text is broken into multiple InlineText elements whenever formatting changes (e.g., switching from regular to bold text creates two separate InlineText elements).

Each InlineText element has:

InlineText elements are discovered by iterating through inline elements using TextView.inlines.

Extract all text content with formatting information:

const inlines = textView.inlines();
for (const rangeInline of inlines) {
if (rangeInline.inline.type === 'text') {
const text = rangeInline.inline.plainText();
const fmt = rangeInline.inline.formatting();
console.log(`Text: "${text}", Bold: ${fmt.bold}, Color: ${fmt.color}`);
}
}

type: "text"

Type discriminator for inline elements.

Always has the value 'text'. Use this property to identify text content elements and distinguish them from other inline types (images, line breaks, etc.).

plainText(): string

Gets the plain text content of this inline element.

string

The text string contained in this element

Returns the actual text content without any formatting information. Each InlineText element represents a contiguous segment of text with uniform formatting.

if (inline.type === 'text') {
const text = inline.plainText();
console.log(`Text content: "${text}"`);
}

formatting(): Formatting

Gets the formatting properties applied to this text.

Formatting

A Formatting object describing all formatting properties

Returns the complete formatting information for this text segment, including font, size, color, bold, italic, and other properties. Properties that are not explicitly set will have null values, indicating they inherit from the paragraph or document style.

if (inline.type === 'text') {
const fmt = inline.formatting();
console.log(`Font: ${fmt.font ?? 'default'}`);
console.log(`Size: ${fmt.fontSize ?? 'default'}`);
console.log(`Bold: ${fmt.bold ?? false}`);
console.log(`Color: ${fmt.color ?? 'default'}`);
}