Single Line
components/single-line-demo.tsx
'use client';
import React from 'react';
import { Plate } from '@udecode/plate/react';
import { SingleLinePlugin } from '@udecode/plate-break/react';
import { editorPlugins } from '@/components/editor/plugins/editor-plugins';
import { useCreateEditor } from '@/components/editor/use-create-editor';
import { singleLineValue } from '@/components/values/single-line-value';
import { Editor, EditorContainer } from '@/components/plate-ui/editor';
export default function SingleLineDemo() {
const editor = useCreateEditor({
plugins: [...editorPlugins, SingleLinePlugin],
value: singleLineValue,
});
return (
<Plate editor={editor}>
<EditorContainer variant="demo">
<Editor />
</EditorContainer>
</Plate>
);
}
Installation
npm install @udecode/plate-break
Usage
import { SingleLinePlugin } from '@udecode/plate-break/react';
const plugins = [
// ...otherPlugins
SingleLinePlugin,
];
Plugins
SingleLinePlugin
Plugin that restricts editor content to a single line of text.
Example:
const plugins = [
SingleLinePlugin.configure({
options: {
disableExtraSpacing: true,
disableBlocks: true,
},
}),
];
Behavior:
- Prevents creation of new blocks with Enter key
- Removes extra spacing between blocks
- Maintains single block structure
- Ideal for title fields or single-line inputs