Skip to content

Commit cc6f5a3

Browse files
committed
docs: tighten Getting Started FAQ pages with correct API usage (SD-2873)
- Theming: createTheme returns a className applied via document.documentElement.classList.add, not a constructor option. Adds popover/CSP pitfalls. - Fonts: modules.toolbar.fonts takes [{ label, key }] objects, not bare strings. Adds dropdown-not-auto-populated pitfall. - AI: chooser table + three concrete paths with real install command. - Import/Export: leads with value statement; adds duplicate-download/HTML-base-DOCX pitfalls.
1 parent a4045b5 commit cc6f5a3

4 files changed

Lines changed: 97 additions & 81 deletions

File tree

apps/docs/getting-started/ai.mdx

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,58 @@
11
---
2-
title: AI
2+
title: Use SuperDoc with AI
33
sidebarTitle: AI
44
keywords: "ai, mcp, claude, cursor, llm tools, ai agents, document automation, ai sdk"
55
---
66

7-
Pick the AI integration that matches what you're building. For the full AI section, see [AI Overview](/ai/overview).
7+
SuperDoc gives AI models structured access to real Word documents. Use MCP when a coding agent is working on files. Use LLM tools when you're building document editing into your own app. Use the SDK or CLI for backend automation.
88

9-
## Pick your path
9+
## Pick the path
1010

11-
<CardGroup cols={2}>
12-
<Card title="I want Claude/Cursor to edit DOCX" icon="terminal" href="/ai/mcp/overview">
13-
**MCP server.** Drop SuperDoc's MCP server into Claude Desktop, Cursor, or any MCP-compatible host. Claude can then open, read, and edit DOCX files locally.
14-
</Card>
15-
<Card title="I want AI editing inside my app" icon="bot" href="/ai/agents/llm-tools">
16-
**LLM tools.** SuperDoc ships pre-typed tool catalogs for OpenAI, Anthropic, Vercel AI SDK, Mastra, and others. Wire them into your existing agent.
17-
</Card>
18-
<Card title="I want scripts or CI to edit DOCX" icon="code" href="/document-engine/cli">
19-
**CLI or SDKs.** Run DOCX operations from a script, GitHub Action, or backend job. No browser needed.
20-
</Card>
21-
<Card title="I want LLM-friendly content from DOCX" icon="file-export" href="/getting-started/import-export">
22-
**Markdown/JSON export.** Pull document content out as Markdown or JSON to feed into your own LLM context.
23-
</Card>
24-
</CardGroup>
11+
| You want to | Use |
12+
|---|---|
13+
| Let Claude/Cursor edit DOCX files | [MCP server](/ai/mcp/overview) |
14+
| Build AI editing into your app | [LLM tools](/ai/agents/llm-tools) |
15+
| Automate DOCX from scripts or CI | [SDK](/document-engine/sdks) or [CLI](/document-engine/cli) |
16+
| Stream generated content into the editor | Browser editor + [`editor.doc.insert`](/document-api/overview) |
2517

26-
## What ships with SuperDoc
18+
## Coding agents (MCP)
2719

28-
SuperDoc treats AI as a first-class consumer. Three packages, all driven by the same Document API:
20+
The fastest path. SuperDoc ships an MCP server that any MCP-aware host can use.
2921

30-
- **`@superdoc-dev/mcp`** — Model Context Protocol server. Lets MCP-aware hosts (Claude Desktop, Cursor) read and edit DOCX files.
31-
- **`@superdoc-dev/sdk`** — Node and Python SDKs for server-side automation. Same operations as the browser editor.
32-
- **`@superdoc-dev/cli`** — Command-line tool for scripts, CI, and one-off operations.
22+
```bash
23+
claude mcp add superdoc -- npx @superdoc-dev/mcp
24+
```
3325

34-
All three share the [Document API](/document-api/overview) under the hood — the same `editor.doc.*` operations you use in the browser.
26+
Then ask Claude to open, read, or edit a DOCX file. The agent calls SuperDoc's typed tools — no HTML wrangling, no re-uploads.
3527

36-
## Why this is different
28+
## App integration (LLM tools)
3729

