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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@paroicms/quill-delta-to-tiptap-json

v0.2.6

Published

Convert Quill Delta to Tiptap JSON

Downloads

421

Readme

@paroicms/quill-delta-to-tiptap-json

A lightweight JavaScript/TypeScript library for converting Quill Delta JSON to Tiptap JSON without any dependency. This package provides naive and fast server-side conversion of Quill Delta operations to Tiptap JSON.

Installation

npm install @paroicms/quill-delta-to-tiptap-json

Usage

import { convertQuillDeltaToTiptap } from "@paroicms/quill-delta-to-tiptap-json";

const quillDelta = {
  ops: [
    { insert: "Hello World", attributes: { bold: true } },
    { insert: "\n", attributes: { header: 1 } },
    // ...
  ],
};

const { result, issues } = convertQuillDeltaToTiptap(quillDelta);

console.log(JSON.stringify(result, null, 2));
// {
//   "type": "doc",
//   "content": [
//     {
//       "type": "heading",
//       "attrs": { "level": 1 },
//       "content": [
//         { "type": "text", "text": "Hello World", "marks": [{ "type": "bold" }] }
//       ]
//     },
//     // ...
//   ]
// }

// Check for any issues during conversion
if (issues) {
  console.warn("Conversion issues:", issues);
}

Custom Converters

You can extend the converter with custom handlers for inline formats, block formats, and embeds:

const { result, issues } = convertQuillDeltaToTiptap(quillDelta, {
  customConverters: {
    // Custom inline format (mark)
    inlineFormats: {
      underline: (value, context) => ({
        type: "underline",
      }),
    },
    // Custom block format
    blockFormats: {
      align: (content, value, context) => ({
        type: "paragraph",
        attrs: { textAlign: value },
        content,
      }),
    },
    // Custom embed type
    embeds: {
      image: (value, context) => ({
        type: "image",
        attrs: {
          src: value,
          alt: null,
          title: null,
        },
      }),
      video: (value, context) => ({
        type: "video",
        attrs: { src: value },
      }),
    },
  },
  // Ignore specific attributes (color and background are ignored by default, set to [] to keep them)
  ignoreAttributes: ["color", "background", "font"],
});

Remapping Built-in Formats

You can use custom converters to remap Quill's built-in formats to different Tiptap marks. For example, to convert Quill's underline format to Tiptap's italic mark (mapping <u> to <em>):

const { result } = convertQuillDeltaToTiptap(quillDelta, {
  customConverters: {
    inlineFormats: {
      // Map underline to italic/emphasis
      underline: (value) => (value ? { type: "italic" } : undefined),
    },
  },
});

This pattern is useful when migrating content and you want to change the semantic meaning of certain formats. The value check ensures that falsy values (like { underline: false }) don't add the mark.

API

convertQuillDeltaToTiptap(input: QuillDelta | string, options?: ConverterOptions): ConversionResult

Converts a Quill Delta object or JSON string to Tiptap JSON format.

Parameters:

  • input: Quill Delta object
  • options (optional): Configuration options
    • customConverters: Custom converter functions for inline formats, block formats, and embeds
    • ignoreAttributes: Array of attribute names to ignore (default: ["color", "background"])

Returns: ConversionResult object containing:

  • result: The Tiptap JSON document (type TiptapJsonValue)
  • issues (optional): Array of warning messages for skipped or unsupported content

Supported Quill Delta Features

Block-Level Formats

  • Headings: { header: 1 } through { header: 6 } → Tiptap headings with bold marks
  • Paragraphs: Default block type for regular text
  • Blockquotes: { blockquote: true }
  • Code blocks: { "code-block": true } or { "code-block": "language" } (with language)
  • Lists:
    • Bullet lists: { list: "bullet" }
    • Ordered lists: { list: "ordered" }
    • Nested lists: Supported via { indent: level } attribute

Inline Formats (Marks)

  • Bold: { bold: true }
  • Italic: { italic: true }
  • Strikethrough: { strike: true }
  • Inline code: { code: true }
  • Superscript: { script: "super" } → Converted to superscript mark
  • Subscript: { script: "sub" } → Converted to subscript mark
  • Links: { link: "url" } → Converted with target="_blank" and security attributes

Embeds

Embeds are handled through the customConverters.embeds option. Common embed types include:

  • Images: { insert: { image: "url" } }
  • Videos: { insert: { video: "url" } }
  • Custom embeds: Any object-type insert can be handled with a custom converter

Special Handling

  • Empty documents: Returns empty doc with no issues
  • Unsupported attributes: Logged in issues array (except size which is silently ignored)
  • Ignored attributes: Color and background are ignored by default (customizable via options)
  • Malformed JSON: Returns empty doc with error in issues
  • Mixed embeds and text: Supported on the same line

Differences from Quill

  • Color/background: Ignored by default (not standard Tiptap features)

License

MIT

Related Packages

This package can be used as a standalone library. It's also part of the ParoiCMS ecosystem. For more information, visit the ParoiCMS repository.