Skip to main content

$setTextFormat

function

Explicitly sets or unsets text formats on the selection. Unlike $formatText which toggles based on the current selection state, this function sets each specified format to the exact boolean value provided. Mutually exclusive formats (subscript/superscript, lowercase/uppercase/capitalize) are reconciled by toggleTextFormatType, with later entries winning when the requested formats conflict.

function $setTextFormat(selection: RangeSelection | NodeSelection, formats: Partial<Record<TextFormatType, boolean>>): void

Import

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