Skip to main content

$formatText

function

Applies the provided format to TextNodes and inline formattable nodes (e.g. DecoratorTextNode) in the selection, splitting or merging TextNodes as necessary and aligning all formattable nodes to the same target format. For RangeSelection the toggle direction is determined by the selection's computed format (intersection of all text nodes) when no explicit alignment is given. For NodeSelection each node is toggled independently when no explicit alignment is given, since there is no TextNode to use as an alignment reference.

function $formatText(selection: RangeSelection | NodeSelection, formatType: TextFormatType, alignWithFormat?: number | null): void

Import

import { $formatText } from '@modular/sdk/editor';