quill2-delta-html
v1.0.0
Published
Convert Quill 2 Delta to HTML or plain text. Zero dependencies. Cloudflare Workers safe.
Maintainers
Readme
quill2-delta-html
Convert Quill 2 Delta to HTML or plain text.
Zero dependencies. Cloudflare Workers / Edge Runtime safe.
Why?
The existing quill-delta-to-html package:
- Is abandoned (last published April 2022)
- Depends on
lodash.isequal, which usesFunction('return this')()— prohibited in Cloudflare Workers and Edge Runtimes - Has no Quill 2 support
This package is a minimal, zero-dependency replacement that handles all standard Quill 2 formats.
Install
npm install quill2-delta-htmlUsage
import { deltaToHtml, deltaToPlainText } from 'quill2-delta-html'
const delta = JSON.stringify({
ops: [
{ insert: 'Hello ' },
{ insert: 'world', attributes: { bold: true } },
{ insert: '\n' }
]
})
deltaToHtml(delta)
// => '<p>Hello <strong>world</strong></p>'
deltaToPlainText(delta)
// => 'Hello world'Supported formats
All standard Quill 2 formats:
| Category | Formats |
|----------|---------|
| Inline | bold, italic, underline, strike |
| Style | color, background |
| Link | link (with target="_blank") |
| Block | header (1-6), blockquote, code-block |
| List | ordered, bullet |
| Layout | align, indent |
| Embed | image, video |
Backward compatibility
If the input is not valid Quill Delta JSON (e.g. legacy HTML or plain text), both functions handle it gracefully:
deltaToHtml()returns the input unchangeddeltaToPlainText()strips HTML tags and returns the text
This makes migration safe — existing HTML content passes through without breaking.
API
deltaToHtml(rawValue: string): string
Converts a Quill Delta JSON string to HTML.
deltaToPlainText(rawValue: string): string
Extracts plain text from a Quill Delta JSON string. Embeds (images, videos) are excluded.
License
MIT
