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

@chika3742/mdedit

v1.20260616.1

Published

> [!WARNING] > > This package is not intended for use outside of my project.

Readme

mdedit

[!WARNING]

This package is not intended for use outside of my project.

An embeddable Markdown editor library built on CodeMirror 6. It provides formatting commands — bold, italic, strikethrough, code, link, font color, font size, horizontal rule, blockquote, bullet list, and ordered list — along with image upload and a way to read the toolbar state (active / inactive / disabled).

Installation

pnpm add @chika3742/mdedit

Usage

import { createMarkdownEditor } from "@chika3742/mdedit"
import type { ButtonState } from "@chika3742/mdedit"

const editor = createMarkdownEditor(document.querySelector("#md-root")!, {
  autofocus: true,
  onStateChange: (state: ButtonState) => {
    // Reflect the state onto your toolbar buttons
    console.log(state)
  },
  // Enable image paste/drop and the uploadImage method
  uploadImage: async (file) => {
    const url = await myUploader(file)
    return url
  },
  onUploadError: (file, error) => console.error(file.name, error),
})

// Run formatting commands
editor.toggleBold()
editor.toggleItalic()
editor.toggleStrikethrough()
editor.toggleCode()
editor.toggleLink()
editor.insertFontColor()
editor.insertFontSize()
editor.toggleHorizontalRule()
editor.toggleBlockquote()
editor.toggleBulletList()
editor.toggleOrderedList()
editor.toggleHeading(2) // ATX heading, level 1–6

// Upload an image at the current cursor
editor.uploadImage(file)

// Read the current state
const state = editor.getButtonState()

// Dispose
editor.destroy()

See example/ for a complete toolbar integration.

API

createMarkdownEditor(element, options?)

Creates a Markdown editor in the given element and returns a MarkdownEditor.

| Option | Type | Description | |-----------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| | autofocus | boolean | Focus the editor on creation | | onStateChange | (state: ButtonState) => void | Called when the button state changes on caret move or edit | | uploadImage | (file: File) => Promise<string> | Uploads an image and resolves to its URL. Enabling this lets the editor accept pasted/dropped images and exposes the uploadImage method | | onUploadError | (file: File, error: unknown) => void | Called when an image upload rejects |

MarkdownEditor methods:

  • toggleBold() / toggleItalic() / toggleStrikethrough() / toggleCode() — toggle the format of the current selection
  • toggleLink() — insert a link template when outside a link, or unwrap to the link text when inside one
  • insertFontColor() — wrap the selection in a <span style="color: ..."> template, with the caret on the color placeholder
  • insertFontSize() — wrap the selection in a <span style="font-size: ..."> template, with the caret on the size placeholder
  • toggleHorizontalRule() — toggle a horizontal rule (---) at the cursor
  • toggleBlockquote() — toggle blockquote (> ) on each selected line
  • toggleBulletList() — toggle a bullet list (- ) on each selected line
  • toggleOrderedList() — toggle an ordered list (1. ) on each selected line, renumbering across a multi-line selection
  • toggleHeading(level) — toggle an ATX heading of the given level (1–6) on each selected line
  • uploadImage(file) — upload an image at the current cursor, inserting a placeholder until the upload resolves (no-op when uploadImage is not configured)
  • getButtonState() — return the current toolbar state (ButtonState)
  • destroy() — dispose the editor

ButtonState has one entry per toggleable command (bold, italic, strikethrough, code, link, horizontalRule, blockquote, bulletList, orderedList, heading2, heading3, heading4), each one of "inactive" | "active" | "disabled".

Keyboard shortcuts

| Action | Shortcut | | --- | --- | | Bold | Mod-b | | Italic | Mod-i | | Strikethrough | Mod-Shift-x | | Code | ` | | Insert link | Mod-k | | Heading 1–6 | Mod-1Mod-6 |

Images can also be added by pasting or dropping them into the editor when uploadImage is configured.

Theming / Styling

| CSS Class | Description | Configuration Example | |--------------------|----------------------|-------------------------------------------------| | .cm-editor | Editor container | Background color, margin, padding | | .cm-content | Editor content | Font family, caret color, text color, font size | | .cm-codeblock-line | Lines of code blocks | Background color, font family | | .cm-inline-code | Inline code span | Background color, font family |

Development

pnpm dev         # Start the example on a local dev server
pnpm test        # Run tests with vitest
pnpm typecheck   # Type-check
pnpm lint        # ESLint
pnpm check       # Run lint, typecheck, and test in order