npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tiptap-extension-mermaid

v0.0.0

Published

A Tiptap extension that enables live Mermaid diagram rendering inside code blocks — built on top of prosemirror-mermaid with debounced updates, syntax highlighting, and SVG cropping.

Readme

Tiptap Extension Mermaid

test Maintainability codecov Version Downloads npm bundle size NPM License

🪄 A drop-in Tiptap extension that adds live Mermaid diagram rendering to CodeBlockLowlight — powered by prosemirror-mermaid.


✨ Features

  • Live Mermaid diagrams — render instantly as you type
  • Debounced updates — smooth editing experience (default: 300 ms)
  • Syntax highlighting — integrates with lowlight and lowlight-mermaid
  • Tight SVG output — powered by @svg-fns/layout
  • Automatic stable IDs — each diagram gets a persistent ID via data-id
  • Drop-in for CodeBlockLowlight — no extra node definitions required

🚀 Installation

pnpm add tiptap-extension-mermaid

or

npm install tiptap-extension-mermaid

or

yarn add tiptap-extension-mermaid

🧩 Quick Start

import { CodeblockLowlightMermaid } from "tiptap-extension-mermaid";
import { createLowlight } from "lowlight";
import { Editor } from "@tiptap/core";
import mermaid from "mermaid";

// Important: initialize Mermaid manually
mermaid.initialize({ startOnLoad: false });

const lowlight = createLowlight();

const editor = new Editor({
  extensions: [
    CodeblockLowlightMermaid.configure({
      lowlight,
      classList: "mermaid-container",
      debounce: 400,
      mermaidConfig: {
        theme: "neutral",
      },
    }),
  ],
  content: `
  \`\`\`mermaid
  graph TD
    A[Start] --> B{Is it working?}
    B -- Yes --> C[Ship it!]
    B -- No --> D[Fix and retry]
  \`\`\`
  `,
});

⚙️ Options

| Option | Type | Default | Description | | ------------------- | ----------------------------------- | ------------------ | ------------------------------------------------ | | lowlight | ReturnType<typeof createLowlight> | {} | Lowlight instance for syntax highlighting. | | debounce | number | 300 | Delay (ms) before re-render after typing stops. | | mermaidConfig | MermaidConfig | {} | Passed directly to mermaid.initialize(). | | classList | string[] \| string | "" | CSS class(es) applied to each diagram container. | | id (auto) | string | Random mxxxxxxxx | Auto-generated, persisted via data-id. |


🧠 How It Works


🧰 Example Styling

.mermaid-container {
  display: flex;
  justify-content: center;
  padding: 0.5rem;
  overflow-x: auto;
  border-radius: 0.5rem;
  background: var(--code-bg, #f8f9fa);
}

🧩 Advanced Example (React + Tiptap)

import { useEditor, EditorContent } from "@tiptap/react";
import { CodeblockLowlightMermaid } from "tiptap-extension-mermaid";
import { createLowlight } from "lowlight";
import mermaid from "mermaid";

const lowlight = createLowlight();
mermaid.initialize({ startOnLoad: false });

export const MermaidEditor = () => {
  const editor = useEditor({
    extensions: [
      CodeblockLowlightMermaid.configure({
        lowlight,
        classList: ["mermaid-container", "diagram"],
      }),
    ],
  });

  return <EditorContent editor={editor} />;
};

🪄 Integration Notes

  • Works seamlessly with Tiptap v2+
  • You must manually initialize Mermaid before using
  • Diagrams render only for code blocks with language = mermaid, mmd, or mindmap
  • Errors during rendering are displayed inline (non-blocking)

🙏 Credits


License

This library is licensed under the MPL-2.0 open-source license.

Please enroll in our courses or sponsor our work.