---
title: Reset Node
---

<ComponentPreview name="reset-node-demo" />

<PackageInfo>

## Features

- Enables quick reset of text block formatting to default on key events (e.g. `Enter`).
- To test, press Enter in an empty or at the end of a block quote, or Backspace at the start of a block quote.

</PackageInfo>

## Installation

```bash
npm install @udecode/plate-reset-node
```

## Usage

```tsx
// ...
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

<APIOptions>

<APIItem name="rules" type="Array" optional>
An array of rules which govern how the node reset will be performed. Each rule includes:
<APISubList>
<APISubListItem parent="rules" name="hotkey" type="string | string[]" optional>
The hotkey(s) that trigger the rule.
</APISubListItem>
<APISubListItem parent="rules" name="defaultType" type="string" optional>
The default type to which the node should be reset.
</APISubListItem>
<APISubListItem parent="rules" name="types" type="string[]">
The types of nodes where the rule applies.
</APISubListItem>
<APISubListItem parent="rules" name="predicate" type="(editor: PlateEditor) => boolean">
An additional condition to the rule which should be a function taking the editor state and returning a boolean.
</APISubListItem>
<APISubListItem parent="rules" name="onReset" type="(editor: PlateEditor) => void" optional>
A callback function that is called when the reset operation is performed.
</APISubListItem>
</APISubList>
</APIItem>
<APIItem name="disableFirstBlockReset" type="boolean" optional>
Whether to disable reset for the first block in the editor.
</APIItem>
<APIItem name="disableEditorReset" type="boolean" optional>
Whether to disable the reset operation for the entire editor.
</APIItem>
</APIOptions>