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

milkdown-inline-diff

v1.0.2

Published

A Milkdown plugin for inline diff visualization and merge functionality

Readme

milkdown-inline-diff

Block-level Markdown diff and merge controls for Milkdown editors.

milkdown-inline-diff demo

Overview

milkdown-inline-diff compares Markdown documents as block structures instead of raw text lines. It is designed for in-editor review flows where users need to inspect and merge changes without leaving the editor.

It works well for:

  • heading
  • paragraph
  • blockquote
  • nested blockquote
  • list
  • nested list
  • table
  • code block

Installation

pnpm add milkdown-inline-diff

You also need the normal Milkdown editor dependencies used by your app.

Quick Start

import { Editor } from "@milkdown/core";
import { commonmark } from "@milkdown/preset-commonmark";
import {
  diffConfig,
  diffPlugins,
} from "milkdown-inline-diff";
import "milkdown-inline-diff/style.css";

const editor = Editor.make()
  .use(commonmark)
  .use(diffPlugins)
  .config(
    diffConfig({
      acceptButtonTitle: "Accept Change",
      rejectButtonTitle: "Keep Original",
      originContent: "# Original",
      modifiedContent: "# Modified",
    }),
  );

await editor.create();

If both originContent and modifiedContent are provided, the plugin will automatically enter diff mode after the editor view is ready.

Public API

diffPlugins

Milkdown plugin array used with:

editor.use(diffPlugins);

diffConfig(options)

Configuration helper used with:

editor.config(diffConfig({ ... }));
interface DiffConfig {
  acceptButtonTitle?: string;
  rejectButtonTitle?: string;
  originContent?: string;
  modifiedContent?: string;
}

diff(ctx, modifiedContent, originContent?)

Enters diff mode on demand.

editor.action((ctx) => {
  diff(ctx, modifiedContent, originContent);
});

Use this when you want to trigger comparison after editor creation, after loading remote content, or after switching between document versions.

jumpTo(ctx, index)

Moves focus to a specific diff group.

editor.action((ctx) => {
  jumpTo(ctx, 0);
});

This is useful for custom navigation bars, side panels, or review workflows.

merge(ctx, action, index, all?)

Accepts or rejects a diff group, or resolves all groups at once.

editor.action((ctx) => {
  merge(ctx, "accept", 0);
});

editor.action((ctx) => {
  merge(ctx, "reject", 0, true);
});

getDiffState(ctx)

Returns the current diff state for external UI.

const state = editor.action((ctx) => getDiffState(ctx));

The returned state includes:

  • count: total number of diff groups
  • currentIndex: current focused diff group index, or -1 before the first group

This is the function to use when building your own merge bar, status panel, or conflict navigator.

Typical Review Flow

editor.use(diffPlugins).config(
  diffConfig({
    acceptButtonTitle: "Accept Change",
    rejectButtonTitle: "Keep Original",
  }),
);

editor.action((ctx) => {
  diff(ctx, modifiedMarkdown, originMarkdown);
});

const state = editor.action((ctx) => getDiffState(ctx));

editor.action((ctx) => {
  jumpTo(ctx, state.currentIndex + 1);
});

editor.action((ctx) => {
  merge(ctx, "accept", state.currentIndex);
});

Listening For Changes

If you want to keep external UI in sync with the editor, listen to Milkdown or Crepe update events and read diff state inside the callback.

const syncDiffState = () => {
  const state = editor.action((ctx) => getDiffState(ctx));
  setDiffState(state);
};

crepe.on((listener) => {
  listener.mounted(syncDiffState);
  listener.updated(syncDiffState);
  listener.selectionUpdated(syncDiffState);
});

This pattern is used in the React demo to drive the custom merge bar.

Demo

The repository includes a runnable React demo in examples/react.

It demonstrates:

  • editor.use(diffPlugins).config(diffConfig(...))
  • automatic diff on initial content
  • custom tooltip button titles
  • custom merge bar UI driven by getDiffState(ctx)
  • jumpTo navigation
  • merge(..., all) bulk actions

Styling

Import the plugin stylesheet once:

import "milkdown-inline-diff/style.css";

You can then override the tooltip and review UI styles in your app theme if needed.

License

MIT