Skip to main content
The TextStyle extension provides a foundation for applying inline styles to text. It’s required by other extensions like Color, FontFamily, and FontSize. This extension renders as a <span> element with inline styles.

Installation

Usage

Configuration Options

Record<string, any>
default:"{}"
HTML attributes to add to the span element.
boolean
default:"true"
When enabled, merges the styles of nested spans into the child span during HTML parsing. This prioritizes the style of the child span and is used when parsing content created in other editors.

Commands

toggleTextStyle(attributes?)

Toggle a text style with the specified attributes.

removeEmptyTextStyle()

Remove spans without inline style attributes.

Usage with Other Extensions

The TextStyle extension is typically used as a foundation for other styling extensions:

Technical Details

  • Priority: 101 (higher than most other marks to ensure proper style application)
  • HTML Element: Renders as <span> with inline styles
  • Parsing: Only parses <span> elements that have a style attribute
  • Nested Spans: By default, merges styles from nested spans up to 20 levels deep

Source Code

View the source code on GitHub: