superdoc 2.13.0-next.1 → 2.13.0-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/chunks/{create-super-doc-ui-BWWWNPP8.cjs → create-super-doc-ui-DNfQTF2k.cjs} +66 -6
  2. package/dist/chunks/{create-super-doc-ui-FnwgTkUv.es.js → create-super-doc-ui-XWtQHPGP.es.js} +66 -6
  3. package/dist/collaboration-upgrade-engine.cjs +1 -1
  4. package/dist/collaboration-upgrade-engine.es.js +1 -1
  5. package/dist/document-api/src/blocks/blocks.d.ts +3 -1
  6. package/dist/document-api/src/blocks/find-text.d.ts +3 -0
  7. package/dist/document-api/src/content-controls/content-controls.types.d.ts +1 -1
  8. package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
  9. package/dist/document-api/src/contract/operation-definitions.d.ts +11 -1
  10. package/dist/document-api/src/contract/operation-registry.d.ts +7 -2
  11. package/dist/document-api/src/index.d.ts +7 -6
  12. package/dist/document-api/src/invoke/invoke.d.ts +2 -1
  13. package/dist/document-api/src/types/blocks.types.d.ts +38 -0
  14. package/dist/document-api/src/types/mutation-plan.types.d.ts +28 -4
  15. package/dist/document-api/src/types/table-operations.types.d.ts +2 -0
  16. package/dist/layout-engine/dom-contract/src/data-attrs.d.ts +3 -0
  17. package/dist/layout-engine/painters/dom/src/page-content.d.ts +3 -2
  18. package/dist/layout-engine/painters/dom/src/renderer.d.ts +1 -0
  19. package/dist/public/collaboration-worker.cjs +9 -0
  20. package/dist/public/collaboration-worker.es.js +8 -0
  21. package/dist/public/ui-react.cjs +1 -1
  22. package/dist/public/ui-react.es.js +1 -1
  23. package/dist/public/ui-vue.cjs +1 -1
  24. package/dist/public/ui-vue.es.js +1 -1
  25. package/dist/public/ui.cjs +1 -1
  26. package/dist/public/ui.es.js +1 -1
  27. package/dist/style.css +26 -26
  28. package/dist/style.layered.css +26 -26
  29. package/dist/superdoc/src/composables/use-viewport-fit.d.ts +1 -0
  30. package/dist/superdoc/src/core/collaboration/collaboration-exception.d.ts +2 -0
  31. package/dist/superdoc/src/core/collaboration/resolve-v2-collaboration-target.d.ts +16 -5
  32. package/dist/superdoc/src/core/theme/create-theme.d.ts +32 -20
  33. package/dist/superdoc/src/core/types/index.d.ts +59 -71
  34. package/dist/superdoc/src/public/collaboration-worker.d.cts +18 -0
  35. package/dist/superdoc/src/public/collaboration-worker.d.ts +48 -0
  36. package/dist/superdoc/src/public/export-types.d.ts +23 -0
  37. package/dist/superdoc/src/public/index.d.cts +12 -0
  38. package/dist/superdoc/src/public/index.d.ts +3 -0
  39. package/dist/superdoc/src/public/ui/types.d.ts +18 -9
  40. package/dist/superdoc.cjs +384 -267
  41. package/dist/superdoc.es.js +384 -267
  42. package/dist-cdn/style.layered.css +1 -1
  43. package/dist-cdn/superdoc.min.css +1 -1
  44. package/dist-cdn/superdoc.min.js +37 -37
  45. package/package.json +13 -2
@@ -10,6 +10,7 @@ import { CustomCommandContext, FontFamilyOption as ToolbarFontFamilyOption } fro
10
10
  export type { DocumentFontOption, FontAssetUrlContext, FontAssetUrlResolver, FontFaceSlot, FontFamilyOption, FontLoadResult, FontLoadStatus, FontLoadSummary, FontResolutionReason, FontResolutionRecord, GlyphException, ResolvedFontEvidence, SubstitutePolicyAction, SubstituteVerdict, } from '../../../../shared/font-system/src/index.js';
11
11
  export type SuperDoc = SuperDocClass;
12
12
  export type { BrowserDocumentApi } from '../../public/browser-document-api.js';
13
+ export type { CommentsType, ExportParams, ExportType } from '../../public/export-types.js';
13
14
  /**
14
15
  * A row in a custom dropdown's option list, and the value handed back to the
15
16
  * `command` callback when one is chosen.
@@ -591,10 +592,12 @@ export interface CollaborationProvider {
591
592
  off?: (...args: unknown[]) => unknown;
592
593
  disconnect?: () => unknown;
593
594
  destroy?: () => unknown;
595
+ /** Send a provider-specific stateless string payload. */
596
+ sendStateless?: (message: string) => unknown;
594
597
  [key: string]: unknown;
595
598
  }
