Options
All
  • Public
  • Public/Protected
  • All
Menu

@pdftron/collab-client

Index

Type aliases

CollabClientOptions: { url: string; subscriptionUrl: string; instance?: WebViewerInstance; notificationHandler?: NotificationFunction; logLevel?: LogLevels; filterLogsByTag?: LogTags | LogTags[]; logTransports?: winston.transport[]; enableConnectedUsers?: boolean; maxAnnotationSize?: number; annotationFilter?: AnnotationFilterFunction; customHeaders?: Record<string, string>; enableDocumentManipulation?: boolean; enableServerLogging?: boolean }

Constructor options for the Collaboration Client

Type declaration

  • url: string

    The HTTP URL of the server. This URL is logged when the server is started

  • subscriptionUrl: string

    The WS URL of the server. This URL is logged when the server is started

  • Optional instance?: WebViewerInstance

    The instance of WebViewer returned from the WebViewer constructor

  • Optional notificationHandler?: NotificationFunction

    A NotificationFunction to handle client side notifications

  • Optional logLevel?: LogLevels

    Determines the level of logging on the client

  • Optional filterLogsByTag?: LogTags | LogTags[]

    Filters client side logs by a certain tag(s)

  • Optional logTransports?: winston.transport[]

    Custom Winston transports used for logging

  • Optional enableConnectedUsers?: boolean

    If true, the client will track users that are connected to the document, including the page they are looking at

  • Optional maxAnnotationSize?: number

    The maximum allowed size of annotations, in bytes

  • Optional annotationFilter?: AnnotationFilterFunction

    This function can be used to prevent annotation changed from being synced to the database.

    Triggered any time a user adds, edits, or deletes an annotation.

    Return true from this function if the change can be synced to the database and other users. Return false if the change can not be synced and should only exist client side for the current user.

  • Optional customHeaders?: Record<string, string>

    Custom headers to be sent with requests to the server. Should not be used unless you are using a custom server.

    Headers can also be set via Client.setCustomHeaders().

  • Optional enableDocumentManipulation?: boolean

    Set this flag to enable document manipulation capabilities.

    Please note that WebViewer Collaboration does not currently support syncing of document manipulations, so setting this flag could be dangerous.

  • Optional enableServerLogging?: boolean

    If set to true, client side logs will be sent to the server. This allows you to store logs on your server.

CreateDocumentOptions: { name: string; document: Parameters<WebViewerInstance["Core"]["createDocument"]>[0]; id?: string; isPublic?: boolean; webviewerOptions?: Parameters<WebViewerInstance["Core"]["createDocument"]>[1] }

Settings for creating a document

Type declaration

  • name: string

    The name of the document

  • document: Parameters<WebViewerInstance["Core"]["createDocument"]>[0]

    The document itself. Can be a string URL, a Blob, a File, or an instance of CoreControls.Document

  • Optional id?: string

    The ID you want to assign to the document. If not provided, an ID will be generated for you.

  • Optional isPublic?: boolean

    Sets whether the document is public or not. When a document is public, it means that anyone can view/join it.

  • Optional webviewerOptions?: Parameters<WebViewerInstance["Core"]["createDocument"]>[1]

    WebViewer options to forward to WebViewers "createDocument" API.

PaginateParams: { limit: number; orderBy?: OrderTypes; orderDirection?: OrderDirections; before?: number }

Type declaration

  • limit: number

    How many items to fetch per query

  • Optional orderBy?: OrderTypes

    Order data by either "createdAt" or "updatedAt". Defaults to "createdAt"

  • Optional orderDirection?: OrderDirections

    Which direction to order - either "ASC" or "DESC". Defaults to "DESC"

  • Optional before?: number

    Only fetch items before a certain time. Can be used for pagination

InviteNotificationData: { type: "invite"; document: Document; invitedBy: string }

Type declaration

  • type: "invite"
  • document: Document

    An instance of [[Document]] that the user was invited to

  • invitedBy: string

    The username or email of the user who sent the invite

MessageNotificationData: { type: "message"; annotation: Annotation }

Type declaration

NotificationFunction: (data: InviteNotificationData | MessageNotificationData) => void

Type declaration

DefaultHandlerParams: { onClick?: any; getText?: any }

Type declaration

  • onClick?:function
    • A callback function that handles what happens when the notification is clicked. If not provided, nothing happens when the notification is clicked.

      example
      import { CollabClient } from '@pdftron/collab-client'

      new CollabClient({
      notificationHandler: CollabClient.defaultNotificationHandler({
      onClick: (data) => {
      if(data.type === 'invite') {
      const { document } = data;
      document.view(); // View the document on click
      }
      }
      })
      })

      Parameters

      Returns void

  • getText?:function
    • A function used to get the text contents of the notification. Should return an object with "title" and "body" properties.

      example
      import { CollabClient } from '@pdftron/collab-client'

      new CollabClient({
      notificationHandler: CollabClient.defaultNotificationHandler({
      getText: (data) => {
      if(data.type === 'invite') {
      return {
      title: `New invite received from ${data.invitedBy}`
      body: `Click here to view ${data.document.name}`
      }
      }
      }
      })
      })

      Parameters

      Returns { title?: string; body?: string }

      • Optional title?: string
      • Optional body?: string
UnsubscribeFunction: () => void

Type declaration

    • (): void
    • A function that unsubscribes from the event you subscribed to. Returned from the "subscribe" function.

      example
      const unsubscribe = client.EventManager.subscribe('documentLoaded', () => {  })

      // Unsubscribe from the "documentLoaded" event
      unsubscribe()

      Returns void

Functions

  • A default function that handles browser notifications. This function asks the user permission to send notifications, and triggers notifications whenever a user receives a new message or invite.

    This function is available as a static on CollabClient

    example
    import { CollabClient } from '@pdftron/collab-client'

    new CollabClient({
    notificationHandler: CollabClient.defaultNotificationHandler({ ...options })
    })

    Parameters

    Returns NotificationFunction

  • getCurrentScrollPosition(instance: WebViewerInstance): { scrollHeight: number; scrollTop: number }
  • Parameters

    • instance: WebViewerInstance

    Returns { scrollHeight: number; scrollTop: number }

    • scrollHeight: number
    • scrollTop: number

Generated using TypeDoc