Keep text selection visible when clicking toolbar buttons. Select text and click the toolbar - your selection stays highlighted for a seamless editing experience.

Why you’d use this

  • Professional UX - Selection doesn’t disappear when using toolbars
  • Seamless editing - Apply multiple formats without reselecting
  • User expectations - Matches desktop word processor behavior

Integration

Add toolbar-button class to toolbar elements. Call restorePreservedSelection() before applying commands.

Commands

restorePreservedSelection

Restore the preserved selection
Used internally to maintain selection when interacting with toolbar
// Restore selection after toolbar interaction
restorePreservedSelection()

Types

SelectionState

Selection state