Loading...
Features
- SingleLinePlugin: Restricts editor to a single line of text with all line breaks removed
- SingleBlockPlugin: Restricts editor to a single block with line breaks converted to soft breaks
- Prevents creation of multiple blocks through normalization
- Filters out line break characters from pasted content
- Suitable for titles, labels, comments, or constrained text inputs
Manual Usage
Add Plugins
import { SingleLinePlugin, SingleBlockPlugin } from 'platejs';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
SingleLinePlugin, // For single-line text
// OR
SingleBlockPlugin, // For single-block text with soft breaks
],
});
Plugins
SingleLinePlugin
Plugin that restricts editor content to a single line of text by removing all line breaks and merging multiple blocks.
Key behaviors:
- Prevents
insertBreak
andinsertSoftBreak
operations - Filters out line break characters
- Merges multiple blocks into the first block without separators
SingleBlockPlugin
Plugin that restricts editor content to a single block while preserving line breaks.
Key behaviors:
- Converts
insertBreak
toinsertSoftBreak
- Merges multiple blocks into the first block with
\n
separators - Preserves existing line break characters in text content