Docs
Reset Node
Reset Node
Reset the block type using rules.
Installation
npm install @udecode/plate-reset-node
Usage
// ...
import {
isBlockAboveEmpty,
isSelectionAtBlockStart,
} from '@udecode/plate-common';
import { ResetNodePlugin } from '@udecode/plate-reset-node/react';
const resetBlockTypesCommonRule = {
types: [BlockquotePlugin.key, TodoListPlugin.key],
defaultType: ParagraphPlugin.key,
};
const resetBlockTypesCodeBlockRule = {
types: [CodeBlockPlugin.key],
defaultType: ParagraphPlugin.key,
onReset: unwrapCodeBlock,
};
const plugins = [
// ...otherPlugins,
ResetNodePlugin.configure({
options: {
rules: [
{
...resetBlockTypesCommonRule,
hotkey: 'Enter',
predicate: isBlockAboveEmpty,
},
{
...resetBlockTypesCommonRule,
hotkey: 'Backspace',
predicate: isSelectionAtBlockStart,
},
{
...resetBlockTypesCodeBlockRule,
hotkey: 'Enter',
predicate: isCodeBlockEmpty,
},
{
...resetBlockTypesCodeBlockRule,
hotkey: 'Backspace',
predicate: isSelectionAtCodeBlockStart,
},
],
},
}),
];
Plugins
ResetNodePlugin
Options
Collapse all
An array of rules which govern how the node reset will be performed. Each rule includes:
Whether to disable reset for the first block in the editor.
Whether to disable the reset operation for the entire editor.
Build your editor even faster
Complete, deployable AI-powered template with backend.
All components included.
Customizable and extensible.
Get all-accessCustomizable and extensible.