596
599
  /**
597
- * Document-level v2 collaboration handoff.
600
+ * Connection settings for one shared document, used at startup and during an upgrade.
598
601
  *
599
602
  * This is the public surface for SuperDoc v2's shipped real-time collaboration
600
603
  * model. v2 collaboration is always single-doc: one `Y.Doc`, one provider
@@ -604,18 +607,19 @@ export interface CollaborationProvider {
604
607
  * single-doc provider internally. One `documentId` maps to exactly one
605
608
  * room/provider/root identity.
606
609
  *
607
- * SuperDoc v2 supports three first-class provider families through this field:
608
- * y-websocket, Hocuspocus, and Liveblocks. The provider is selected with
609
- * `providerType`; omitting it preserves the original y-websocket-only shape
610
- * (`{ documentId, serverUrl, params? }`) for backward compatibility.
610
+ * SuperDoc v2 includes y-websocket, Hocuspocus, and Liveblocks adapters and can
611
+ * route a named provider extension through a configured collaboration Worker.
612
+ * The provider is selected with `providerType`; omitting it preserves the
613
+ * original y-websocket-only shape (`{ documentId, serverUrl, params? }`).
611
614
  *
612
615
  * This is intentionally distinct from the legacy provider-agnostic
613
- * {@link CollaborationConfig} (`Config.modules.collaboration`): v2 owns its
614
- * provider internally and does **not** accept an external Yjs `provider`/`ydoc`
615
- * through this field. External `{ ydoc, provider }` remains a v1 /
616
- * provider-compat concern only and is rejected as a v2 content driver.
616
+ * {@link CollaborationConfig} (`Config.modules.collaboration`): v2 owns the
617
+ * Y.Doc. Provider extensions receive that document inside the collaboration
618
+ * Worker instead of replacing it.
617
619
  */
618
- export type V2CollaborationConfig = V2YWebsocketCollaborationConfig | V2HocuspocusCollaborationConfig | V2LiveblocksCollaborationConfig;
620
+ export type DocumentCollaborationConfig = V2YWebsocketCollaborationConfig | V2HocuspocusCollaborationConfig | V2LiveblocksCollaborationConfig | V2ProviderExtensionCollaborationConfig;
621
+ /** @deprecated replaceWith=`DocumentCollaborationConfig` compat-indefinitely: existing v2 integrations import this type. */
622
+ export type V2CollaborationConfig = DocumentCollaborationConfig;
619
623
  /**
620
624
  * y-websocket single-doc provider config.
621
625
  *
@@ -653,8 +657,8 @@ export interface V2HocuspocusCollaborationConfig {
653
657
  url?: string;
654
658
  /** Optional connection params forwarded to the backend. */
655
659
  params?: Record<string, string> | null;
656
- /** Auth-message token forwarded to the Hocuspocus backend. */
657
- token?: string;
660
+ /** Static auth token or resolver invoked for every Hocuspocus connection. */
661
+ token?: string | (() => string | Promise<string>);
658
662
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
659
663
  roomMode?: 'join' | 'create';
660
664
  }
@@ -681,6 +685,20 @@ export interface V2LiveblocksCollaborationConfig {
681
685
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
682
686
  roomMode?: 'join' | 'create';
683
687
  }
