Tiptap Utility Functions

1.13.1 · deprecated · verified Sun Apr 19

tiptap-utils is an older, standalone JavaScript package providing a collection of general utility functions designed for the Tiptap editor. Its current stable version is 1.13.1, with its last release approximately five years ago. This package is distinct from the modern `@tiptap/core` (v2/v3) monorepo and its associated extensions, which now integrate many of the functionalities previously offered by `tiptap-utils` directly into the core library or specific extensions. As such, `tiptap-utils` does not adhere to the active and rapid release cadence of the current Tiptap ecosystem. Developers are generally advised to use the utilities provided by `@tiptap/core` for modern Tiptap implementations, as `tiptap-utils` may have compatibility issues with newer editor versions due to significant API changes.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing and using `markIsActive` and `nodeIsActive` with an older Tiptap v1.x Editor instance to check the active state of marks and nodes.

import { Editor } from 'tiptap';
import { markIsActive, nodeIsActive } from 'tiptap-utils';
import { Bold, Paragraph, Document } from 'tiptap-extensions'; // Example extensions for older Tiptap

// This example is for older Tiptap v1.x, which `tiptap-utils` was designed for.
// It is NOT compatible with @tiptap/core v2/v3.
const editor = new Editor({
  extensions: [
    new Document(),
    new Paragraph(),
    new Bold(),
  ],
  content: '<p>This is <strong>bold</strong> text.</p>',
  onUpdate: ({ editor }) => {
    const state = editor.state;
    console.log('Is bold mark active?', markIsActive(state, 'bold'));
    console.log('Is paragraph node active?', nodeIsActive(state, 'paragraph'));
  },
});

// To simulate usage in a non-interactive environment or test:
setTimeout(() => {
  const state = editor.state;
  console.log('Is bold mark active after timeout?', markIsActive(state, 'bold'));
  console.log('Is paragraph node active after timeout?', nodeIsActive(state, 'paragraph'));
  editor.destroy();
}, 1000);

view raw JSON →