Nutrient Web SDK

Class Comment

A text comment made by the user. A comment belongs to a thread by pointing its rootId to the id of a root annotation. The root annotation can be a NutrientViewer.Annotations.CommentMarkerAnnotation or an existing markup annotation with isCommentThreadRoot enabled.

Use NutrientViewer.Instance#create, NutrientViewer.Instance#getComments, NutrientViewer.Instance#update, and NutrientViewer.Instance#delete to create, read, update, and delete comments.

Class

Example

Create a comment thread with a marker annotation.

const rootId = NutrientViewer.generateInstantId();
const marker = new NutrientViewer.Annotations.CommentMarkerAnnotation({
id: rootId,
pageIndex: 0,
boundingBox: new NutrientViewer.Geometry.Rect({
top: 50,
left: 50,
width: 20,
height: 20,
}),
});
const comment = new NutrientViewer.Comment({
pageIndex: 0,
rootId,
text: {
format: "plain",
value: "Please review this area.",
},
});

await instance.create([marker, comment]);

Hierarchy

RecordComment

Constructors

  • Parameters

    options
    Partial<{ … }>
    Optional

Properties

canSetGroup

OptionalReadonly
boolean

This property defines whether the user has permission to edit the group of this comment. The value of this field depends on the set of collaboration permissions defined in the JWT token.

It is only available when collaboration permissions is enabled on Server-Backed deployments.

createdAt

Readonly

The time when the comment was created.

createdBy

Readonly
string | null

The ID of the user who created the comment, as determined by the authenticated user (the user_id claim of the JWT) that created it.

You cannot change who is recorded as the author: the value is assigned by the backend, and a locally set value is never sent. It is only available on Server-Backed deployments, and is null for comments created without an authenticated user, as well as when the server holds an author it can no longer resolve to an upstream user id.

creatorName

Readonly
string | null

The name of the person who created the comment.

customData

Readonly
Record<string, unknown> | null

Arbitrary JSON-serializable data the user can attach to the comment.

group

OptionalReadonly
string | null

This property is used to define the permission scope for a particular comment.

It is only available when collaboration permissions is enabled on Server-Backed deployments.

id

Readonly
string | null

A unique identifier for the comment. When comment is created in the UI, the viewer has to generate a unique ID.

isDeletable

OptionalReadonly
boolean

This property defines whether this comment can be deleted or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

It is only available when collaboration permissions is enabled on Server-Backed deployments.

isEditable

OptionalReadonly
boolean

This property defines whether this comment can be edited or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

It is only available when collaboration permissions is enabled on Server-Backed deployments.

pageIndex

Readonly
number | null

The page index that this comment resides at.

pdfObjectId

Readonly
number | null

If this comment is from the original PDF, then this ID is from that PDF note annotation that defined the comment.

rootId

Readonly
string | null

The ID of the annotation that this comment stems from. In Nutrient Web SDK, this should be either a NutrientViewer.Annotations.MarkupAnnotation or a NutrientViewer.Annotations.CommentMarkerAnnotation.

text

Readonly
{ format: "xhtml" | "plain"; value: string | null }

The text of the comment in xhtml/plain text format.

In case of XHTML, we support the following tags:

  • <b>: Bold
  • <i>: Italic
  • <span>: Font color, background color and underline using the style attribute (e.g. <span style="color: red; background-color: blue; text-decoration: underline">Hello</span>)
  • p: Paragraph. You can use this to add a newline between paragraphs.
  • a: Link. You can use this to add a link to the comment. The href attribute is required.
PropertyDescription
format
value

updatedAt

Readonly

The time when the comment was last updated.

Methods

  • A method that returns a set of user IDs that are mentioned in the comment.

    Returns

    An immutable set of user IDs that are mentioned in the comment.

    Example

    const ids = comment.getMentionedUserIds()
    

Immutable Record API

31
string

