import "superdoc/style.css";
import { Editor, getStarterExtensions } from "superdoc/super-editor";
async function initEditor() {
// 1. Load and prepare the DOCX file
const response = await fetch("/document.docx");
const blob = await response.blob();
const file = new File([blob], "document.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
});
// 2. Parse the DOCX file
const [content, media, mediaFiles, fonts] = await Editor.loadXmlData(file);
// 3. Create the editor
const editor = new Editor({
mode: "docx",
documentMode: "editing",
element: document.getElementById("editor"),
documentId: "doc-123",
extensions: getStarterExtensions(),
fileSource: file,
content,
media,
mediaFiles,
fonts,
});
}
initEditor();