38-
Most editors expose AI via "ask the AI to write something." SuperDoc exposes the document itself: AI can list comments, decide tracked changes, replace text by selection, insert tables, format runs — all as discrete typed operations. No HTML wrangling, no re-uploading the file after each change.
30+
For agent editing inside your own app, SuperDoc ships pre-typed tool catalogs for OpenAI, Anthropic, Vercel AI SDK, Mastra, and others. Wire them into your existing model loop.
3931

40-
For the agent best-practices guide and the full tool catalog, see [AI > Agents](/ai/agents/llm-tools).
32+
```javascript
33+
import { tools } from '@superdoc-dev/sdk';
34+
// pass tools to your model, dispatch tool calls against the SuperDoc SDK
35+
```
36+
37+
## Browser editor + AI output
38+
39+
If you're already running the SuperDoc editor in the browser and want AI-generated content to land in the document:
40+
41+
```javascript
42+
const html = await callYourLLM(prompt);
43+
editor.doc.insert({ target: cursor, html });
44+
```
45+
46+
The same Document API the editor uses internally — typed inputs, structured outputs, no string parsing.
47+
48+
## Common pitfalls
49+
50+
- **MCP server in the wrong host context.** The MCP server runs on the same machine as the agent. Configure it in Claude Desktop / Cursor / your MCP host, not in the SuperDoc browser app.
51+
- **Tool dispatch with stale schemas.** SDK tool catalogs are versioned with the SDK. Pin both packages together to keep types and runtime in sync.
4152

4253
## Where to next
4354

4455
- [AI Overview](/ai/overview) — the full AI section
45-
- [AI > MCP](/ai/mcp/overview)Model Context Protocol setup
46-
- [AI > Agents > LLM tools](/ai/agents/llm-tools) — typed tool catalogs for OpenAI, Anthropic, etc.
56+
- [AI > MCP > Overview](/ai/mcp/overview)MCP setup for Claude Desktop, Cursor, and other hosts
57+
- [AI > Agents > LLM tools](/ai/agents/llm-tools) — typed tool catalogs and integration patterns
4758
- [Document API](/document-api/overview) — the operations all AI integrations share

apps/docs/getting-started/fonts.mdx

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,60 @@ sidebarTitle: Font Support
44
keywords: "fonts, font loading, calibri, cambria, aptos, font fallback, custom fonts, font dropdown, office fonts"
55
---
66

7-
How fonts work in SuperDoc, and what to do when a document looks different from how it looks in Word.
7+
SuperDoc keeps the font name from the Word document. Rendering that font is the browser's job. If the browser can't find Calibri, Cambria, Aptos, or your brand font, it falls back to another font and the layout shifts.
88

9-
## How SuperDoc handles fonts
9+
## Load fonts in your app
1010

