tiptap-unique-id

1.2.1 • Public • Published

TipTap Unique ID extension

npm version

An extension that enables unique IDs for nodes. A JS fork of the original MIT licensed extension-unique-id that has since been abandoned in favour of a closed source internal version.

Installation

npm i tiptap-unique-id

Usage

import { Editor } from "@tiptap/core";
// ... extensions
import UniqueId from "tiptap-unique-id";

new Editor({
  element: document.body,
  extensions: [
    // ... extensions
    UniqueId.configure({
      attributeName: "id",
      types: ["paragraph", "heading", "orderedList", "bulletList", "listItem"],
      createId: () => window.crypto.randomUUID(),
    }),
  ],
})

This package is ESM only, transpiled to ES2019.

Configuration

Parameter Default Description
attribute "id" The attribute to assign the value of the id to
types [] A list of node types that should receive ids. The exact list you need will depend on your requirements and tiptap extensions you use.
createId () => window.crypto.randomUUID() A function, returning a different string everytime it is called. Instead of UUIDv4 created by default, nanoid, hyperid or other options can be used

Package Sidebar

Install

npm i tiptap-unique-id

Weekly Downloads

281

Version

1.2.1

License

MIT

Unpacked Size

6.52 kB

Total Files

4

Last publish

Collaborators

  • tjhui