Skip to content

Commit c70738f

Browse files
committed
Add ProseMirror comments docs
1 parent c29d40a commit c70738f

4 files changed

Lines changed: 547 additions & 1 deletion

File tree

api-reference/sdk/api/api-methods.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,45 @@ Returns a DraftJS `ContentState` with Velt comment entities removed.
526526
- React Hook: `n/a`
527527
- [Full Documentation →](/async-collaboration/comments/setup/draftjs#exportcontentstatewithoutcomments)
528528

529+
### ProseMirror
530+
531+
#### VeltCommentsPlugin()
532+
Creates the ProseMirror plugin that powers Velt comments. Add it to the editor state's `plugins` array.
533+
- Params: `config?:` [VeltCommentsPluginConfig](/api-reference/sdk/models/data-models#veltcommentspluginconfig-1)
534+
- Returns: ProseMirror `Plugin`
535+
- React Hook: `n/a`
536+
- [Full Documentation →](/async-collaboration/comments/setup/prosemirror#veltcommentsplugin)
537+
538+
#### addComment()
539+
Creates a comment annotation for the currently selected text in the ProseMirror editor.
540+
- Signature: `async (request:` [AddCommentRequest](/api-reference/sdk/models/data-models#addcommentrequest-8)`) => Promise<void>`
541+
- Params: `request:` [AddCommentRequest](/api-reference/sdk/models/data-models#addcommentrequest-8)
542+
- Returns: `Promise<void>`
543+
- React Hook: `n/a`
544+
- [Full Documentation →](/async-collaboration/comments/setup/prosemirror#addcomment)
545+
546+
#### renderComments()
547+
Renders and highlights comment annotations in the ProseMirror editor.
548+
- Signature: `(request:` [RenderCommentsRequest](/api-reference/sdk/models/data-models#rendercommentsrequest-8)`) => void`
549+
- Params: `request:` [RenderCommentsRequest](/api-reference/sdk/models/data-models#rendercommentsrequest-8)
550+
- Returns: `void`
551+
- React Hook: `n/a`
552+
- [Full Documentation →](/async-collaboration/comments/setup/prosemirror#rendercomments)
553+
554+
#### isVeltAvailable()
555+
Checks whether the Velt SDK is loaded on `window.Velt`.
556+
- Params: none
557+
- Returns: `boolean`
558+
- React Hook: `n/a`
559+
- [Full Documentation →](/async-collaboration/comments/setup/prosemirror#isveltavailable)
560+
561+
#### veltCommentsPluginKey
562+
The ProseMirror `PluginKey` used by the package. Exported for advanced plugin state inspection.
563+
- Params: none
564+
- Returns: `PluginKey<VeltPluginState>`
565+
- React Hook: `n/a`
566+
- [Full Documentation →](/async-collaboration/comments/setup/prosemirror#veltcommentspluginkey)
567+
529568

530569
### Messages
531570

api-reference/sdk/models/data-models.mdx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,78 @@ Props for the `DraftJSVeltEditor` React wrapper.
10031003

10041004
For the CommentAnnotation model referenced above, see [CommentAnnotation](#commentannotation).
10051005

1006+
### ProseMirror
1007+
1008+
#### AddCommentRequest
1009+
1010+
---
1011+
1012+
| Property | Type | Required | Description |
1013+
| ---------- | ---------------------------------------------------- | -------- | ---------------------------------------------------- |
1014+
| `view` | `EditorView` | Yes | ProseMirror editor view instance. |
1015+
| `editorId` | `string` | No | Optional editor ID used to scope operations. |
1016+
| `context` | [`CommentAnnotationContext`](#commentannotationcontext-1) | No | Optional custom context to attach to the annotation. |
1017+
1018+
#### RenderCommentsRequest
1019+
1020+
---
1021+
1022+
| Property | Type | Required | Description |
1023+
| -------------------- | --------------------- | -------- | -------------------------------------------- |
1024+
| `view` | `EditorView` | Yes | ProseMirror editor view instance. |
1025+
| `editorId` | `string` | No | Optional editor ID used to scope operations. |
1026+
| `commentAnnotations` | `CommentAnnotation[]` | No | Annotations to render/highlight. |
1027+
1028+
For the CommentAnnotation model referenced above, see [CommentAnnotation](#commentannotation).
1029+
1030+
#### VeltCommentsPluginConfig
1031+
1032+
---
1033+
1034+
Configuration options for the `VeltCommentsPlugin()` function.
1035+
1036+
| Property | Type | Required | Description |
1037+
| ------------------ | --------- | -------- | --------------------------------------------------------------------------------- |
1038+
| `editorId` | `string` | No | Unique identifier for this editor instance. Use it for multi-editor scenarios. |
1039+
| `persistVeltMarks` | `boolean` | No | Reserved for API parity. ProseMirror highlights are always view-only overlays. |
1040+
1041+
#### CommentAnnotationContext
1042+
1043+
---
1044+
1045+
Context object for comment annotations. Contains text editor configuration and any additional custom metadata.
1046+
1047+
| Property | Type | Required | Description |
1048+
| ------------------ | ----------------------------------------- | -------- | ---------------------------------------------------------- |
1049+
| `textEditorConfig` | [`TextEditorConfig`](#texteditorconfig-2) | No | Text editor configuration auto-generated by the library. |
1050+
| `[key: string]` | `unknown` | No | Any additional custom properties you want to attach. |
1051+
1052+
#### TextEditorConfig
1053+
1054+
---
1055+
1056+
Nested in `CommentAnnotationContext`.
1057+
1058+
| Property | Type | Required | Description |
1059+
| ------------ | -------- | -------- | ------------------------------------------------- |
1060+
| `text` | `string` | Yes | The selected text content. |
1061+
| `occurrence` | `number` | Yes | The occurrence index of the text in the document. |
1062+
| `editorId` | `string` | No | The editor ID associated with this comment. |
1063+
1064+
#### SelectionContext
1065+
1066+
---
1067+
1068+
Context extracted from the current ProseMirror editor selection.
1069+
1070+
| Property | Type | Required | Description |
1071+
| ------------ | -------- | -------- | ---------------------------------------------------------------------- |
1072+
| `text` | `string` | Yes | Selected text content. |
1073+
| `from` | `number` | Yes | ProseMirror start position of the selection. |
1074+
| `to` | `number` | Yes | ProseMirror end position of the selection. |
1075+
| `occurrence` | `number` | Yes | 1-based index of `text` among all matches in the document. |
1076+
| `locationId` | `string` | No | Optional Velt location id derived from a `data-velt-location-id` ancestor. |
1077+
10061078
### Messages
10071079

10081080
#### ENUMs

0 commit comments

Comments
 (0)