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

@bhaswanth53/markdown-editor

v0.1.5

Published

Obsidian-style live markdown editor — inline editing, editable code blocks, image paste

Downloads

619

Readme

markdown-editor

Obsidian-style live markdown editor. Click any line to edit its raw markdown inline; click away to render it. Code blocks always stay styled and are edited directly inside the block.

Features

  • Live per-line editing — each line flips between rendered HTML and raw markdown on focus/blur
  • Always-editable code blocks — click inside any code block to type directly; it stays dark and styled at all times
  • Toolbar — headings, bold, italic, strikethrough, links, images, inline code, code blocks, blockquotes, lists, tables, dividers
  • Three view modes — Live Preview · Source+Preview split · Read-only Preview
  • Keyboard shortcutsCtrl+B, Ctrl+I, Ctrl+Z/Y, Ctrl+S, / slash menu, Tab indent in code
  • Image paste & drag-drop — images become base64 data-URIs inline
  • Undo/redo history (150 steps)
  • Auto-save event (debounced 2 s)
  • Accepts HTML or Markdown as input — auto-detected
  • Zero framework dependencies

Install

npm install @bhaswanth53/markdown-editor

Peer dependencies — install these alongside the editor:

npm install highlight.js marked

Quick start

import { MarkdownEditor } from '@bhaswanth53/markdown-editor';
import '@bhaswanth53/markdown-editor/style.css';

const editor = new MarkdownEditor('#my-div', {
  placeholder:   'Start writing…',
  initialValue:  '<p>Hello <strong>world</strong></p>', // HTML or Markdown
  mode: 'live' // live / source
});
editor.init();

// Events
editor.on('change',   (html, md) => console.log(html));
editor.on('save',     (html, md) => fetch('/save', { method: 'POST', body: html }));
editor.on('autosave', (html, md) => localStorage.setItem('draft', md));

// API
editor.getValue();      // → HTML string  (for storing in a database)
editor.getMarkdown();   // → Markdown string
editor.loadValue(str);  // load new HTML or Markdown
editor.clear();
editor.focus();
editor.destroy();

Options

| Option | Type | Default | Description | |---|---|---|---| | placeholder | string | 'Start writing…' | Placeholder shown when editor is empty | | initialValue | string | '' | Initial content — HTML or Markdown | | bindTo | string | undefined | CSS selector of a hidden <input> to keep in sync with HTML output |

Events

| Event | Callback signature | When | |---|---|---| | change | (html: string, md: string) | Every edit | | save | (html: string, md: string) | Ctrl+S | | autosave | (html: string, md: string) | 2 s after last change |

Keyboard shortcuts

| Shortcut | Action | |---|---| | Ctrl+B | Bold | | Ctrl+I | Italic | | Ctrl+Z | Undo | | Ctrl+Y / Ctrl+Shift+Z | Redo | | Ctrl+S | Save | | / on empty line | Slash insert menu | | Tab (inside code block) | Indent 2 spaces | | / (at line edge) | Navigate between lines / code blocks | | Enter | New line (continues list/blockquote prefix) | | Escape | Blur current line |

Styling

All CSS custom properties are prefixed with --mde-. Override them in your stylesheet:

:root {
  --mde-surface:   #ffffff;
  --mde-accent:    #7c3aed;
  --mde-font-body: 'Georgia', serif;
  --mde-font-mono: 'Fira Code', monospace;
}

For syntax highlighting themes, import any highlight.js theme:

import 'highlight.js/styles/github-dark.css';

Dev

npm install
npm run dev      # Vite dev server on http://localhost:5173
npm run build    # outputs dist/markdown-editor.es.js + dist/markdown-editor.umd.js + dist/style.css

Module structure

src/
  index.js           ← package entry point (re-exports everything)
  MarkdownEditor.js  ← main editor class
  code-block.js      ← self-contained editable code block element
  line-renderer.js   ← per-line render / edit helpers
  md-to-html.js      ← markdown → output HTML (marked + hljs)
  html-to-md.js      ← HTML DOM → markdown (for paste / loadValue)
  toolbar.js         ← toolbar HTML builder
  utils.js           ← esc(), uid(), isHtml()
  style.css          ← all component styles

License

MIT