The name provided to Record(values, name) can be accessed with displayName.

  • Returns

    IterableIterator<
    [
    keyof { … },
    | string
    | number
    | boolean
    | Date
    | Record<string, unknown>
    | { format: "xhtml" | "plain"; value: string | null }
    | null
    | undefined
    ]
    >
  • Returns

    this

    See Also

    • Map#asImmutable

  • Returns

    this

    See Also

    • Map#asMutable

  • Returns a new instance of this Record type with all values set to their default values.

    Returns

    this
  • Returns a new instance of this Record type with the value for the specific key set to its default value.

    Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK

    Returns

    this
  • Parameters

    keyPathIterable<unknown>

    Returns

    this
  • Parameters

    otherunknown

    Returns

    boolean
  • Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.

    If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.

    Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK
    notSetValueunknown
    Optional

    Returns

    { … }[K]
  • Type Parameters

    T

    Parameters

    keystring
    notSetValueT

    Returns

  • Parameters

    keyPathIterable<unknown>

    Returns

    unknown
  • Parameters

    keystring

    Returns

    key is
    | "id"
    | "pageIndex"
    | "pdfObjectId"
    | "createdAt"
    | "updatedAt"
    | "creatorName"
    | "customData"
    | "isAnonymous"
    | "group"
    | "text"
    | "createdBy"
    | "isEditable"
    | "isDeletable"
    | "canSetGroup"
    | "rootId"
  • Returns

    number
  • Parameters

    keyPathIterable<unknown>

    Returns

    boolean
  • Parameters

    ...collections
    (Partial<{ … }> | Iterable<[string, unknown], any, any>)[]

    Returns

    this
  • Parameters

    ...collections
    (Partial<{ … }> | Iterable<[string, unknown], any, any>)[]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    ...collectionsunknown[]

    Returns

    this
  • Parameters

    merger(oldVal: unknown, newVal: unknown, key: unknown) => unknown
    ...collections
    (Partial<{ … }> | Iterable<[string, unknown], any, any>)[]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    ...collectionsunknown[]

    Returns

    this
  • Parameters

    merger
    (oldVal: unknown, newVal: unknown, key: keyof { … }) => unknown
    ...collections
    (Partial<{ … }> | Iterable<[string, unknown], any, any>)[]

    Returns

    this
  • Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK

    Returns

    this
  • Parameters

    keyPathIterable<unknown>

    Returns

    this
  • Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK
    value
    { … }[K]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    valueunknown

    Returns

    this
  • Deeply converts this Record to equivalent native JavaScript Object.

    Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.

    Returns

    { … }
    • OptionalReadonly
      canSetGroup?: boolean

      This property defines whether the user has permission to edit the group of this comment. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • createdAt: unknown

      The time when the comment was created.

    • Readonly
      createdBy: string | null

      The ID of the user who created the comment, as determined by the authenticated user (the user_id claim of the JWT) that created it.

      You cannot change who is recorded as the author: the value is assigned by the backend, and a locally set value is never sent. It is only available on Server-Backed deployments, and is null for comments created without an authenticated user, as well as when the server holds an author it can no longer resolve to an upstream user id.

    • creatorName: string | null

      The name of the person who created the comment.

    • customData: unknown

      Arbitrary JSON-serializable data the user can attach to the comment.

    • Optional
      group?: string | null

      This property is used to define the permission scope for a particular comment.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • id: string | null

      A unique identifier for the comment. When comment is created in the UI, the viewer has to generate a unique ID.

    • OptionalReadonly
      isDeletable?: boolean

      This property defines whether this comment can be deleted or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • OptionalReadonly
      isEditable?: boolean

      This property defines whether this comment can be edited or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • pageIndex: number | null

      The page index that this comment resides at.

    • pdfObjectId: number | null

      If this comment is from the original PDF, then this ID is from that PDF note annotation that defined the comment.

    • rootId: string | null

      The ID of the annotation that this comment stems from. In Nutrient Web SDK, this should be either a NutrientViewer.Annotations.MarkupAnnotation or a NutrientViewer.Annotations.CommentMarkerAnnotation.

    • text: unknown

      The text of the comment in xhtml/plain text format.

      In case of XHTML, we support the following tags:

      • <b>: Bold
      • <i>: Italic
      • <span>: Font color, background color and underline using the style attribute (e.g. <span style="color: red; background-color: blue; text-decoration: underline">Hello</span>)
      • p: Paragraph. You can use this to add a newline between paragraphs.
      • a: Link. You can use this to add a link to the comment. The href attribute is required.
    • updatedAt: unknown

      The time when the comment was last updated.

  • Shallowly converts this Record to equivalent native JavaScript Object.

    Returns

    { … }
    • OptionalReadonly
      canSetGroup?: boolean

      This property defines whether the user has permission to edit the group of this comment. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • createdAt: Date

      The time when the comment was created.

    • Readonly
      createdBy: string | null

      The ID of the user who created the comment, as determined by the authenticated user (the user_id claim of the JWT) that created it.

      You cannot change who is recorded as the author: the value is assigned by the backend, and a locally set value is never sent. It is only available on Server-Backed deployments, and is null for comments created without an authenticated user, as well as when the server holds an author it can no longer resolve to an upstream user id.

    • creatorName: string | null

      The name of the person who created the comment.

    • customData: Record<string, unknown> | null

      Arbitrary JSON-serializable data the user can attach to the comment.

    • Optional
      group?: string | null

      This property is used to define the permission scope for a particular comment.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • id: string | null

      A unique identifier for the comment. When comment is created in the UI, the viewer has to generate a unique ID.

    • OptionalReadonly
      isDeletable?: boolean

      This property defines whether this comment can be deleted or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • OptionalReadonly
      isEditable?: boolean

      This property defines whether this comment can be edited or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • pageIndex: number | null

      The page index that this comment resides at.

    • pdfObjectId: number | null

      If this comment is from the original PDF, then this ID is from that PDF note annotation that defined the comment.

    • rootId: string | null

      The ID of the annotation that this comment stems from. In Nutrient Web SDK, this should be either a NutrientViewer.Annotations.MarkupAnnotation or a NutrientViewer.Annotations.CommentMarkerAnnotation.

    • text: { format: "xhtml" | "plain"; value: string | null }

      The text of the comment in xhtml/plain text format.

      In case of XHTML, we support the following tags:

      • <b>: Bold
      • <i>: Italic
      • <span>: Font color, background color and underline using the style attribute (e.g. <span style="color: red; background-color: blue; text-decoration: underline">Hello</span>)
      • p: Paragraph. You can use this to add a newline between paragraphs.
      • a: Link. You can use this to add a link to the comment. The href attribute is required.
    • updatedAt: Date

      The time when the comment was last updated.

  • Shallowly converts this Record to equivalent JavaScript Object.

    Returns

    { … }
    • OptionalReadonly
      canSetGroup?: boolean

      This property defines whether the user has permission to edit the group of this comment. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • createdAt: Date

      The time when the comment was created.

    • Readonly
      createdBy: string | null

      The ID of the user who created the comment, as determined by the authenticated user (the user_id claim of the JWT) that created it.

      You cannot change who is recorded as the author: the value is assigned by the backend, and a locally set value is never sent. It is only available on Server-Backed deployments, and is null for comments created without an authenticated user, as well as when the server holds an author it can no longer resolve to an upstream user id.

    • creatorName: string | null

      The name of the person who created the comment.

    • customData: Record<string, unknown> | null

      Arbitrary JSON-serializable data the user can attach to the comment.

    • Optional
      group?: string | null

      This property is used to define the permission scope for a particular comment.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • id: string | null

      A unique identifier for the comment. When comment is created in the UI, the viewer has to generate a unique ID.

    • OptionalReadonly
      isDeletable?: boolean

      This property defines whether this comment can be deleted or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • OptionalReadonly
      isEditable?: boolean

      This property defines whether this comment can be edited or not. The value of this field depends on the set of collaboration permissions defined in the JWT token.

      It is only available when collaboration permissions is enabled on Server-Backed deployments.

    • pageIndex: number | null

      The page index that this comment resides at.

    • pdfObjectId: number | null

      If this comment is from the original PDF, then this ID is from that PDF note annotation that defined the comment.

    • rootId: string | null

      The ID of the annotation that this comment stems from. In Nutrient Web SDK, this should be either a NutrientViewer.Annotations.MarkupAnnotation or a NutrientViewer.Annotations.CommentMarkerAnnotation.

    • text: { format: "xhtml" | "plain"; value: string | null }

      The text of the comment in xhtml/plain text format.

      In case of XHTML, we support the following tags:

      • <b>: Bold
      • <i>: Italic
      • <span>: Font color, background color and underline using the style attribute (e.g. <span style="color: red; background-color: blue; text-decoration: underline">Hello</span>)
      • p: Paragraph. You can use this to add a newline between paragraphs.
      • a: Link. You can use this to add a link to the comment. The href attribute is required.
    • updatedAt: Date

      The time when the comment was last updated.

  • Returns

    Keyed<
    keyof { … },
    | string
    | number
    | boolean
    | Date
    | Record<string, unknown>
    | { format: "xhtml" | "plain"; value: string | null }
    | null
    | undefined
    >
  • Type Parameters

    K
    extends keyof { … }

    Parameters

    keyK
    updater
    (value: { … }[K]) => { … }[K]

    Returns

    this
  • Parameters

    keyPathIterable<unknown>
    updater(value: unknown) => unknown

    Returns

    this
  • Returns

    boolean

    See Also

    • Map#wasAltered

  • Note: Not all methods can be used on a mutable collection or within withMutations! Only set may be used mutatively.

    Parameters

    mutator(mutable: this) => unknown

    Returns

    this

    See Also

    • Map#withMutations