@richhtmleditor/export
v1.2.9
Published
Markdown, plain-text, and PDF export plugin for Rich HTML Editor.
Maintainers
Readme
@richhtmleditor/export
Export plugin for Rich HTML Editor. Adds toolbar tools for exporting documents to DOCX, PDF, Markdown, and plain text formats. Built on @richhtmleditor/core.
Current release: 1.2.9 — Depends on @richhtmleditor/core ^1.2.9.
Repository: github.com/rajkishorsahu89/richhtmleditor
Demo: richhtmleditor.stackkitlabs.com — demo · guide · API
What's in 1.2.9
- Bug fix:
htmlToMarkdownreturned empty string —nodeToMarkdownreceived aDocumentFragment(node type 11) and returned""immediately since it only handled text and element nodes. Fixed by iteratingtemplate.content.childNodesdirectly. Markdown (.md) downloads now produce correct output. createExportPlugin— registers export toolbar tools (DOCX, PDF, Markdown, text)- DOCX export — full document export with headings, tables, images, shapes, and diagrams (SVG rasterization to PNG); table column widths (
w:tblGrid/w:tcW), cell padding (w:tcMar), borders, row spans, and background colours faithfully round-tripped; callout blocks exported with colored left border (w:pBdr), shading (w:shd), and icon prefix run - PDF export (1.2.9) — callout block backgrounds and colors printed with
print-color-adjust:exact;!importanton variant colors ensures browser print stylesheets do not suppress them - DOCX import —
importDocxtoolbar tool; hyperlinks, image dimensions, row spans, page breaks, cell padding, column widths, paragraph spacing, and table-style header fills all imported correctly - PDF export — opens print dialog with full preview CSS including shapes and diagrams
- Markdown export — converts document HTML to clean Markdown
- Plain text export — strips all formatting for text-only output
- Configurable callbacks —
onExporthook to handle exports in your own pipeline
Enterprise feature — requires enterprise licence.
Keywords: richhtmleditor export docx pdf markdown wysiwyg
Install
npm install @richhtmleditor/export
# Requires @richhtmleditor/core (via framework wrapper or direct install).Usage
import { createEditor } from "@richhtmleditor/core";
import { createExportPlugin } from "@richhtmleditor/export";
const editor = createEditor({
element: host,
toolbar: { preset: "full" },
plugins: [
createExportPlugin({
filename: "my-document",
pdfTitle: "My Document"
})
]
});Angular
import { createExportPlugin } from "@richhtmleditor/export";
plugins = [createExportPlugin({ filename: "report" })];<richhtmleditor [plugins]="plugins" [toolbar]="{ preset: 'full' }" />Custom export handler
createExportPlugin({
onExport: (format, content) => {
// format: "docx" | "pdf" | "markdown" | "text"
// content: string (HTML for pdf, markdown string, plain text, or HTML for docx)
uploadToServer(format, content);
}
})API
createExportPlugin(options?)
Returns an EditorPlugin that registers export toolbar tools.
| Option | Type | Description |
| --- | --- | --- |
| filename | string? | Base filename for downloaded files (default: "document"). |
| pdfTitle | string? | Title shown in the PDF print window (default: "Document"). |
| onExport | (format, content) => void | Custom export handler; bypasses default download/print behavior. |
Related packages
@richhtmleditor/core— editor engine and plugins API.@richhtmleditor/themes— shared CSS.@richhtmleditor/diagrams— Mermaid diagrams plugin.@richhtmleditor/math— LaTeX/MathML equation plugin.@richhtmleditor/angular— Angular wrapper.@richhtmleditor/react— React wrapper.
