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

@qynpm/rich-text

v1.0.0

Published

起印富文本编辑器和安全查看器组件包。

Readme

@qynpm/rich-text

起印富文本包,提供 Vue 3 + Quill 编辑器和不创建 Quill 实例的安全查看器。Quill 与 DOMPurify 只在包内部使用,业务侧只依赖 Qy HTML 协议和 Qy 类型。

使用

<script setup lang="ts">
import { ref } from 'vue'
import { QyRichTextEditor } from '@qynpm/rich-text'

const html = ref('<p>欢迎使用。</p>')

const uploadImage = async (file: File) => {
  // 由宿主上传并返回最终 URL;组件不持有接口、token 或 store。
  return await uploadToYourService(file)
}
</script>

<template>
  <QyRichTextEditor
    v-model="html"
    :upload-image="uploadImage"
    placeholder="输入内容"
    :height="320"
  />
</template>

安全查看器:

<script setup lang="ts">
import { QyRichTextViewer } from '@qynpm/rich-text'
import { openQyImagePreview } from '@qynpm/ui'

const html = '<h2>只读标题</h2><p>正文和列表会保留,危险标签会被移除。</p>'
</script>

<template>
  <QyRichTextViewer
    :content="html"
    empty-text="暂无内容"
    :max-height="360"
    :image-preview="(url) => openQyImagePreview({ url })"
  />
</template>

QyRichTextViewercontent 始终经过内置 DOMPurify adapter 清理;脚本、事件属性、危险协议、iframeobjectembedstyle 和 SVG 会被拒绝。allowedTagsallowedAttributes 只能追加受限的 Qy 标记/属性,不能关闭清理或传入 DOMPurify hook。imagePreview 是可选的 (url: string) => void 回调,宿主可在其中调用 openQyImagePreview

单组件查看器入口:

import QyRichTextViewer from '@qynpm/rich-text/qy-rich-text-viewer'

查看器公开 props:content?: stringemptyText?: stringminHeight?: number | stringmaxHeight?: number | stringlinkTarget?: '_self' | '_blank' | '_parent' | '_top'imagePreview?: (url: string) => voidallowedTags?allowedAttributes?

单组件入口:

import QyRichTextEditor from '@qynpm/rich-text/qy-rich-text-editor'

公共协议

  • props:modelValue?: stringuploadImage?: (file: File) => string | Promise<string>readOnly?disabled?placeholder?height?: number | string
  • emits:update:modelValue(html)change(html)focusblurupload-error(error)
  • uploadImage 只接受 PNG/JPEG/GIF/WebP,单文件上限 5MB;粘贴批次和连续粘贴按顺序串行上传,单个失败不会阻断后续文件。
  • 图片尺寸工具栏提供 10%30%50%70%100%复原
  • expose:getHTML()setHTML(html)focus()blur()insertImage(url)。不暴露 Quill 实例、Delta、Range 或厂商事件对象。

上传失败通过 upload-error 事件和 upload-error slot 反馈;组件不会调用 Element Plus 消息或 window.alert