Overview
The@lexical/plain-text package provides plain text editing functionality for Lexical, handling basic text operations without rich formatting like headings or quotes.
Installation
Registration
registerPlainText
Registers plain text editing behavior including keyboard handlers and clipboard operations.The editor instance to register plain text behavior on
Extension
PlainTextExtension
A Lexical extension for plain text editing.Conflicts with
@lexical/rich-text - use one or the other, not bothDepends on
DragonExtension for Dragon NaturallySpeaking supportSupported Commands
The plain text package handles the following commands:DELETE_CHARACTER_COMMAND- Delete character before/after cursorDELETE_WORD_COMMAND- Delete word before/after cursorDELETE_LINE_COMMAND- Delete line before/after cursorCONTROLLED_TEXT_INSERTION_COMMAND- Insert text programmaticallyREMOVE_TEXT_COMMAND- Remove selected textINSERT_LINE_BREAK_COMMAND- Insert line breakINSERT_PARAGRAPH_COMMAND- Insert paragraph (as line break in plain text)KEY_ARROW_LEFT_COMMAND- Handle left arrow keyKEY_ARROW_RIGHT_COMMAND- Handle right arrow keyKEY_BACKSPACE_COMMAND- Handle backspace keyKEY_DELETE_COMMAND- Handle delete keyKEY_ENTER_COMMAND- Handle enter keySELECT_ALL_COMMAND- Select all textCOPY_COMMAND- Copy selection to clipboardCUT_COMMAND- Cut selection to clipboardPASTE_COMMAND- Paste from clipboardDROP_COMMAND- Handle drag and dropDRAGSTART_COMMAND- Handle drag start
Behavior Differences from Rich Text
Plain text mode differs from rich text in several ways:- Enter key inserts a line break instead of creating a new paragraph
- No block formatting - no headings, quotes, or other block elements
- Clipboard operations preserve only plain text, stripping formatting
- Simpler keyboard navigation without decorator or block element support