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

square-9-png

v0.4.2

Published

react使用的九宫格图编辑器

Readme

square-9-png

react.js 使用的九宫格图编辑器,可以快速定义九宫格模板,并将模板信息写入图片中,无需单独存储数据

作者: [email protected]


一、编辑器

1. 使用方法

  • 安装依赖
    npm install --save square-9-png

  • 安装完毕后, 在 react 组件中使用

import React, { useState } from 'react';
import Square from 'square-9-png';
...
function App() {
  const [visible, setVisible] = useState<Boolean>(false);
  return (
    <Square
      visible={visible}
      onClose={() => {
        setVisible(false);
      }}
      onExport={(file: Blob) => {
        //TODO: 处理导出文件
      }}
      testWord="测试\n文本"
    />
  );
}

2. 参数

| 参数名 | 类型 | 必填 | 默认值 | 描述 | | -------- | --------------------- | ---- | ------------------ | ------------------------------ | | visible | boolean | - | true | 编辑器是否可见 | | source | string | - | undefined | 默认使用九宫格底图 | | testWord | string | - | 这是一条测试文本 | 测试九宫格时显示的内容(可换行) | | onExport | (target:Blob)=>void | - | undefined | 用户点击导出时的处理方法 | | onClose | ()=>void | - | undefined |  用户点击关闭时的处理方法 |


项目依赖

1. antd v4 - UI组件
2. brower-image-combiner 用于导出PNG写入头信息的图形库

二、单独使用预览器

  import React, { useState, use } from 'react';
  import Previewer, { SquareInfoAdapter, SquareInfoExtractor, SquareInfo } from 'square-9-png/lib/previewer'
  ...


  const url="***.png" //经过编辑器编辑过的九宫格图
  const WIDTH = 400;
  function App() {
    const [previewInfo, setPreviewInfo] = useState<SquareInfo | null>(false);
    useEffect(() => {
      SquareInfoAdapter(SquareInfoExtractor(url))
        .then((data) => {
          setPreviewInfo(data);
        })
        .catch(console.error);
    }, []);
    return (
      <div>
        {previewInfo && <Previewer {...previewInfo} src={url} />}
      </div>
    );
  }