@ckeditor/ckeditor5-comments 48.2.0 → 48.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/annotations/annotation.d.ts +84 -87
  2. package/dist/annotations/annotationcollection.d.ts +83 -83
  3. package/dist/annotations/annotations.d.ts +148 -148
  4. package/dist/annotations/annotationsuis.d.ts +235 -235
  5. package/dist/annotations/editorannotations.d.ts +71 -71
  6. package/dist/annotations/inlineannotations.d.ts +93 -93
  7. package/dist/annotations/narrowsidebar.d.ts +88 -88
  8. package/dist/annotations/sidebar.d.ts +105 -105
  9. package/dist/annotations/view/annotationcounterbuttonview.d.ts +24 -24
  10. package/dist/annotations/view/annotationview.d.ts +83 -83
  11. package/dist/annotations/view/sidebaritemview.d.ts +54 -54
  12. package/dist/annotations/view/sidebarview.d.ts +48 -48
  13. package/dist/annotations/widesidebar.d.ts +80 -80
  14. package/dist/augmentation.d.ts +57 -57
  15. package/dist/comments/addcommentthreadcommand.d.ts +69 -69
  16. package/dist/comments/commentsarchive.d.ts +34 -34
  17. package/dist/comments/commentsarchiveui.d.ts +48 -48
  18. package/dist/comments/commentsediting.d.ts +90 -90
  19. package/dist/comments/commentsrepository.d.ts +1042 -1054
  20. package/dist/comments/commentsui.d.ts +40 -40
  21. package/dist/comments/integrations/clipboard.d.ts +21 -21
  22. package/dist/comments/integrations/commentsrestrictededitingmode.d.ts +12 -12
  23. package/dist/comments/integrations/importword.d.ts +16 -16
  24. package/dist/comments/integrations/showcommenthighlights.d.ts +14 -14
  25. package/dist/comments/ui/commenteditor/commenteditor.d.ts +33 -32
  26. package/dist/comments/ui/commenteditor/commenteditorui.d.ts +27 -27
  27. package/dist/comments/ui/commenteditor/commenteditoruiview.d.ts +32 -32
  28. package/dist/comments/ui/commentthreadcontroller.d.ts +62 -60
  29. package/dist/comments/ui/view/basecommentthreadview.d.ts +134 -134
  30. package/dist/comments/ui/view/basecommentview.d.ts +136 -136
  31. package/dist/comments/ui/view/collapsedcommentsview.d.ts +9 -9
  32. package/dist/comments/ui/view/commentcontentview.d.ts +10 -10
  33. package/dist/comments/ui/view/commentinputview.d.ts +93 -93
  34. package/dist/comments/ui/view/commentsarchiveview.d.ts +41 -41
  35. package/dist/comments/ui/view/commentslistview.d.ts +107 -107
  36. package/dist/comments/ui/view/commentthreadheadercontextview.d.ts +19 -19
  37. package/dist/comments/ui/view/commentthreadheaderview.d.ts +67 -67
  38. package/dist/comments/ui/view/commentthreadinputview.d.ts +51 -51
  39. package/dist/comments/ui/view/commentthreadview.d.ts +116 -116
  40. package/dist/comments/ui/view/commentview.d.ts +225 -230
  41. package/dist/comments.d.ts +38 -38
  42. package/dist/commentsonly.d.ts +36 -36
  43. package/dist/config.d.ts +186 -186
  44. package/dist/index.d.ts +35 -35
  45. package/dist/index.js +11 -11
  46. package/dist/translations/af.js +1 -1
  47. package/dist/translations/af.umd.js +1 -1
  48. package/dist/translations/ar.js +1 -1
  49. package/dist/translations/ar.umd.js +1 -1
  50. package/dist/translations/ast.js +1 -1
  51. package/dist/translations/ast.umd.js +1 -1
  52. package/dist/translations/az.js +1 -1
  53. package/dist/translations/az.umd.js +1 -1
  54. package/dist/translations/be.js +1 -1
  55. package/dist/translations/be.umd.js +1 -1
  56. package/dist/translations/bg.js +1 -1
  57. package/dist/translations/bg.umd.js +1 -1
  58. package/dist/translations/bn.js +1 -1
  59. package/dist/translations/bn.umd.js +1 -1
  60. package/dist/translations/bs.js +1 -1
  61. package/dist/translations/bs.umd.js +1 -1
  62. package/dist/translations/ca.js +1 -1
  63. package/dist/translations/ca.umd.js +1 -1
  64. package/dist/translations/cs.js +1 -1
  65. package/dist/translations/cs.umd.js +1 -1
  66. package/dist/translations/da.js +1 -1
  67. package/dist/translations/da.umd.js +1 -1
  68. package/dist/translations/de-ch.js +1 -1
  69. package/dist/translations/de-ch.umd.js +1 -1
  70. package/dist/translations/de.js +1 -1
  71. package/dist/translations/de.umd.js +1 -1
  72. package/dist/translations/el.js +1 -1
  73. package/dist/translations/el.umd.js +1 -1
  74. package/dist/translations/en-au.js +1 -1
  75. package/dist/translations/en-au.umd.js +1 -1
  76. package/dist/translations/en-gb.js +1 -1
  77. package/dist/translations/en-gb.umd.js +1 -1
  78. package/dist/translations/en.js +1 -1
  79. package/dist/translations/en.umd.js +1 -1
  80. package/dist/translations/eo.js +1 -1
  81. package/dist/translations/eo.umd.js +1 -1
  82. package/dist/translations/es-co.js +1 -1
  83. package/dist/translations/es-co.umd.js +1 -1
  84. package/dist/translations/es.js +1 -1
  85. package/dist/translations/es.umd.js +1 -1
  86. package/dist/translations/et.js +1 -1
  87. package/dist/translations/et.umd.js +1 -1
  88. package/dist/translations/eu.js +1 -1
  89. package/dist/translations/eu.umd.js +1 -1
  90. package/dist/translations/fa.js +1 -1
  91. package/dist/translations/fa.umd.js +1 -1
  92. package/dist/translations/fi.js +1 -1
  93. package/dist/translations/fi.umd.js +1 -1
  94. package/dist/translations/fr.js +1 -1
  95. package/dist/translations/fr.umd.js +1 -1
  96. package/dist/translations/gl.js +1 -1
  97. package/dist/translations/gl.umd.js +1 -1
  98. package/dist/translations/gu.js +1 -1
  99. package/dist/translations/gu.umd.js +1 -1
  100. package/dist/translations/he.js +1 -1
  101. package/dist/translations/he.umd.js +1 -1
  102. package/dist/translations/hi.js +1 -1
  103. package/dist/translations/hi.umd.js +1 -1
  104. package/dist/translations/hr.js +1 -1
  105. package/dist/translations/hr.umd.js +1 -1
  106. package/dist/translations/hu.js +1 -1
  107. package/dist/translations/hu.umd.js +1 -1
  108. package/dist/translations/hy.js +1 -1
  109. package/dist/translations/hy.umd.js +1 -1
  110. package/dist/translations/id.js +1 -1
  111. package/dist/translations/id.umd.js +1 -1
  112. package/dist/translations/it.js +1 -1
  113. package/dist/translations/it.umd.js +1 -1
  114. package/dist/translations/ja.js +1 -1
  115. package/dist/translations/ja.umd.js +1 -1
  116. package/dist/translations/jv.js +1 -1
  117. package/dist/translations/jv.umd.js +1 -1
  118. package/dist/translations/kk.js +1 -1
  119. package/dist/translations/kk.umd.js +1 -1
  120. package/dist/translations/km.js +1 -1
  121. package/dist/translations/km.umd.js +1 -1
  122. package/dist/translations/kn.js +1 -1
  123. package/dist/translations/kn.umd.js +1 -1
  124. package/dist/translations/ko.js +1 -1
  125. package/dist/translations/ko.umd.js +1 -1
  126. package/dist/translations/ku.js +1 -1
  127. package/dist/translations/ku.umd.js +1 -1
  128. package/dist/translations/lt.js +1 -1
  129. package/dist/translations/lt.umd.js +1 -1
  130. package/dist/translations/lv.js +1 -1
  131. package/dist/translations/lv.umd.js +1 -1
  132. package/dist/translations/ms.js +1 -1
  133. package/dist/translations/ms.umd.js +1 -1
  134. package/dist/translations/nb.js +1 -1
  135. package/dist/translations/nb.umd.js +1 -1
  136. package/dist/translations/ne.js +1 -1
  137. package/dist/translations/ne.umd.js +1 -1
  138. package/dist/translations/nl.js +1 -1
  139. package/dist/translations/nl.umd.js +1 -1
  140. package/dist/translations/no.js +1 -1
  141. package/dist/translations/no.umd.js +1 -1
  142. package/dist/translations/oc.js +1 -1
  143. package/dist/translations/oc.umd.js +1 -1
  144. package/dist/translations/pl.js +1 -1
  145. package/dist/translations/pl.umd.js +1 -1
  146. package/dist/translations/pt-br.js +1 -1
  147. package/dist/translations/pt-br.umd.js +1 -1
  148. package/dist/translations/pt.js +1 -1
  149. package/dist/translations/pt.umd.js +1 -1
  150. package/dist/translations/ro.js +1 -1
  151. package/dist/translations/ro.umd.js +1 -1
  152. package/dist/translations/ru.js +1 -1
  153. package/dist/translations/ru.umd.js +1 -1
  154. package/dist/translations/si.js +1 -1
  155. package/dist/translations/si.umd.js +1 -1
  156. package/dist/translations/sk.js +1 -1
  157. package/dist/translations/sk.umd.js +1 -1
  158. package/dist/translations/sl.js +1 -1
  159. package/dist/translations/sl.umd.js +1 -1
  160. package/dist/translations/sq.js +1 -1
  161. package/dist/translations/sq.umd.js +1 -1
  162. package/dist/translations/sr-latn.js +1 -1
  163. package/dist/translations/sr-latn.umd.js +1 -1
  164. package/dist/translations/sr.js +1 -1
  165. package/dist/translations/sr.umd.js +1 -1
  166. package/dist/translations/sv.js +1 -1
  167. package/dist/translations/sv.umd.js +1 -1
  168. package/dist/translations/th.js +1 -1
  169. package/dist/translations/th.umd.js +1 -1
  170. package/dist/translations/ti.js +1 -1
  171. package/dist/translations/ti.umd.js +1 -1
  172. package/dist/translations/tk.js +1 -1
  173. package/dist/translations/tk.umd.js +1 -1
  174. package/dist/translations/tr.js +1 -1
  175. package/dist/translations/tr.umd.js +1 -1
  176. package/dist/translations/tt.js +1 -1
  177. package/dist/translations/tt.umd.js +1 -1
  178. package/dist/translations/ug.js +1 -1
  179. package/dist/translations/ug.umd.js +1 -1
  180. package/dist/translations/uk.js +1 -1
  181. package/dist/translations/uk.umd.js +1 -1
  182. package/dist/translations/ur.js +1 -1
  183. package/dist/translations/ur.umd.js +1 -1
  184. package/dist/translations/uz.js +1 -1
  185. package/dist/translations/uz.umd.js +1 -1
  186. package/dist/translations/vi.js +1 -1
  187. package/dist/translations/vi.umd.js +1 -1
  188. package/dist/translations/zh-cn.js +1 -1
  189. package/dist/translations/zh-cn.umd.js +1 -1
  190. package/dist/translations/zh.js +1 -1
  191. package/dist/translations/zh.umd.js +1 -1
  192. package/dist/utils/common-translations.d.ts +6 -6
  193. package/dist/utils/createmutationobserver.d.ts +9 -9
  194. package/dist/utils/splitmarkername.d.ts +10 -10
  195. package/package.json +16 -16
