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 🙏

© 2025 – Pkg Stats / Ryan Hefner

block-text

v0.1.3

Published

A Notion-like block editor library for React with rich text formatting, syntax highlighting, and LaTeX support

Downloads

19

Readme

Block Text

A powerful, Notion-like block editor library for React with rich text formatting, syntax highlighting, and LaTeX support.

Features

  • 🧱 Block-based Architecture: Everything is a block (paragraphs, headings, images, etc.)
  • Rich Text Formatting: Bold, italic, underline, code, and links
  • 🎨 Syntax Highlighting: Code blocks with Prism.js support
  • 📐 LaTeX Support: Mathematical formulas with KaTeX
  • 🌙 Dark Mode: Built-in dark/light theme support
  • 📱 Responsive: Works on desktop and mobile
  • 🎯 TypeScript: Full TypeScript support
  • 🎨 Customizable: Easy to style and extend

Installation

npm install block-text

Quick Start

import React, { useState } from "react";
import { BlockEditor, BlockRenderer, Block, createBlock } from "block-text";

function App() {
  const [blocks, setBlocks] = useState<Block[]>([
    createBlock("heading1", "Welcome to Block Editor"),
    createBlock("paragraph", "Start typing your content here..."),
  ]);

  return (
    <div>
      <BlockEditor blocks={blocks} onChange={setBlocks} isDarkMode={false} />
      <BlockRenderer blocks={blocks} />
    </div>
  );
}

Block Types

Text Blocks

  • Paragraph: Multi-line text with formatting
  • Heading 1, 2, 3: Different heading levels
  • Quote: Styled quote blocks

Special Blocks

  • Code Block: Syntax-highlighted code with language support
  • Formula: LaTeX mathematical expressions
  • Image: Image blocks with alt text and captions
  • Callout: Highlighted information blocks
  • Divider: Visual separators

List Blocks

  • Bullet List: Unordered lists with nested items
  • Numbered List: Ordered lists with nested items

API Reference

Components

BlockEditor

Main editor component for creating and editing blocks.

<BlockEditor
  blocks={Block[]}
  onChange={(blocks: Block[]) => void}
  isDarkMode?: boolean
  className?: string
/>

BlockRenderer

Component for rendering blocks in read-only mode.

<BlockRenderer
  blocks={Block[]}
  className?: string
/>

Utility Functions

createBlock

Creates a new block with the specified type and content.

createBlock(
  type: Block["type"],
  content?: string,
  metadata?: any
): Block

createTextSegment

Creates a text segment with formatting.

createTextSegment(
  text: string,
  formats: Format[] = []
): TextSegment

Keyboard Shortcuts

  • Enter: New line (in paragraphs)
  • Shift+Enter: New block
  • Ctrl/Cmd+B: Bold
  • Ctrl/Cmd+I: Italic
  • Ctrl/Cmd+U: Underline
  • Ctrl/Cmd+K: Code formatting

Styling

The library uses Tailwind CSS classes. You can customize the appearance by:

  1. Overriding CSS classes
  2. Using the className prop on components
  3. Modifying the dark mode implementation

Supported Languages (Code Blocks)

  • JavaScript, TypeScript
  • Python, Java, C#, C, C++
  • HTML, CSS, JSON, YAML
  • SQL, Bash, Markdown
  • And many more via Prism.js

LaTeX Examples

E = mc^2
\frac{1}{2}mv^2
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}

Development

# Install dependencies
npm install

# Build library
npm run build

# Watch mode for development
npm run dev

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.