Options
All
  • Public
  • Public/Protected
  • All
Menu

A class representing a Document

Warning: Should not be instantiated directly. Please retrieve Document instances from functions on the [[User]] class

Hierarchy

  • BoundEntity<Document, DocumentEntity, { onChange: any; snapshotAdded: any; connectedUsersChanged: any }>
    • Document

Index

Properties

id: string

The ID of the document

name: string

The name of the document

isPublic: boolean

Whether or not the document is public

unreadCount: number

The total number of unread annotations on the document

author: User

The author of the document

createdAt: Date
updatedAt: Date
__type: keyof EntityStateMetadata

Methods

  • getConnectedUsers(): Promise<User[]>
  • Gets a list of users currently connected to the document. Throws an error if "enableConnectedUsers" is not set

    Returns Promise<User[]>

  • isMember(): Promise<boolean>
  • Determines if the current user is a member of the document

    Returns Promise<boolean>

  • Returns all the mentions of the current user for this document

    Returns Promise<Mention[]>

  • markAllAnnotationsAsRead(): Promise<void>
  • Marks all annotations for this document as read for the current user

    Returns Promise<void>

  • canJoin(): Promise<boolean>
  • Determines if the current user can join the document. The criteria for joining a document are:

    1. The document must be public
    2. The user must not already be a member
    3. A user must be logged in

    Returns Promise<boolean>

  • leave(): Promise<boolean>
  • Leaves the current document Returns a boolean representing if the operation was successful

    Returns Promise<boolean>

  • unload(options?: { closeDocument?: boolean }): Promise<void>
  • Parameters

    • options: { closeDocument?: boolean } = {}
      • Optional closeDocument?: boolean

    Returns Promise<void>

  • join(): Promise<boolean>
  • Adds the current user to the document. Returns true on success, or false if not allowed.

    Returns Promise<boolean>

  • inviteUsers(invitedUserDetails?: string[]): Promise<boolean>
  • Invites a list of users to a document

    Parameters

    • invitedUserDetails: string[] = []

    Returns Promise<boolean>

  • Creates a scroll sync session for the current document

    Returns Promise<ScrollSyncSession>

  • getMembers(): Promise<User[]>
  • Gets a list of all members of the document

    Returns Promise<User[]>

    An array of User classes

  • createSnapshot(name: string): Promise<Snapshot>
  • Create a snapshot of document The snapshot can be used to revert a document back to an older version.

    Throws if the user does not have permissions to create a snapshot.

    Parameters

    • name: string

      The name of the snapshot

    Returns Promise<Snapshot>

  • getAnnotations(forceRefetch?: boolean): Promise<Annotation[]>
  • Gets a list of all annotations for the document.

    Throws if the user does not have permission to view annotations.

    Parameters

    • forceRefetch: boolean = false

    Returns Promise<Annotation[]>

  • copyAnnotationsToDocument(toDocumentId: string, annotationFilter?: (annot: Annotation) => boolean): Promise<void>
  • Copies all annotations from this document to another document.

    Throws if the documentId provided does not exist, or the user does not have permissions to perform this action.

    example
    // copy all annotations to document '2'
    await document.copyAnnotationsToDocument('2');

    // Copy only square annotations to document '2'
    await document.copyAnnotationsToDocument('2', (annot) => {
    return annot instanceof instance.Core.Annotations.RectangleAnnotation
    });

    Parameters

    • toDocumentId: string

      The ID of the document to copy to

    • Optional annotationFilter: (annot: Annotation) => boolean
        • (annot: Annotation): boolean
        • Parameters

          • annot: Annotation

          Returns boolean

    Returns Promise<void>

  • Fetches all snapshots for the document.

    Warning: This function can become slow if a lot of snapshots belong to the document. It is recommended to use "getSnapshotPaginator" instead to help prevent over fetching.

    Throws if user does not have permissions to read snapshots.

    Returns Promise<Snapshot[]>

  • Returns a Paginator that can be used to fetch document snapshots

    Parameters

    Returns Paginator<GetSnapshotsFilteredVariables, GetSnapshotsFiltered_snapshots, Snapshot>

  • syncAnnotations(path: string | File | Blob | Document | PDFDoc, options?: {}): Promise<{ added: string[]; updated: string[] }>
  • Syncs annotations from the provided document to the the database. The following operations will take place:

    • Any annotations that exist in the new document that do not exist in the database will be created
    • If any annotations were edited, then the annotation that was last edited will become the source of truth
    • Detecting deleted annotations is not possible, so no deletions will never take place

    Parameters

    • path: string | File | Blob | Document | PDFDoc
    • Optional options: {}

      Returns Promise<{ added: string[]; updated: string[] }>

      Returns an object indicating the annotations that were added and edited

    • view(path: string | File | Blob | Document | PDFDoc, options?: {}): Promise<void>
    • Loads this document in the viewer

      Parameters

      • path: string | File | Blob | Document | PDFDoc
      • Optional options: {}

        Returns Promise<void>

      • edit(data: { name?: string; isPublic?: boolean }): Promise<Document>
      • Edits a document.

        Throws if the user does not have permission to edit the document.

        Parameters

        • data: { name?: string; isPublic?: boolean }

          Properties to edit. At least one key is required

          • Optional name?: string

            The new name for the document

          • Optional isPublic?: boolean

            Toggle if the document is public or not

        Returns Promise<Document>

      • Fired when anything about this document changes

        Parameters

        • event: "onChange"
        • listener: (document: Document) => void

        Returns UnsubscribeFunction

        Returns a function that can be called to unsubscribe from the event

      • Fired when the document is deleted

        Parameters

        • event: "onDestroy"
        • listener: (id: string) => void
            • (id: string): void
            • Parameters

              • id: string

              Returns void

        Returns UnsubscribeFunction

        Returns a function that can be called to unsubscribe from the event

      • Fired when a snapshot of the document is created

        Parameters

        • event: "snapshotAdded"
        • listener: (snapshot: Snapshot) => void

        Returns UnsubscribeFunction

        Returns a function that can be called to unsubscribe from the event

      • Fired when a user connects, disconnects, or changes the page they are viewing. Only triggered if the "enableConnectedUsers" feature is enabled

        Parameters

        • event: "connectedUsersChanged"
        • listener: (users: User[], action: Omit<ChangeEventTypes, "INVITE">) => void
            • (users: User[], action: Omit<ChangeEventTypes, "INVITE">): void
            • Parameters

              • users: User[]
              • action: Omit<ChangeEventTypes, "INVITE">

              Returns void

        Returns UnsubscribeFunction

        Returns a function that can be called to unsubscribe from the event

      Accessors

      • get isAuthor(): boolean
      • A boolean representing if the current user is the author of the document

        Returns boolean

      • get isActive(): boolean
      • Returns boolean

      Generated using TypeDoc