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

@v5md/react

v0.0.8

Published

v5md 的 React 组件

Readme

@v5md/react

@v5md/view 的 React 封装。组件名是 V5Editor,由 value 和 onChange 受控。

peer dependency 是 react 与 react-dom 的 18 或 19。样式从 @v5md/view/theme.css 引入,本包不打包主题。

用法

import { useState } from 'react'
import type { Editor } from '@v5md/view'
import { V5Editor } from '@v5md/react'
import '@v5md/view/theme.css'

export function Page() {
  const [markdown, setMarkdown] = useState('# 标题\n')
  const [editor, setEditor] = useState<Editor | null>(null)

  return (
    <V5Editor
      value={markdown}
      onChange={setMarkdown}
      placeholder="开始编写…"
      onReady={setEditor}
      onUploadImage={(file) => URL.createObjectURL(file)}
    />
  )
}

属性

| 属性 | 说明 | | --- | --- | | value | Markdown 全文 | | onChange | 文档变化时收到新全文 | | placeholder | 空文档提示,变化时同步到编辑器 | | theme | 视觉主题,默认 paper;内置可选 github / nord / tokyo-night / catppuccin / one-dark / dracula / solarized-light / solarized-dark / catppuccin-latte / rose-pine-dawn,也可传任意自定义 id(需自行提供对应 CSS),变化时调用 setTheme | | className | 加在宿主元素上,宿主同时有 v5md-host | | editable | 是否可编辑,默认 true。传 false 进入只读预览,变化时调用 setEditable;预览下待办复选框仍可切换 | | plugins | 插件数组,挂载时传给 Editor | | onUploadImage | (file: File) => string \| Promise<string> | | onPickImage | 点击工具条图片按钮时调用;返回 false 则继续使用系统文件选择框 | | onFindRequest | (request: { kind: 'find' \| 'replace' }) => void。不传时按 Mod+F / Mod+H 打开内置查找栏 | | onReady | 挂载完成后拿到 Editor 实例 |

编辑器只在挂载时创建一次。之后 value 与内部全文不同时,才调用 setMarkdown。onChange、onUploadImage、onPickImage、onFindRequest、onReady 的后续变化不会重建编辑器;editable、placeholder、locale 和 theme 会直接同步到实例。

plugins 只在挂载时读取。运行时安装插件可以通过 onReady 拿到实例后调用 editor.use(plugin),卸载调用返回句柄的 dispose()。

onReady 得到的实例可以调用 undo、redo、openFind、setSourceMode、setToolbarVisible、setOutlineVisible、copyForWechat、use、runCommand。工具条最右侧的「复制到公众号」会生成带内联样式的富文本,也可以直接调用 editor.copyForWechat()。工具条和大纲默认显示。卸载时会 destroy()。

构建

npm run build -w @v5md/react