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

md-dragger

v2.0.2

Published

Core markdown block drag-and-drop engine

Readme

md-dragger

Platform-agnostic markdown block drag-and-drop engine.

md-dragger is a headless core for block-level drag and drop in markdown editors: it detects markdown blocks (headings, lists, tables, callouts, code, math, …), runs the drag gesture, computes the move, and produces a minimal document edit. It does not import Obsidian, CodeMirror, DOM events, or any editor API — hosts wire it into their editor of choice.

npm License CI

  • Headless — no UI, no editor, no platform dependency in the core.
  • Markdown-aware — block detection, nesting, container rules, list renumbering, and table/math/fence integrity are all computed on the document model.
  • Two integration levels — drop in the CodeMirror 6 adapter, or drive the runtime with your own input/commit/locate hosts.
  • Small & typed — strict TypeScript, tree-shakeable entry points.

Reference hosts:

Install

npm install md-dragger
# peer dependencies for the CM6 adapter
npm install @codemirror/state @codemirror/view

Entry points

| Import | Contents | | --- | --- | | md-dragger | Domain + runtime aggregates | | md-dragger/domain | Pure markdown model: detectBlock, parseLine, planMove, moveTx, locateDropPosition, selection helpers | | md-dragger/runtime | Headless DraggerRuntime, input/locate/commit host types | | md-dragger/runtime/modules | Reusable runtime modules (e.g. autoScroll) | | md-dragger/adapter/codemirror | CM6 wiring: mdDragger(), dragHandleGutter, dragRuntime, paint/decorations helpers |

Quick start (CodeMirror 6)

import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { mdDragger } from 'md-dragger/adapter/codemirror';

const view = new EditorView({
    parent: document.body,
    state: EditorState.create({
        doc: '# Title\n\n- item one\n- item two',
        extensions: [
            mdDragger({
                // Required: structural config. tabSize is re-read live from the
                // editor state; listIndentUnit is the nesting step in columns.
                config: { tabSize: 4, listIndentUnit: 4 },
                // Required: rendered pixel width of one list nesting level
                // (x-axis drag step). Measure it from your theme.
                listIndentWidthPx: 36,
            }),
        ],
    }),
});

The adapter paints a ⋮⋮ handle per block in a gutter and wires pointer input, drop hit-testing, cross-pane commits, and the drag pipeline. Hosts provide the CSS (the protocol classes are documented in docs/api-reference.md; see the Obsidian plugin's styles.css for a reference implementation).

For non-CM6 editors, drive DraggerRuntime directly — see docs/getting-started.md.

Architecture

┌──────────────────────────────────────────────────────────┐
│ Host — owns the editor, renders handles/seam, styles     │
│   (obsidian-dragger, the site playground, …)             │
└──────────────────────────┬───────────────────────────────┘
                           │ mdDragger() / DraggerRuntime
┌──────────────────────────┴───────────────────────────────┐
│ adapter/codemirror — CM6 gutter, pointer input, locate,  │
│   commit routing, paint decorations                      │
├──────────────────────────────────────────────────────────┤
│ runtime — headless gesture state machine & drag pipeline │
├──────────────────────────────────────────────────────────┤
│ domain — pure markdown block model, parsing, move plans  │
└──────────────────────────────────────────────────────────┘
  • domain is pure: text in, plans/edits out. No I/O, no DOM.
  • runtime is headless: it consumes an InputSource, a DocumentHost, a LocateHost, and a CommitHost and drives the gesture/drop pipeline.
  • adapter connects the runtime to CodeMirror 6 and exposes decoration builders hosts paint from.

See docs/architecture.md for the full host responsibility checklist.

Documentation

License

MIT