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

picture-note-react

v2.0.1

Published

前端图片批注功能react版

Readme

图片批注插件react版

欢迎大家使用,有问题可以在这csdn下方留言,我会不定期来这看有什么bug和优化点,尽量快速更新优化

https://blog.csdn.net/cdy_1/article/details/138723978?spm=1001.2014.3001.5502

install

pnpm i picture-note
# 请先下载最新的 picture-note 因为picture-note-react内部依赖picture-note
pnpm i picture-note-react
npm i picture-note-react
yarn add picture-note-react

使用

import { useRef, useState, useEffect } from 'react'
import img from '@/assets/2.jpg'
import PicNote, { NoteData, DrawingMode, NoteRef } from 'picture-note-react'
import 'picture-note/lib/index.css'

function PictureNote() {
  const picRef = useRef<NoteRef>({})
  const [mode, setMode] = useState<DrawingMode>('')
  const [color, setColor] = useState('')
  const [size, setSize] = useState('')
  const [data, setData] = useState<NoteData[]>([])

  const save = (v: NoteData[]) => {
    console.log(v);
    setData(v)
  }

  useEffect(() => {
    return () => {
      picRef.current?.destroy?.()
    }
  }, [])

  return (
    <div>
      <PicNote
        img={img}
        ref={picRef}
        width={1000}
        height={600}
        mode={mode}
        color={color}
        size={size}
        noteData={data}
        save={save}
      />
      <div>
        <button onClick={() => setMode('rect')}>矩形</button>
        <button onClick={() => setMode('pen')}>画笔</button>
        <button onClick={() => setMode('text')}>文本</button>
        <button onClick={() => setMode(' ')}>空</button>&emsp;
        颜色:<input type="color" onChange={(e) => setColor(e.target.value)} />&emsp;
        尺寸: <input type="number" onChange={(e) => setSize(e.target.value)} />&emsp;
        <button onClick={() => picRef.current.reload?.([
          {
            "id": "af4b7442ec6a1",
            "type": "pen",
            "d": "M262,132 L262,132 L263,132 L266,132 L269,132 L274,132 L278,135 L283,137 L285,141 L289,144 L293,147 L297,150 L299,152 L302,154 L302,155 L303,159 L304,161 L306,164 L306,169 L306,175 L306,180 L306,187 L306,193 L306,202 L306,211 L303,222 L297,232 L290,244 L284,255 L276,268 L269,277 L262,287 L255,297 L252,300 L245,306 L232,316 L230,318 L217,325 L211,328 L202,329 L195,330 L192,330 L183,330 L179,330 L174,330 L171,330 L169,330 L167,328 L166,327 L166,326 L166,324 L166,319 L166,314 L166,308 L166,299 L171,288 L178,278 L188,264 L200,251 L217,238 L233,225 L257,210 L279,198 L304,187 L330,177 L354,169 L378,163 L402,157 L419,153 L436,152 L440,152 L452,150 L460,149 L467,149 L470,149 L473,149 L474,149 L475,149 L476,149 L476,149",
            "x": 0,
            "y": 0,
            "color": "red",
            "size": "2"
          }
        ])}>重新加载</button>
        <button onClick={() => {
          const data = picRef.current.removeChild?.()
          console.log(data);
        }}>删除</button>
        <button onClick={async() => {
          const data = await picRef.current.getImg?.()
          console.log(data);
        }}>获取图片</button>
      </div>
    </div>
  )
}
export default PictureNote

types

// 更多类型请到 https://www.npmjs.com/package/picture-note?activeTab=readme 看
import type { Destroy, DrawingMode, NoteData, Reload, RemoveChild, Plugin, GetImg } from 'picture-note/lib/index.d.ts'
/**
 * @react
 */
type PropsReact = {
  img: string; // 图片地址
  noteData?: NoteData[] | (() => NoteData[]), // 回填数据
  save?: (data: NoteData[], type: DrawingMode) => void, // 创建、移动、修改大小和文本框失焦后会触发保存;触发保存后会执行传入的回调
  width?: string | number,
  height?: string | number,
  style?: React.CSSProperties,
  color?: string,
  size?: number | string,
  mode?: DrawingMode,
  plugins?: Plugin[],
}

type NoteRef = {
  removeChild?: RemoveChild,
  reload?: Reload,
  destroy?: Destroy,
  getImg?: GetImg,
}