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

@editkit/export

v2.0.4

Published

Document import and export adapters for EditKit with Word and Google Docs paste normalization — Markdown, clean/email HTML, plain text, JSON, DOCX, and PDF.

Readme

@editkit/export

Import and export helpers for EditKit Text Editor. Convert editor HTML to Markdown, clean HTML, email-safe HTML, plain text, JSON, DOCX, or PDF, and normalize HTML pasted from Microsoft Word and Google Docs.

Install

pnpm add @editkit/export
# or
npm install @editkit/export

The package has no required runtime dependency. It expects a DOM Window when used outside a browser or in SSR/tests.

Quick start

import { toMarkdown, toCleanHtml, toPlainText } from '@editkit/export';

const html = editor.getHTML();
const markdown = toMarkdown(html);
const cleanHtml = toCleanHtml(html);
const plainText = toPlainText(html);

API

ExportOptions

All HTML conversion functions accept an optional options object:

interface ExportOptions {
  /** DOM window used to parse HTML. Required in SSR/Node. */
  window?: Window;
  /** Sanitize HTML before parsing or before returning generated HTML. */
  sanitize?: (html: string) => string;
  /** Keep inline styles for clean HTML output. */
  inlineStyles?: boolean;
}

With EditKit, pass the editor sanitizer at the export boundary:

const options = { sanitize: editor.sanitize };
const markdown = toMarkdown(editor.getHTML(), options);
const cleanHtml = toCleanHtml(editor.getHTML(), options);

Markdown

import { toMarkdown, fromMarkdown } from '@editkit/export';

const markdown = toMarkdown(html, options);
const htmlAgain = fromMarkdown(markdown, options);

The converters support headings, paragraphs, emphasis, links, images, code blocks, blockquotes, horizontal rules, ordered/unordered/task lists, tables, and EditKit image/panel blocks.

HTML and plain text

import { toCleanHtml, toEmailHtml, toPlainText } from '@editkit/export';

const htmlForStorage = toCleanHtml(html, { inlineStyles: false });
const htmlForEmail = toEmailHtml(html);
const text = toPlainText(html);

toCleanHtml() removes editor-only controls, transient attributes, editing classes, and (unless enabled) inline styles. toEmailHtml() removes SVG and converts EditKit layout/button blocks to email-compatible tables.

JSON editor documents

import { editorToJSON, editorFromJSON } from '@editkit/export';

const document = editorToJSON(editor);
editorFromJSON(editor, document);

These helpers delegate to the editor's existing getJSON() and setJSON() methods.

Word and Google Docs HTML

import { normalizeWordHtml } from '@editkit/export';

const normalized = normalizeWordHtml(pastedHtml, {
  sanitize: editor.sanitize,
});

This removes common Microsoft Office mso-* styles and Google Docs internal wrapper elements while preserving content.

DOCX export

DOCX support is optional:

pnpm add docx
import { exportDocx } from '@editkit/export';

const result = await exportDocx(editor.getHTML(), {
  sanitize: editor.sanitize,
  filename: 'article.docx',
});
// result.blob is the generated file; result.filename is its name.

If docx is not installed, exportDocx() throws an actionable error when called.

PDF export

Use the browser print dialog for a zero-dependency PDF flow:

import { printPdf } from '@editkit/export';

printPdf(editor.getHTML(), { sanitize: editor.sanitize });

For a PDF library or server-side renderer, provide an adapter returning a Blob:

import { exportPdfViaAdapter } from '@editkit/export';

const result = await exportPdfViaAdapter(
  editor.getHTML(),
  safeHtml => myPdfAdapter.render(safeHtml),
  { sanitize: editor.sanitize, filename: 'article.pdf' },
);

SSR and tests

Pass a DOM window explicitly when no global browser window exists:

const markdown = toMarkdown(html, { window: jsdomWindow });

Do not pass unsanitized user-controlled HTML to a DOM sink. Prefer editor.sanitize or another trusted sanitizer before exporting or rendering generated HTML.

Related packages

License

MIT © Ashikur Rahman