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

lexical-ai-tools

v0.2.0

Published

AI editing toolkit for Lexical — selection rewrite, inline diff preview, accept/reject

Readme

lexical-ai-tools

npm npm bundle size license

AI editing primitives for Lexical — selection rewrite, inline diff preview, and low-level tree ops.

  • Provider-agnostic — bring your own AI (OpenAI, Anthropic, local, etc.)
  • Headless — no UI, you build the toolbar
  • Small — ~10 KB, zero runtime deps beyond Lexical
  • TypeScript-first — full types + JSDoc

Install

pnpm add lexical-ai-tools

Peers: lexical, @lexical/react, @lexical/markdown, react

Usage

1. Register the node

import { DiffHighlightNode } from 'lexical-ai-tools';

const config = {
  nodes: [DiffHighlightNode],
  theme: {
    diffHighlight: {
      inserted: 'bg-green-100 text-green-900',
      deleted: 'bg-red-100 text-red-900 line-through',
    },
  },
};

2. AI Rewrite — useAIEdit

import { useAIEdit } from 'lexical-ai-tools';

const { isProcessing, selectedText, rewrite } = useAIEdit({
  editor,
  onRewrite: async (text, instruction) => {
    const res = await fetch('/api/rewrite', {
      method: 'POST',
      body: JSON.stringify({ text, instruction }),
    });
    return (await res.json()).result;
  },
});

// rewrite('Make it shorter')
// rewriteWithPreset('formal')

3. Diff Preview — AIDiffPlugin

import { AIDiffPlugin } from 'lexical-ai-tools';
import { TRANSFORMERS } from '@lexical/markdown';

<AIDiffPlugin
  diff={{ newMarkdown: '# Updated\n\nNew content.' }}
  transformers={TRANSFORMERS}
  onCleared={() => setDiff(null)}
/>

4. Low-level ops

import { $captureSelection, $replaceSelection } from 'lexical-ai-tools';

// Before async AI call
let saved;
editor.getEditorState().read(() => { saved = $captureSelection(); });

// After AI responds
editor.update(() => { $replaceSelection(saved, result); });

API

| Export | Type | Description | |---|---|---| | useAIEdit | Hook | Selection rewrite lifecycle | | AIDiffPlugin | Component | Diff preview with highlight + fade | | DiffHighlightNode | Node | Inline diff marks | | $captureSelection | $ fn | Snapshot range selection | | $replaceSelection | $ fn | Replace saved selection | | $collectBlockTexts | $ fn | Block text array | | $highlightChangedBlocks | $ fn | Mark changed blocks | | $clearDiffHighlights | $ fn | Remove all diff marks |

License

MIT