import { CSSProperties } from 'react'; import { Editor } from 'superdoc'; import { ForwardRefExoticComponent } from 'react'; import { ReactNode } from 'react'; import { RefAttributes } from 'react'; import { SuperDoc } from 'superdoc'; import { SuperDocExceptionPayload } from 'superdoc'; import { Transaction } from 'superdoc'; /** * Explicitly typed callback props to ensure proper TypeScript inference. * These override any loosely-typed callbacks from SuperDocConfig. */ export declare interface CallbackProps { /** Callback when SuperDoc is ready */ onReady?: (event: SuperDocReadyEvent) => void; /** Callback after an editor is created */ onEditorCreate?: (event: SuperDocEditorCreateEvent) => void; /** Callback when editor is destroyed */ onEditorDestroy?: () => void; /** Callback when document content is updated */ onEditorUpdate?: (event: SuperDocEditorUpdateEvent) => void; /** Callback when a transaction is emitted */ onTransaction?: (event: SuperDocTransactionEvent) => void; /** Callback when there is a content parsing error */ onContentError?: (event: SuperDocContentErrorEvent) => void; /** Callback when an exception is thrown */ onException?: (event: SuperDocExceptionEvent) => void; /** Callback when the zoom level changes (setZoom, toolbar, or fit-width mode) */ onZoomChange?: (event: SuperDocZoomChangeEvent) => void; /** Callback when the implied fit changes (rounded fit zoom or base page width); see the core viewport-change event */ onViewportChange?: (event: SuperDocViewportChangeEvent) => void; } /** Document mode - extracted from Config.documentMode */ export declare type DocumentMode = NonNullable; export { Editor } /** * Explicitly typed editor implementation props. */ declare interface EditorImplementationProps { /** Select the DOCX editor implementation. @default 1 */ editorVersion?: 1 | 2; /** Private editor integration object or factory. Required when editorVersion is 2. */ editorIntegration?: unknown; } /** Surface where an editor event originated. */ export declare type EditorSurface = 'body' | 'header' | 'footer'; /** * Callback props that are explicitly typed in CallbackProps. * These are excluded from SuperDocConfig to avoid type conflicts. */ declare type ExplicitCallbackProps = 'onReady' | 'onEditorCreate' | 'onEditorDestroy' | 'onEditorUpdate' | 'onTransaction' | 'onContentError' | 'onException' | 'onZoomChange' | 'onViewportChange'; /** * Props managed internally by the React component (not exposed to users). * - selector: managed by component (creates internal container) */ declare type InternalProps = 'selector'; /** * Props that are required in core but should be optional in React. * - documentMode: defaults to 'editing' if not provided */ declare type OptionalInReact = 'documentMode'; /** * React-specific props added on top of SuperDocConfig. */ declare interface ReactProps { /** Optional ID for the editor container. Auto-generated if not provided. */ id?: string; /** Render function for loading state */ renderLoading?: () => ReactNode; /** Hide the toolbar container. When true, no toolbar is rendered. @default false */ hideToolbar?: boolean; /** Enable contained mode for fixed-height container embedding. When true, SuperDoc * fits within its parent's height and scrolls internally. @default false */ contained?: boolean; /** Additional CSS class name for the wrapper element */ className?: string; /** Additional inline styles for the wrapper element */ style?: CSSProperties; } /** Full SuperDoc config - extracted from constructor */ export declare type SuperDocConfig = SuperDocConstructorConfig; /** * Types for @superdoc-dev/react * * Core types are extracted from the SuperDoc constructor parameter type, * ensuring they stay in sync with the superdoc package. */ /** SuperDoc constructor config - extracted from superdoc package */ declare type SuperDocConstructorConfig = ConstructorParameters[0]; /** * Event passed to onContentError callback. Re-derived from the core * `SuperDocConfig['onContentError']` parameter so the React wrapper * cannot drift from the core contract: any widening or tightening * upstream surfaces here automatically. See the core * `Config.onContentError` JSDoc for the field semantics * (`error: unknown`, `file: File | Blob | null | undefined`). */ export declare type SuperDocContentErrorEvent = Parameters>[0]; /** * SuperDocEditor component with forwardRef - Initializes SuperDoc instance and handles cleanup. */ declare const SuperDocEditor: ForwardRefExoticComponent>; export { SuperDocEditor } export default SuperDocEditor; /** Event passed to onEditorCreate callback */ export declare interface SuperDocEditorCreateEvent { editor: Editor; } /** * Props for SuperDocEditor component. * * Extends SuperDocConfig (minus internal props) with React-specific additions. * When new props are added to SuperDoc core, they're automatically available here. * * Callback props are explicitly typed to ensure proper TypeScript inference. */ export declare interface SuperDocEditorProps extends Omit, Partial>, EditorImplementationProps, CallbackProps, ReactProps { } /** Event passed to onEditorUpdate callback. Mirrors superdoc's EditorUpdateEvent. */ export declare interface SuperDocEditorUpdateEvent { /** The primary editor associated with the update. For header/footer edits, this is the main body editor. */ editor: Editor; /** The editor instance that emitted the update. For body edits, this matches `editor`. */ sourceEditor: Editor; /** The surface where the edit originated. */ surface: EditorSurface; /** Relationship ID for header/footer edits. */ headerId?: string | null; /** Header/footer variant (`default`, `first`, `even`, `odd`) when available. */ sectionType?: string | null; } /** * Event passed to onException callback. Re-exports the core union so * the React wrapper matches what consumers receive when SuperDoc emits * an `exception` event. The union has three runtime shapes (store init, * restore failure, editor lifecycle); narrow with `'stage' in event` * or `'code' in event` to access shape-specific fields. */ export declare type SuperDocExceptionEvent = SuperDocExceptionPayload; /** SuperDoc instance type - from superdoc package */ export declare type SuperDocInstance = InstanceType; /** Modules configuration - extracted from Config.modules */ export declare type SuperDocModules = NonNullable; /** Event passed to onReady callback */ export declare interface SuperDocReadyEvent { superdoc: SuperDocInstance; } /** * Ref interface for SuperDocEditor component */ export declare interface SuperDocRef { /** Get the underlying SuperDoc instance. Returns null if not yet initialized. */ getInstance(): SuperDocInstance | null; } /** Event passed to onTransaction callback. Mirrors superdoc's EditorTransactionEvent. */ export declare interface SuperDocTransactionEvent { /** The primary editor associated with the transaction. For header/footer edits, this is the main body editor. */ editor: Editor; /** The editor instance that emitted the transaction. For body edits, this matches `editor`. */ sourceEditor: Editor; /** The ProseMirror transaction emitted by the source editor. */ transaction: Transaction; /** Time spent applying the transaction, in milliseconds. */ duration?: number; /** The surface where the transaction originated. */ surface: EditorSurface; /** Relationship ID for header/footer edits. */ headerId?: string | null; /** Header/footer variant (`default`, `first`, `even`, `odd`) when available. */ sectionType?: string | null; } /** User object - extracted from Config.user */ export declare type SuperDocUser = NonNullable; /** * Event passed to onViewportChange callback. Re-derived from the core * `Config.onViewportChange` parameter so the React wrapper cannot * drift from the core contract. */ export declare type SuperDocViewportChangeEvent = Parameters>[0]; /** * Event passed to onZoomChange callback. Re-derived from the core * `Config.onZoomChange` parameter so the React wrapper cannot drift * from the core contract. */ export declare type SuperDocZoomChangeEvent = Parameters>[0]; /** User role - extracted from Config.role */ export declare type UserRole = NonNullable; export { }