docs/(plugins)/(functionality)/(utils)/single-block.mdx
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
],
});
SingleLinePluginPlugin that restricts editor content to a single line of text by removing all line breaks and merging multiple blocks.
Key behaviors:
insertBreak and insertSoftBreak operationsSingleBlockPluginPlugin that restricts editor content to a single block while preserving line breaks.
Key behaviors:
insertBreak to insertSoftBreak\n separators