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

@tangramino/base-editor

v0.1.3

Published

A visual drag and drop base editor

Readme

@tangramino/base-editor

English | 简体中文


生产级拖拽可视化编辑器框架

低代码编辑器:拖拽交互、画布管理、物料系统和插件架构。基于 dnd-kit 构建,交互流畅。

✨ 特性

| 特性 | 描述 | | --------------- | ---------------------- | | 🎯 拖拽功能 | 内置 dnd-kit 集成 | | 🎨 物料系统 | 定义可复用的组件物料 | | 🔌 插件架构 | 通过插件扩展功能 | | 📜 历史记录 | 内置撤销/重做支持 | | 🖼️ 画布管理 | 选中、定位、覆盖层 | | 🛡️ 类型安全 | 完整的 TypeScript 支持 |

📦 安装

npm install @tangramino/base-editor

🚀 快速开始

import React from 'react';
import { EditorProvider, CanvasEditor, Draggable, useEditorCore } from '@tangramino/base-editor';

const materials = [
  {
    type: 'button',
    title: '按钮',
    Component: (props) => <button {...props}>{props.children || '点击'}</button>,
    defaultProps: { children: '按钮' },
  },
];

function App() {
  return (
    <EditorProvider materials={materials}>
      <div style={{ display: 'flex', height: '100vh' }}>
        <MaterialPanel />
        <CanvasEditor style={{ flex: 1 }} />
      </div>
    </EditorProvider>
  );
}

function MaterialPanel() {
  const { materials } = useEditorCore();
  return (
    <div style={{ width: 200, padding: 16 }}>
      {materials.map((m) => (
        <Draggable key={m.type} material={m}>
          <div style={{ padding: 8, border: '1px solid #ddd', marginBottom: 8, cursor: 'move' }}>
            {m.title}
          </div>
        </Draggable>
      ))}
    </div>
  );
}

📘 API 参考

<EditorProvider />

| 属性 | 类型 | 必填 | 描述 | | ----------- | ------------------ | :--: | --------------- | | materials | Material[] | ✓ | 可用的组件物料 | | schema | Schema | | 初始 Schema | | plugins | Plugin[] | | 编辑器插件 | | onChange | (schema) => void | | Schema 变更回调 |

useEditorCore()

const {
  schema, // 当前 Schema
  activeId, // 选中的元素 ID
  materials, // 注册的物料
  setActiveId, // 设置选中
  updateElement, // 更新元素属性
  deleteElement, // 删除元素
  insertElement, // 插入新元素
} = useEditorCore();

物料定义

interface Material {
  type: string; // 唯一标识符
  title: string; // 显示名称
  Component: ComponentType; // React 组件
  defaultProps?: object; // 默认属性
  isContainer?: boolean; // 是否为容器
  editorConfig?: EditorConfig;
}

🔌 插件系统

import { definePlugin } from '@tangramino/base-editor';

const myPlugin = definePlugin(() => ({
  id: 'my-plugin',

  transformMaterials(materials) {
    // 转换物料
    return materials;
  },

  onBeforeInsert(schema, parentId, element) {
    // 插入前校验
    return true;
  },
}));