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

inline-editor

v0.1.0

Published

AI-powered inline editor component for React - Select text → Input instruction → Content replacement

Downloads

135

Readme

InlineEditor

一个 React 组件库,提供"选中文字 → 指令输入 → 内容回填"的内联编辑交互体验。

🚀 安装

npm install inline-editor
# 或
yarn add inline-editor
# 或
pnpm add inline-editor

📖 使用方法

基础使用

import { InlineEditor } from 'inline-editor';

function App() {
  const containerRef = useRef<HTMLDivElement>(null);

  const handleRequest = async (payload) => {
    // 调用你的AI服务
    const response = await fetch('/api/ai-process', {
      method: 'POST',
      body: JSON.stringify(payload)
    });
    return await response.text();
  };

  const handleReplace = (info) => {
    console.log('内容被替换:', info);
  };

  return (
    <div ref={containerRef}>
      <p>这是一段可以编辑的文本...</p>
      <InlineEditor
        targetRef={containerRef}
        onRequest={handleRequest}
        onReplace={handleReplace}
      />
    </div>
  );
}

支持 Markdown

import { InlineEditor } from 'inline-editor';
import ReactMarkdown from 'react-markdown';

function MarkdownApp() {
  const containerRef = useRef<HTMLDivElement>(null);

  return (
    <div ref={containerRef}>
      <ReactMarkdown>
        # 这是一个 Markdown 文档
        
        你可以**选中**任何文本进行编辑
      </ReactMarkdown>
      <InlineEditor
        targetRef={containerRef}
        onRequest={handleRequest}
        onReplace={handleReplace}
      />
    </div>
  );
}

🔧 API

InlineEditor Props

| 属性 | 类型 | 默认值 | 描述 | |------|------|--------|------| | targetRef | RefObject<HTMLElement> | - | 目标容器的 ref | | onRequest | (payload: RequestPayload) => Promise<string> | - | AI 请求处理函数 | | onReplace | (info: ReplaceInfo) => void | - | 内容替换回调 | | onSave? | () => void | - | 保存回调 | | onError? | (error: unknown) => void | - | 错误处理回调 | | onClose? | () => void | - | 关闭回调 |

类型定义

interface RequestPayload {
  selectedText: string;
  instruction: string;
  blockIndex: number;
}

interface ReplaceInfo {
  originalText: string;
  newText: string;
  blockIndex: number;
}

🎯 特性

  • 智能编辑: AI 驱动的文本编辑体验
  • Markdown 支持: 完美支持 Markdown 文档编辑
  • 响应式设计: 适配各种屏幕尺寸
  • TypeScript: 完整的类型支持
  • 轻量级: 无额外依赖,体积小巧

📄 许可证

MIT License