Replacement
Replacement:
{}Specifies replacement content for text operations, including both text and formatting.
Remarks
Section titled “Remarks”Replacement is used with replace operations to specify what should replace the matched content.
When used in ReplaceTextSignature operations, if text is omitted, the original
matched text is preserved and only formatting is modified.
Examples
Section titled “Examples”Replace formatting only (preserve text):
// Highlight all occurrences of "important" without changing textparagraph.replaceText(/important/gi, { formatting: { highlight: "#ffff00", bold: true }});Dynamic replacement based on match (using with ReplaceFn):
// Convert numbers to currency format with stylingparagraph.replaceText(/\$?(\d+(\.\d{2})?)/g, (match) => { const amount = parseFloat(match.replace('$', '')); return { text: `$${amount.toFixed(2)}`, formatting: { color: amount > 100 ? "#ff0000" : "#00ff00", bold: amount > 100 } };});Properties
Section titled “Properties”
optionaltext:string
The replacement text content.
Remarks
Section titled “Remarks”When specified, replaces the matched text with this string. When omitted, the original matched text is preserved (useful for formatting-only changes).
formatting?
Section titled “formatting?”
optionalformatting:Partial<Formatting>
Formatting to apply to the replacement text.
Remarks
Section titled “Remarks”Specifies formatting properties to apply.