Hiyve Components - v1.0.0
    Preparing search index...

    Interface UseWhiteboardFileOptions

    Options for the useWhiteboardFile hook

    interface UseWhiteboardFileOptions {
        canvas: Canvas | null;
        currentColor?: string;
        enableAutoSave?: boolean;
        fileId: string;
        getExtraFileData?: () => Partial<WhiteboardFile>;
        getLastRemoteApplyAt?: () => number;
        initialFileData?: WhiteboardFile;
        isOwner: boolean;
        onAfterLoad?: (file: WhiteboardFile) => void;
        onAfterSave?: () => void;
        onBeforeLoad?: () => void;
        onBeforeSave?: () => void;
        onError?: (error: Error) => void;
        onLoadError?: (error: Error) => void;
        onObjectLoaded?: (object: WhiteboardObject) => void;
        ownerPresent?: boolean;
        relayConnected?: boolean;
        styles?: Partial<WhiteboardStyles>;
        userId: string;
    }
    Index

    Properties

    canvas: Canvas | null

    Fabric.js canvas instance

    currentColor?: string

    Current drawing color (to save)

    enableAutoSave?: boolean

    Whether auto-save is enabled

    fileId: string

    File ID to load/save

    getExtraFileData?: () => Partial<WhiteboardFile>

    Return extra data to merge into the file on save (e.g., background pages)

    getLastRemoteApplyAt?: () => number

    Returns the ms timestamp of the most recent remote message applied to the canvas, or 0 if none. The autosave defers when a remote update arrived in the last REMOTE_QUIESCENT_MS window — otherwise the save can capture a half-applied snapshot (e.g., the owner saves while a peer's OBJECT_ADDED is still being applied) and the persisted file misses peer changes.

    initialFileData?: WhiteboardFile

    Initial file data for newly created whiteboards. When provided, the whiteboard will initialize with this data instead of fetching from the server.

    isOwner: boolean

    Whether the current user is the owner

    onAfterLoad?: (file: WhiteboardFile) => void

    Called after load

    onAfterSave?: () => void

    Called after save

    onBeforeLoad?: () => void

    Called before load to set suppress state

    onBeforeSave?: () => void

    Called before save to set suppress state

    onError?: (error: Error) => void

    Called when an async operation fails

    onLoadError?: (error: Error) => void

    Called when the load fails (network, parse error, etc.). Fires INSTEAD of onAfterLoad. Consumers must symmetrically reset any state they set in onBeforeLoad (suppress-broadcast, loading flags) — without this, a transient load failure leaves the whiteboard wedged in suppressed state for the rest of the session: broadcasts dropped, undo broken, autosave deferred.

    onObjectLoaded?: (object: WhiteboardObject) => void

    Called when object is loaded

    ownerPresent?: boolean

    Whether the file owner is currently active in the room. When the owner is absent, non-owners are allowed to save so their work isn't lost if the owner never reopens the board this session. When the owner is present, non-owners defer to the owner's authoritative save. Sourced from useWhiteboardSync.ownerPresent.

    true (preserves the historical behaviour where the
    owner is always considered present)
    relayConnected?: boolean

    Whether a live collaboration relay is connected for this file. Used to relax the save permission for standalone editing (library, no <SemanticRelayProvider>): when the relay isn't connected, the local user is the sole authoritative editor for this session and is allowed to save even if they aren't the file's owner — otherwise their edits would be silently lost. Inside a live lesson (relay connected), only the owner saves to avoid concurrent-write races against the owner's autosave — unless the owner is currently absent (see ownerPresent).

    true
    
    styles?: Partial<WhiteboardStyles>

    Custom styles

    userId: string

    User ID