Inline Formatter

Inline tag wrapping, toggling, and decoration for the current text selection.

Access:

app.getService('inlineFormatter')

App code:

const inlineFormatter = app.getService('inlineFormatter');

Plugin:

const inlineFormatter = this.app.getService('inlineFormatter');

applyDecorations#

Applies attrs, classes, and/or styles to selected inline elements matching the given tag (including equivalent tags like B/STRONG). Emits inline:decorations:change and returns changed connected elements.

Parameters:

  • tag (string) — target inline tag (default: 'span')
  • attrs (object) — HTML attributes ({ name: value }; true / null sets a boolean attribute)
  • classes (string | string[]) — CSS class names to toggle (string or array)
  • styles (object) — CSS declarations to toggle ({ color: '#f00' } or { backgroundColor: 'yellow' })

Returns: HTMLElement[]

inlineFormatter.applyDecorations({ tag: 'a', attrs: { href: 'https://example.com' } });

removeFormat#

Unwraps selected inline elements deepest-first, optionally filtered by tag, restores the saved character offset, and normalizes affected blocks.

Parameters:

  • tag (string) — only unwrap elements matching this tag (default: unwrap any inline formatting tag)

Returns: boolean

inlineFormatter.removeFormat('strong');

format#

Wraps, toggles, splits, or decorates inline content for the current collapsed or ranged selection, including multi-block and partial-inline scenarios. Emits inline:format and returns created or modified wrapper elements.

Parameters:

  • tag (string) — target inline tag (default: 'span')
  • attrs (object) — HTML attributes ({ name: value }; true / null sets a boolean attribute)
  • classes (string | string[]) — CSS class names to toggle (string or array)
  • styles (object) — CSS declarations to toggle ({ color: '#f00' } or { backgroundColor: 'yellow' })

Returns: HTMLElement[]

inlineFormatter.format({ tag: 'strong' });