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
Constructors
Parameters
Properties
canSetGroup
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.
createdBy
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.
customData
Arbitrary JSON-serializable data the user can attach to the comment.
group
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
A unique identifier for the comment. When comment is created in the UI, the viewer has to generate a unique ID.
isDeletable
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
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.
pdfObjectId
If this comment is from the original PDF, then this ID is from that PDF note annotation that defined the comment.
rootId
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
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 thestyleattribute (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. Thehrefattribute is required.
| Property | Description |
|---|---|
| format | |
| value |
Methods
A method that returns a set of user IDs that are mentioned in the comment.
Returns
NutrientViewer.Immutable.Set<string>An immutable set of user IDs that are mentioned in the comment.
Example
const ids = comment.getMentionedUserIds()
fromSerializableObject
Comment deserializer. Converts a comment object to a NutrientViewer.Comment.
Parameters
commentCommentJSONThe comment to deserialize.
Returns
The deserialized comment.
toSerializableObject
Comment serializer. Converts a comment to a InstantJSON compliant object.
Parameters
commentNutrientViewer.CommentThe comment to serialize.
Returns
The serialized comment.
Immutable Record API
31
Returns
thisSee Also
Map#asImmutable
Returns
thisSee Also
Map#asMutable
Returns a new instance of this Record type with all values set to their default values.
Returns
this
delete<K extends keyof { … }>(key: K): this
Returns a new instance of this Record type with the value for the specific key set to its default value.
Parameters
otherunknownReturns
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.
- has(
key: string,
): key is
| "id"
| "pageIndex"
| "pdfObjectId"
| "createdAt"
| "updatedAt"
| "creatorName"
| "customData"
| "isAnonymous"
| "group"
| "text"
| "createdBy"
| "isEditable"
| "isDeletable"
| "canSetGroup"
| "rootId"Parameters
keystringReturns
key is
| "id"
| "pageIndex"
| "pdfObjectId"
| "createdAt"
| "updatedAt"
| "creatorName"
| "customData"
| "isAnonymous"
| "group"
| "text"
| "createdBy"
| "isEditable"
| "isDeletable"
| "canSetGroup"
| "rootId"
Returns
number
Parameters
keyPathIterable<unknown>...collectionsunknown[]Returns
this
Parameters
keyPathIterable<unknown>...collectionsunknown[]Returns
this
remove<K extends keyof { … }>(key: K): this
Parameters
keyPathIterable<unknown>valueunknownReturns
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
{ … }
- OptionalReadonlycanSetGroup?: 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.
- ReadonlycreatedBy: string | null
The ID of the user who created the comment, as determined by the authenticated user (the
user_idclaim 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
nullfor 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.
- Optionalgroup?: 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.
- OptionalReadonlyisDeletable?: 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.
- OptionalReadonlyisEditable?: 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 thestyleattribute (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. Thehrefattribute is required.
updatedAt: unknown
The time when the comment was last updated.
Shallowly converts this Record to equivalent native JavaScript Object.
Returns
{ … }
- OptionalReadonlycanSetGroup?: 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.
- ReadonlycreatedBy: string | null
The ID of the user who created the comment, as determined by the authenticated user (the
user_idclaim 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
nullfor 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.
- Optionalgroup?: 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.
- OptionalReadonlyisDeletable?: 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.
- OptionalReadonlyisEditable?: 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 thestyleattribute (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. Thehrefattribute is required.
updatedAt: Date
The time when the comment was last updated.
Shallowly converts this Record to equivalent JavaScript Object.
Returns
{ … }
- OptionalReadonlycanSetGroup?: 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.
- ReadonlycreatedBy: string | null
The ID of the user who created the comment, as determined by the authenticated user (the
user_idclaim 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
nullfor 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.
- Optionalgroup?: 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.
- OptionalReadonlyisDeletable?: 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.
- OptionalReadonlyisEditable?: 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 thestyleattribute (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. Thehrefattribute is required.
updatedAt: Date
The time when the comment was last updated.
Parameters
keyPathIterable<unknown>updater(value: unknown) => unknownReturns
this
Returns
booleanSee Also
Map#wasAltered
Note: Not all methods can be used on a mutable collection or within
withMutations! Onlysetmay be used mutatively.Parameters
mutator(mutable: this) => unknownReturns
thisSee Also
Map#withMutations
A text comment made by the user. A comment belongs to a thread by pointing its
rootIdto theidof a root annotation. The root annotation can be a NutrientViewer.Annotations.CommentMarkerAnnotation or an existing markup annotation withisCommentThreadRootenabled.Use NutrientViewer.Instance#create, NutrientViewer.Instance#getComments, NutrientViewer.Instance#update, and NutrientViewer.Instance#delete to create, read, update, and delete comments.