import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode } from 'react'; import { a as ArtifactPaneProps } from './artifact-pane-DpuWcAiF.js'; import { HocuspocusProvider } from '@hocuspocus/provider'; import * as Yjs from 'yjs'; /** * Connection state for the Hocuspocus provider. */ type ConnectionState = "disconnected" | "connecting" | "connected" | "synced"; /** * Collaborator information from awareness. */ interface Collaborator { clientId: number; user: { name: string; color: string; userId?: string; }; } /** * Editor context value exposed to children. */ interface EditorContextValue { /** The Y.Doc instance for collaboration */ doc: Yjs.Doc; /** The Hocuspocus provider instance */ provider: HocuspocusProvider | null; /** Current connection state */ connectionState: ConnectionState; /** List of active collaborators */ collaborators: Collaborator[]; /** Whether the document is synced with the server */ isSynced: boolean; /** Connect to the collaboration server */ connect: () => void; /** Disconnect from the collaboration server */ disconnect: () => void; } /** * User information for presence/awareness. */ interface EditorUser { name: string; color?: string; userId?: string; } interface EditorTokenRefreshResult { token: string; expiresAt?: number; } /** * Props for EditorProvider. */ interface EditorProviderProps { /** WebSocket URL for the Hocuspocus server */ websocketUrl: string; /** Document name (e.g., "doc:my-document") */ documentName: string; /** JWT token for authentication */ token: string; /** Unix timestamp (seconds) when the current token expires */ tokenExpiresAt?: number; /** Current user information for awareness */ user: EditorUser; /** Auto-connect on mount (default: true) */ autoConnect?: boolean; /** Reconnect on disconnect (default: true) */ autoReconnect?: boolean; /** Max reconnect attempts (default: 5) */ maxReconnectAttempts?: number; /** Callback when connection state changes */ onConnectionChange?: (state: ConnectionState) => void; /** Callback when sync completes */ onSync?: () => void; /** Callback on authentication error */ onAuthError?: (error: Error) => void; /** Optional token refresh callback used before reconnect/auth retry */ onRefreshToken?: () => Promise; /** Children components */ children: ReactNode; } /** * EditorProvider wraps children with Hocuspocus collaboration context. * Manages WebSocket connection, Y.Doc, and awareness state. Loads `yjs` and * `@hocuspocus/provider` — and no tiptap package — before it renders children, * because every child hook reads a context that only the loaded provider can * supply. A consumer that drives its own editor from that context therefore * needs those two peers alone. */ declare function EditorProvider(props: EditorProviderProps): react_jsx_runtime.JSX.Element; /** * Hook to access the editor context. * Must be used within an EditorProvider. */ declare function useEditorContext(): EditorContextValue; type DocumentEditorMode = "preview" | "edit"; type DocumentEditorBackend = "local" | "collaborative"; interface DocumentEditorPaneCollaborationConfig extends Omit { } interface DocumentEditorPaneProps extends Omit { tabs?: ArtifactPaneProps["tabs"]; toolbar?: ReactNode; markdown?: string; mode?: DocumentEditorMode; defaultMode?: DocumentEditorMode; onModeChange?: (mode: DocumentEditorMode) => void; backend?: DocumentEditorBackend; placeholder?: string; autoFocus?: boolean; readOnly?: boolean; onChange?: (markdown: string) => void; onSave?: (markdown: string) => Promise | void; saving?: boolean; saveLabel?: string; previewClassName?: string; editorClassName?: string; collaboration?: DocumentEditorPaneCollaborationConfig; } /** * DocumentEditorPane — reusable markdown document surface with preview/edit * modes and optional collaborative editing backed by Yjs/Hocuspocus. */ declare function DocumentEditorPane({ eyebrow, title, subtitle, meta, headerActions, footer, className, contentClassName, headerClassName, hideTitleBlock, tabs, toolbar, markdown, mode, defaultMode, onModeChange, backend, placeholder, autoFocus, readOnly, onChange, onSave, saving, saveLabel, previewClassName, editorClassName, collaboration, }: DocumentEditorPaneProps): react_jsx_runtime.JSX.Element; export { type Collaborator as C, type DocumentEditorBackend as D, type EditorContextValue as E, type ConnectionState as a, type DocumentEditorMode as b, DocumentEditorPane as c, type DocumentEditorPaneCollaborationConfig as d, type DocumentEditorPaneProps as e, EditorProvider as f, type EditorProviderProps as g, type EditorTokenRefreshResult as h, type EditorUser as i, useEditorContext as u };