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

@docx-editor.dev/core

v2.21.1

Published

Framework-agnostic core for docx-editor.dev: OOXML parse/serialize, the canonical document tree, layout and paint, and the Editor contract the adapters render.

Readme

@docx-editor.dev/core

The engine behind docx-editor.dev. It reads a .docx into a canonical document tree, lays that tree out into pages, paints them, and writes the tree back to OOXML. No framework dependency and no UI.

Install this package alongside the React or Vue adapter. Both adapters require it as a peer dependency. You can also use its public contracts to build your own adapter.

npm install @docx-editor.dev/core

Node.js requires ^20.16.0 || >=22.3.0.

Entry points

Import editor creation, font helpers, and contract types from the package root:

import { createDocxEditor, loadFonts, WORD_DEFAULT_FONT } from '@docx-editor.dev/core';
import type { Editor, EditorSnapshot } from '@docx-editor.dev/core';

The root covers most uses: creating an editor, the Editor contract it implements, fonts, the chrome registry, and the document model types. Subpaths expose the canonical tree, the layout pass, and the paint step directly.

| Subpath | What's there | | --- | --- | | . | Create an editor, the contract, fonts, the chrome registry, the document model. | | ./editor | Everything the root re-exports, plus the paginated surface and ruler geometry. | | ./contracts/editor | Editor, EditorCommand, EditorQuery, EditorSnapshot, PageSetup. | | ./contracts/document | The document-level edit and query vocabulary. | | ./contracts/interaction | Semantic addressing (SemanticTarget) and the InteractionOutcome an attempt answers with. | | ./contracts/types | Document model types. | | ./contracts/modules | EditorModule — the shape @docx-editor.dev/pro implements. | | ./store | The canonical tree and its transactional store. | | ./layout | The DOM-free layout pass. | | ./output | Paint layouts and selection overlays into the DOM. | | ./export | Document layout sessions for exporters. No DOM required. | | ./automation | The object model behind @docx-editor.dev/editor-api. | | ./collaboration | Provider-neutral collaboration session contracts. | | ./collaboration/replication | Replication helpers for collaboration providers. | | ./styles/editor.css | The one editor stylesheet, shared by packaged and custom chrome. |

Architecture

The engine reads DOCX bytes into a canonical OOXML tree. Layout reads the tree and produces painted pages. Saving serializes the tree back into a DOCX package.

There is one document model. The painted pages are the editable surface: they are contenteditable, but the DOM is a picture. Browser mutations are prevented and re-expressed as tree operations, so the browser never invents markup inside your document.

Nodes are typed where layout needs them and generic everywhere else, preserving the element structure. Content the engine does not model is carried rather than dropped, so a document full of unknown extensions still opens, edits, and saves.

Export sessions default to all-markup, which shows inserted and deleted text. Use displayMode: 'proposed' for the accepted view or displayMode: 'original' for the rejected view.

Build a paginated exporter

For exports that need font-based page breaks, use openFontBackedDocumentForExport. It resolves the fonts used throughout the document before layout. Without a measurer, openDocumentForExport(bytes) uses a fixed-width approximation.

Install @docx-editor.dev/fonts to use packaged substitutes in this example:

import { readFile } from 'node:fs/promises';
import { openFontBackedDocumentForExport } from '@docx-editor.dev/core/export';
import { packagedFonts } from '@docx-editor.dev/fonts';

const bytes = new Uint8Array(await readFile('contract.docx'));
const opened = await openFontBackedDocumentForExport(bytes, {
  fonts: packagedFonts(),
  fontPolicy: 'strict',
  onFontResolution: (report) => console.info(report),
});

if (!opened.ok) throw new Error(`DOCX rejected: ${opened.reason}`);
try {
  const layout = await opened.session.layout();
  console.log(layout); // Replace this with your exporter.
} finally {
  opened.session.dispose(); // releases document-owned shaping bytes
}

Let the engine manage fonts, resources, and layout. Build your output from the returned pages. For a live HeadlessDocumentView, pass the editor's revision-stable measurer.

Fidelity

Untouched content, unsupported OOXML, and package payloads survive editing and save. The canonical tree preserves document structure while embedded fonts, macros, media, and other payloads pass through untouched. Two oracles gate this in CI: a canonical fingerprint over the tree, and a save-and-reopen semantic digest.

Untrusted input

Treat DOCX files as untrusted input. The engine validates URLs and limits XML entities, archive expansion, nesting, and element counts. It does not automatically fetch external document relationships. Serialization escapes document text.

Anything you render from document data (a font name, a hyperlink target, a comment body) is still attacker-controlled at your boundary. Render it as text; do not build markup or URLs from it.

Documentation

License

Apache-2.0