āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/udecode/plate/(plugins)/(functionality)/(utils)/exit-break ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
The fastest way to add exit break functionality is with the ExitBreakKit, which includes pre-configured ExitBreakPlugin with keyboard shortcuts.
import { createPlateEditor } from 'platejs/react';
import { ExitBreakKit } from '@/components/editor/plugins/exit-break-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...ExitBreakKit,
],
});
</Steps>
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' },
},
}),
],
});
shortcuts.insert: Defines a keyboard shortcut to exit and insert block after.shortcuts.insertBefore: Defines a keyboard shortcut to exit and insert block before.ExitBreakPluginProvides transforms to exit nested block structures automatically. The plugin determines the appropriate exit point by finding the first ancestor that allows standard block siblings.
<API name="ExitBreakPlugin"> <APIOptions> <APIItem name="shortcuts" type="object" optional> Keyboard shortcuts configuration. <APISubList> <APISubListItem parent="shortcuts" name="insert" type="Shortcut" optional> Shortcut to exit and insert block after. - **Example:** `{ keys: 'mod+enter' }` </APISubListItem> <APISubListItem parent="shortcuts" name="insertBefore" type="Shortcut" optional> Shortcut to exit and insert block before. - **Example:** `{ keys: 'mod+shift+enter' }` </APISubListItem> </APISubList> </APIItem> </APIOptions> </API>Exit break uses the isStrictSiblings property to determine where to insert new blocks when exiting nested structures.
When you trigger exit break:
isStrictSiblings: falseCode Block:
<codeblock> // ā Exit point (top-level block)
<codeline>code|</codeline> // ā Starting position
</codeblock>
<p>|</p> // ā New paragraph inserted here
Table in Column (exits at table level):
// First exit
<column_group>
<column>
<table> // ā Exit point (isStrictSiblings: false)
<tr> // isStrictSiblings: true
<td> // isStrictSiblings: true
<p>content|</p> // ā Starting position
</td>
</tr>
</table>
<p>|</p> // ā New paragraph inserted here
</column>
</column_group>
// Second exit
<column_group> // ā Exit point (isStrictSiblings: false)
<column> // isStrictSiblings: true
<table>
<tr>
<td>
<p>content</p>
</td>
</tr>
</table>
<p>|</p> // ā Starting position
</column>
</column_group>
<p>|</p> // ā New paragraph inserted here
Configure isStrictSiblings for custom plugins:
// Table structure
const CustomTablePlugin = createSlatePlugin({
key: 'table',
node: {
isElement: true,
// isStrictSiblings: false (default) - allows paragraph siblings
},
});
const CustomTableRowPlugin = createSlatePlugin({
key: 'tr',
node: {
isElement: true,
isStrictSiblings: true, // Only allows tr siblings
},
});
const CustomTableCellPlugin = createSlatePlugin({
key: 'td',
node: {
isElement: true,
isStrictSiblings: true, // Only allows td/th siblings
},
});
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā