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

quill-format-blockquote

v1.0.0

Published

Grouped and nested blockquotes for Quill 2

Downloads

150

Readme

quill-format-blockquote

为 Quill 2.0.3 及更高的 2.x 版本提供支持分组和嵌套的引用块格式。

安装

npm install quill quill-format-blockquote

使用

在页面中添加编辑器元素:

<div id="editor"></div>

创建编辑器前注册引用块格式,并在 Quill 主题样式之后导入本包的 CSS:

import Quill from 'quill'
import Blockquote, { matchBlockquote } from 'quill-format-blockquote'
import 'quill/dist/quill.snow.css'
import 'quill-format-blockquote/style.css'

Quill.register(Blockquote, true)

const quill = new Quill('#editor', {
  theme: 'snow',
  modules: {
    toolbar: [['bold', 'italic', 'blockquote']],
    clipboard: {
      matchers: [['blockquote', matchBlockquote]],
    },
  },
})

工具栏使用标准的 blockquote 格式名称。注册 Blockquote 时会同时注册 BlockquoteContainer。

导入和导出 HTML

按上述示例配置 matchBlockquote 后,在粘贴 HTML、转换 HTML 或向编辑器加载初始 HTML 时,都能保留引用块的分组和嵌套结构。

quill.clipboard.dangerouslyPasteHTML(
  '<blockquote><p>第一段</p><p>第二段</p><blockquote><p>嵌套引用</p></blockquote></blockquote>'
)

const html = quill.getSemanticHTML()

getSemanticHTML() 会导出标准的嵌套 <blockquote><p>...</p></blockquote> 标记,并保留行内格式。

为已有编辑器添加匹配器:

import { addBlockquoteMatcher } from 'quill-format-blockquote'

const removeMatcher = addBlockquoteMatcher(quill.clipboard)

// 不再需要此匹配器时,调用该函数将其移除。
removeMatcher()

如果已经配置了 matchBlockquote,此辅助函数会保留现有匹配器,不会重复添加。

通过代码设置引用块

使用 true 设置顶层引用块,使用 false 移除引用块格式:

quill.formatLine(0, 1, 'blockquote', true)
quill.formatLine(0, 1, 'blockquote', false)

使用 true 设置格式的相邻行会合并为同一个引用块。使用分组 ID 可以让引用块保持独立,使用斜杠分隔的路径可以创建嵌套引用块:

import { createBlockquoteGroup } from 'quill-format-blockquote'

const root = createBlockquoteGroup()
const child = createBlockquoteGroup()

quill.setText('第一段\n嵌套段落\n')
quill.formatLine(0, 1, 'blockquote', root)
quill.formatLine('第一段\n'.length, 1, 'blockquote', `${root}/${child}`)

路径中首个分组 ID 相同的行属于同一个根引用块,根 ID 不同的引用块则保持独立。使用 getBlockquotePath(value) 可以将引用块格式值解析为路径片段数组。

配置

  • 如果使用 Quill 的 formats 允许列表,请加入 'blockquote';其所需的容器会自动包含在内。
  • 如果使用自定义 Parchment 注册表,请在该注册表中同时注册 Blockquote 和具名导出的 BlockquoteContainer。
  • 在 SSR 应用中,请仅在客户端加载本包,因为它依赖浏览器 DOM。