While composing this answer, I recalled a venerable
HTMLDocumentEditor by Charles Bell that illustrates the typical usage of the subclasses found in
javax.swing.text.TextAction. That editor is listed among the credits of
Metaphase Editor. This related example showing actions found in
StyledEditorKit follows the same approach. All such actions are suitable for Key Bindings, and all operate on the current selection maintained by the
Caret, whenever possible.