SuperEditor configuration gives you low-level control over the DOCX engine.
Quick Start
import "superdoc/style.css" ;
import { Editor , getStarterExtensions } from "superdoc/super-editor" ;
// Parse DOCX file first
const [ content , media , mediaFiles , fonts ] = await Editor . loadXmlData ( docxFile );
// Create editor
const editor = new Editor ({
mode: "docx" ,
documentMode: "editing" ,
element: document . getElementById ( "editor" ),
documentId: "doc-123" ,
extensions: getStarterExtensions (),
fileSource: docxFile ,
content ,
media ,
mediaFiles ,
fonts ,
});
Required Parameters
DOM element where the editor will mount element : document . getElementById ( "editor" );
Unique identifier for this document instance. Used for collaboration and
storage.
Extensions that define the editor schema and functionality. import { getStarterExtensions } from "superdoc/super-editor" ;
extensions : getStarterExtensions ();
DOCX Mode Parameters
Parsed XML content from Editor.loadXmlData()
Media file mappings from Editor.loadXmlData()
Media blob data from Editor.loadXmlData()
Font configuration from Editor.loadXmlData()
Modes & Permissions
Editor rendering mode
docx - Full DOCX features
text - Plain text mode
html - HTML mode
documentMode
string
default: "'editing'"
Current editing state
editing - Full editing capabilities
viewing - Read-only mode
suggesting - Track changes enabled
User permission level. Overrides documentMode when more restrictive. Role always wins over documentMode in permission conflicts
Whether the editor accepts input
User & Collaboration
All users with document access. Used for @mentions and awareness.
Yjs document for real-time collaboration
Provider instance for collaboration sync
Content Initialization
Initialize with HTML content (for mode: 'html')
Initialize with Markdown (converts to document)
Use ProseMirror JSON content instead of DOCX parsing
Features
Advanced Options
Run without mounting an editor view (Node.js/server-side processing).
You must provide document from JSDOM for serialization methods like getHTML().
DOM Document for serialization in headless mode (e.g., window.document from JSDOM).
Y.Doc XML fragment for collaborative document content. Use with headless mode to read Y.Doc content.
Deprecated. Use document instead.
Deprecated. No longer required — just pass document.
Custom image upload handler handleImageUpload : async ( file ) => {
const url = await uploadToS3 ( file );
return url ;
};
Configuration Patterns
Full DOCX Editor
import "superdoc/style.css" ;
import { Editor , getStarterExtensions } from "superdoc/super-editor" ;
async function createDocxEditor ( docxFile ) {
const [ content , media , mediaFiles , fonts ] = await Editor . loadXmlData (
docxFile
);
return new Editor ({
mode: "docx" ,
documentMode: "editing" ,
element: document . getElementById ( "editor" ),
documentId: "doc-123" ,
extensions: getStarterExtensions (),
fileSource: docxFile ,
content ,
media ,
mediaFiles ,
fonts ,
user: { name: "John" , email: "[email protected] " },
});
}
Headless Converter (Node.js)
Convert DOCX files server-side without a browser using JSDOM.
import { readFile } from "fs/promises" ;
import { JSDOM } from "jsdom" ;
import { Editor , getStarterExtensions } from "superdoc/super-editor" ;
const { window } = new JSDOM ( "<!DOCTYPE html><html><body></body></html>" );
const { document } = window ;
// Pass `true` as second arg for Node.js
const buffer = await readFile ( "document.docx" );
const [ content , media , mediaFiles , fonts ] = await Editor . loadXmlData (
buffer ,
true
);
const editor = new Editor ({
mode: "docx" ,
documentId: "headless" ,
element: document . createElement ( "div" ),
extensions: getStarterExtensions (),
fileSource: buffer ,
content ,
media ,
mediaFiles ,
fonts ,
isHeadless: true ,
mockDocument: document ,
mockWindow: window ,
});
// Output formats
const html = editor . getHTML ();
const json = editor . getJSON ();
const text = editor . state . doc . textContent ;
const markdown = await editor . getMarkdown ();
editor . destroy ();
Headless Y.Doc to HTML (Collaboration)
Read content from a collaborative Y.Doc in your backend — useful for AI agents or APIs that need to access document content without a browser.
Even with isHeadless: true, methods like getHTML() need a DOM for serialization. Always set up JSDOM first.
import { JSDOM } from "jsdom" ;
import { Editor , getStarterExtensions } from "superdoc/super-editor" ;
// Set up JSDOM
const { window } = new JSDOM ( "<!DOCTYPE html><html><body></body></html>" );
// Get the YXmlFragment from your Y.Doc
const fragment = ydoc . getXmlFragment ( "prosemirror" );
const editor = new Editor ({
mode: "docx" ,
isHeadless: true ,
document: window . document ,
extensions: getStarterExtensions (),
fragment , // YXmlFragment from Y.Doc
});
const html = editor . getHTML ();
editor . destroy ();
The document option replaces the deprecated mockDocument and mockWindow options.
Custom Collaboration
import { Editor , getStarterExtensions } from "superdoc/super-editor" ;
import * as Y from "yjs" ;
import { HocuspocusProvider } from "@hocuspocus/provider" ;
const [ content , media , mediaFiles , fonts ] = await Editor . loadXmlData ( docxFile );
const editor = new Editor ({
mode: "docx" ,
documentMode: "editing" ,
element: document . getElementById ( "editor" ),
documentId: roomId ,
extensions: getStarterExtensions (),
fileSource: docxFile ,
content ,
media ,
mediaFiles ,
fonts ,
ydoc: new Y . Doc (),
collaborationProvider: new HocuspocusProvider ({
url: "wss://collab.example.com" ,
name: roomId ,
}),
user: currentUser ,
users: roomUsers ,
});
Track Changes Mode
const [ content , media , mediaFiles , fonts ] = await Editor . loadXmlData ( docxFile );
const editor = new Editor ({
mode: "docx" ,
documentMode: "suggesting" ,
element: document . getElementById ( "editor" ),
documentId: "review-doc" ,
extensions: getStarterExtensions (),
fileSource: docxFile ,
content ,
media ,
mediaFiles ,
fonts ,
user: reviewer ,
});