Skip to content

Bidi Isolation Plugin

The BidiIsolationPlugin registers a bdi mark for inline bidi isolation — wrapping selected text in a <bdi> element with an explicit dir attribute. Use it when a single block contains text in mixed directions (e.g., an English phrase inside an Arabic paragraph).

It is independent of the Text Direction plugin, but consumes the optional TextDirectionService for a smarter toggleBidiIsolation cycle: when the surrounding block is RTL, the toggled isolation defaults to LTR, and vice versa. Without TextDirectionPlugin registered, toggleBidiIsolation always applies rtl as the starting direction.

import { BidiIsolationPlugin } from '@notectl/core/plugins/bidi-isolation';
new BidiIsolationPlugin();
interface BidiIsolationConfig {
/** Custom locale for toolbar labels and announcements. */
readonly locale?: BidiIsolationLocale;
}
TypeHTML TagAttributesDescription
bdi<bdi>dir="ltr" | "rtl" | "auto"Inline bidi isolation element
CommandDescriptionReturns
toggleBidiLTRApply inline LTR isolation to selectionboolean
toggleBidiRTLApply inline RTL isolation to selectionboolean
toggleBidiAutoApply inline auto isolation to selectionboolean
removeBidiRemove inline direction isolationboolean
toggleBidiIsolationToggle bidi: applies opposite of block direction (or 'rtl' as fallback), or removes if already activeboolean
editor.executeCommand('toggleBidiLTR');
editor.executeCommand('removeBidi');
ShortcutAction
Ctrl+Shift+B / Cmd+Shift+BToggle inline bidi isolation

Renders an Inline Direction toolbar dropdown (format group) with LTR, RTL, Auto, and Remove options. Only enabled when text is selected.

When TextDirectionPlugin is also registered, the toggleBidiIsolation command picks the opposite of the surrounding block’s direction so the isolated word visually stands out. Without it, the toggle defaults to 'rtl'.

  • Uses the semantic HTML <bdi> element for proper bidi isolation in assistive technology
  • Screen reader announcements for all bidi changes via context.announce()
  • Keyboard accessible via Mod-Shift-B
  • Toolbar items keyboard navigable

Ships with translations for 9 languages (ar, de, en, es, fr, hi, pt, ru, zh). Custom locales can be provided via the locale config option.