688
+ /** Named provider adapter implemented by the configured collaboration Worker. */
689
+ export interface V2ProviderExtensionCollaborationConfig {
690
+ providerType: 'extension';
691
+ /** Adapter registration key understood by the collaboration Worker. */
692
+ adapterId: string;
693
+ /** Stable shared document identity. */
694
+ documentId: string;
695
+ /** Structured-clone-safe options passed to the registered adapter factory. */
696
+ providerOptions?: unknown;
697
+ /** Optional host-owned credential resolver available to the adapter. */
698
+ token?: string | (() => string | Promise<string>);
699
+ /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
700
+ roomMode?: 'join' | 'create';
701
+ }
684
702
  export interface Comment {
685
703
  id?: string;
686
704
  commentId?: string;
@@ -932,29 +950,21 @@ export interface AwarenessUser extends User {
932
950
  }
933
951
  /**
934
952
  * One entry in the `states` array delivered to
935
- * {@link Config.onAwarenessUpdate}. SuperDoc emits an entry per remote
936
- * client, derived from the underlying Yjs awareness states.
953
+ * {@link Config.onAwarenessUpdate}. In V2, `states` includes the current
954
+ * user and remote participants. Do not append the current user again.
937
955
  *
938
- * The runtime helper `awarenessStatesToArray` spreads each remote user
939
- * onto the top of the entry (`{ clientId, ...value.user, color }`), so
940
- * `User` fields like `name`, `email`, `image` appear at the top level
941
- * (not nested under a `user` property). Consumers should read `state.id`,
942
- * `state.name`, and `state.email`, not `state.user.name`.
956
+ * Display fields such as `name`, `email`, and `color` are at the top
957
+ * level, not nested under `user`. Fields may be absent; a presence
958
+ * entry is not an authenticated account record.
943
959
  *
944
960
  * Application-specific fields attached to the awareness state by the
945
961
  * provider surface through the `[key: string]: unknown` index
946
962
  * signature; consumers narrow before use.
947
963
  */
948
964
  export interface AwarenessState extends User {
949
- /** Yjs client identifier for the remote peer. */
965
+ /** Presence identifier. In V2, scoped to this editor instance, not a Yjs transport id. */
950
966
  clientId?: number;
951
- /**
952
- * Color assigned by SuperDoc's presence system. Spread onto the
953
- * awareness entry after the user fields, so it takes precedence
954
- * over any color the awareness user carried in (see
955
- * {@link AwarenessUser.color}). Used when the presence system
956
- * computes a stable palette assignment for the remote peer.
957
- */
967
+ /** Resolved cursor color supplied by the presence system. */
958
968
  color?: string;
959
969
  /** Application-specific fields spread from the awareness provider. */
960
970
  [key: string]: unknown;
@@ -998,12 +1008,11 @@ export interface Document {
998
1008
  */
999
1009
  provider?: CollaborationProvider;
1000
1010
  /**
1001
- * Document-level v2 collaboration handoff. When present, the v2 runtime
1002
- * makes this document collaborative through the shipped single-doc
1003
- * y-websocket provider (one room / Y.Doc / awareness channel per
1004
- * `documentId`). See {@link V2CollaborationConfig}. Ignored by the v1
1005
- * editor, which uses `Config.modules.collaboration` instead.
1011
+ * Connect this document to a shared room. SuperDoc owns the provider and Y.Doc.
1012
+ * Takes precedence over `v2Collaboration`; `null` opens a local document.
1006
1013
  */
1014
+ collaboration?: DocumentCollaborationConfig | null;
1015
+ /** @deprecated replaceWith=`collaboration` compat-indefinitely: existing v2 integrations use this field. */
1007
1016
  v2Collaboration?: V2CollaborationConfig | null;
1008
1017
  }
1009
1018
  type DocumentSourceOptions = Omit<Document, 'data' | 'type' | 'url'>;
@@ -1126,9 +1135,8 @@ export interface CollaborationConfig {
1126
1135
  /**
1127
1136
  * Options for `upgradeToCollaboration()`.
1128
1137
  *
1129
- * v2 promotes a local single-DOCX editor into the shipped single-doc
1130
- * y-websocket room described by {@link V2CollaborationConfig}. Pass a
1131
- * `v2Collaboration` target to promote into a supported v2 room.
1138
+ * Promote a local DOCX into a shared room using `collaboration`.
1139
+ * Supports the same providers as {@link DocumentCollaborationConfig}.
1132
1140
  *
1133
1141
  * The legacy `ydoc` / `provider` fields remain accepted for source
1134
1142
  * compatibility with v1-shaped callers, but v2 does **not** drive document
@@ -1138,14 +1146,15 @@ export interface CollaborationConfig {
1138
1146
  * fields are therefore optional and only honored when they resolve to a
1139
1147
  * supported v2 room.
1140
1148
  *
1141
- * @see {@link V2CollaborationConfig}
1149
+ * @see {@link DocumentCollaborationConfig}
1142
1150
  */
1143
1151
  export interface UpgradeToCollaborationOptions {
1144
1152
  /**
1145
- * Canonical supported v2 promotion target: the single-doc y-websocket room
1146
- * ({ documentId, serverUrl, params? }) to create from the current document.
1147
- * Promotion fails if the v2 room already exists.
1153
+ * Create a shared room from the current document. Fails if the room already exists.
1154
+ * Takes precedence over `v2Collaboration`.
1148
1155
  */
1156
+ collaboration?: DocumentCollaborationConfig;
1157
+ /** @deprecated replaceWith=`collaboration` compat-indefinitely: existing v2 integrations use this field. */
1149
1158
  v2Collaboration?: V2CollaborationConfig;
1150
1159
  /**
1151
1160
  * Legacy external Yjs document. Accepted for v1 source compatibility; not a
@@ -2781,12 +2790,6 @@ export interface TrackChangesModuleConfig {
2781
2790
  semanticColors?: TrackChangesSemanticColorsConfig;
2782
2791
  }
2783
2792
  export type DocumentMode = 'editing' | 'viewing' | 'suggesting';
2784
- export type ExportType = 'docx';
2785
- /**
2786
- * - 'external': Include only external comments (default)
2787
- * - 'clean': Export without any comments
2788
- */
2789
- export type CommentsType = 'external' | 'clean';
2790
2793
  /**
2791
2794
  * Document view layout values — mirrors OOXML ST_View (ECMA-376 §17.18.102).
2792
2795
  * - 'print': Print Layout View — displays document as it prints (default)
@@ -2805,30 +2808,6 @@ export interface ViewOptions {
2805
2808
  */
2806
2809
  layout?: ViewLayout;
2807
2810
  }
2808
- export interface ExportParams {
2809
- /** Browser export format. DOCX is the only supported output. */
2810
- exportType?: readonly [ExportType];
2811
- /** How to handle comments. */
2812
- commentsType?: CommentsType;
2813
- /** Custom filename (without extension). */
2814
- exportedName?: string;
2815
- /** Extra files to include in the export zip. */
2816
- additionalFiles?: globalThis.Blob[];
2817
- /** Filenames for the additional files. */
2818
- additionalFileNames?: string[];
2819
- /** Whether this is a final document export. */
2820
- isFinalDoc?: boolean;
2821
- /** Auto-download or return blob. */
2822
- triggerDownload?: boolean;
2823
- /**
2824
- * Color for field highlights. The runtime defaults to `null` when no
2825
- * value is supplied (and forwards `null` through to the underlying
2826
- * editor export, which accepts `string | null`); the typedef accepts
2827
- * `null` explicitly so consumers can pass an explicit "no highlight"
2828
- * value without a typecheck failure.
2829
- */
2830
- fieldsHighlightColor?: string | null;
2831
- }
2832
2811
  /** Surface where the edit originated. */
2833
2812
  export type EditorSurface = 'body' | 'header' | 'footer';
2834
2813
  export interface EditorUpdateEvent {
@@ -3242,6 +3221,14 @@ export interface SuperDocExceptionEditorPayload {
3242
3221
  /** Structured browser-worker failure detail when editor startup failed in its worker transport. */
3243
3222
  workerFailure?: SuperDocWorkerFailureDetail;
3244
3223
  }
3224
+ /** Connection failure while opening a collaboration room, reported through `onException`. */
3225
+ export interface SuperDocExceptionCollaborationPayload extends SuperDocExceptionEditorPayload {
3226
+ error: Error;
3227
+ code: 'collaboration-access-denied' | 'collaboration-connection-failed' | 'collaboration-sync-timeout';
3228
+ /** Access denial requires an explicit provider rejection; a timeout is not proof of denied access. */
3229
+ collaborationReason: 'access-denied' | 'connection-failed' | 'sync-timeout';
3230
+ editor: null;
3231
+ }
3245
3232
  /**
3246
3233
  * Exception payload raised by the built-in toolbar.
3247
3234
  *
@@ -3311,6 +3298,7 @@ export interface SuperDocExceptionDiagnosticPayload {
3311
3298
  * Consumers can narrow with `'stage' in payload` (store init),
3312
3299
  * `'code' in payload` (editor lifecycle), `'itemName' in payload`
3313
3300
  * (built-in toolbar), `'source' in payload` (hyperlink activation),
3301
+ * `'collaborationReason' in payload` (collaboration connection),
3314
3302
  * or `'diagnosticCode' in payload` (structured diagnostic).
3315
3303
  *
3316
3304
  * The union exists today because multiple independent emit sites pre-date a
@@ -3318,7 +3306,7 @@ export interface SuperDocExceptionDiagnosticPayload {
3318
3306
  * separate follow-up; consumers can narrow with the `in` checks above in the
3319
3307
  * meantime.
3320
3308
  */
3321
- export type SuperDocExceptionPayload = SuperDocExceptionStorePayload | SuperDocExceptionRestorePayload | SuperDocExceptionEditorPayload | SuperDocExceptionToolbarPayload | SuperDocExceptionHyperlinkPayload | SuperDocExceptionDiagnosticPayload;
3309
+ export type SuperDocExceptionPayload = SuperDocExceptionStorePayload | SuperDocExceptionRestorePayload | SuperDocExceptionEditorPayload | SuperDocExceptionCollaborationPayload | SuperDocExceptionToolbarPayload | SuperDocExceptionHyperlinkPayload | SuperDocExceptionDiagnosticPayload;
3322
3310
  /**
3323
3311
  * Zoom mode. `manual` holds whatever value was last set; `fit-width`
3324
3312
  * continuously recomputes the zoom that fits the page width into the
@@ -3827,7 +3815,7 @@ export interface Config {
3827
3815
  role?: 'editor' | 'viewer' | 'suggester';
3828
3816
  /**
3829
3817
  * Document to open. Pass a URL, file, byte source, or structured source.
3830
- * Use a structured document carrying `v2Collaboration` for collaboration,
3818
+ * Use a structured document carrying `collaboration` for collaboration,
3831
3819
  * or a structured source for other metadata. Omit it to open a blank DOCX.
3832
3820
  */
3833
3821
  document?: DocumentSource | null;
@@ -0,0 +1,18 @@
1
+ // Generated by scripts/ensure-types.cjs. Do not edit by hand.
2
+ import type { SuperDocCollaborationProviderAdapter as __Cjs_SuperDocCollaborationProviderAdapter } from './collaboration-worker.js' with { "resolution-mode": "import" };
3
+ import type { SuperDocCollaborationProviderAttachInput as __Cjs_SuperDocCollaborationProviderAttachInput } from './collaboration-worker.js' with { "resolution-mode": "import" };
4
+ import type { SuperDocCollaborationProviderAwareness as __Cjs_SuperDocCollaborationProviderAwareness } from './collaboration-worker.js' with { "resolution-mode": "import" };
5
+ import type { SuperDocCollaborationProviderFactory as __Cjs_SuperDocCollaborationProviderFactory } from './collaboration-worker.js' with { "resolution-mode": "import" };
6
+ import type { SuperDocCollaborationProviderFactoryInput as __Cjs_SuperDocCollaborationProviderFactoryInput } from './collaboration-worker.js' with { "resolution-mode": "import" };
7
+ import type { SuperDocCollaborationProviderFamily as __Cjs_SuperDocCollaborationProviderFamily } from './collaboration-worker.js' with { "resolution-mode": "import" };
8
+ import type { SuperDocCollaborationProviderTransport as __Cjs_SuperDocCollaborationProviderTransport } from './collaboration-worker.js' with { "resolution-mode": "import" };
9
+ import type { SuperDocCollaborationWorkerOptions as __Cjs_SuperDocCollaborationWorkerOptions } from './collaboration-worker.js' with { "resolution-mode": "import" };
10
+ export declare const bootstrapSuperDocCollaborationWorker: typeof import('./collaboration-worker.js', { with: { "resolution-mode": "import" } }).bootstrapSuperDocCollaborationWorker;
11
+ export type { __Cjs_SuperDocCollaborationProviderAdapter as SuperDocCollaborationProviderAdapter };
12
+ export type { __Cjs_SuperDocCollaborationProviderAttachInput as SuperDocCollaborationProviderAttachInput };
13
+ export type { __Cjs_SuperDocCollaborationProviderAwareness as SuperDocCollaborationProviderAwareness };
14
+ export type { __Cjs_SuperDocCollaborationProviderFactory as SuperDocCollaborationProviderFactory };
15
+ export type { __Cjs_SuperDocCollaborationProviderFactoryInput as SuperDocCollaborationProviderFactoryInput };
16
+ export type { __Cjs_SuperDocCollaborationProviderFamily as SuperDocCollaborationProviderFamily };
17
+ export type { __Cjs_SuperDocCollaborationProviderTransport as SuperDocCollaborationProviderTransport };
18
+ export type { __Cjs_SuperDocCollaborationWorkerOptions as SuperDocCollaborationWorkerOptions };
@@ -0,0 +1,48 @@
1
+ import { Doc as YDoc } from 'yjs';
2
+ export type SuperDocCollaborationProviderFamily = 'y-websocket' | 'hocuspocus' | 'liveblocks';
3
+ export interface SuperDocCollaborationProviderAwareness {
4
+ getLocalState(): Record<string, unknown> | null;
5
+ setLocalState(state: Record<string, unknown> | null): void;
6
+ getStates(): Map<number, Record<string, unknown>>;
7
+ on(event: 'change' | 'update', listener: (payload: {
8
+ added: number[];
9
+ updated: number[];
10
+ removed: number[];
11
+ }) => void): void;
12
+ off(event: 'change' | 'update', listener: (payload: {
13
+ added: number[];
14
+ updated: number[];
15
+ removed: number[];
16
+ }) => void): void;
17
+ }
18
+ export interface SuperDocCollaborationProviderAttachInput {
19
+ readonly rootId: string;
20
+ readonly ydoc: YDoc;
21
+ readonly providerRoomName: string;
22
+ onSynced(): void;
23
+ onDegraded(): void;
24
+ onFailed(detail: Record<string, unknown>): void;
25
+ onStateless(message: string): void;
26
+ }
27
+ export interface SuperDocCollaborationProviderTransport {
28
+ readonly awareness?: SuperDocCollaborationProviderAwareness | null;
29
+ disconnect(): void;
30
+ destroy(): void;
31
+ sendStateless?(message: string): Promise<void> | void;
32
+ }
33
+ export interface SuperDocCollaborationProviderAdapter {
34
+ readonly providerFamily: SuperDocCollaborationProviderFamily;
35
+ attach(input: SuperDocCollaborationProviderAttachInput): SuperDocCollaborationProviderTransport;
36
+ destroy?(): void;
37
+ }
38
+ export interface SuperDocCollaborationProviderFactoryInput {
39
+ readonly documentId: string;
40
+ readonly providerOptions: unknown;
41
+ readonly token: string | (() => Promise<string>) | null;
42
+ }
43
+ export type SuperDocCollaborationProviderFactory = (input: SuperDocCollaborationProviderFactoryInput) => SuperDocCollaborationProviderAdapter;
44
+ export interface SuperDocCollaborationWorkerOptions {
45
+ readonly providerAdapters: Readonly<Record<string, SuperDocCollaborationProviderFactory>>;
46
+ }
47
+ /** Register provider adapters and start the worker used by `workerUrls.collaboration`. */
48
+ export declare function bootstrapSuperDocCollaborationWorker(options: SuperDocCollaborationWorkerOptions): void;
@@ -0,0 +1,23 @@
1
+ /** Browser export format. DOCX is the only supported output. */
2
+ export type ExportType = 'docx';
3
+ /** Comment output: `external` includes external comments; `clean` removes comments. */
4
+ export type CommentsType = 'external' | 'clean';
5
+ /** Options accepted by `SuperDoc.export()` and `ui.document.export()`. */
6
+ export interface ExportParams {
7
+ /** Browser export format. DOCX is the only supported output. */
8
+ exportType?: readonly [ExportType];
9
+ /** How to handle comments. */
10
+ commentsType?: CommentsType;
11
+ /** Custom filename without an extension. */
12
+ exportedName?: string;
13
+ /** Extra files to include in the export zip. */
14
+ additionalFiles?: globalThis.Blob[];
15
+ /** Filenames for the additional files. */
16
+ additionalFileNames?: string[];
17
+ /** Whether this is a final document export. */
18
+ isFinalDoc?: boolean;
19
+ /** Download the file or return its Blob without downloading. */
20
+ triggerDownload?: boolean;
21
+ /** Field-highlight color, or `null` to omit field highlighting. */
22
+ fieldsHighlightColor?: string | null;
23
+ }
@@ -38,6 +38,7 @@ import type { DirectSurfaceRequest as __Cjs_DirectSurfaceRequest } from './index
38
38
  import type { DocRange as __Cjs_DocRange } from './index.js' with { "resolution-mode": "import" };
39
39
  import type { Document as __Cjs_Document } from './index.js' with { "resolution-mode": "import" };
40
40
  import type { DocumentApi as __Cjs_DocumentApi } from './index.js' with { "resolution-mode": "import" };
41
+ import type { DocumentCollaborationConfig as __Cjs_DocumentCollaborationConfig } from './index.js' with { "resolution-mode": "import" };
41
42
  import type { DocumentDataSource as __Cjs_DocumentDataSource } from './index.js' with { "resolution-mode": "import" };
42
43
  import type { DocumentMode as __Cjs_DocumentMode } from './index.js' with { "resolution-mode": "import" };
43
44
  import type { DocumentProtectionState as __Cjs_DocumentProtectionState } from './index.js' with { "resolution-mode": "import" };
@@ -131,6 +132,7 @@ import type { SuperDocDiagnosticStage as __Cjs_SuperDocDiagnosticStage } from '.
131
132
  import type { SuperDocDisposableBag as __Cjs_SuperDocDisposableBag } from './index.js' with { "resolution-mode": "import" };
132
133
  import type { SuperDocDocumentModeChangePayload as __Cjs_SuperDocDocumentModeChangePayload } from './index.js' with { "resolution-mode": "import" };
133
134
  import type { SuperDocEditorPayload as __Cjs_SuperDocEditorPayload } from './index.js' with { "resolution-mode": "import" };
135
+ import type { SuperDocExceptionCollaborationPayload as __Cjs_SuperDocExceptionCollaborationPayload } from './index.js' with { "resolution-mode": "import" };
134
136
  import type { SuperDocExceptionDiagnosticPayload as __Cjs_SuperDocExceptionDiagnosticPayload } from './index.js' with { "resolution-mode": "import" };
135
137
  import type { SuperDocExceptionEditorPayload as __Cjs_SuperDocExceptionEditorPayload } from './index.js' with { "resolution-mode": "import" };
136
138
  import type { SuperDocExceptionHyperlinkPayload as __Cjs_SuperDocExceptionHyperlinkPayload } from './index.js' with { "resolution-mode": "import" };
@@ -213,6 +215,10 @@ import type { SurfacesModuleConfig as __Cjs_SurfacesModuleConfig } from './index
213
215
  import type { TextAddress as __Cjs_TextAddress } from './index.js' with { "resolution-mode": "import" };
214
216
  import type { TextSegment as __Cjs_TextSegment } from './index.js' with { "resolution-mode": "import" };
215
217
  import type { TextTarget as __Cjs_TextTarget } from './index.js' with { "resolution-mode": "import" };
218
+ import type { ThemeColors as __Cjs_ThemeColors } from './index.js' with { "resolution-mode": "import" };
219
+ import type { ThemeConfig as __Cjs_ThemeConfig } from './index.js' with { "resolution-mode": "import" };
220
+ import type { ThemeResult as __Cjs_ThemeResult } from './index.js' with { "resolution-mode": "import" };
221
+ import type { ThemeVariableOverrides as __Cjs_ThemeVariableOverrides } from './index.js' with { "resolution-mode": "import" };
216
222
  import type { ToolbarCommandId as __Cjs_ToolbarCommandId } from './index.js' with { "resolution-mode": "import" };
217
223
  import type { ToolbarConfig as __Cjs_ToolbarConfig } from './index.js' with { "resolution-mode": "import" };
218
224
  import type { ToolbarCustomButton as __Cjs_ToolbarCustomButton } from './index.js' with { "resolution-mode": "import" };
@@ -298,6 +304,7 @@ export type { __Cjs_DirectSurfaceRequest as DirectSurfaceRequest };
298
304
  export type { __Cjs_DocRange as DocRange };
299
305
  export type { __Cjs_Document as Document };
300
306
  export type { __Cjs_DocumentApi as DocumentApi };
307
+ export type { __Cjs_DocumentCollaborationConfig as DocumentCollaborationConfig };
301
308
  export type { __Cjs_DocumentDataSource as DocumentDataSource };
302
309
  export type { __Cjs_DocumentMode as DocumentMode };
303
310
  export type { __Cjs_DocumentProtectionState as DocumentProtectionState };
@@ -396,6 +403,7 @@ export type { __Cjs_SuperDocDiagnosticStage as SuperDocDiagnosticStage };
396
403
  export type { __Cjs_SuperDocDisposableBag as SuperDocDisposableBag };
397
404
  export type { __Cjs_SuperDocDocumentModeChangePayload as SuperDocDocumentModeChangePayload };
398
405
  export type { __Cjs_SuperDocEditorPayload as SuperDocEditorPayload };
406
+ export type { __Cjs_SuperDocExceptionCollaborationPayload as SuperDocExceptionCollaborationPayload };
399
407
  export type { __Cjs_SuperDocExceptionDiagnosticPayload as SuperDocExceptionDiagnosticPayload };
400
408
  export type { __Cjs_SuperDocExceptionEditorPayload as SuperDocExceptionEditorPayload };
401
409
  export type { __Cjs_SuperDocExceptionHyperlinkPayload as SuperDocExceptionHyperlinkPayload };
@@ -478,6 +486,10 @@ export type { __Cjs_SurfacesModuleConfig as SurfacesModuleConfig };
478
486
  export type { __Cjs_TextAddress as TextAddress };
479
487
  export type { __Cjs_TextSegment as TextSegment };
480
488
  export type { __Cjs_TextTarget as TextTarget };
489
+ export type { __Cjs_ThemeColors as ThemeColors };
490
+ export type { __Cjs_ThemeConfig as ThemeConfig };
491
+ export type { __Cjs_ThemeResult as ThemeResult };
492
+ export type { __Cjs_ThemeVariableOverrides as ThemeVariableOverrides };
481
493
  export type { __Cjs_ToolbarCommandId as ToolbarCommandId };
482
494
  export type { __Cjs_ToolbarConfig as ToolbarConfig };
483
495
  export type { __Cjs_ToolbarCustomButton as ToolbarCustomButton };
@@ -9,6 +9,7 @@ export { DOCX, PDF, HTML, getFileObject, compareVersions };
9
9
  export { SuperDoc } from '../core/SuperDoc.js';
10
10
  export { buildTheme } from '../core/theme/create-theme.js';
11
11
  export { createTheme } from '../core/theme/create-theme.js';
12
+ export type { ThemeColors, ThemeConfig, ThemeResult, ThemeVariableOverrides } from '../core/theme/create-theme.js';
12
13
  export type { AwarenessState } from '../core/types/index.js';
13
14
  export type { AwarenessUser } from '../core/types/index.js';
14
15
  export type { BlockNavigationAddress } from '../core/types/index.js';
@@ -23,6 +24,7 @@ export type { Config } from '../core/types/index.js';
23
24
  export type { DirectSurfaceRequest } from '../core/types/index.js';
24
25
  export type { DocRange } from '../core/types/index.js';
25
26
  export type { Document } from '../core/types/index.js';
27
+ export type { DocumentCollaborationConfig } from '../core/types/index.js';
26
28
  export type { DocumentDataSource } from '../core/types/index.js';
27
29
  export type { DocumentSource } from '../core/types/index.js';
28
30
  export type { DocumentUploadSource } from '../core/types/index.js';
@@ -86,6 +88,7 @@ export type { SuperDocWorkerFailureDetail } from '../core/types/index.js';
86
88
  export type { SuperDocExceptionHyperlinkPayload } from '../core/types/index.js';
87
89
  export type { SuperDocExceptionToolbarPayload } from '../core/types/index.js';
88
90
  export type { SuperDocExceptionPayload } from '../core/types/index.js';
91
+ export type { SuperDocExceptionCollaborationPayload } from '../core/types/index.js';
89
92
  export type { SuperDocExceptionRestorePayload } from '../core/types/index.js';
90
93
  export type { SuperDocExceptionStorePayload } from '../core/types/index.js';
91
94
  export type { SuperDocFitWidthOptions } from '../core/types/index.js';
@@ -1,5 +1,6 @@
1
1
  import { CommentsListQuery as DocumentApiCommentsListQuery, CommentsListResult, TrackChangesListResult, EntityAddress, TextAddress, TextTarget, ScrollIntoViewInput, ScrollIntoViewOutput, SelectionInfo, SelectionTarget, Receipt, ReceiptFailureCode, ContentControlInfo, StyleCatalogItem, StyleCatalogDiagnostic, StyleCatalogSourceStatus, StylesGetCatalogInput, StylesGetCatalogResult } from '../../../../document-api/src/index.js';
2
2
  import { PartialBrowserDocumentApi } from '../browser-document-api.js';
3
+ import { ExportParams } from '../export-types.js';
3
4
  import { SuperDocUIReason } from './reasons.js';
4
5
  import { BuiltInCommandId } from './commands.js';
5
6
  /**
@@ -657,7 +658,7 @@ export interface DocumentSlice {
657
658
  ready: boolean;
658
659
  /** Current document mode. */
659
660
  mode: 'editing' | 'suggesting' | 'viewing' | null;
660
- /** The document has unsaved changes. */
661
+ /** The current document has local changes. */
661
662
  dirty: boolean;
662
663
  }
663
664
  /**
@@ -735,7 +736,10 @@ export interface StylesHandle extends SnapshotSubscribable<StylesSlice> {
735
736
  /** Resolve the active paragraph style for the current selection. */
736
737
  getActiveParagraphStyle(): ActiveParagraphStyle;
737
738
  }
738
- /** A painted rectangle in viewport coordinates. */
739
+ /**
740
+ * A painted document rectangle. Coordinates use browser client space by
741
+ * default, or the element-relative space requested through `relativeTo`.
742
+ */
739
743
  export interface ViewportRect {
740
744
  /** Zero-based page index the rect belongs to. */
741
745
  pageIndex: number;
@@ -762,7 +766,7 @@ export type ViewportGetRectTarget = SelectionTarget | TextAddress | TextTarget |
762
766
  export interface ViewportGetRectInput {
763
767
  /** Target to resolve to painted geometry. */
764
768
  target: ViewportGetRectTarget;
765
- /** Optional element to anchor returned coordinates against. */
769
+ /** Return coordinates relative to this element instead of browser client space. */
766
770
  relativeTo?: HTMLElement;
767
771
  }
768
772
  /** Result of `ui.viewport.getRect`. */
@@ -791,7 +795,7 @@ export interface SelectionHandle extends SnapshotSubscribable<SelectionSlice> {
791
795
  * Returns `null` before the first async browser read settles.
792
796
  */
793
797
  current(): SelectionInfo | null;
794
- /** Freeze the current selection for later comment/format actions. */
798
+ /** Preserve the current non-empty selection for work that moves focus into application UI. */
795
799
  capture(): SelectionCapture | null;
796
800
  /**
797
801
  * Restore a previously captured selection, best-effort. Never throws;
@@ -820,7 +824,9 @@ export interface SelectionHandle extends SnapshotSubscribable<SelectionSlice> {
820
824
  relativeTo?: HTMLElement;
821
825
  }): readonly ViewportRect[];
822
826
  }
827
+ /** A non-empty selection snapshot preserved independently of browser focus. */
823
828
  export interface SelectionCapture extends SelectionSlice {
829
+ /** Unix time in milliseconds when the selection was captured. */
824
830
  capturedAt: number;
825
831
  }
826
832
  /**
@@ -1144,8 +1150,8 @@ export interface DocumentHandle extends SnapshotSubscribable<DocumentSlice> {
1144
1150
  getSnapshot(): DocumentSlice;
1145
1151
  /** Set the document mode (editing / suggesting / viewing). */
1146
1152
  setMode(mode: 'editing' | 'suggesting' | 'viewing'): void;
1147
- /** Export the document; returns the SuperDoc export promise when available. */
1148
- export(input?: unknown): Promise<unknown> | undefined;
1153
+ /** Export the document and return the produced Blob, optionally downloading it. */
1154
+ export(input?: ExportParams): Promise<Blob> | undefined;
1149
1155
  /** Read text through the Document API; `null` when unavailable. */
1150
1156
  getText(): string | null;
1151
1157
  /** Replace the active document file, when supported by the host. */
@@ -1153,9 +1159,12 @@ export interface DocumentHandle extends SnapshotSubscribable<DocumentSlice> {
1153
1159
  }
1154
1160
  /** Viewport handle. */
1155
1161
  export interface ViewportHandle {
1156
- /** Resolve painted geometry for an entity / content-control address. */
1162
+ /** Resolve current painted geometry for a selection, text target, or supported entity address. */
1157
1163
  getRect(input: ViewportGetRectInput): ViewportRectResult;
1158
- /** Subscribe to viewport/geometry invalidation. */
1164
+ /**
1165
+ * Subscribe to geometry invalidation after selection, zoom, scroll, resize,
1166
+ * layout, or repaint changes. The callback is coalesced to one per frame.
1167
+ */
1159
1168
  observe(listener: () => void): () => void;
1160
1169
  /** Painted editor host element, when available. */
1161
1170
  getHost(): HTMLElement | null;
@@ -1433,7 +1442,7 @@ export interface SuperDocLike {
1433
1442
  /** Set the document mode across the instance. */
1434
1443
  setDocumentMode?(mode: string): unknown;
1435
1444
  /** Export the active document. */
1436
- export?(...args: unknown[]): Promise<unknown> | unknown;
1445
+ export?(params?: ExportParams): Promise<Blob> | Blob;
1437
1446
  /** Set an absolute zoom value. */
1438
1447
  setZoom?(value: number): unknown;
1439
1448
  /** Set a zoom mode. */