feat(superdoc/ui): ui.document surface for export, mode, ready (SD-2816)#3015
Conversation
A custom toolbar's Export button, document-mode toggle, and
ready-state guard previously had to reach for the host SuperDoc
instance. The React provider exposed a SuperDocHost interface as an
escape hatch for that single use case (export); ui.document removes
the need for it.
Adds ui.document with:
- getSnapshot() / subscribe() over { ready, mode } memoized so
typing-only transactions don't re-fire the listener.
- setMode(mode) that forwards to superdoc.setDocumentMode.
- export(options) that forwards to superdoc.export and propagates
the result / rejection. Throws a clear error when the host stub
omits export() instead of silently returning undefined.
Dirty / unsaved-changes tracking is intentionally not on this slice:
SuperDoc has no host-side dirty primitive today, and inventing one
(transaction listener + reset semantics) is a separate ticket.
Re-exports DocumentSlice / DocumentHandle / DocumentExportInput
through superdoc/ui and packages/superdoc/src/ui.d.ts so consumers
can type their own toolbar bindings without reaching into the
internal ui types module.
12 new tests cover snapshot / subscribe memoization / setMode (with
host omission and host throwing) / export forwarding / export
missing / export rejection. 140 ui tests pass; bundle audit clean.
0337c8e to
c201f87
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.15 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0-next.60 |
|
🎉 This PR is included in @superdoc-dev/react v1.2.0-next.58 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.8.0-next.33 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.8.0-next.19 |
|
🎉 This PR is included in superdoc v1.30.0-next.18 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-cli v0.8.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc-sdk v1.8.0 |
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0 The release is available on GitHub release |
|
🎉 This PR is included in superdoc v1.31.0 The release is available on GitHub release |
|
🎉 This PR is included in vscode-ext v2.3.0 |
|
🎉 This PR is included in @superdoc-dev/react v1.3.0 The release is available on GitHub release |
A custom toolbar's Export button, document-mode toggle, and ready-state guard previously had to reach for the host SuperDoc instance. The React provider in SD-2813 exposed a `SuperDocHost` interface as an escape hatch for that single use case (export); `ui.document` removes the need for it.
Adds `ui.document` with:
Dirty / unsaved-changes is intentionally not on this slice. SuperDoc has no host-side dirty primitive today, and inventing one (transaction listener + reset semantics) is a separate ticket.
Re-exports `DocumentSlice` / `DocumentHandle` / `DocumentExportInput` through `superdoc/ui` and `packages/superdoc/src/ui.d.ts` so consumers can type their toolbar bindings from one entrypoint.
Stacked on #3014 (SD-2815). Once that merges, this rebases against main.
Resolves SD-2816.
Verified: `pnpm --filter @superdoc/super-editor test src/ui/` -> 140 passed (12 new); `pnpm --filter superdoc build:es` -> ensure-types + bundle audit clean.