The fastest way to add exit break functionality is with the ExitBreakKit, which includes pre-configured ExitBreakPlugin with keyboard shortcuts.
'use client';
import { ExitBreakPlugin } from 'platejs';
export const ExitBreakKit = [
ExitBreakPlugin.configure({
shortcuts: {
insert: { keys: 'mod+enter' },
insertBefore: { keys: 'mod+shift+enter' },
},
}),
];'use client';
import { ExitBreakPlugin } from 'platejs';
export const ExitBreakKit = [
ExitBreakPlugin.configure({
shortcuts: {
insert: { keys: 'mod+enter' },
insertBefore: { keys: 'mod+shift+enter' },
},
}),
];import { createPlateEditor } from 'platejs/react';
import { ExitBreakKit } from '@/components/editor/exit-break';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...ExitBreakKit,
],
});import { createPlateEditor } from 'platejs/react';
import { ExitBreakKit } from '@/components/editor/exit-break';
const editor = createPlateEditor
import { ExitBreakPlugin } from 'platejs';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
ExitBreakPlugin,
],
});import { ExitBreakPlugin } from 'platejs';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
ExitBreakPlugin,
],
});import { ExitBreakPlugin } from 'platejs';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
ExitBreakPlugin.configure({
shortcuts: {
insert: { keys: 'mod+enter' },
insertBefore: { keys: 'mod+shift+enter' },
},
}),
],
});
| Key | Description |
|---|---|
| Cmd + Enter | Exit the current block structure and insert a new block after. |
| Cmd + Shift + Enter | Exit the current block structure and insert a new block before. |
Provides transforms to exit nested block structures automatically. The plugin determines the appropriate exit point by finding the first ancestor that allows standard block siblings.
Exit break uses the compiled element content grammar to determine where a paragraph can be inserted when exiting nested structures.
When you trigger exit break:
Code Block:
<codeBlock> // ← Exit point (top-level block)
<codeLine>code|</codeLine> // ← Starting position
</codeBlock>
<paragraph>|</paragraph> // ← New paragraph inserted here<codeBlock> // ← Exit point (top-level block)
<codeLine>code|</codeLine> // ← Starting position
</codeBlock>
<paragraph>|</paragraph> // ← New paragraph inserted hereTable in Column (exits at table level):
// First exit
<columnGroup>
<column>
<table> // ← Exit point (column allows blocks)
<tableRow> // table allows rows only
<tableCell> // row allows cells only
<paragraph>content|</paragraph>// ← Starting position
</tableCell>
</tableRow>
</table>
<paragraph>|</paragraph> // ← New paragraph inserted here
</column>
</columnGroup>
// Second exit
<columnGroup> // ← Exit point (root allows blocks)
<column> // group allows columns only
<table>
<tableRow>
<tableCell>
<paragraph>content</paragraph>
</tableCell>
</tableRow>
</table>
<paragraph>|</paragraph> // ← Starting position
</column>
</columnGroup>
<paragraph>|</paragraph> // ← New paragraph inserted here// First exit
<columnGroup>
<column>
<table> // ← Exit point (column allows blocks)
<tableRow> // table allows rows only
<tableCell> // row allows cells only
<paragraph>content|</paragraph>// ← Starting position
</tableCell>
</tableRow>
</table>
<paragraph>|</paragraph> // ← New paragraph inserted here
</column>
</columnGroup>
// Second exit
<columnGroup> // ← Exit point (root allows blocks)
<column
Declare each custom element's allowed child content:
import { defineBasePlugin, schema } from 'platejs';
// Table structure
const CustomTablePlugin = defineBasePlugin('table', {
schema: {
element: {
content: schema.content.type('tr', { min: 1 }),
},
},
});
const CustomTableRowPlugin = defineBasePlugin('tr', {
schema: {
element: {
content: schema.content.types(['td', 'th'], { min: 1 }),
},
},
});
const CustomTableCellPlugin = defineBasePlugin('td', {
schema: {
element: {
content: schema.content.group('block', { min: 1 }),
},
},
});import { defineBasePlugin, schema } from 'platejs';
// Table structure
const CustomTablePlugin = defineBasePlugin('table', {
schema: {
element: {
content: schema.content.type('tr', { min: 1 }),
},
},
});
const CustomTableRowPlugin = defineBasePlugin('tr', {
schema: {
element: {
content: schema.content.types(['td', 'th'], { min: 1 }),
},
},
});
const CustomTableCellPlugin =