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

@domternal/extension-toc

v1.2.0

Published

Notion-style Table of Contents for Domternal: floating right-rail outline with collapsed/expanded states + insertable inline /toc block, both fed by a shared heading-discovery data layer

Readme

@domternal/extension-toc

Version MIT License

Notion-style Table of Contents for the Domternal editor.

A shared heading-discovery data layer feeds three pieces that work together:

  • TableOfContents - the headless heading observer that maintains a reactive heading list in editor.storage.toc and exposes the scrollToHeading command.
  • FloatingTocOutline - a sticky right-rail outline with a hover-expanded card, anchored to the editor or the viewport.
  • TableOfContentsBlock - a block-level atom node, inserted from the slash menu by typing /toc.

Active-heading tracking, smooth click-to-jump scrolling, and initial-load #hash navigation are built in.

Links

Website    •    Documentation    •    Live examples

Install

pnpm add @domternal/extension-toc

@domternal/core and @domternal/pm are peer dependencies. TableOfContents also requires the UniqueID extension (from @domternal/core) to be loaded: it reads UniqueID's id attribute on headings as the navigation anchor and stays inert without it.

Version 1.2.0 requires both @domternal/core and @domternal/pm in the range >=1.2.0 <2.0.0. Upgrade these packages together with this extension.

Usage

import { Editor, StarterKit, UniqueID } from '@domternal/core';
import {
  TableOfContents,
  FloatingTocOutline,
  TableOfContentsBlock,
} from '@domternal/extension-toc';
import '@domternal/theme';

const editor = new Editor({
  element: document.getElementById('editor')!,
  extensions: [
    StarterKit,
    // UniqueID's default `types` already stamps headings; pass `types` only
    // when TableOfContents' `anchorTypes` point at custom node types.
    UniqueID,
    TableOfContents.configure({ levels: [1, 2, 3] }),
    FloatingTocOutline.configure({ anchor: 'editor' }),
    TableOfContentsBlock,
  ],
});

// Jump to a heading by its UniqueID-assigned id (updates the URL hash).
editor.commands.scrollToHeading('introduction');

// Read the live heading list, or subscribe via the onUpdate option.
console.log(editor.storage.toc.content); // HeadingEntry[]

UniqueID stamps ids on headings; TableOfContents watches the document and keeps editor.storage.toc in sync; FloatingTocOutline renders the sticky outline; TableOfContentsBlock adds the /toc atom so users can drop a contents list into the document.

Options

TableOfContents.configure({ ... }):

  • levels (default [1, 2, 3]) - heading levels to track
  • anchorTypes (default ['heading']) - node names treated as anchors. Every type listed here must also be in UniqueID.options.types
  • onUpdate - called with the storage object whenever the heading list or the active heading changes

Activity tracking belongs to TableOfContents, so HeadingEntry.domNode, isActive, and isScrolledOver stay current even without FloatingTocOutline. The inline block, floating outline, and scrollToHeading command share its navigation state. These observer options are also accepted:

  • activeScrollParent (default null, meaning the window): the scroll container
  • activeRootMargin (default '0px 0px -85% 0px'): the observer margin that schedules measurements
  • activeOffset (default 0): the activation line in pixels below the scroll root's inner top
  • clickOverrideMs (default 500): how long a navigation target stays active while scrolling catches up

Explicit TableOfContents options take precedence. Omitted scroll-parent, root-margin, and click-override options inherit the corresponding legacy FloatingTocOutline options, preserving existing configurations. Use activeOffset to move the activation line; root margin controls observation.

FloatingTocOutline.configure({ ... }):

  • anchor (default 'editor') - 'editor' pins the outline to the editor container's right gutter, 'viewport' fixes it to the right edge of the viewport
  • minHeadings (default 1) - hide the outline while the document has fewer headings than this
  • mobileBreakpoint (default 1024) - viewport width in px at or below which the outline is hidden; 0 never hides it
  • activeScrollParent (default null, meaning the window) - scroll container for the active-heading tracker. Set it when the editor lives in its own scrolling region
  • activeRootMargin (default '0px 0px -85% 0px') - IntersectionObserver rootMargin used to schedule active-heading measurements
  • clickOverrideMs (default 500) - how long scroll-derived updates are ignored after a tick is clicked, so the click target stays active until the scroll lands
  • hoverInDelay / hoverOutDelay (defaults 120 / 350) - ms before the expanded card appears and before it collapses back to ticks
  • outlineHost - (view: EditorView) => HTMLElement overriding where the outline DOM mounts. The default walks up from the editor's DOM to the first ancestor whose computed overflow is not hidden

TableOfContentsBlock.configure({ ... }):

  • emptyStateText (default 'Add headings to create a table of contents.') - placeholder shown while the document has no headings
  • HTMLAttributes - extra attributes for the block wrapper

Exports

import {
  TableOfContents,
  tocPluginKey,
  FloatingTocOutline,
  floatingTocOutlinePluginKey,
  TableOfContentsBlock,
  walkHeadings,
  scrollToHeading,
  createActiveStateTracker,
} from '@domternal/extension-toc';

walkHeadings, scrollToHeading, and createActiveStateTracker are exposed as standalone helpers so you can build a custom outline UI on top of the same data layer and active-tracking rule.

The tracker snapshot type is exported as ActiveStateSnapshot, with activeId and scrolledOverIds. The saved inline node remains tableOfContents; no document migration or change to UniqueID defaults is required.

Localization

This package exports tocMessages for typed custom catalogs. Optional German UI messages and search aliases are available from @domternal/extension-toc/locales/de as deMessages and deSearchAliases. Merge them with the core and other enabled feature catalogs. Missing entries fall back to English. Authored heading text remains unchanged.