For the complete documentation index, see llms.txt. This page is also available as Markdown.

Format text with DOCX Editor

DOCX Editor supports applying formatting to text in the document, ranging from bolding to highlighting. You can apply formatting to the currently selected text or to the cursor so any new text gets the formatting.

Applying formatting to selected text in the DOCX Editor. The toolbar buttons update to show the formatting that's currently applied.
Applying formatting to selected text in the DOCX Editor. The toolbar buttons update to show the formatting that's currently applied.

Format text in the UI

When editing a document in DOCX Editor, the text formatting buttons appear in the toolbar by default. Multiple text formatting options can be active at the same time.

Toolbar buttons reflect the current formatting of the selected text. For color-based properties such as font color and highlight color, the button updates to display the color applied to the selected text, or the current cursor position when no text is selected.

Format selected text

To format existing text:

  1. Select the text to format.

  2. Click the desired text formatting button.

  3. The style is applied to the selection.

Format text as you type

To format text you want to insert by typing:

  1. Place the cursor where you want to start typing.

  2. Click the desired text formatting button.

  3. Start typing and watch the new text use the selected style until you turn it off.

Format text via API

Use the OfficeEditor APIs to format text from your own code. You can set several formatting styles at once on the selected text or at the cursor, turn a single style on or off, and apply highlight colors (version 12.2.0+). All of these methods are on the OfficeEditor object, which you get from the current document:

Set formatting styles

To set a formatting style to a specific state, use one of the following APIs and pass in the desired state for the text formatting option(s):

Method

Applies to

Core.Document.OfficeEditor.updateSelectionStyle()

The currently selected text.

Core.Document.OfficeEditor.setMainCursorStyle()

The cursor and any text typed next.

You can update multiple properties at once. Color-related properties can be passed in as either RGB objects or hex strings. Colors will always have full opacity (or none for highlight color).

Toggle formatting styles

For supported text format options, such as bold and underline, OfficeEditor.toggleSelectedTextStyle() flips a single formatting style on the currently selected text, allowing for easy toggling. The OfficeEditor.ToggleableStyles enum provides all supported options.

Apply highlight colors

Starting in version 12.2.0, you can apply highlight colors to text in DOCX Editor. To make sure highlights save as text highlights in Word, use a HighlightColors value.

Highlight colors may be saved as either text highlights or character shading, depending on the color value, which may affect how other DOCX editors handle them. See the DOCX Editor highlighting and shading FAQ.

Last updated

Was this helpful?