11-
SuperDoc preserves the font names that come from your DOCX. It does **not** load font files for you. Whether `Calibri Light` actually renders as Calibri Light depends on whether that font is available to the browser running your app.
12-
13-
Three things you control:
14-
15-
1. **Loading font files** — your app's responsibility (CSS `@font-face`, `<link>` tags, font CDNs).
16-
2. **Toolbar dropdown options** — which fonts users can pick from in the built-in toolbar.
17-
3. **Font fallbacks** — what happens when the requested font isn't available.
18-
19-
## The "why does it look different from Word?" question
20-
21-
Most of the time, the document references Microsoft fonts (Calibri, Cambria, Aptos, Times New Roman) that aren't on the user's system or aren't loaded by your host page. The browser falls back to a default font and the layout shifts.
22-
23-
Two common fixes:
24-
25-
- **License the actual fonts** and load them via `@font-face`. This gives pixel-accurate rendering.
26-
- **Load free substitutes** with similar metrics. [Carlito](https://fonts.google.com/specimen/Carlito) for Calibri, [Caladea](https://fonts.google.com/specimen/Caladea) for Cambria are common Google Fonts swaps.
11+
Fonts are your host page's responsibility. `@font-face`, a hosted stylesheet, or a font CDN — anything the browser can resolve.
2712

2813
```css
29-
/* Example: load Carlito as a Calibri substitute */
3014
@font-face {
3115
font-family: 'Calibri';
32-
src: url('https://fonts.gstatic.com/s/carlito/...') format('woff2');
16+
src: url('/fonts/Carlito-Regular.woff2') format('woff2');
3317
font-display: swap;
3418
}
3519
```
3620

37-
## Configuring the toolbar font dropdown
21+
For Office fonts that aren't free (Calibri, Cambria, Aptos), either license them or alias compatible substitutes — [Carlito](https://fonts.google.com/specimen/Carlito) for Calibri, [Caladea](https://fonts.google.com/specimen/Caladea) for Cambria.
22+
23+
## Register fonts in the toolbar
3824

39-
The built-in toolbar has a font picker. By default it shows a curated list. To customize the available fonts:
25+
The toolbar's font dropdown shows whatever you register in `modules.toolbar.fonts`. Each entry is a `{ label, key }` pair where `key` is the CSS `font-family` value:
4026

4127
```javascript
4228
new SuperDoc({
4329
selector: '#editor',
4430
document: 'contract.docx',
4531
modules: {
4632
toolbar: {
47-
fonts: ['Inter', 'Calibri', 'Times New Roman', 'Custom Brand Font'],
33+
fonts: [
34+
{ label: 'Calibri', key: 'Calibri, sans-serif' },
35+
{ label: 'Inter', key: 'Inter, sans-serif' },
36+
{ label: 'Times New Roman', key: '"Times New Roman", serif' },
37+
],
4838
},
4939
},
5040
});
5141
```
5242

53-
<Note>
54-
Adding a font to the toolbar dropdown does **not** load the font file. You still need to make the font available to the browser via CSS. The dropdown only controls which fonts the user can select.
55-
</Note>
43+
Registering a font makes it **selectable** in the dropdown. It does **not** load the font file. You still need the `@font-face` (or equivalent) on your host page.
5644

57-
For the full toolbar font configuration options, see [Built-in UI > Toolbar](/editor/built-in-ui/toolbar#font-configuration).
45+
## Programmatic font changes
5846

59-
## Setting fonts programmatically
60-
61-
To set fonts from code (e.g. an AI agent applying a brand font), use the Document API:
47+
For AI agents or scripts setting a brand font:
6248

6349
```javascript
6450
editor.doc.format.fontFamily({ target, value: 'Inter' });
6551
```
6652

67-
For the full font formatting API surface, see [Document API > Available operations](/document-api/available-operations).
53+
## Common pitfalls
54+
55+
- **Font name preserved, browser falls back.** The font name from the DOCX is intact, but the actual file isn't loaded. Add `@font-face`.
56+
- **Dropdown doesn't show a font.** Imported documents don't auto-populate the toolbar list. If a `.docx` uses Cambria but Cambria isn't in `fonts`, the user can't pick it from the dropdown — even though the current selection indicator may show "Cambria" if that's what the run uses.
57+
- **Office font licensing.** Calibri, Cambria, and Aptos are licensed Microsoft fonts. Self-hosting requires a license. Free substitutes are common in non-pixel-perfect contexts.
6858

6959
## Where to next
7060

71-
- [Built-in UI > Toolbar](/editor/built-in-ui/toolbar) — toolbar font configuration
61+
- [Built-in UI > Toolbar](/editor/built-in-ui/toolbar#font-configuration)full toolbar font configuration options
7262
- [Document API > Available operations](/document-api/available-operations) — programmatic font formatting
7363
- [Editor > Theming](/editor/theming/overview) — set the default font for SuperDoc's UI chrome

apps/docs/getting-started/import-export.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ sidebarTitle: Import/Export
44
keywords: "import, export, docx export, html import, markdown import, document formats"
55
---
66

7-
Five-minute orientation for getting documents in and out of SuperDoc. For the full reference, see [Editor > SuperDoc > Import/Export](/editor/superdoc/import-export).
7+
SuperDoc treats DOCX as the real document, not an export target. Load a Word file, edit it in the browser, and export a Word file again — tracked changes, comments, complex tables, all preserved. HTML and Markdown are useful for AI-generated content, but DOCX is the full-fidelity path.
8+
9+
For the full reference, see [Editor > SuperDoc > Import/Export](/editor/superdoc/import-export).
810

911
## Loading a document
1012

@@ -65,6 +67,12 @@ DOCX preserves tracked changes, comments, complex tables, and section breaks. HT
6567

6668
Store the **DOCX blob** if you want full fidelity (recommended). Store JSON if you want programmatic search/diff and don't need round-tripping with Word users. Don't store HTML or Markdown unless you accept losing fidelity.
6769

70+
## Common pitfalls
71+
72+
- **Duplicate downloads.** `superdoc.export()` triggers a browser download by default. If you want to upload to a backend, pass `{ triggerDownload: false }` — otherwise you get the file twice.
73+
- **HTML import without a base DOCX.** The `html` and `markdown` options need a `document` (a base `.docx`) for styles. Without one, headings and lists fall back to defaults.
74+
- **HTML round-trips lose styling.** Importing HTML, exporting DOCX, and then importing the resulting HTML back will not produce the original Word styling. For round-tripping, use DOCX or JSON.
75+
6876
## Where to next
6977

7078
- [Editor > SuperDoc > Import/Export](/editor/superdoc/import-export) — full API reference (every option, every export flag)

apps/docs/getting-started/theming.mdx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
11
---
2-
title: Theming
2+
title: Theme SuperDoc
33
sidebarTitle: Theming
44
keywords: "theming, css variables, custom theme, dark mode, design tokens, branding, createTheme"
55
---
66

7-
Five-minute setup for matching SuperDoc to your brand. For the full token catalog and `createTheme()` reference, see [Editor > Theming](/editor/theming/overview).
7+
SuperDoc's UI is styled with CSS variables. `createTheme()` generates a class name that sets those variables; you apply the class to `<html>` and every SuperDoc surface picks it up — toolbar, comments, dropdowns, context menu, popovers.
88

9-
## Set your brand colors
9+
## The fast path
1010

1111
```javascript
1212
import { SuperDoc, createTheme } from 'superdoc';
1313

1414
const theme = createTheme({
1515
colors: {
16-
action: '#6366f1', // buttons, links, active states
17-
bg: '#ffffff', // panels, dropdowns
18-
text: '#1e293b',
19-
border: '#e2e8f0',
16+
action: '#1355FF', // buttons, links, active states
17+
bg: '#ffffff',
18+
text: '#1f2937',
19+
border: '#d1d5db',
2020
},
2121
font: 'Inter, sans-serif',
22-
radius: '8px',
22+
radius: '6px',
2323
});
2424

25-
new SuperDoc({
26-
selector: '#editor',
27-
document: 'contract.docx',
28-
theme,
29-
});
25+
document.documentElement.classList.add(theme);
26+
27+
new SuperDoc({ selector: '#editor', document: 'contract.docx' });
3028
```
3129

32-
The toolbar, comments sidebar, dropdowns, and every other built-in surface pick up the theme automatically.
30+
`theme` is a className string. Apply it to `<html>` (not the editor container) so popovers, dropdowns, and the comments sidebar — which can render outside the editor element — pick up the same tokens.
31+
32+
## What themes affect
3333

34-
## Common patterns
34+
Toolbar buttons, comments sidebar, dropdowns, context menu, search bar, dialog surfaces. Any chrome SuperDoc renders. The document content itself (paragraphs, headings, tables) renders with its own styles from the DOCX.
3535

36-
**Dark mode**: pass a different theme when your app's color scheme changes.
36+
## When to drop to CSS variables
37+
38+
`createTheme()` covers the common case. For component-level overrides, use the `vars` option or set raw `--sd-*` variables in your stylesheet:
3739

3840
```javascript
39-
const dark = createTheme({
40-
colors: { action: '#818cf8', bg: '#0f172a', text: '#f1f5f9', border: '#334155' },
41+
const theme = createTheme({
42+
colors: { action: '#1355FF', bg: '#ffffff', text: '#1f2937', border: '#d1d5db' },
43+
vars: {
44+
'--sd-ui-toolbar-bg': '#f8fafc',
45+
'--sd-comments-resolved-bg': '#ecfdf5',
46+
},
4147
});
4248
```
4349

44-
**Per-instance override**: each `SuperDoc` instance can have its own theme.
50+
## Common pitfalls
4551

46-
**CSS variable escape hatch**: every theme value is a CSS custom property (`--sd-color-action`, `--sd-color-bg`, etc.). You can override individual variables in your stylesheet without rewriting the whole theme.
52+
- **Theme class on the wrong element.** Add it to `document.documentElement` (the `<html>` tag), not the editor's container. Popovers render at the body level and won't pick up the theme otherwise.
53+
- **CSP environments.** `createTheme()` injects a `<style>` tag. If you serve with a strict CSP, use `buildTheme()` instead — it returns `{ className, css }` so you can inject the CSS yourself with the right nonce.
4754

4855
## Where to next
4956

0 commit comments

Comments
 (0)