Skip to content

Commit 781ea01

Browse files
committed
feat: add feature and headless examples, improve docs clarity
1 parent eac6bc3 commit 781ea01

43 files changed

Lines changed: 921 additions & 102 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-examples.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@ jobs:
6565
working-directory: examples/__tests__
6666
run: EXAMPLE=collaboration/${{ matrix.example }} npx playwright test
6767

68+
features:
69+
runs-on: ubuntu-latest
70+
strategy:
71+
matrix:
72+
example: [track-changes, ai-redlining, comments, custom-toolbar]
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Setup Node.js
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: '20'
80+
81+
- name: Install example dependencies
82+
working-directory: examples/features/${{ matrix.example }}
83+
run: npm install
84+
85+
- name: Install smoke test dependencies
86+
working-directory: examples/__tests__
87+
run: npm install && npx playwright install chromium
88+
89+
- name: Run smoke test
90+
working-directory: examples/__tests__
91+
run: EXAMPLE=features/${{ matrix.example }} npx playwright test
92+
6893
headless:
6994
runs-on: ubuntu-latest
7095
steps:
@@ -76,9 +101,9 @@ jobs:
76101
node-version: '20'
77102

78103
- name: Install dependencies
79-
working-directory: examples/headless/converter
104+
working-directory: examples/headless/ai-redlining
80105
run: npm install
81106

82-
- name: Run headless converter
83-
working-directory: examples/headless/converter
84-
run: npx tsx src/index.ts sample.docx --format text
107+
- name: Run headless tests
108+
working-directory: examples/headless/ai-redlining
109+
run: npx tsx src/index.test.ts

apps/docs/core/superdoc/configuration.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ new SuperDoc({
196196
Toolbar configuration
197197

198198
<Expandable title="properties" defaultOpen>
199-
<ParamField path="selector" type="string | HTMLElement">
200-
Toolbar container
199+
<ParamField path="selector" type="string">
200+
CSS selector for the toolbar container (e.g. `'#toolbar'`)
201201
</ParamField>
202202
<ParamField path="groups" type="string[]" default="['left', 'center', 'right']">
203203
Layout groups
@@ -262,9 +262,8 @@ new SuperDoc({
262262
Show document rulers
263263
</ParamField>
264264

265-
<ParamField path="toolbar" type="string | HTMLElement">
266-
DOM element for toolbar
267-
<Note>Alternative to `modules.toolbar.selector`</Note>
265+
<ParamField path="toolbar" type="string">
266+
CSS selector for the toolbar container (e.g. `'#toolbar'`). Shorthand for `modules.toolbar.selector`.
268267
</ParamField>
269268

270269
## Advanced options

apps/docs/core/superdoc/methods.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Export the document with various options.
2828
Base filename
2929
</ParamField>
3030
<ParamField path="triggerDownload" type="boolean" default="true">
31-
Auto-download file
31+
Automatically trigger a browser file download. Set to `false` to get a `Blob` back without downloading.
3232
</ParamField>
3333
<ParamField path="fieldsHighlightColor" type="string" default="'#FFFF00'">
3434
Field highlight color

apps/docs/core/supereditor/methods.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ const blob = await editor.exportDocument({ isFinalDoc: true });
180180

181181
Lower-level export with additional control.
182182

183+
**Returns:** `Promise<Blob>` in the browser, `Promise<Buffer>` in headless/Node.js mode.
184+
183185
<ParamField path="options" type="Object">
184186
<Expandable title="properties">
185187
<ParamField path="isFinalDoc" type="boolean" default="false">

apps/docs/docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
"extensions/text-indent",
167167
"extensions/text-style",
168168
"extensions/text-transform",
169+
"extensions/track-changes",
169170
"extensions/underline"
170171
]
171172
}

apps/docs/extensions/track-changes.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ const superdoc = new SuperDoc({
283283
```
284284
</CodeGroup>
285285

286+
## Full example
287+
288+
<Card
289+
title="Track Changes Example"
290+
icon="github"
291+
href="https://github.com/superdoc-dev/superdoc/tree/main/examples/features/track-changes"
292+
>
293+
Runnable example with mode switching, accept/reject, and comments sidebar
294+
</Card>
295+
286296
## Source code
287297

288298
import { SourceCodeLink } from '/snippets/components/source-code-link.jsx'

apps/docs/getting-started/ai-agents.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,20 @@ https://docs.superdoc.dev/llms-full.txt // Complete documentation
107107
>
108108
Content formats, export options, and round-trip behavior
109109
</Card>
110+
111+
<Card
112+
title="AI Redlining (Browser)"
113+
icon="github"
114+
href="https://github.com/superdoc-dev/superdoc/tree/main/examples/features/ai-redlining"
115+
>
116+
React app: upload a DOCX, LLM reviews it, tracked changes in the UI
117+
</Card>
118+
119+
<Card
120+
title="AI Redlining (Headless)"
121+
icon="github"
122+
href="https://github.com/superdoc-dev/superdoc/tree/main/examples/headless/ai-redlining"
123+
>
124+
Node.js script: open DOCX, LLM reviews, export redlined document
125+
</Card>
110126
</CardGroup>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ const superdoc = new SuperDoc({
110110

111111
### DOCX export
112112

113+
<Note>
114+
`superdoc.export()` **triggers a browser download by default**. If you need the raw `Blob` (e.g. to upload to a server), pass `triggerDownload: false` — otherwise you'll get a duplicate download.
115+
</Note>
116+
113117
<CodeGroup>
114118
```javascript Usage
115119
// Download as .docx file

apps/docs/modules/comments.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,3 +639,13 @@ onCommentsUpdate: ({ type, comment, meta }) => {
639639
</ResponseField>
640640
</Expandable>
641641
</ResponseField>
642+
643+
## Full example
644+
645+
<Card
646+
title="Comments Example"
647+
icon="github"
648+
href="https://github.com/superdoc-dev/superdoc/tree/main/examples/features/comments"
649+
>
650+
Runnable example: threaded comments with resolve workflow and event log
651+
</Card>

apps/docs/modules/toolbar.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const superdoc = new SuperDoc({
1717

1818
## Configuration
1919

20-
<ParamField path="modules.toolbar.selector" type="string | HTMLElement">
21-
Container element for toolbar
20+
<ParamField path="modules.toolbar.selector" type="string">
21+
CSS selector for the toolbar container (e.g. `'#toolbar'`). Must be a string selector, not a DOM element reference.
2222
</ParamField>
2323

2424
<ParamField path="modules.toolbar.toolbarGroups" type="string[]" default="['left', 'center', 'right']">
@@ -594,3 +594,13 @@ const superdoc = new SuperDoc({
594594
```
595595

596596
</CodeGroup>
597+
598+
## Full example
599+
600+
<Card
601+
title="Custom Toolbar Example"
602+
icon="github"
603+
href="https://github.com/superdoc-dev/superdoc/tree/main/examples/features/custom-toolbar"
604+
>
605+
Runnable example: custom button groups, excluded items, and a custom clear-formatting button
606+
</Card>

0 commit comments

Comments
 (0)