@@ -1,1123 +1,1111 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module comments/comments/commentsrepository
7
- * @publicApi
8
- */
9
- import { PendingActions, ContextPlugin, Editor, type Context } from '@ckeditor/ckeditor5-core';
10
- import { Collection } from '@ckeditor/ckeditor5-utils';
11
- import { Users, type User } from '@ckeditor/ckeditor5-collaboration-core';
12
- import { CommentThreadController } from './ui/commentthreadcontroller.js';
13
- import '../../theme/comment.css';
14
- import '../../theme/commentthread.css';
15
- import '../../theme/commentinput.css';
16
- import { Annotation, type AnnotationTarget } from '../annotations/annotation.js';
17
- import { Annotations } from '../annotations/annotations.js';
18
- import type { BaseCommentThreadView } from './ui/view/basecommentthreadview.js';
6
+ * @module comments/comments/commentsrepository
7
+ * @publicApi
8
+ */
9
+ import { PendingActions, ContextPlugin, Editor, type Context, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
10
+ import { Collection, type ObservableMixinConstructor } from "@ckeditor/ckeditor5-utils";
11
+ import { Users, type User } from "@ckeditor/ckeditor5-collaboration-core";
12
+ import { CommentThreadController } from "./ui/commentthreadcontroller.js";
13
+ import "../../theme/comment.css";
14
+ import "../../theme/commentthread.css";
15
+ import "../../theme/commentinput.css";
16
+ import { Annotation, type AnnotationTarget } from "../annotations/annotation.js";
17
+ import { Annotations } from "../annotations/annotations.js";
18
+ import type { BaseCommentThreadView } from "./ui/view/basecommentthreadview.js";
19
+ declare const _CommentThreadBase: ObservableMixinConstructor;
20
+ declare const _CommentBase: ObservableMixinConstructor;
19
21
  /**
20
- * Stores the list of {@link module:comments/comments/commentsrepository~CommentThread}
21
- * and provides event-driven API for managing them. It is also responsible for using the comments adapter
22
- * to communicate with the data source.
23
- *
24
- * {@link module:comments/comments/commentsrepository~CommentsRepository} is a context plugin.
25
- * It can be added to a context or to an editor. Add it to the context configuration if you use
26
- * {@link module:core/context~Context} in your integration.
27
- *
28
- * The event-driven API makes it possible to attach a listener to each action that changes comment data.
29
- * Using different event priorities allows to attach an action before the main action ('low' priority)
30
- * or after the main action ('high' priority). It works very similar to
31
- * {@link module:utils/observablemixin~Observable#decorate}.
32
- *
33
- * Sample usage:
34
- *
35
- * ```ts
36
- * // Get the comments repository:
37
- * const commentsRepository = editor.plugins.get( 'CommentsRepository' );
38
- *
39
- * // Create a new, empty comment thread on a DOM form field element:
40
- * commentsRepository.openNewCommentThread( { channelId, target: formFieldElement } );
41
- *
42
- * // Get all comment threads:
43
- * commentsRepository.getCommentThreads();
44
- *
45
- * // Set the adapter:
46
- * commentsRepository.adapter = {
47
- * // ...
48
- * };
49
- * ```
50
- *
51
- * For more information about the comments adapter see {@link module:comments/comments/commentsrepository~CommentsAdapter}.
52
- */
22
+ * Stores the list of {@link module:comments/comments/commentsrepository~CommentThread}
23
+ * and provides event-driven API for managing them. It is also responsible for using the comments adapter
24
+ * to communicate with the data source.
25
+ *
26
+ * {@link module:comments/comments/commentsrepository~CommentsRepository} is a context plugin.
27
+ * It can be added to a context or to an editor. Add it to the context configuration if you use
28
+ * {@link module:core/context~Context} in your integration.
29
+ *
30
+ * The event-driven API makes it possible to attach a listener to each action that changes comment data.
31
+ * Using different event priorities allows to attach an action before the main action ('low' priority)
32
+ * or after the main action ('high' priority). It works very similar to
33
+ * {@link module:utils/observablemixin~Observable#decorate}.
34
+ *
35
+ * Sample usage:
36
+ *
37
+ * ```ts
38
+ * // Get the comments repository:
39
+ * const commentsRepository = editor.plugins.get( 'CommentsRepository' );
40
+ *
41
+ * // Create a new, empty comment thread on a DOM form field element:
42
+ * commentsRepository.openNewCommentThread( { channelId, target: formFieldElement } );
43
+ *
44
+ * // Get all comment threads:
45
+ * commentsRepository.getCommentThreads();
46
+ *
47
+ * // Set the adapter:
48
+ * commentsRepository.adapter = {
49
+ * // ...
50
+ * };
51
+ * ```
52
+ *
53
+ * For more information about the comments adapter see {@link module:comments/comments/commentsrepository~CommentsAdapter}.
54
+ */
53
55
  export declare class CommentsRepository extends ContextPlugin {
54
- /**
55
- * The currently active comment thread.
56
- * An annotation with this thread will be marked as active.
57
- *
58
- * @observable
59
- */
60
- activeCommentThread: CommentThread | null;
61
- /**
62
- * @inheritDoc
63
- */
64
- static get requires(): readonly [typeof Annotations, typeof PendingActions, typeof Users];
65
- /**
66
- * @inheritDoc
67
- */
68
- static get pluginName(): "CommentsRepository";
69
- /**
70
- * @inheritDoc
71
- */
72
- static get isOfficialPlugin(): true;
73
- /**
74
- * @inheritDoc
75
- */
76
- static get isPremiumPlugin(): true;
77
- /**
78
- * @inheritDoc
79
- */
80
- constructor(context: Context | Editor);
81
- /**
82
- * @inheritDoc
83
- */
84
- init(): void;
85
- /**
86
- * An adapter object that should communicate with the data source to fetch or save the comments data.
87
- */
88
- set adapter(adapter: CommentsAdapter);
89
- get adapter(): CommentsAdapter;
90
- /**
91
- * Adds a new comment thread.
92
- *
93
- * When a target is provided, the comment annotation will be attached to this target.
94
- *
95
- * Use this method to load the comments data during the editor initialization
96
- * if you do not use the adapter integration.
97
- *
98
- * **Note:** This method fires the {@link #event:addCommentThread} event and the default behavior
99
- * is added as a `'normal'` priority listener. It makes it possible to cancel the method
100
- * or call some custom code before or after the default behavior is executed.
101
- *
102
- * **Note:** The comments adapter will send the data only if `commentThreadData.comments`
103
- * is not empty and `commentThreadData.isFromAdapter` is set to `false`.
104
- *
105
- * See also `CommentsRepository#openNewCommentThread()`.
106
- *
107
- * An example of loading a comment thread on editor initialization:
108
- *
109
- * ```ts
110
- * commentsRepository.addCommentThread( {
111
- * threadId: 'thread-id',
112
- * channelId: 'channel-id',
113
- * comments: [
114
- * {
115
- * commentId: 'comment-1', // String
116
- * authorId: 'author-id', // String
117
- * content: 'First comment', // String
118
- * createdAt: new Date( ... ) // Date instance
119
- * },
120
- * // ...
121
- * ],
122
- * target: () => ...,
123
- * // Added during initialization, so do not call the adapter:
124
- * isFromAdapter: true
125
- * } );
126
- * ```
127
- *
128
- * See also {@link module:comments/comments/commentsrepository~CommentThread#setAttribute} and
129
- * {@link module:comments/comments/commentsrepository~CommentThread#removeAttribute}.
130
- *
131
- * @fires addCommentThread
132
- * @param data The data of the comment thread to add.
133
- * @param data.channelId The ID of a document or context to which the comment thread is added.
134
- * @param data.threadId The ID of the added comment thread.
135
- * @param data.comments Comments in the comment thread. See the example above.
136
- * @param data.unlinkedAt The date when the content related to the comment thread was lost (usually, the commented content was
137
- * removed from the document).
138
- * @param data.resolvedAt The date when the comment thread has been resolved.
139
- * @param data.resolvedBy The ID of user who resolved the comment thread.
140
- * @param data.target The target that the comment
141
- * balloon should be attached to. If a function is passed, it should return a DOM element or `Rect`.
142
- * @param data.context The text on which the comment thread was created on or similar contextual information for the comment thread.
143
- * To be displayed as an additional hint for archived comment threads.
144
- * @param data.attributes Custom comment attributes.
145
- * @param data.isResolvable Indicates whether the comment thread can become resolved.
146
- * Set this flag to `false` to disable the possibility of resolving given comment thread.
147
- * @param data.isSubmitted Indicates whether the comment thread has been submitted.
148
- * Comment thread is submitted after adding the first comment, however, in some cases,
149
- * it could be necessary to manage it in a custom way (e.g. track changes).
150
- * @param data.isFromAdapter A flag describing whether the added data
151
- * comes from an adapter (`true`) or is a new data (`false`). If set to `true`, the
152
- * comment data will be added only in the editor and will not be sent to the adapter.
153
- * @returns The added comment thread.
154
- */
155
- addCommentThread({ channelId, threadId, comments, unlinkedAt, resolvedAt, resolvedBy, target, context, attributes, isResolvable, isSubmitted, isFromAdapter }?: Partial<AddCommentThreadEventData>): CommentThread | undefined;
156
- /**
157
- * Creates a new, empty comment thread.
158
- *
159
- * Displays a new comment annotation attached to the target and focuses the comment editor.
160
- * When the comment data is submitted, the comment thread is added to the editor
161
- * and sent to the adapter.
162
- *
163
- * Use this method to start a new comment thread after a user performed an action
164
- * (clicked a button, etc.).
165
- *
166
- * @param commentThreadData The data of the comment thread to add.
167
- * @returns The created comment thread or `null` if there was a problem
168
- * creating the thread (for example, if the comments repository was in the read-only mode).
169
- * @fires addCommentThread
170
- */
171
- openNewCommentThread({ channelId, threadId, target, context, isResolvable }: AddCommentThreadEventData): CommentThread | null;
172
- /**
173
- * Checks if a comment thread with a given ID is added to the repository.
174
- */
175
- hasCommentThread(threadId: string): boolean;
176
- /**
177
- * Updates an existing comment thread. See also
178
- * {@link module:comments/comments/commentsrepository~CommentThread#setAttribute} and
179
- * {@link module:comments/comments/commentsrepository~CommentThread#removeAttribute}.
180
- *
181
- * @param data The data of the comment thread to add.
182
- * @returns The updated comment thread.
183
- * @fires updateCommentThread
184
- */
185
- updateCommentThread({ channelId, threadId, context, unlinkedAt, attributes, isFromAdapter }: UpdateCommentThreadEventData): CommentThread;
186
- /**
187
- * Returns comment thread of given id.
188
- */
189
- getCommentThread(threadId: string): CommentThread | undefined;
190
- /**
191
- * Gets the comment thread data using the adapter and adds the thread to the editor.
192
- *
193
- * When the comment thread is already present in the repository,
194
- * then the adapter will not be used but the result will be asynchronous as well.
195
- */
196
- fetchCommentThread({ channelId, threadId }?: BaseCommentThread): Promise<CommentThread | undefined>;
197
- getCommentThreads(data?: {
198
- channelId?: string | symbol;
199
- skipNotAttached?: boolean;
200
- skipEmpty?: boolean;
201
- toJSON?: false;
202
- }): Array<CommentThread>;
203
- getCommentThreads(data: {
204
- channelId?: string | symbol;
205
- skipNotAttached?: boolean;
206
- skipEmpty?: boolean;
207
- toJSON: true;
208
- }): Array<CommentThreadDataJSON>;
209
- /**
210
- * Returns the annotation associated with the given comment thread.
211
- */
212
- getAnnotationForCommentThread(thread: CommentThread): Annotation | null;
213
- /**
214
- * Returns the comment thread associated with the given annotation.
215
- */
216
- getCommentThreadForAnnotation(annotation: Annotation): CommentThread | null;
217
- /**
218
- * Marks a comment thread with the given ID as active.
219
- * When `threadId` is `null`, the currently active comment thread will be deactivated.
220
- */
221
- setActiveCommentThread(threadId: string | null): void;
222
- /**
223
- * Changes the read-only state for comment threads.
224
- *
225
- * When the value is `true` then all comment threads will be switched to read-only,
226
- * when the value is `false` then all comment threads will be switched to editing mode.
227
- *
228
- * Optionally new state can be applied to a comment threads limited to a given channel.
229
- * This function has precedence over any permission settings.
230
- */
231
- switchReadOnly(value: boolean, channelId?: string | symbol): void;
232
- /**
233
- * Returns `true` if a given channel is set to read-only mode, returns `false` otherwise.
234
- */
235
- isReadOnly(channelId: string | symbol): boolean;
236
- /**
237
- * Create an instance of the {@link module:comments/comments/ui/commentthreadcontroller~CommentThreadController} class.
238
- *
239
- * @param commentThreadModel Comment thread model.
240
- * @param commentThreadView Comment thread view.
241
- */
242
- createCommentThreadController(commentThreadModel: CommentThread, commentThreadView: BaseCommentThreadView): CommentThreadController;
243
- /**
244
- * Gets permissions set for repository (or default if permissions was not set).
245
- */
246
- getPermissions(channelId?: string | symbol): CommentPermissionsConfig;
56
+ /**
57
+ * The currently active comment thread.
58
+ * An annotation with this thread will be marked as active.
59
+ *
60
+ * @observable
61
+ */
62
+ activeCommentThread: CommentThread | null;
63
+ /**
64
+ * @inheritDoc
65
+ */
66
+ static get requires(): PluginDependenciesOf<[Annotations, PendingActions, Users]>;
67
+ /**
68
+ * @inheritDoc
69
+ */
70
+ static get pluginName(): "CommentsRepository";
71
+ /**
72
+ * @inheritDoc
73
+ */
74
+ static override get isOfficialPlugin(): true;
75
+ /**
76
+ * @inheritDoc
77
+ */
78
+ static override get isPremiumPlugin(): true;
79
+ /**
80
+ * @inheritDoc
81
+ */
82
+ constructor(context: Context | Editor);
83
+ /**
84
+ * @inheritDoc
85
+ */
86
+ init(): void;
87
+ /**
88
+ * An adapter object that should communicate with the data source to fetch or save the comments data.
89
+ */
90
+ set adapter(adapter: CommentsAdapter);
91
+ get adapter(): CommentsAdapter;
92
+ /**
93
+ * Adds a new comment thread.
94
+ *
95
+ * When a target is provided, the comment annotation will be attached to this target.
96
+ *
97
+ * Use this method to load the comments data during the editor initialization
98
+ * if you do not use the adapter integration.
99
+ *
100
+ * **Note:** This method fires the {@link #event:addCommentThread} event and the default behavior
101
+ * is added as a `'normal'` priority listener. It makes it possible to cancel the method
102
+ * or call some custom code before or after the default behavior is executed.
103
+ *
104
+ * **Note:** The comments adapter will send the data only if `commentThreadData.comments`
105
+ * is not empty and `commentThreadData.isFromAdapter` is set to `false`.
106
+ *
107
+ * See also `CommentsRepository#openNewCommentThread()`.
108
+ *
109
+ * An example of loading a comment thread on editor initialization:
110
+ *
111
+ * ```ts
112
+ * commentsRepository.addCommentThread( {
113
+ * threadId: 'thread-id',
114
+ * channelId: 'channel-id',
115
+ * comments: [
116
+ * {
117
+ * commentId: 'comment-1', // String
118
+ * authorId: 'author-id', // String
119
+ * content: 'First comment', // String
120
+ * createdAt: new Date( ... ) // Date instance
121
+ * },
122
+ * // ...
123
+ * ],
124
+ * target: () => ...,
125
+ * // Added during initialization, so do not call the adapter:
126
+ * isFromAdapter: true
127
+ * } );
128
+ * ```
129
+ *
130
+ * See also {@link module:comments/comments/commentsrepository~CommentThread#setAttribute} and
131
+ * {@link module:comments/comments/commentsrepository~CommentThread#removeAttribute}.
132
+ *
133
+ * @fires addCommentThread
134
+ * @param data The data of the comment thread to add.
135
+ * @param data.channelId The ID of a document or context to which the comment thread is added.
136
+ * @param data.threadId The ID of the added comment thread.
137
+ * @param data.comments Comments in the comment thread. See the example above.
138
+ * @param data.unlinkedAt The date when the content related to the comment thread was lost (usually, the commented content was
139
+ * removed from the document).
140
+ * @param data.resolvedAt The date when the comment thread has been resolved.
141
+ * @param data.resolvedBy The ID of user who resolved the comment thread.
142
+ * @param data.target The target that the comment
143
+ * balloon should be attached to. If a function is passed, it should return a DOM element or `Rect`.
144
+ * @param data.context The text on which the comment thread was created on or similar contextual information for the comment thread.
145
+ * To be displayed as an additional hint for archived comment threads.
146
+ * @param data.attributes Custom comment attributes.
147
+ * @param data.isResolvable Indicates whether the comment thread can become resolved.
148
+ * Set this flag to `false` to disable the possibility of resolving given comment thread.
149
+ * @param data.isSubmitted Indicates whether the comment thread has been submitted.
150
+ * Comment thread is submitted after adding the first comment, however, in some cases,
151
+ * it could be necessary to manage it in a custom way (e.g. track changes).
152
+ * @param data.isFromAdapter A flag describing whether the added data
153
+ * comes from an adapter (`true`) or is a new data (`false`). If set to `true`, the
154
+ * comment data will be added only in the editor and will not be sent to the adapter.
155
+ * @returns The added comment thread.
156
+ */
157
+ addCommentThread({ channelId, threadId, comments, unlinkedAt, resolvedAt, resolvedBy, target, context, attributes, isResolvable, isSubmitted, isFromAdapter }?: Partial<Omit<AddCommentThreadEventData, "target">> & {
158
+ target?: AnnotationTarget | null;
159
+ }): CommentThread | undefined;
160
+ /**
161
+ * Creates a new, empty comment thread.
162
+ *
163
+ * Displays a new comment annotation attached to the target and focuses the comment editor.
164
+ * When the comment data is submitted, the comment thread is added to the editor
165
+ * and sent to the adapter.
166
+ *
167
+ * Use this method to start a new comment thread after a user performed an action
168
+ * (clicked a button, etc.).
169
+ *
170
+ * @param commentThreadData The data of the comment thread to add.
171
+ * @returns The created comment thread or `null` if there was a problem
172
+ * creating the thread (for example, if the comments repository was in the read-only mode).
173
+ * @fires addCommentThread
174
+ */
175
+ openNewCommentThread({ channelId, threadId, target, context, isResolvable }: AddCommentThreadEventData): CommentThread | null;
176
+ /**
177
+ * Checks if a comment thread with a given ID is added to the repository.
178
+ */
179
+ hasCommentThread(threadId: string): boolean;
180
+ /**
181
+ * Updates an existing comment thread. See also
182
+ * {@link module:comments/comments/commentsrepository~CommentThread#setAttribute} and
183
+ * {@link module:comments/comments/commentsrepository~CommentThread#removeAttribute}.
184
+ *
185
+ * @param data The data of the comment thread to add.
186
+ * @returns The updated comment thread.
187
+ * @fires updateCommentThread
188
+ */
189
+ updateCommentThread({ channelId, threadId, context, unlinkedAt, attributes, isFromAdapter }: UpdateCommentThreadEventData): CommentThread;
190
+ /**
191
+ * Returns comment thread of given id.
192
+ */
193
+ getCommentThread(threadId: string): CommentThread | undefined;
194
+ /**
195
+ * Gets the comment thread data using the adapter and adds the thread to the editor.
196
+ *
197
+ * When the comment thread is already present in the repository,
198
+ * then the adapter will not be used but the result will be asynchronous as well.
199
+ */
200
+ fetchCommentThread({ channelId, threadId }?: BaseCommentThread): Promise<CommentThread | undefined>;
201
+ getCommentThreads(data?: {
202
+ channelId?: string | symbol;
203
+ skipNotAttached?: boolean;
204
+ skipEmpty?: boolean;
205
+ toJSON?: false;
206
+ }): Array<CommentThread>;
207
+ getCommentThreads(data: {
208
+ channelId?: string | symbol;
209
+ skipNotAttached?: boolean;
210
+ skipEmpty?: boolean;
211
+ toJSON: true;
212
+ }): Array<CommentThreadDataJSON>;
213
+ /**
214
+ * Returns the annotation associated with the given comment thread.
215
+ */
216
+ getAnnotationForCommentThread(thread: CommentThread): Annotation | null;
217
+ /**
218
+ * Returns the comment thread associated with the given annotation.
219
+ */
220
+ getCommentThreadForAnnotation(annotation: Annotation): CommentThread | null;
221
+ /**
222
+ * Marks a comment thread with the given ID as active.
223
+ * When `threadId` is `null`, the currently active comment thread will be deactivated.
224
+ */
225
+ setActiveCommentThread(threadId: string | null): void;
226
+ /**
227
+ * Changes the read-only state for comment threads.
228
+ *
229
+ * When the value is `true` then all comment threads will be switched to read-only,
230
+ * when the value is `false` then all comment threads will be switched to editing mode.
231
+ *
232
+ * Optionally new state can be applied to a comment threads limited to a given channel.
233
+ * This function has precedence over any permission settings.
234
+ */
235
+ switchReadOnly(value: boolean, channelId?: string | symbol): void;
236
+ /**
237
+ * Returns `true` if a given channel is set to read-only mode, returns `false` otherwise.
238
+ */
239
+ isReadOnly(channelId: string | symbol): boolean;
240
+ /**
241
+ * Create an instance of the {@link module:comments/comments/ui/commentthreadcontroller~CommentThreadController} class.
242
+ *
243
+ * @param commentThreadModel Comment thread model.
244
+ * @param commentThreadView Comment thread view.
245
+ */
246
+ createCommentThreadController(commentThreadModel: CommentThread, commentThreadView: BaseCommentThreadView): CommentThreadController;
247
+ /**
248
+ * Gets permissions set for repository (or default if permissions was not set).
249
+ */
250
+ getPermissions(channelId?: string | symbol): CommentPermissionsConfig;
247
251
  }
248
252
  export interface CommentPermissionsConfig {
249
- /**
250
- * Allows for removing other users' threads.
251
- */
252
- admin: boolean;
253
- /**
254
- * Allows for editing and removing any comments created by other users.
255
- */
256
- modifyAll: boolean;
257
- /**
258
- * Allows for adding new comments as well as editing and removing comments created by this user.
259
- */
260
- write: boolean;
261
- /**
262
- * Allows for resolving and reopening comment threads.
263
- */
264
- resolve: boolean;
253
+ /**
254
+ * Allows for removing other users' threads.
255
+ */
256
+ admin: boolean;
257
+ /**
258
+ * Allows for editing and removing any comments created by other users.
259
+ */
260
+ modifyAll: boolean;
261
+ /**
262
+ * Allows for adding new comments as well as editing and removing comments created by this user.
263
+ */
264
+ write: boolean;
265
+ /**
266
+ * Allows for resolving and reopening comment threads.
267
+ */
268
+ resolve: boolean;
265
269
  }
266
- declare const CommentThread_base: {
267
- new (): import("@ckeditor/ckeditor5-utils").Observable;
268
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
269
- };
270
270
  /**
271
- * Comment thread representation.
272
- * Stores a list of {@link module:comments/comments/commentsrepository~Comment `Comments`}.
273
- */
274
- export declare class CommentThread extends /* #__PURE__ -- @preserve */ CommentThread_base {
275
- /**
276
- * Informs if the comment thread is in read-only state (`true`) or not (`false`).
277
- *
278
- * @observable
279
- */
280
- isReadOnly: boolean;
281
- /**
282
- * Informs if the comment thread can be removed by the local user.
283
- *
284
- * @observable
285
- */
286
- isRemovable: boolean;
287
- /**
288
- * Informs if a user has permission to add a new comment to the comment thread.
289
- *
290
- * @observable
291
- */
292
- canComment: boolean;
293
- /**
294
- * Date when the comment thread has been archived.
295
- *
296
- * Comment threads become archived after they are {@link #resolvedAt resolved} or {@link #unlinkedAt unlinked}.
297
- * If the comment thread is resolved and/or unlinked, this value is set to the earliest of the dates. Otherwise, it is `null`.
298
- *
299
- * @observable
300
- */
301
- archivedAt: Date | null;
302
- /**
303
- * The date when the content related to the comment thread was lost (usually, the commented content was removed from the document).
304
- *
305
- * @observable
306
- */
307
- unlinkedAt: Date | null;
308
- /**
309
- * User id which resolved the comment thread.
310
- *
311
- * @observable
312
- */
313
- resolvedBy: User | null;
314
- /**
315
- * Date when the comment thread has been resolved.
316
- *
317
- * @observable
318
- */
319
- resolvedAt: Date | null;
320
- /**
321
- * Informs if the comment thread is resolved.
322
- *
323
- * @observable
324
- */
325
- readonly isResolved: boolean;
326
- /**
327
- * Custom comment thread attributes. See also {@link #setAttribute} and {@link #removeAttribute}.
328
- *
329
- * @observable
330
- */
331
- attributes: Record<string, unknown>;
332
- /**
333
- * The channel where the comment thread was created.
334
- */
335
- channelId: string | symbol;
336
- /**
337
- * The comment thread ID.
338
- */
339
- id: string;
340
- /**
341
- * A collection of {@link module:comments/comments/commentsrepository~Comment}s belonging to this thread.
342
- *
343
- * @readonly
344
- */
345
- readonly comments: Collection<Comment>;
346
- constructor(commentsRepository: CommentsRepository, data: {
347
- channelId: string | symbol;
348
- id: string;
349
- context: CommentThreadContext;
350
- attributes: Record<string, unknown>;
351
- unlinkedAt: Date | null;
352
- resolvedAt: Date | null;
353
- resolvedBy: User | null;
354
- isResolvable: boolean;
355
- isSubmitted: boolean;
356
- });
357
- /**
358
- * Sum of {@link module:comments/comments/commentsrepository~Comment#weight weights of all comments} in this thread.
359
- */
360
- get weight(): number;
361
- /**
362
- * The number of {@link module:comments/comments/commentsrepository~Comment comments} in the comment thread.
363
- */
364
- get length(): number;
365
- /**
366
- * Informs if the comment thread is attached to any target at the moment.
367
- */
368
- get isAttached(): boolean;
369
- /**
370
- * Informs if the comment thread has been submitted.
371
- */
372
- get isSubmitted(): boolean;
373
- /**
374
- * Submits the locally created comment thread draft.
375
- */
376
- submit(): void;
377
- /**
378
- * Updates the unlinked date.
379
- */
380
- setUnlinkedAt(unlinkedAt: Date | null): void;
381
- /**
382
- * Resolves the comment thread.
383
- */
384
- resolve({ resolvedAt, resolvedBy, isFromAdapter }?: {
385
- resolvedAt?: Date | undefined;
386
- resolvedBy?: string | undefined;
387
- isFromAdapter?: boolean | undefined;
388
- }): void;
389
- /**
390
- * Reopens the resolved comment thread.
391
- */
392
- reopen({ isFromAdapter }?: {
393
- isFromAdapter?: boolean | undefined;
394
- }): void;
395
- /**
396
- * Set the context on the comment thread.
397
- * This method should be called only when the context has been not set during initialization.
398
- *
399
- * @param context Text context of comment thread.
400
- */
401
- setContext(context: CommentThreadContext): void;
402
- /**
403
- * Adds attribute to the comment thread.
404
- *
405
- * Comment thread attributes are custom data that can be set and used by features
406
- * built around comments. Use it to store your feature data with other comment thread data.
407
- * You can also group multiple values in an object, using dot notation:
408
- *
409
- * ```ts
410
- * commentThread.setAttribute( 'customData.isImportant', true );
411
- * ```
412
- *
413
- * Attributes set on the comment can be accessed through the `attribute` property:
414
- *
415
- * ```ts
416
- * const isImportant = commentThread.attributes.customData.isImportant;
417
- * ```
418
- *
419
- * You can also observe the `attributes` property or bind other properties to it:
420
- *
421
- * ```ts
422
- * myObj.bind( 'customData' ).to( commentThread, 'attributes', attributes => attributes.customData );
423
- * ```
424
- *
425
- * Whenever `setAttribute()` or `removeAttribute()` is called, the `attributes` property
426
- * is re-set and observables are refreshed.
427
- *
428
- * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateCommentThread
429
- * @param name Attribute name.
430
- * @param value Attribute value.
431
- */
432
- setAttribute(name: string, value: unknown): void;
433
- /**
434
- * Removes a comment attribute.
435
- *
436
- * See also {@link module:comments/comments/commentsrepository~CommentThread#setAttribute}.
437
- *
438
- * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateCommentThread
439
- * @param name The attribute name.
440
- */
441
- removeAttribute(name: string): void;
442
- /**
443
- * Removes comment thread.
444
- *
445
- * **Note** This method is event-driven. It means it fires an event then a normal priority listener catches
446
- * it and executes an action. It makes it possible to add some actions before and after method will be executed.
447
- *
448
- * @fires module:comments/comments/commentsrepository~RemoveCommentThreadEvent
449
- */
450
- remove({ isFromAdapter }?: {
451
- isFromAdapter?: boolean | undefined;
452
- }): void;
453
- /**
454
- * Creates comment annotations and displays it attached to the given target.
455
- *
456
- * @returns Created annotation.
457
- */
458
- attachTo(target: AnnotationTarget): Annotation;
459
- /**
460
- * Creates a new comment inside the comment thread.
461
- *
462
- * **Note** This method is event-driven. It means it fires an event then a normal priority listener catches
463
- * it and executes an action. It makes it possible to add some actions before and after method will be executed.
464
- *
465
- * See also
466
- * {@link module:comments/comments/commentsrepository~Comment#setAttribute} and
467
- * {@link module:comments/comments/commentsrepository~Comment#removeAttribute}.
468
- *
469
- * @fires module:comments/comments/commentsrepository~CommentsRepository#event:addComment
470
- * @param data Data object.
471
- */
472
- addComment(data: CommentData): void;
473
- /**
474
- * Returns comment of given id.
475
- */
476
- getComment(commentId: string): Comment | null;
477
- toJSON(): CommentThreadDataJSON;
271
+ * Comment thread representation.
272
+ * Stores a list of {@link module:comments/comments/commentsrepository~Comment `Comments`}.
273
+ */
274
+ export declare class CommentThread extends _CommentThreadBase {
275
+ /**
276
+ * Informs if the comment thread is in read-only state (`true`) or not (`false`).
277
+ *
278
+ * @observable
279
+ */
280
+ isReadOnly: boolean;
281
+ /**
282
+ * Informs if the comment thread can be removed by the local user.
283
+ *
284
+ * @observable
285
+ */
286
+ isRemovable: boolean;
287
+ /**
288
+ * Informs if a user has permission to add a new comment to the comment thread.
289
+ *
290
+ * @observable
291
+ */
292
+ canComment: boolean;
293
+ /**
294
+ * Date when the comment thread has been archived.
295
+ *
296
+ * Comment threads become archived after they are {@link #resolvedAt resolved} or {@link #unlinkedAt unlinked}.
297
+ * If the comment thread is resolved and/or unlinked, this value is set to the earliest of the dates. Otherwise, it is `null`.
298
+ *
299
+ * @observable
300
+ */
301
+ archivedAt: Date | null;
302
+ /**
303
+ * The date when the content related to the comment thread was lost (usually, the commented content was removed from the document).
304
+ *
305
+ * @observable
306
+ */
307
+ unlinkedAt: Date | null;
308
+ /**
309
+ * User id which resolved the comment thread.
310
+ *
311
+ * @observable
312
+ */
313
+ resolvedBy: User | null;
314
+ /**
315
+ * Date when the comment thread has been resolved.
316
+ *
317
+ * @observable
318
+ */
319
+ resolvedAt: Date | null;
320
+ /**
321
+ * Informs if the comment thread is resolved.
322
+ *
323
+ * @observable
324
+ */
325
+ readonly isResolved: boolean;
326
+ /**
327
+ * Custom comment thread attributes. See also {@link #setAttribute} and {@link #removeAttribute}.
328
+ *
329
+ * @observable
330
+ */
331
+ attributes: Record<string, unknown>;
332
+ /**
333
+ * The channel where the comment thread was created.
334
+ */
335
+ channelId: string | symbol;
336
+ /**
337
+ * The comment thread ID.
338
+ */
339
+ id: string;
340
+ /**
341
+ * A collection of {@link module:comments/comments/commentsrepository~Comment}s belonging to this thread.
342
+ *
343
+ * @readonly
344
+ */
345
+ readonly comments: Collection<Comment>;
346
+ constructor(commentsRepository: CommentsRepository, data: {
347
+ channelId: string | symbol;
348
+ id: string;
349
+ context: CommentThreadContext;
350
+ attributes: Record<string, unknown>;
351
+ unlinkedAt: Date | null;
352
+ resolvedAt: Date | null;
353
+ resolvedBy: User | null;
354
+ isResolvable: boolean;
355
+ isSubmitted: boolean;
356
+ });
357
+ /**
358
+ * Sum of {@link module:comments/comments/commentsrepository~Comment#weight weights of all comments} in this thread.
359
+ */
360
+ get weight(): number;
361
+ /**
362
+ * The number of {@link module:comments/comments/commentsrepository~Comment comments} in the comment thread.
363
+ */
364
+ get length(): number;
365
+ /**
366
+ * Informs if the comment thread is attached to any target at the moment.
367
+ */
368
+ get isAttached(): boolean;
369
+ /**
370
+ * Informs if the comment thread has been submitted.
371
+ */
372
+ get isSubmitted(): boolean;
373
+ /**
374
+ * Submits the locally created comment thread draft.
375
+ */
376
+ submit(): void;
377
+ /**
378
+ * Updates the unlinked date.
379
+ */
380
+ setUnlinkedAt(unlinkedAt: Date | null): void;
381
+ /**
382
+ * Resolves the comment thread.
383
+ */
384
+ resolve({ resolvedAt, resolvedBy, isFromAdapter }?: Partial<Pick<ResolveCommentThreadEventData, "resolvedAt" | "resolvedBy" | "isFromAdapter">>): void;
385
+ /**
386
+ * Reopens the resolved comment thread.
387
+ */
388
+ reopen({ isFromAdapter }?: Pick<BaseCommentThread, "isFromAdapter">): void;
389
+ /**
390
+ * Set the context on the comment thread.
391
+ * This method should be called only when the context has been not set during initialization.
392
+ *
393
+ * @param context Text context of comment thread.
394
+ */
395
+ setContext(context: CommentThreadContext): void;
396
+ /**
397
+ * Adds attribute to the comment thread.
398
+ *
399
+ * Comment thread attributes are custom data that can be set and used by features
400
+ * built around comments. Use it to store your feature data with other comment thread data.
401
+ * You can also group multiple values in an object, using dot notation:
402
+ *
403
+ * ```ts
404
+ * commentThread.setAttribute( 'customData.isImportant', true );
405
+ * ```
406
+ *
407
+ * Attributes set on the comment can be accessed through the `attribute` property:
408
+ *
409
+ * ```ts
410
+ * const isImportant = commentThread.attributes.customData.isImportant;
411
+ * ```
412
+ *
413
+ * You can also observe the `attributes` property or bind other properties to it:
414
+ *
415
+ * ```ts
416
+ * myObj.bind( 'customData' ).to( commentThread, 'attributes', attributes => attributes.customData );
417
+ * ```
418
+ *
419
+ * Whenever `setAttribute()` or `removeAttribute()` is called, the `attributes` property
420
+ * is re-set and observables are refreshed.
421
+ *
422
+ * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateCommentThread
423
+ * @param name Attribute name.
424
+ * @param value Attribute value.
425
+ */
426
+ setAttribute(name: string, value: unknown): void;
427
+ /**
428
+ * Removes a comment attribute.
429
+ *
430
+ * See also {@link module:comments/comments/commentsrepository~CommentThread#setAttribute}.
431
+ *
432
+ * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateCommentThread
433
+ * @param name The attribute name.
434
+ */
435
+ removeAttribute(name: string): void;
436
+ /**
437
+ * Removes comment thread.
438
+ *
439
+ * **Note** This method is event-driven. It means it fires an event then a normal priority listener catches
440
+ * it and executes an action. It makes it possible to add some actions before and after method will be executed.
441
+ *
442
+ * @fires module:comments/comments/commentsrepository~RemoveCommentThreadEvent
443
+ */
444
+ remove({ isFromAdapter }?: Pick<BaseCommentThread, "isFromAdapter">): void;
445
+ /**
446
+ * Creates comment annotations and displays it attached to the given target.
447
+ *
448
+ * @returns Created annotation.
449
+ */
450
+ attachTo(target: AnnotationTarget): Annotation;
451
+ /**
452
+ * Creates a new comment inside the comment thread.
453
+ *
454
+ * **Note** This method is event-driven. It means it fires an event then a normal priority listener catches
455
+ * it and executes an action. It makes it possible to add some actions before and after method will be executed.
456
+ *
457
+ * See also
458
+ * {@link module:comments/comments/commentsrepository~Comment#setAttribute} and
459
+ * {@link module:comments/comments/commentsrepository~Comment#removeAttribute}.
460
+ *
461
+ * @fires module:comments/comments/commentsrepository~CommentsRepository#event:addComment
462
+ * @param data Data object.
463
+ */
464
+ addComment(data: CommentData): void;
465
+ /**
466
+ * Returns comment of given id.
467
+ */
468
+ getComment(commentId: string): Comment | null;
469
+ toJSON(): CommentThreadDataJSON;
478
470
  }
479
- declare const Comment_base: {
480
- new (): import("@ckeditor/ckeditor5-utils").Observable;
481
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
482
- };
483
471
  /**
484
- * Single comment representation. A part of a {@link module:comments/comments/commentsrepository~CommentThread commentThread}.
485
- */
486
- export declare class Comment extends /* #__PURE__ -- @preserve */ Comment_base {
487
- /**
488
- * When is set to `true`, editing the comment is blocked.
489
- *
490
- * @observable
491
- */
492
- readonly isEditable: boolean;
493
- /**
494
- * When is set to `false`, removing the comment is blocked.
495
- *
496
- * @observable
497
- */
498
- readonly isRemovable: boolean;
499
- /**
500
- * The read-only state inherited from the parent {@link module:comments/comments/commentsrepository~CommentThread}.
501
- * When is set to `true`, then removing and editing the comment thread is blocked.
502
- *
503
- * In contrast to {@link #isEditable} and {@link #isRemovable}, this state can be used to
504
- * hide some UI parts instead of temporarily disabling them.
505
- *
506
- * @observable
507
- */
508
- readonly isReadOnly: boolean;
509
- /**
510
- * The comment content.
511
- */
512
- content: string;
513
- /**
514
- * Date when the comment was made.
515
- *
516
- * Usually the same as {@link #createdAt `createdAt`} but may be different in some cases
517
- * (e.g. when comment was added from an external source).
518
- *
519
- * @observable
520
- */
521
- authoredAt: Date;
522
- /**
523
- * The date when the comment thread was resolved or `null` if it is not resolved.
524
- *
525
- * @observable
526
- */
527
- resolvedAt: Date | null;
528
- /**
529
- * Custom comment attributes. See also {@link #setAttribute} and {@link #removeAttribute}.
530
- *
531
- * @observable
532
- */
533
- attributes: Record<string, any>;
534
- /**
535
- * The comment ID.
536
- */
537
- readonly id: string;
538
- /**
539
- * The ID of the comment thread that contains this comment.
540
- */
541
- readonly threadId: string;
542
- /**
543
- * The comment author.
544
- */
545
- readonly author: User;
546
- /**
547
- * The user which saved the comment data in the database.
548
- *
549
- * Usually the same as author but may be different in some cases (e.g. when comment was added from an external source).
550
- */
551
- readonly creator: User;
552
- /**
553
- * The flag indicating whether the comment comes from an external source.
554
- */
555
- readonly isExternal: boolean;
556
- /**
557
- * Date when the comment was saved in the database.
558
- */
559
- createdAt: Date;
560
- /**
561
- * @param commentsRepository
562
- * @param data Configuration object.
563
- * @param data.id Comment id.
564
- * @param data.threadId Comment thread id.
565
- * @param data.content Comment content.
566
- * @param data.author Comment author.
567
- * @param data.creator The user which saved the comment data.
568
- * Usually the same as author but may be different in some cases (e.g. when comment was added from an external source).
569
- * @param data.createdAt Date when the comment was saved in the database.
570
- * @param data.authoredAt Date when the comment was made.
571
- * @param data.attributes Custom comment attributes. See also
572
- * {@link module:comments/comments/commentsrepository~Comment#setAttribute} and
573
- * {@link module:comments/comments/commentsrepository~Comment#removeAttribute}.
574
- */
575
- constructor(commentsRepository: CommentsRepository, data: {
576
- id: string;
577
- threadId: string;
578
- content: string;
579
- author: User;
580
- creator: User;
581
- createdAt: Date;
582
- authoredAt: Date;
583
- attributes: Record<string, unknown>;
584
- });
585
- /**
586
- * The comment weight.
587
- *
588
- * It is equal to the length of the comment content, however it is never smaller than `200`.
589
- * This limit is set to avoid a long list of very short not collapsed comments.
590
- */
591
- get weight(): number;
592
- /**
593
- * Updates the comment with provided data.
594
- *
595
- * **Note:** This method fires the {@link module:comments/comments/commentsrepository~CommentsRepository#event:updateComment}
596
- * event and the default behavior is added as a normal priority listener. It makes it
597
- * possible to cancel the method or call some custom code before or after the default
598
- * behavior is executed.
599
- *
600
- * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateComment
601
- * @param data Data object. Available properties:
602
- *
603
- * - `content` — Comment content.
604
- * - `createdAt` — Creation date.
605
- * - `attributes` — Custom comment attributes. See also
606
- * {@link module:comments/comments/commentsrepository~Comment#setAttribute} and
607
- * {@link module:comments/comments/commentsrepository~Comment#removeAttribute}.
608
- * - `isFromAdapter`
609
- */
610
- update(data: UpdateCommentData): void;
611
- /**
612
- * Adds attribute to the comment.
613
- *
614
- * Comment attributes are custom data that can be set and used by features
615
- * built around comments. Use it to store your feature data with other comment data.
616
- *
617
- * comment.setAttribute( 'isImportant', true );
618
- *
619
- * You can group multiple values in an object, using dot notation:
620
- *
621
- * comment.setAttribute( 'customData.type', 'image' );
622
- * comment.setAttribute( 'customData.src', 'foo.jpg' );
623
- *
624
- * Attributes set on the comment can be accessed through the `attribute` property:
625
- *
626
- * const isImportant = comment.attributes.isImportant;
627
- * const type = comment.attributes.customData.type;
628
- *
629
- * You can also observe the `attributes` property or bind other properties to it:
630
- *
631
- * myObj.bind( 'customData' ).to( comment, 'attributes', attributes => attributes.customData );
632
- *
633
- * Whenever `setAttribute()` or `removeAttribute()` is called, the `attributes` property
634
- * is re-set and observables are refreshed.
635
- *
636
- * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateComment
637
- * @param name Attribute name.
638
- * @param value Attribute value.
639
- */
640
- setAttribute(name: string, value: unknown): void;
641
- /**
642
- * Removes a comment attribute.
643
- *
644
- * See also {@link module:comments/comments/commentsrepository~Comment#setAttribute}.
645
- *
646
- * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateComment
647
- * @param name The attribute name.
648
- */
649
- removeAttribute(name: string): void;
650
- /**
651
- * Removes the comment.
652
- *
653
- * **Note:** This method fires the {@link module:comments/comments/commentsrepository~CommentsRepository#event:updateComment}
654
- * event and the default behavior is added as a normal priority listener. It makes it
655
- * possible to cancel the method or call some custom code before or after the default
656
- * behavior is executed.
657
- *
658
- * @fires module:comments/comments/commentsrepository~CommentsRepository#event:removeComment
659
- * @param data.isFromAdapter A flag describing whether the comment was
660
- * updated from an adapter (`true`) or from the UI (`false`). If set to `true`, the adapter will not be called.
661
- */
662
- remove(data?: {
663
- isFromAdapter?: boolean;
664
- }): void;
665
- toJSON(): CommentDataJSON;
666
- /**
667
- * Destroys the comment instance.
668
- */
669
- destroy(): void;
472
+ * Single comment representation. A part of a {@link module:comments/comments/commentsrepository~CommentThread commentThread}.
473
+ */
474
+ export declare class Comment extends _CommentBase {
475
+ /**
476
+ * When is set to `true`, editing the comment is blocked.
477
+ *
478
+ * @observable
479
+ */
480
+ readonly isEditable: boolean;
481
+ /**
482
+ * When is set to `false`, removing the comment is blocked.
483
+ *
484
+ * @observable
485
+ */
486
+ readonly isRemovable: boolean;
487
+ /**
488
+ * The read-only state inherited from the parent {@link module:comments/comments/commentsrepository~CommentThread}.
489
+ * When is set to `true`, then removing and editing the comment thread is blocked.
490
+ *
491
+ * In contrast to {@link #isEditable} and {@link #isRemovable}, this state can be used to
492
+ * hide some UI parts instead of temporarily disabling them.
493
+ *
494
+ * @observable
495
+ */
496
+ readonly isReadOnly: boolean;
497
+ /**
498
+ * The comment content.
499
+ */
500
+ content: string;
501
+ /**
502
+ * Date when the comment was made.
503
+ *
504
+ * Usually the same as {@link #createdAt `createdAt`} but may be different in some cases
505
+ * (e.g. when comment was added from an external source).
506
+ *
507
+ * @observable
508
+ */
509
+ authoredAt: Date;
510
+ /**
511
+ * The date when the comment thread was resolved or `null` if it is not resolved.
512
+ *
513
+ * @observable
514
+ */
515
+ resolvedAt: Date | null;
516
+ /**
517
+ * Custom comment attributes. See also {@link #setAttribute} and {@link #removeAttribute}.
518
+ *
519
+ * @observable
520
+ */
521
+ attributes: Record<string, any>;
522
+ /**
523
+ * The comment ID.
524
+ */
525
+ readonly id: string;
526
+ /**
527
+ * The ID of the comment thread that contains this comment.
528
+ */
529
+ readonly threadId: string;
530
+ /**
531
+ * The comment author.
532
+ */
533
+ readonly author: User;
534
+ /**
535
+ * The user which saved the comment data in the database.
536
+ *
537
+ * Usually the same as author but may be different in some cases (e.g. when comment was added from an external source).
538
+ */
539
+ readonly creator: User;
540
+ /**
541
+ * Date when the comment was saved in the database.
542
+ */
543
+ createdAt: Date;
544
+ /**
545
+ * @param commentsRepository
546
+ * @param data Configuration object.
547
+ * @param data.id Comment id.
548
+ * @param data.threadId Comment thread id.
549
+ * @param data.content Comment content.
550
+ * @param data.author Comment author.
551
+ * @param data.creator The user which saved the comment data.
552
+ * Usually the same as author but may be different in some cases (e.g. when comment was added from an external source).
553
+ * @param data.createdAt Date when the comment was saved in the database.
554
+ * @param data.authoredAt Date when the comment was made.
555
+ * @param data.attributes Custom comment attributes. See also
556
+ * {@link module:comments/comments/commentsrepository~Comment#setAttribute} and
557
+ * {@link module:comments/comments/commentsrepository~Comment#removeAttribute}.
558
+ */
559
+ constructor(commentsRepository: CommentsRepository, data: {
560
+ id: string;
561
+ threadId: string;
562
+ content: string;
563
+ author: User;
564
+ creator: User;
565
+ createdAt: Date;
566
+ authoredAt: Date;
567
+ attributes: Record<string, unknown>;
568
+ });
569
+ /**
570
+ * The flag indicating whether the comment comes from an external source.
571
+ */
572
+ get isExternal(): boolean;
573
+ /**
574
+ * The comment weight.
575
+ *
576
+ * It is equal to the length of the comment content, however it is never smaller than `200`.
577
+ * This limit is set to avoid a long list of very short not collapsed comments.
578
+ */
579
+ get weight(): number;
580
+ /**
581
+ * Updates the comment with provided data.
582
+ *
583
+ * **Note:** This method fires the {@link module:comments/comments/commentsrepository~CommentsRepository#event:updateComment}
584
+ * event and the default behavior is added as a normal priority listener. It makes it
585
+ * possible to cancel the method or call some custom code before or after the default
586
+ * behavior is executed.
587
+ *
588
+ * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateComment
589
+ * @param data Data object. Available properties:
590
+ *
591
+ * - `content` — Comment content.
592
+ * - `createdAt` — Creation date.
593
+ * - `attributes` — Custom comment attributes. See also
594
+ * {@link module:comments/comments/commentsrepository~Comment#setAttribute} and
595
+ * {@link module:comments/comments/commentsrepository~Comment#removeAttribute}.
596
+ * - `isFromAdapter`
597
+ */
598
+ update(data: UpdateCommentData): void;
599
+ /**
600
+ * Adds attribute to the comment.
601
+ *
602
+ * Comment attributes are custom data that can be set and used by features
603
+ * built around comments. Use it to store your feature data with other comment data.
604
+ *
605
+ * comment.setAttribute( 'isImportant', true );
606
+ *
607
+ * You can group multiple values in an object, using dot notation:
608
+ *
609
+ * comment.setAttribute( 'customData.type', 'image' );
610
+ * comment.setAttribute( 'customData.src', 'foo.jpg' );
611
+ *
612
+ * Attributes set on the comment can be accessed through the `attribute` property:
613
+ *
614
+ * const isImportant = comment.attributes.isImportant;
615
+ * const type = comment.attributes.customData.type;
616
+ *
617
+ * You can also observe the `attributes` property or bind other properties to it:
618
+ *
619
+ * myObj.bind( 'customData' ).to( comment, 'attributes', attributes => attributes.customData );
620
+ *
621
+ * Whenever `setAttribute()` or `removeAttribute()` is called, the `attributes` property
622
+ * is re-set and observables are refreshed.
623
+ *
624
+ * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateComment
625
+ * @param name Attribute name.
626
+ * @param value Attribute value.
627
+ */
628
+ setAttribute(name: string, value: unknown): void;
629
+ /**
630
+ * Removes a comment attribute.
631
+ *
632
+ * See also {@link module:comments/comments/commentsrepository~Comment#setAttribute}.
633
+ *
634
+ * @fires module:comments/comments/commentsrepository~CommentsRepository#event:updateComment
635
+ * @param name The attribute name.
636
+ */
637
+ removeAttribute(name: string): void;
638
+ /**
639
+ * Removes the comment.
640
+ *
641
+ * **Note:** This method fires the {@link module:comments/comments/commentsrepository~CommentsRepository#event:updateComment}
642
+ * event and the default behavior is added as a normal priority listener. It makes it
643
+ * possible to cancel the method or call some custom code before or after the default
644
+ * behavior is executed.
645
+ *
646
+ * @fires module:comments/comments/commentsrepository~CommentsRepository#event:removeComment
647
+ * @param data.isFromAdapter A flag describing whether the comment was
648
+ * updated from an adapter (`true`) or from the UI (`false`). If set to `true`, the adapter will not be called.
649
+ */
650
+ remove(data?: {
651
+ isFromAdapter?: boolean;
652
+ }): void;
653
+ toJSON(): CommentDataJSON;
654
+ /**
655
+ * Destroys the comment instance.
656
+ */
657
+ destroy(): void;
670
658
  }
671
659
  export type CommentThreadContext = null | {
672
- type: string;
673
- value: unknown;
660
+ type: string;
661
+ value: unknown;
674
662
  };
675
663
  /**
676
- * @param channelId The ID of a document or context that the comment thread is handled.
677
- * @param threadId The ID of the comment thread.
678
- * @param isFromAdapter A flag describing whether the operation was done on a remote client (`true`) or a local one (`false`).
679
- */
664
+ * @param channelId The ID of a document or context that the comment thread is handled.
665
+ * @param threadId The ID of the comment thread.
666
+ * @param isFromAdapter A flag describing whether the operation was done on a remote client (`true`) or a local one (`false`).
667
+ */
680
668
  export interface BaseCommentThread {
681
- channelId: string | symbol;
682
- threadId: string;
683
- isFromAdapter?: boolean;
669
+ channelId: string | symbol;
670
+ threadId: string;
671
+ isFromAdapter?: boolean;
684
672
  }
685
673
  /**
686
- * @param commentId The comment ID.
687
- */
674
+ * @param commentId The comment ID.
675
+ */
688
676
  export interface BaseComment extends BaseCommentThread {
689
- commentId: string;
677
+ commentId: string;
690
678
  }
691
679
  /**
692
- * @param content The comment content.
693
- * @param attributes Comment custom attributes.
694
- */
680
+ * @param content The comment content.
681
+ * @param attributes Comment custom attributes.
682
+ */
695
683
  export interface BaseCommentData {
696
- content: string;
697
- attributes: Record<string, any>;
684
+ content: string;
685
+ attributes: Record<string, any>;
698
686
  }
699
687
  /**
700
- * Fired whenever a comment thread is added to the comments repository.
701
- *
702
- * The event name includes `channelId` so it is possible to listen only
703
- * on changes happening in the specified channel.
704
- *
705
- * ```ts
706
- * const channelId = 'foo';
707
- *
708
- * commentsRepository.on( `addCommentThread:${ channelId }`, ( evt, data ) => {
709
- * console.log( evt, data );
710
- * } );
711
- * ```
712
- *
713
- * @eventName ~CommentsRepository#addCommentThread
714
- */
688
+ * Fired whenever a comment thread is added to the comments repository.
689
+ *
690
+ * The event name includes `channelId` so it is possible to listen only
691
+ * on changes happening in the specified channel.
692
+ *
693
+ * ```ts
694
+ * const channelId = 'foo';
695
+ *
696
+ * commentsRepository.on( `addCommentThread:${ channelId }`, ( evt, data ) => {
697
+ * console.log( evt, data );
698
+ * } );
699
+ * ```
700
+ *
701
+ * @eventName ~CommentsRepository#addCommentThread
702
+ */
715
703
  export type AddCommentThreadEvent = {
716
- name: string;
717
- args: [Required<AddCommentThreadEventData>];
704
+ name: string;
705
+ args: [Required<AddCommentThreadEventData>];
718
706
  };
719
707
  /**
720
- * @param context The comment ID.
721
- * @param attributes Comment thread custom attributes.
722
- * @param resolvedAt ID of the comment author.
723
- * @param resolvedBy The comment creation date.
724
- */
708
+ * @param context The comment ID.
709
+ * @param attributes Comment thread custom attributes.
710
+ * @param resolvedAt ID of the comment author.
711
+ * @param resolvedBy The comment creation date.
712
+ */
725
713
  export type CommentThreadData = BaseCommentThread & Partial<{
726
- context: CommentThreadContext;
727
- attributes: Record<string, any>;
728
- unlinkedAt: Date | null;
729
- resolvedAt: Date | null;
730
- resolvedBy: string | null;
714
+ context: CommentThreadContext;
715
+ attributes: Record<string, any>;
716
+ unlinkedAt: Date | null;
717
+ resolvedAt: Date | null;
718
+ resolvedBy: string | null;
731
719
  }>;
732
720
  /**
733
- * @param comments Comments in the comment thread.
734
- * @param target The target that the comment balloon should be attached to.
735
- */
721
+ * @param comments Comments in the comment thread.
722
+ * @param target The target that the comment balloon should be attached to.
723
+ */
736
724
  export type AddCommentThreadEventData = CommentThreadData & {
737
- comments?: Array<CommentData>;
738
- target?: AnnotationTarget;
739
- isResolvable?: boolean;
740
- isSubmitted?: boolean;
725
+ comments?: Array<CommentData>;
726
+ target?: AnnotationTarget;
727
+ isResolvable?: boolean;
728
+ isSubmitted?: boolean;
741
729
  };
742
730
  /**
743
- * Fired whenever a new comment thread is submitted and occurs after creating the first comment.
744
- *
745
- * The event name includes `channelId` so it is possible to listen only
746
- * on changes happening in the specified channel.
747
- *
748
- * ```ts
749
- * const channelId = 'foo';
750
- *
751
- * commentsRepository.on( `submitCommentThread:${ channelId }`, ( evt, data ) => {
752
- * console.log( evt, data );
753
- * } );
754
- * ```
755
- *
756
- * @eventName ~CommentsRepository#submitCommentThread
757
- */
731
+ * Fired whenever a new comment thread is submitted and occurs after creating the first comment.
732
+ *
733
+ * The event name includes `channelId` so it is possible to listen only
734
+ * on changes happening in the specified channel.
735
+ *
736
+ * ```ts
737
+ * const channelId = 'foo';
738
+ *
739
+ * commentsRepository.on( `submitCommentThread:${ channelId }`, ( evt, data ) => {
740
+ * console.log( evt, data );
741
+ * } );
742
+ * ```
743
+ *
744
+ * @eventName ~CommentsRepository#submitCommentThread
745
+ */
758
746
  export type SubmitCommentThreadEvent = {
759
- name: string;
760
- args: [BaseCommentThread];
747
+ name: string;
748
+ args: [BaseCommentThread];
761
749
  };
762
750
  /**
763
- * Fired whenever a comment thread is updated in comments repository.
764
- *
765
- * The event name includes `channelId` so it is possible to listen only
766
- * on changes happening in the specified channel.
767
- *
768
- * @eventName ~CommentsRepository#updateCommentThread
769
- */
751
+ * Fired whenever a comment thread is updated in comments repository.
752
+ *
753
+ * The event name includes `channelId` so it is possible to listen only
754
+ * on changes happening in the specified channel.
755
+ *
756
+ * @eventName ~CommentsRepository#updateCommentThread
757
+ */
770
758
  export type UpdateCommentThreadEvent = {
771
- name: string;
772
- args: [UpdateCommentThreadEventData];
759
+ name: string;
760
+ args: [UpdateCommentThreadEventData];
773
761
  };
774
- export type UpdateCommentThreadEventData = Omit<CommentThreadData, 'resolvedAt' | 'resolvedBy'>;
762
+ export type UpdateCommentThreadEventData = Omit<CommentThreadData, "resolvedAt" | "resolvedBy">;
775
763
  /**
776
- * Fired whenever a comment thread is resolved.
777
- *
778
- * The event name includes `channelId` so it is possible to listen only
779
- * on changes happening in the specified channel.
780
- *
781
- * ```ts
782
- * const channelId = 'foo';
783
- *
784
- * commentsRepository.on( `resolveCommentThread:${ channelId }`, ( evt, data ) => {
785
- * console.log( evt, data );
786
- * } );
787
- * ```
788
- *
789
- * @eventName ~CommentsRepository#resolveCommentThread
790
- */
764
+ * Fired whenever a comment thread is resolved.
765
+ *
766
+ * The event name includes `channelId` so it is possible to listen only
767
+ * on changes happening in the specified channel.
768
+ *
769
+ * ```ts
770
+ * const channelId = 'foo';
771
+ *
772
+ * commentsRepository.on( `resolveCommentThread:${ channelId }`, ( evt, data ) => {
773
+ * console.log( evt, data );
774
+ * } );
775
+ * ```
776
+ *
777
+ * @eventName ~CommentsRepository#resolveCommentThread
778
+ */
791
779
  export type ResolveCommentThreadEvent = {
792
- name: string;
793
- args: [ResolveCommentThreadEventData];
780
+ name: string;
781
+ args: [ResolveCommentThreadEventData];
794
782
  };
795
783
  export type ResolveCommentThreadEventData = BaseCommentThread & {
796
- resolvedAt: Date | null;
797
- resolvedBy: string | null;
784
+ resolvedAt: Date | null;
785
+ resolvedBy: string | null;
798
786
  };
799
787
  /**
800
- * Fired whenever a comment thread is reopened.
801
- *
802
- * The event name includes `channelId` so it is possible to listen only
803
- * on changes happening in the specified channel.
804
- *
805
- * ```ts
806
- * const channelId = 'foo';
807
- *
808
- * commentsRepository.on( `reopenCommentThread:${ channelId }`, ( evt, data ) => {
809
- * console.log( evt, data );
810
- * } );
811
- * ```
812
- *
813
- * @eventName ~CommentsRepository#reopenCommentThread
814
- */
788
+ * Fired whenever a comment thread is reopened.
789
+ *
790
+ * The event name includes `channelId` so it is possible to listen only
791
+ * on changes happening in the specified channel.
792
+ *
793
+ * ```ts
794
+ * const channelId = 'foo';
795
+ *
796
+ * commentsRepository.on( `reopenCommentThread:${ channelId }`, ( evt, data ) => {
797
+ * console.log( evt, data );
798
+ * } );
799
+ * ```
800
+ *
801
+ * @eventName ~CommentsRepository#reopenCommentThread
802
+ */
815
803
  export type ReopenCommentThreadEvent = {
816
- name: string;
817
- args: [BaseCommentThread];
804
+ name: string;
805
+ args: [BaseCommentThread];
818
806
  };
819
807
  /**
820
- * Fired whenever a comment thread is removed from the comments repository.
821
- *
822
- * The event name includes `channelId` so it is possible to listen only
823
- * on changes happening in the specified channel.
824
- *
825
- * ```ts
826
- * const channelId = 'foo';
827
- *
828
- * commentsRepository.on( `removeCommentThread:${ channelId }`, ( evt, data ) => {
829
- * console.log( evt, data );
830
- * } );
831
- * ```
832
- *
833
- * @eventName ~CommentsRepository#removeCommentThread
834
- */
808
+ * Fired whenever a comment thread is removed from the comments repository.
809
+ *
810
+ * The event name includes `channelId` so it is possible to listen only
811
+ * on changes happening in the specified channel.
812
+ *
813
+ * ```ts
814
+ * const channelId = 'foo';
815
+ *
816
+ * commentsRepository.on( `removeCommentThread:${ channelId }`, ( evt, data ) => {
817
+ * console.log( evt, data );
818
+ * } );
819
+ * ```
820
+ *
821
+ * @eventName ~CommentsRepository#removeCommentThread
822
+ */
835
823
  export type RemoveCommentThreadEvent = {
836
- name: string;
837
- args: [BaseCommentThread];
824
+ name: string;
825
+ args: [BaseCommentThread];
838
826
  };
839
827
  /**
840
- * Fired whenever a comment is added.
841
- *
842
- * The event name includes `channelId` so it is possible to listen only
843
- * on changes happening in the specified channel.
844
- *
845
- * It is also possible to listen to events from the given thread ID by appending `:[threadId]` part to the event name
846
- *
847
- * ```ts
848
- * const channelId = 'foo';
849
- * const threadId = '1234';
850
- *
851
- * commentsRepository.on( `addComment:${ channelId }:${ threadId }`, ( evt, data ) => {
852
- * console.log( evt, data );
853
- * } );
854
- * ```
855
- *
856
- * @eventName ~CommentsRepository#addComment
857
- */
828
+ * Fired whenever a comment is added.
829
+ *
830
+ * The event name includes `channelId` so it is possible to listen only
831
+ * on changes happening in the specified channel.
832
+ *
833
+ * It is also possible to listen to events from the given thread ID by appending `:[threadId]` part to the event name
834
+ *
835
+ * ```ts
836
+ * const channelId = 'foo';
837
+ * const threadId = '1234';
838
+ *
839
+ * commentsRepository.on( `addComment:${ channelId }:${ threadId }`, ( evt, data ) => {
840
+ * console.log( evt, data );
841
+ * } );
842
+ * ```
843
+ *
844
+ * @eventName ~CommentsRepository#addComment
845
+ */
858
846
  export type AddCommentEvent = {
859
- name: string;
860
- args: [CommentEventData];
847
+ name: string;
848
+ args: [CommentEventData];
861
849
  };
862
850
  /**
863
- * @param commentId The comment ID.
864
- * @param authorId ID of the comment author.
865
- * @param createdAt The comment creation date.
866
- * @param isFromAdapter A flag describing whether the comment was updated on a remote client (`true`) or a local one (`false`).
867
- */
851
+ * @param commentId The comment ID.
852
+ * @param authorId ID of the comment author.
853
+ * @param createdAt The comment creation date.
854
+ * @param isFromAdapter A flag describing whether the comment was updated on a remote client (`true`) or a local one (`false`).
855
+ */
868
856
  export type CommentData = BaseCommentData & {
869
- commentId?: string;
870
- authorId: string;
871
- createdAt: Date;
872
- isFromAdapter?: boolean;
857
+ commentId?: string;
858
+ authorId: string;
859
+ createdAt: Date;
860
+ isFromAdapter?: boolean;
873
861
  };
874
862
  export type CommentEventData = BaseCommentThread & CommentData;
875
863
  /**
876
- * Fired whenever a comment is updated.
877
- *
878
- * The event name includes `channelId` so it is possible to listen only
879
- * to changes happening in the specified channel.
880
- *
881
- * It is also possible to listen to events from the given thread ID by appending `:[threadId]` part to the event name
882
- *
883
- * ```ts
884
- * const channelId = 'foo';
885
- * const threadId = '1234';
886
- *
887
- * commentsRepository.on( `updateComment:${ channelId }:${ threadId }`, ( evt, data ) => {
888
- * console.log( evt, data );
889
- * } );
890
- * ```
891
- *
892
- * @eventName ~CommentsRepository#updateComment
893
- */
864
+ * Fired whenever a comment is updated.
865
+ *
866
+ * The event name includes `channelId` so it is possible to listen only
867
+ * to changes happening in the specified channel.
868
+ *
869
+ * It is also possible to listen to events from the given thread ID by appending `:[threadId]` part to the event name
870
+ *
871
+ * ```ts
872
+ * const channelId = 'foo';
873
+ * const threadId = '1234';
874
+ *
875
+ * commentsRepository.on( `updateComment:${ channelId }:${ threadId }`, ( evt, data ) => {
876
+ * console.log( evt, data );
877
+ * } );
878
+ * ```
879
+ *
880
+ * @eventName ~CommentsRepository#updateComment
881
+ */
894
882
  export type UpdateCommentEvent = {
895
- name: string;
896
- args: [UpdateCommentEventData];
883
+ name: string;
884
+ args: [UpdateCommentEventData];
897
885
  };
898
886
  export type UpdateCommentData = Partial<CommentEventData>;
899
887
  export type UpdateCommentEventData = UpdateCommentData & BaseComment;
900
888
  /**
901
- * Fired whenever a comment is removed.
902
- *
903
- * The event name includes `channelId` so it is possible to listen only
904
- * to changes happening in the specified channel.
905
- *
906
- * It is also possible to listen to events from the given thread ID by appending `:[threadId]` part to the event name
907
- *
908
- * ```ts
909
- * const channelId = 'foo';
910
- * const threadId = '1234';
911
- *
912
- * commentsRepository.on( `removeComment:${ channelId }:${ threadId }`, ( evt, data ) => {
913
- * console.log( evt, data );
914
- * } );
915
- * ```
916
- *
917
- * @eventName ~CommentsRepository#removeComment
918
- */
889
+ * Fired whenever a comment is removed.
890
+ *
891
+ * The event name includes `channelId` so it is possible to listen only
892
+ * to changes happening in the specified channel.
893
+ *
894
+ * It is also possible to listen to events from the given thread ID by appending `:[threadId]` part to the event name
895
+ *
896
+ * ```ts
897
+ * const channelId = 'foo';
898
+ * const threadId = '1234';
899
+ *
900
+ * commentsRepository.on( `removeComment:${ channelId }:${ threadId }`, ( evt, data ) => {
901
+ * console.log( evt, data );
902
+ * } );
903
+ * ```
904
+ *
905
+ * @eventName ~CommentsRepository#removeComment
906
+ */
919
907
  export type RemoveCommentEvent = {
920
- name: string;
921
- args: [BaseComment];
908
+ name: string;
909
+ args: [BaseComment];
922
910
  };
923
- export type CommentDataJSON = Omit<CommentData, 'isFromAdapter'>;
911
+ export type CommentDataJSON = Omit<CommentData, "isFromAdapter">;
924
912
  export type CommentThreadDataJSON = {
925
- threadId: string;
926
- context: CommentThreadContext;
927
- unlinkedAt: Date | null;
928
- resolvedAt: Date | null;
929
- resolvedBy: string | null;
930
- archivedAt: Date | null;
931
- comments: Array<CommentDataJSON>;
932
- attributes: Record<string, unknown>;
913
+ threadId: string;
914
+ context: CommentThreadContext;
915
+ unlinkedAt: Date | null;
916
+ resolvedAt: Date | null;
917
+ resolvedBy: string | null;
918
+ archivedAt: Date | null;
919
+ comments: Array<CommentDataJSON>;
920
+ attributes: Record<string, unknown>;
933
921
  };
934
922
  /**
935
- * Comments adapter.
936
- *
937
- * The comments adapter is an object that communicates asynchronously with the data source to fetch or save
938
- * the comment data. It is used internally by the comments feature whenever a comment is loaded, created or deleted.
939
- * The adapter is optional. You might need to provide it if you are {@glink features/collaboration/comments/comments-integration
940
- * using the comments feature without real-time collaboration}.
941
- * To set the adapter, overwrite the `CommentsRepository#adapter` property.
942
- */
923
+ * Comments adapter.
924
+ *
925
+ * The comments adapter is an object that communicates asynchronously with the data source to fetch or save
926
+ * the comment data. It is used internally by the comments feature whenever a comment is loaded, created or deleted.
927
+ * The adapter is optional. You might need to provide it if you are {@glink features/collaboration/comments/comments-integration
928
+ * using the comments feature without real-time collaboration}.
929
+ * To set the adapter, overwrite the `CommentsRepository#adapter` property.
930
+ */
943
931
  export interface CommentsAdapter {
944
- /**
945
- * Called whenever a new comment thread is created.
946
- *
947
- * The object which is passed as a parameter can contain the following properties:
948
- * * channelId: string | symbol;
949
- * * threadId: string;
950
- * * context?: {@link module:comments/comments/commentsrepository~CommentThreadContext CommentThreadContext};
951
- * * comments?: Array<{@link module:comments/comments/commentsrepository~CommentDataJSON CommentDataJSON}>;
952
- * * resolvedAt?: Date | null;
953
- * * resolvedBy?: string | null;
954
- * * attributes?: Record<string, any> | null;
955
- *
956
- * It should return a promise that resolves with the new comment thread data.
957
- * The resolved data object should contain the following properties:
958
- * * threadId: string;
959
- * * comments: Array<\{ commentId: string; createdAt: Date; \}>;
960
- */
961
- addCommentThread: (data: Omit<CommentThreadData, 'isFromAdapter'> & {
962
- comments: Array<CommentDataJSON>;
963
- }) => Promise<{
964
- threadId: string;
965
- comments: Array<{
966
- commentId: string;
967
- createdAt: Date;
968
- }>;
969
- }>;
970
- /**
971
- * Called when the editor needs the data for a comment thread.
972
- *
973
- * It should return a promise that resolves with the comment thread data.
974
- * The resolved data object should contain the following properties:
975
- * * threadId: string;
976
- * * comments: Array<\{ commentId?: string; authorId: string; createdAt: Date; content: string; attributes: Record<string, any>; \}>;
977
- * * resolvedAt?: Date | null;
978
- * * resolvedBy?: string | null;
979
- * * attributes: Record<string, unknown>;
980
- *
981
- * @param data.channelId The ID of the document or context to which the comment is added.
982
- * @param data.threadId The ID of the comment thread that the comment is added to.
983
- */
984
- getCommentThread: (data: Omit<BaseCommentThread, 'isFromAdapter'>) => Promise<{
985
- threadId: string;
986
- comments: Array<CommentData>;
987
- resolvedAt?: Date | null;
988
- resolvedBy?: string | null;
989
- attributes: Record<string, unknown>;
990
- } | null>;
991
- /**
992
- * Called each time the user changes the existing comment thread.
993
- *
994
- * Keep in mind that for security reasons, the `authorId`, `createdAt`, `resolvedBy` and `resolvedAt` properties
995
- * are not passed in the `updateCommentThread()` call and you should not set them as a result of this call.
996
- *
997
- * It updates the comment data in the database and returns a promise
998
- * that will be resolved when the update is completed.
999
- *
1000
- * The object which is passed as a parameter can contain the following properties:
1001
- * * channelId: string | symbol;
1002
- * * threadId: string;
1003
- * * context?: {@link module:comments/comments/commentsrepository~CommentThreadContext};
1004
- * * attributes?: Record<string, any> | null;
1005
- */
1006
- updateCommentThread: (data: Omit<UpdateCommentThreadEventData, 'isFromAdapter'>) => Promise<void>;
1007
- /**
1008
- * Called each time the user resolves a comment thread.
1009
- *
1010
- * Should set `resolvedAt` and `resolvedBy` properties in your database and should resolve with an object
1011
- * containing these two properties and returns a promise that will be resolved when the operation is completed.
1012
- *
1013
- * The resolved data object should contain the following properties:
1014
- * * threadId: string;
1015
- * * resolvedAt: Date;
1016
- * * resolvedBy: string;
1017
- *
1018
- * @param data.channelId The ID of the document or context that the comment thread is removed from.
1019
- * @param data.threadId The ID of the thread to remove.
1020
- */
1021
- resolveCommentThread: (data: Omit<BaseCommentThread, 'isFromAdapter'>) => Promise<{
1022
- threadId: string;
1023
- resolvedAt: Date;
1024
- resolvedBy: string;
1025
- }>;
1026
- /**
1027
- * Called when the user reopens a resolved comment thread.
1028
- *
1029
- * Should set `resolvedAt` and `resolvedBy` properties to `null` in your database and returns a promise
1030
- * that will be resolved when the operation is completed.
1031
- *
1032
- * @param data.channelId The ID of the document or context that the comment thread is removed from.
1033
- * @param data.threadId The ID of the thread to remove.
1034
- */
1035
- reopenCommentThread: (data: Omit<BaseCommentThread, 'isFromAdapter'>) => Promise<void>;
1036
- /**
1037
- * Called each time the user removes a comment thread.
1038
- *
1039
- * It should return a promise that resolves when the thread is removed.
1040
- *
1041
- * @param data.channelId The ID of the document or context that the comment thread is removed from.
1042
- * @param data.threadId The ID of the thread to remove.
1043
- */
1044
- removeCommentThread: (data: Omit<BaseCommentThread, 'isFromAdapter'>) => Promise<void>;
1045
- /**
1046
- * Called each time the user adds a new comment to a thread.
1047
- *
1048
- * It saves the comment data in the database and returns a promise
1049
- * that should get resolved when the save is completed.
1050
- *
1051
- * If the promise resolves with an object with the `createdAt` property, the
1052
- * comment property will be updated in the comment in the editor.
1053
- * This is to update the comment data with the server-side information.
1054
- *
1055
- * The `data` object does not expect the `authorId` property.
1056
- * For security reasons, the author of the comment should be set
1057
- * on the server side.
1058
- *
1059
- * The `data` object does not expect the `createdAt` property either.
1060
- * You should use the server-side time generator to ensure that all users
1061
- * see the same date.
1062
- *
1063
- * It is recommended to stringify the `data.attributes` value to JSON
1064
- * and to save it as a string in your database and then to parse the
1065
- * value from JSON when loading comments.
1066
- *
1067
- * The object which is passed as a parameter can contain the following properties:
1068
- * * channelId: string | symbol;
1069
- * * threadId: string;
1070
- * * commentId: string;
1071
- * * content: string;
1072
- * * attributes: Record<string, any>;
1073
- *
1074
- * The resolved data object should contain the following properties:
1075
- * * commentId: string;
1076
- * * createdAt: Date;
1077
- *
1078
- * @param data.channelId The ID of the document or context to which the comment is added.
1079
- * @param data.threadId The ID of the comment thread that the comment is added to.
1080
- * @param data.commentId The comment ID.
1081
- * @param data.content The comment content.
1082
- * @param data.attributes Comment custom attributes.
1083
- */
1084
- addComment: (data: Omit<BaseComment, 'isFromAdapter'> & BaseCommentData) => Promise<{
1085
- commentId: string;
1086
- createdAt: Date;
1087
- }>;
1088
- /**
1089
- * Called each time the user changes the existing comment.
1090
- *
1091
- * It updates the comment data in the database and returns a promise
1092
- * that will be resolved when the update is completed.
1093
- *
1094
- * Keep in mind that the `data` parameter only contains the
1095
- * properties of a comment that have changed.
1096
- *
1097
- * The object which is passed as a parameter can contain the following properties:
1098
- * * channelId: string | symbol;
1099
- * * threadId: string;
1100
- * * commentId: string;
1101
- * * content?: string;
1102
- * * attributes?: Record<string, any>;
1103
- *
1104
- * @param data.channelId The ID of the document or context where the comment is updated.
1105
- * @param data.threadId The ID of the comment thread where the comment is updated.
1106
- * @param data.commentId The ID of the comment to update.
1107
- * @param data.content The new content of the comment.
1108
- * @param data.attributes Custom comment attributes.
1109
- */
1110
- updateComment: (data: Omit<BaseComment, 'isFromAdapter'> & Partial<BaseCommentData>) => Promise<void>;
1111
- /**
1112
- * Called each time the user removes a comment from the thread.
1113
- *
1114
- * It removes the comment from the database and returns a promise
1115
- * that will be resolved when the removal is completed.
1116
- *
1117
- * @param data.channelId The ID of the document or context that the comment is removed from.
1118
- * @param data.threadId The ID of the comment thread that the comment is removed from.
1119
- * @param data.commentId The ID of the comment to remove.
1120
- */
1121
- removeComment: (data: Omit<BaseComment, 'isFromAdapter'>) => Promise<void>;
932
+ /**
933
+ * Called whenever a new comment thread is created.
934
+ *
935
+ * The object which is passed as a parameter can contain the following properties:
936
+ * * channelId: string | symbol;
937
+ * * threadId: string;
938
+ * * context?: {@link module:comments/comments/commentsrepository~CommentThreadContext CommentThreadContext};
939
+ * * comments?: Array<{@link module:comments/comments/commentsrepository~CommentDataJSON CommentDataJSON}>;
940
+ * * resolvedAt?: Date | null;
941
+ * * resolvedBy?: string | null;
942
+ * * attributes?: Record<string, any> | null;
943
+ *
944
+ * It should return a promise that resolves with the new comment thread data.
945
+ * The resolved data object should contain the following properties:
946
+ * * threadId: string;
947
+ * * comments: Array<\{ commentId: string; createdAt: Date; \}>;
948
+ */
949
+ addCommentThread: (data: Omit<CommentThreadData, "isFromAdapter"> & {
950
+ comments: Array<CommentDataJSON>;
951
+ }) => Promise<{
952
+ threadId: string;
953
+ comments: Array<{
954
+ commentId: string;
955
+ createdAt: Date;
956
+ }>;
957
+ }>;
958
+ /**
959
+ * Called when the editor needs the data for a comment thread.
960
+ *
961
+ * It should return a promise that resolves with the comment thread data.
962
+ * The resolved data object should contain the following properties:
963
+ * * threadId: string;
964
+ * * comments: Array<\{ commentId?: string; authorId: string; createdAt: Date; content: string; attributes: Record<string, any>; \}>;
965
+ * * resolvedAt?: Date | null;
966
+ * * resolvedBy?: string | null;
967
+ * * attributes: Record<string, unknown>;
968
+ *
969
+ * @param data.channelId The ID of the document or context to which the comment is added.
970
+ * @param data.threadId The ID of the comment thread that the comment is added to.
971
+ */
972
+ getCommentThread: (data: Omit<BaseCommentThread, "isFromAdapter">) => Promise<{
973
+ threadId: string;
974
+ comments: Array<CommentData>;
975
+ resolvedAt?: Date | null;
976
+ resolvedBy?: string | null;
977
+ attributes: Record<string, unknown>;
978
+ } | null>;
979
+ /**
980
+ * Called each time the user changes the existing comment thread.
981
+ *
982
+ * Keep in mind that for security reasons, the `authorId`, `createdAt`, `resolvedBy` and `resolvedAt` properties
983
+ * are not passed in the `updateCommentThread()` call and you should not set them as a result of this call.
984
+ *
985
+ * It updates the comment data in the database and returns a promise
986
+ * that will be resolved when the update is completed.
987
+ *
988
+ * The object which is passed as a parameter can contain the following properties:
989
+ * * channelId: string | symbol;
990
+ * * threadId: string;
991
+ * * context?: {@link module:comments/comments/commentsrepository~CommentThreadContext};
992
+ * * attributes?: Record<string, any> | null;
993
+ */
994
+ updateCommentThread: (data: Omit<UpdateCommentThreadEventData, "isFromAdapter">) => Promise<void>;
995
+ /**
996
+ * Called each time the user resolves a comment thread.
997
+ *
998
+ * Should set `resolvedAt` and `resolvedBy` properties in your database and should resolve with an object
999
+ * containing these two properties and returns a promise that will be resolved when the operation is completed.
1000
+ *
1001
+ * The resolved data object should contain the following properties:
1002
+ * * threadId: string;
1003
+ * * resolvedAt: Date;
1004
+ * * resolvedBy: string;
1005
+ *
1006
+ * @param data.channelId The ID of the document or context that the comment thread is removed from.
1007
+ * @param data.threadId The ID of the thread to remove.
1008
+ */
1009
+ resolveCommentThread: (data: Omit<BaseCommentThread, "isFromAdapter">) => Promise<{
1010
+ threadId: string;
1011
+ resolvedAt: Date;
1012
+ resolvedBy: string;
1013
+ }>;
1014
+ /**
1015
+ * Called when the user reopens a resolved comment thread.
1016
+ *
1017
+ * Should set `resolvedAt` and `resolvedBy` properties to `null` in your database and returns a promise
1018
+ * that will be resolved when the operation is completed.
1019
+ *
1020
+ * @param data.channelId The ID of the document or context that the comment thread is removed from.
1021
+ * @param data.threadId The ID of the thread to remove.
1022
+ */
1023
+ reopenCommentThread: (data: Omit<BaseCommentThread, "isFromAdapter">) => Promise<void>;
1024
+ /**
1025
+ * Called each time the user removes a comment thread.
1026
+ *
1027
+ * It should return a promise that resolves when the thread is removed.
1028
+ *
1029
+ * @param data.channelId The ID of the document or context that the comment thread is removed from.
1030
+ * @param data.threadId The ID of the thread to remove.
1031
+ */
1032
+ removeCommentThread: (data: Omit<BaseCommentThread, "isFromAdapter">) => Promise<void>;
1033
+ /**
1034
+ * Called each time the user adds a new comment to a thread.
1035
+ *
1036
+ * It saves the comment data in the database and returns a promise
1037
+ * that should get resolved when the save is completed.
1038
+ *
1039
+ * If the promise resolves with an object with the `createdAt` property, the
1040
+ * comment property will be updated in the comment in the editor.
1041
+ * This is to update the comment data with the server-side information.
1042
+ *
1043
+ * The `data` object does not expect the `authorId` property.
1044
+ * For security reasons, the author of the comment should be set
1045
+ * on the server side.
1046
+ *
1047
+ * The `data` object does not expect the `createdAt` property either.
1048
+ * You should use the server-side time generator to ensure that all users
1049
+ * see the same date.
1050
+ *
1051
+ * It is recommended to stringify the `data.attributes` value to JSON
1052
+ * and to save it as a string in your database and then to parse the
1053
+ * value from JSON when loading comments.
1054
+ *
1055
+ * The object which is passed as a parameter can contain the following properties:
1056
+ * * channelId: string | symbol;
1057
+ * * threadId: string;
1058
+ * * commentId: string;
1059
+ * * content: string;
1060
+ * * attributes: Record<string, any>;
1061
+ *
1062
+ * The resolved data object should contain the following properties:
1063
+ * * commentId: string;
1064
+ * * createdAt: Date;
1065
+ *
1066
+ * @param data.channelId The ID of the document or context to which the comment is added.
1067
+ * @param data.threadId The ID of the comment thread that the comment is added to.
1068
+ * @param data.commentId The comment ID.
1069
+ * @param data.content The comment content.
1070
+ * @param data.attributes Comment custom attributes.
1071
+ */
1072
+ addComment: (data: Omit<BaseComment, "isFromAdapter"> & BaseCommentData) => Promise<{
1073
+ commentId: string;
1074
+ createdAt: Date;
1075
+ }>;
1076
+ /**
1077
+ * Called each time the user changes the existing comment.
1078
+ *
1079
+ * It updates the comment data in the database and returns a promise
1080
+ * that will be resolved when the update is completed.
1081
+ *
1082
+ * Keep in mind that the `data` parameter only contains the
1083
+ * properties of a comment that have changed.
1084
+ *
1085
+ * The object which is passed as a parameter can contain the following properties:
1086
+ * * channelId: string | symbol;
1087
+ * * threadId: string;
1088
+ * * commentId: string;
1089
+ * * content?: string;
1090
+ * * attributes?: Record<string, any>;
1091
+ *
1092
+ * @param data.channelId The ID of the document or context where the comment is updated.
1093
+ * @param data.threadId The ID of the comment thread where the comment is updated.
1094
+ * @param data.commentId The ID of the comment to update.
1095
+ * @param data.content The new content of the comment.
1096
+ * @param data.attributes Custom comment attributes.
1097
+ */
1098
+ updateComment: (data: Omit<BaseComment, "isFromAdapter"> & Partial<BaseCommentData>) => Promise<void>;
1099
+ /**
1100
+ * Called each time the user removes a comment from the thread.
1101
+ *
1102
+ * It removes the comment from the database and returns a promise
1103
+ * that will be resolved when the removal is completed.
1104
+ *
1105
+ * @param data.channelId The ID of the document or context that the comment is removed from.
1106
+ * @param data.threadId The ID of the comment thread that the comment is removed from.
1107
+ * @param data.commentId The ID of the comment to remove.
1108
+ */
1109
+ removeComment: (data: Omit<BaseComment, "isFromAdapter">) => Promise<void>;
1122
1110
  }
1123
1111
  export {};