import { Editor } from 'superdoc/super-editor'; import OpenAI from 'openai'; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Write a service agreement in HTML.' }], }); const editor = await Editor.open(templateDocx); editor.commands.insertContent(completion.choices[0].message.content, { contentType: 'html', }); const docx = await editor.exportDocx();
editor.commands.insertContent(value, { contentType: 'html' }); // Recommended for LLMs editor.commands.insertContent(value, { contentType: 'markdown' }); editor.commands.insertContent(value, { contentType: 'text' }); editor.commands.insertContent(value, { contentType: 'schema' }); // ProseMirror JSON
suggesting
const contract = await readFile('./contract.docx'); const editor = await Editor.open(contract, { documentMode: 'suggesting', }); // AI suggestions are tracked — users review them in Word editor.commands.insertContent(aiRevisions, { contentType: 'html' }); const redlined = await editor.exportDocx();
https://docs.superdoc.dev/llms.txt // Quick reference https://docs.superdoc.dev/llms-full.txt // Complete documentation
Was this page helpful?