InlineText
InlineText:
{}Represents a text segment with consistent formatting within a paragraph.
Remarks
Section titled “Remarks”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:
- The actual text content (via
plainText) - The formatting applied to that text (via
formatting)
InlineText elements are discovered by iterating through inline elements using
TextView.inlines.
Example
Section titled “Example”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}`); }}Properties
Section titled “Properties”type:
"text"
Type discriminator for inline elements.
Remarks
Section titled “Remarks”Always has the value 'text'. Use this property to identify text content
elements and distinguish them from other inline types (images, line breaks, etc.).
Methods
Section titled “Methods”plainText()
Section titled “plainText()”plainText():
string
Gets the plain text content of this inline element.
Returns
Section titled “Returns”The text string contained in this element
Remarks
Section titled “Remarks”Returns the actual text content without any formatting information. Each InlineText
element represents a contiguous segment of text with uniform formatting.
Example
Section titled “Example”if (inline.type === 'text') { const text = inline.plainText(); console.log(`Text content: "${text}"`);}formatting()
Section titled “formatting()”formatting():
Formatting
Gets the formatting properties applied to this text.
Returns
Section titled “Returns”A Formatting object describing all formatting properties
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”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'}`);}