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

@docen/docx

v0.3.0

Published

DOCX editor and converter powered by @office-open/docx with Tiptap editing layer, supporting bidirectional conversion between DOCX, HTML, and Markdown

Readme

@docen/docx

npm version npm downloads npm license

DOCX editor and converter powered by @office-open/docx with Tiptap editing layer, supporting bidirectional conversion between DOCX, HTML, and Markdown.

Features

  • 📝 Tiptap Editor — Full-featured WYSIWYG editor with DOCX-aware extensions
  • 🔄 DOCX Round-trip — Near-lossless DOCX ↔ Editor conversion via @office-open/docx
  • 🌐 HTML Conversion — Bidirectional Tiptap JSON ↔ HTML (editor path + standalone)
  • 📄 Markdown Support — Tiptap JSON ↔ Markdown conversion
  • 🎨 DOCX Properties — Custom Tiptap extensions carry shading, borders, indent, spacing, floating, crop
  • 🔗 Template Patching — Replace {{placeholders}} in DOCX templates with Tiptap-JSON content

Installation

# Install with pnpm
$ pnpm add @docen/docx

# Install with npm
$ npm install @docen/docx

Quick Start

import { createDocxEditor, docxExtensions, parseDOCX, generateDOCX } from "@docen/docx";

// Create editor
const editor = createDocxEditor({
  element: document.querySelector("#editor"),
});

// Load a DOCX file
editor.commands.setContent(parseDOCX(buffer));

// Save back to DOCX
const output = await generateDOCX(editor.getJSON());

API

Standalone Functions (Core)

These work without an editor instance — for headless/server/batch use.

import {
  parseDOCX,
  generateDOCX,
  generateDOCXSync,
  generateDOCXStream,
  parseHTML,
  generateHTML,
  parseMarkdown,
  generateMarkdown,
} from "@docen/docx";

// DOCX pipeline: DOCX binary ↔ Tiptap JSON
const json = parseDOCX(buffer); // → JSONContent
const buffer = await generateDOCX(json); // → Buffer (pre-fetches http images by default)
const blob = await generateDOCX(json, { packer: { type: "blob" } }); // → Blob
const sync = generateDOCXSync(json); // → Buffer (skips prepare)
const stream = await generateDOCXStream(json); // → ReadableStream<Uint8Array>

// HTML pipeline: HTML string ↔ Tiptap JSON
const json = parseHTML("<p>Hello</p>"); // → JSONContent
const html = generateHTML(json); // → string

// Markdown pipeline: Markdown string ↔ Tiptap JSON
const json = parseMarkdown("# Hello"); // → JSONContent
const md = generateMarkdown(json); // → string

Editor

import { createDocxEditor, docxExtensions } from "@docen/docx";

const editor = createDocxEditor({
  element: document.querySelector("#editor"),
  extensions: docxExtensions,
  spellcheck: true,
  editable: true,
});

Extension Commands (Thin Wrappers)

Convenience commands that call standalone functions internally.

// Load DOCX into editor (calls parseDOCX → setContent)
editor.commands.importDocx(buffer);

// Export editor content as DOCX (calls getJSON → generateDOCX)
const buffer = await editor.commands.exportDocx();

Template Patching

Replace {{placeholders}} in a DOCX template with Tiptap-JSON content. Each patch's content is prepared (default: fetch http images) then compiled to DOCX.

import { patchDOCX, parseHTML } from "@docen/docx";

const result = await patchDOCX({
  template: templateBuffer,
  patches: {
    title: { content: parseHTML("<h1>Report</h1>") },
  },
  outputType: "nodebuffer",
});

Advanced: Model Bridge

generateDOCX runs prepareDocument → compileDocument → generateDocument internally. You rarely need these directly — reach for them only when working with the intermediate DocumentOptions (the OOXML persistence model):

import { resolveDocument, compileDocument, prepareDocument } from "@docen/docx";

const json = resolveDocument(docOpts); // DocumentOptions → JSONContent
const docOpts = compileDocument(json); // JSONContent → DocumentOptions
await prepareDocument(json); // in place: http image URLs → data URLs

Architecture

Standalone Functions (core)
  parseDOCX / generateDOCX / generateDOCXSync / generateDOCXStream / patchDOCX
  parseHTML / generateHTML / parseMarkdown / generateMarkdown
  resolveDocument / compileDocument / prepareDocument  (model bridge, advanced)
        ↕ used by
Tiptap Extension Commands (thin wrappers)
  editor.commands.importDocx() / exportDocx()
        ↕ used by
@docen/ui (Fluent UI Web Components)
  <docx-editor> toolbar / ribbon / menus
  • Runtime model: Tiptap JSON with DOCX-rich attributes via custom extensions
  • Persistence model: DocumentOptions (complete OOXML expressiveness)
  • Standalone functions are core — extension commands are thin wrappers

License