Docs
Node ID

Node ID

Automatically assign unique IDs to nodes in the document.

Features

  • Automatically assigns unique IDs to nodes
  • Configurable ID generation and storage
  • Handles node operations (insert, split) with ID preservation
  • Optional ID reuse for undo/redo and copy/paste operations

Installation

npm install @udecode/plate-node-id

Usage

import { NodeIdPlugin } from '@udecode/plate-node-id';
const plugins = [
  // ...otherPlugins,
  NodeIdPlugin.configure({
    options: {
      idKey: 'id',
      filterText: true,
      idCreator: () => Math.random().toString(36).slice(2, 7),
    },
  }),
];

Plugins

NodeIdPlugin

Options

Collapse all

    When true, disables using existing IDs during node insertion, even if they don't exist in the document.

    Filter Text nodes from receiving IDs.

    • Default: true

    Function to generate unique IDs.

    • Default: () => Math.random().toString(36).slice(2, 7)

    Node key used to store the ID.

    • Default: 'id'

    Reuse IDs on undo/redo and copy/pasting if not existing in the document.

    • Default: false