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

@scrivr/docx

v1.0.11

Published

DOCX import + export for Scrivr documents — semantic round-trip to WordprocessingML

Readme

@scrivr/docx

DOCX import + export for Scrivr documents — semantic round-trip to Office Open XML (WordprocessingML).

Both sides are extension-aware: nodes and marks contributed by your custom extensions can register their own DOCX serializers and parsers, so the round-trip stays lossless for the schema you actually use.

Installation

pnpm add @scrivr/core @scrivr/docx

Usage in the editor

Add the extensions to wire up toolbar buttons and editor commands:

import { Editor, StarterKit } from '@scrivr/core';
import { DocxExport, DocxImport } from '@scrivr/docx';

new Editor({
  extensions: [
    StarterKit,
    DocxImport,
    DocxExport.configure({ filename: 'my-doc' }),
  ],
});

This adds:

  • A "⬆ DOCX" toolbar button + editor.commands.importDocxFromFile() — opens a file picker and replaces the document.
  • A "⬇ DOCX" toolbar button + editor.commands.exportDocx() — triggers a browser download.

Usage on the server

The bare functions don't need a view or a layout. Pair them with ServerEditor from @scrivr/core:

import { ServerEditor, StarterKit } from '@scrivr/core';
import { importDocx, exportDocx } from '@scrivr/docx';

const editor = new ServerEditor({ extensions: [StarterKit] });

// Import
const { doc, diagnostics } = await importDocx(editor, bytes);
editor.setContent(doc.toJSON());

// Export
const { bytes: out, diagnostics: warnings } = await exportDocx(editor);

Both functions return a diagnostics array — DOCX conversion is inherently lossy, and warnings (dropped nodes, approximated mappings, missing media parts) surface here instead of throwing. Fatal failures throw DocxImportError / DocxExportError with the same diagnostics attached.

Options

await exportDocx(editor, {
  unsupported: 'drop',        // 'drop' | 'warn' | 'throw'  — default: 'drop'
  fidelity: 'compatible',     // 'compatible' | 'strict'    — default: 'compatible'
});

await importDocx(editor, bytes, {
  unsupported: 'drop',
  fidelity: 'compatible',
  media: 'data-url',          // 'data-url' | 'skip' | custom sink — default: 'data-url'
});

The same options can be set as defaults on the extension via .configure({...}); per-call options on editor.commands.exportDocx({...}) override them.

Extending

Custom nodes/marks can contribute their own DOCX handlers via the extension API:

import { Extension } from '@scrivr/core';

export const Callout = Extension.create({
  name: 'callout',
  addExports() {
    return {
      docx: {
        nodes: {
          callout: (node, ctx) => { /* return XML nodes */ },
        },
      },
    };
  },
  addImports() {
    return {
      docx: {
        paragraph: (intermediate, ctx) => { /* return PM node or null */ },
      },
    };
  },
});

The exported xml / serializeXml helpers and DocxContext / DocxImportContext types are available for advanced handlers.

License

Apache-2.0