@ckeditor/ckeditor5-comments 41.3.1 → 41.4.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 (265) hide show
  1. package/build/comments.js +1 -1
  2. package/build/translations/ti.js +1 -0
  3. package/dist/index-content.css +4 -0
  4. package/dist/index-editor.css +596 -0
  5. package/dist/index.css +990 -0
  6. package/dist/index.js +23 -0
  7. package/dist/translations/af.d.ts +8 -0
  8. package/dist/translations/af.js +23 -0
  9. package/dist/translations/af.umd.js +23 -0
  10. package/dist/translations/ar.d.ts +8 -0
  11. package/dist/translations/ar.js +23 -0
  12. package/dist/translations/ar.umd.js +23 -0
  13. package/dist/translations/bg.d.ts +8 -0
  14. package/dist/translations/bg.js +23 -0
  15. package/dist/translations/bg.umd.js +23 -0
  16. package/dist/translations/bn.d.ts +8 -0
  17. package/dist/translations/bn.js +23 -0
  18. package/dist/translations/bn.umd.js +23 -0
  19. package/dist/translations/bs.d.ts +8 -0
  20. package/dist/translations/bs.js +23 -0
  21. package/dist/translations/bs.umd.js +23 -0
  22. package/dist/translations/ca.d.ts +8 -0
  23. package/dist/translations/ca.js +23 -0
  24. package/dist/translations/ca.umd.js +23 -0
  25. package/dist/translations/cs.d.ts +8 -0
  26. package/dist/translations/cs.js +23 -0
  27. package/dist/translations/cs.umd.js +23 -0
  28. package/dist/translations/da.d.ts +8 -0
  29. package/dist/translations/da.js +23 -0
  30. package/dist/translations/da.umd.js +23 -0
  31. package/dist/translations/de-ch.d.ts +8 -0
  32. package/dist/translations/de-ch.js +23 -0
  33. package/dist/translations/de-ch.umd.js +23 -0
  34. package/dist/translations/de.d.ts +8 -0
  35. package/dist/translations/de.js +23 -0
  36. package/dist/translations/de.umd.js +23 -0
  37. package/dist/translations/el.d.ts +8 -0
  38. package/dist/translations/el.js +23 -0
  39. package/dist/translations/el.umd.js +23 -0
  40. package/dist/translations/en-au.d.ts +8 -0
  41. package/dist/translations/en-au.js +23 -0
  42. package/dist/translations/en-au.umd.js +23 -0
  43. package/dist/translations/en.d.ts +8 -0
  44. package/dist/translations/en.js +23 -0
  45. package/dist/translations/en.umd.js +23 -0
  46. package/dist/translations/es-co.d.ts +8 -0
  47. package/dist/translations/es-co.js +23 -0
  48. package/dist/translations/es-co.umd.js +23 -0
  49. package/dist/translations/es.d.ts +8 -0
  50. package/dist/translations/es.js +23 -0
  51. package/dist/translations/es.umd.js +23 -0
  52. package/dist/translations/et.d.ts +8 -0
  53. package/dist/translations/et.js +23 -0
  54. package/dist/translations/et.umd.js +23 -0
  55. package/dist/translations/fa.d.ts +8 -0
  56. package/dist/translations/fa.js +23 -0
  57. package/dist/translations/fa.umd.js +23 -0
  58. package/dist/translations/fi.d.ts +8 -0
  59. package/dist/translations/fi.js +23 -0
  60. package/dist/translations/fi.umd.js +23 -0
  61. package/dist/translations/fr.d.ts +8 -0
  62. package/dist/translations/fr.js +23 -0
  63. package/dist/translations/fr.umd.js +23 -0
  64. package/dist/translations/gl.d.ts +8 -0
  65. package/dist/translations/gl.js +23 -0
  66. package/dist/translations/gl.umd.js +23 -0
  67. package/dist/translations/he.d.ts +8 -0
  68. package/dist/translations/he.js +23 -0
  69. package/dist/translations/he.umd.js +23 -0
  70. package/dist/translations/hi.d.ts +8 -0
  71. package/dist/translations/hi.js +23 -0
  72. package/dist/translations/hi.umd.js +23 -0
  73. package/dist/translations/hr.d.ts +8 -0
  74. package/dist/translations/hr.js +23 -0
  75. package/dist/translations/hr.umd.js +23 -0
  76. package/dist/translations/hu.d.ts +8 -0
  77. package/dist/translations/hu.js +23 -0
  78. package/dist/translations/hu.umd.js +23 -0
  79. package/dist/translations/id.d.ts +8 -0
  80. package/dist/translations/id.js +23 -0
  81. package/dist/translations/id.umd.js +23 -0
  82. package/dist/translations/it.d.ts +8 -0
  83. package/dist/translations/it.js +23 -0
  84. package/dist/translations/it.umd.js +23 -0
  85. package/dist/translations/ja.d.ts +8 -0
  86. package/dist/translations/ja.js +23 -0
  87. package/dist/translations/ja.umd.js +23 -0
  88. package/dist/translations/jv.d.ts +8 -0
  89. package/dist/translations/jv.js +23 -0
  90. package/dist/translations/jv.umd.js +23 -0
  91. package/dist/translations/ko.d.ts +8 -0
  92. package/dist/translations/ko.js +23 -0
  93. package/dist/translations/ko.umd.js +23 -0
  94. package/dist/translations/lt.d.ts +8 -0
  95. package/dist/translations/lt.js +23 -0
  96. package/dist/translations/lt.umd.js +23 -0
  97. package/dist/translations/lv.d.ts +8 -0
  98. package/dist/translations/lv.js +23 -0
  99. package/dist/translations/lv.umd.js +23 -0
  100. package/dist/translations/ms.d.ts +8 -0
  101. package/dist/translations/ms.js +23 -0
  102. package/dist/translations/ms.umd.js +23 -0
  103. package/dist/translations/nl.d.ts +8 -0
  104. package/dist/translations/nl.js +23 -0
  105. package/dist/translations/nl.umd.js +23 -0
  106. package/dist/translations/no.d.ts +8 -0
  107. package/dist/translations/no.js +23 -0
  108. package/dist/translations/no.umd.js +23 -0
  109. package/dist/translations/pl.d.ts +8 -0
  110. package/dist/translations/pl.js +23 -0
  111. package/dist/translations/pl.umd.js +23 -0
  112. package/dist/translations/pt-br.d.ts +8 -0
  113. package/dist/translations/pt-br.js +23 -0
  114. package/dist/translations/pt-br.umd.js +23 -0
  115. package/dist/translations/pt.d.ts +8 -0
  116. package/dist/translations/pt.js +23 -0
  117. package/dist/translations/pt.umd.js +23 -0
  118. package/dist/translations/ro.d.ts +8 -0
  119. package/dist/translations/ro.js +23 -0
  120. package/dist/translations/ro.umd.js +23 -0
  121. package/dist/translations/ru.d.ts +8 -0
  122. package/dist/translations/ru.js +23 -0
  123. package/dist/translations/ru.umd.js +23 -0
  124. package/dist/translations/sk.d.ts +8 -0
  125. package/dist/translations/sk.js +23 -0
  126. package/dist/translations/sk.umd.js +23 -0
  127. package/dist/translations/sq.d.ts +8 -0
  128. package/dist/translations/sq.js +23 -0
  129. package/dist/translations/sq.umd.js +23 -0
  130. package/dist/translations/sr-latn.d.ts +8 -0
  131. package/dist/translations/sr-latn.js +23 -0
  132. package/dist/translations/sr-latn.umd.js +23 -0
  133. package/dist/translations/sr.d.ts +8 -0
  134. package/dist/translations/sr.js +23 -0
  135. package/dist/translations/sr.umd.js +23 -0
  136. package/dist/translations/sv.d.ts +8 -0
  137. package/dist/translations/sv.js +23 -0
  138. package/dist/translations/sv.umd.js +23 -0
  139. package/dist/translations/th.d.ts +8 -0
  140. package/dist/translations/th.js +23 -0
  141. package/dist/translations/th.umd.js +23 -0
  142. package/dist/translations/ti.d.ts +8 -0
  143. package/dist/translations/ti.js +23 -0
  144. package/dist/translations/ti.umd.js +23 -0
  145. package/dist/translations/tk.d.ts +8 -0
  146. package/dist/translations/tk.js +23 -0
  147. package/dist/translations/tk.umd.js +23 -0
  148. package/dist/translations/tr.d.ts +8 -0
  149. package/dist/translations/tr.js +23 -0
  150. package/dist/translations/tr.umd.js +23 -0
  151. package/dist/translations/tt.d.ts +8 -0
  152. package/dist/translations/tt.js +23 -0
  153. package/dist/translations/tt.umd.js +23 -0
  154. package/dist/translations/ug.d.ts +8 -0
  155. package/dist/translations/ug.js +23 -0
  156. package/dist/translations/ug.umd.js +23 -0
  157. package/dist/translations/uk.d.ts +8 -0
  158. package/dist/translations/uk.js +23 -0
  159. package/dist/translations/uk.umd.js +23 -0
  160. package/dist/translations/ur.d.ts +8 -0
  161. package/dist/translations/ur.js +23 -0
  162. package/dist/translations/ur.umd.js +23 -0
  163. package/dist/translations/vi.d.ts +8 -0
  164. package/dist/translations/vi.js +23 -0
  165. package/dist/translations/vi.umd.js +23 -0
  166. package/dist/translations/zh-cn.d.ts +8 -0
  167. package/dist/translations/zh-cn.js +23 -0
  168. package/dist/translations/zh-cn.umd.js +23 -0
  169. package/dist/translations/zh.d.ts +8 -0
  170. package/dist/translations/zh.js +23 -0
  171. package/dist/translations/zh.umd.js +23 -0
  172. package/dist/types/annotations/annotation.d.ts +94 -0
  173. package/dist/types/annotations/annotationcollection.d.ts +102 -0
  174. package/dist/types/annotations/annotations.d.ts +158 -0
  175. package/dist/types/annotations/annotationsuis.d.ts +236 -0
  176. package/dist/types/annotations/editorannotations.d.ts +71 -0
  177. package/dist/types/annotations/inlineannotations.d.ts +94 -0
  178. package/dist/types/annotations/narrowsidebar.d.ts +89 -0
  179. package/dist/types/annotations/sidebar.d.ts +104 -0
  180. package/dist/types/annotations/view/annotationcounterbuttonview.d.ts +33 -0
  181. package/dist/types/annotations/view/annotationview.d.ts +94 -0
  182. package/dist/types/annotations/view/sidebaritemview.d.ts +59 -0
  183. package/dist/types/annotations/view/sidebarview.d.ts +36 -0
  184. package/dist/types/annotations/widesidebar.d.ts +81 -0
  185. package/dist/types/augmentation.d.ts +56 -0
  186. package/dist/types/comments/addcommentthreadcommand.d.ts +39 -0
  187. package/dist/types/comments/commentsarchive.d.ts +35 -0
  188. package/dist/types/comments/commentsarchiveui.d.ts +42 -0
  189. package/dist/types/comments/commentsediting.d.ts +84 -0
  190. package/dist/types/comments/commentsrepository.d.ts +1134 -0
  191. package/dist/types/comments/commentsui.d.ts +37 -0
  192. package/dist/types/comments/integrations/clipboard.d.ts +30 -0
  193. package/dist/types/comments/integrations/commentsrestrictededitingmode.d.ts +21 -0
  194. package/dist/types/comments/integrations/importword.d.ts +25 -0
  195. package/dist/types/comments/ui/commenteditor/commenteditor.d.ts +40 -0
  196. package/dist/types/comments/ui/commenteditor/commenteditorui.d.ts +35 -0
  197. package/dist/types/comments/ui/commenteditor/commenteditoruiview.d.ts +40 -0
  198. package/dist/types/comments/ui/commentthreadcontroller.d.ts +68 -0
  199. package/dist/types/comments/ui/view/basecommentthreadview.d.ts +123 -0
  200. package/dist/types/comments/ui/view/basecommentview.d.ts +116 -0
  201. package/dist/types/comments/ui/view/collapsedcommentsview.d.ts +17 -0
  202. package/dist/types/comments/ui/view/commentcontentview.d.ts +18 -0
  203. package/dist/types/comments/ui/view/commentinputview.d.ts +90 -0
  204. package/dist/types/comments/ui/view/commentsarchiveview.d.ts +42 -0
  205. package/dist/types/comments/ui/view/commentslistview.d.ts +104 -0
  206. package/dist/types/comments/ui/view/commentthreadheaderview.d.ts +54 -0
  207. package/dist/types/comments/ui/view/commentthreadinputview.d.ts +45 -0
  208. package/dist/types/comments/ui/view/commentthreadview.d.ts +122 -0
  209. package/dist/types/comments/ui/view/commentview.d.ts +247 -0
  210. package/dist/types/comments.d.ts +39 -0
  211. package/dist/types/commentsonly.d.ts +37 -0
  212. package/dist/types/config.d.ts +202 -0
  213. package/dist/types/index.d.ts +28 -0
  214. package/dist/types/utils/common-translations.d.ts +13 -0
  215. package/dist/types/utils/createmutationobserver.d.ts +18 -0
  216. package/lang/translations/ti.po +120 -0
  217. package/package.json +4 -3
  218. package/src/annotations/annotation.js +1 -1
  219. package/src/annotations/annotationcollection.js +1 -1
  220. package/src/annotations/annotations.js +1 -1
  221. package/src/annotations/annotationsuis.js +1 -1
  222. package/src/annotations/editorannotations.js +1 -1
  223. package/src/annotations/inlineannotations.js +1 -1
  224. package/src/annotations/narrowsidebar.js +1 -1
  225. package/src/annotations/sidebar.js +1 -1
  226. package/src/annotations/view/annotationcounterbuttonview.js +1 -1
  227. package/src/annotations/view/annotationview.js +1 -1
  228. package/src/annotations/view/sidebaritemview.js +1 -1
  229. package/src/annotations/view/sidebarview.js +1 -1
  230. package/src/annotations/widesidebar.js +1 -1
  231. package/src/comments/addcommentthreadcommand.js +1 -1
  232. package/src/comments/commentsarchive.js +1 -1
  233. package/src/comments/commentsarchiveui.js +1 -1
  234. package/src/comments/commentsediting.js +1 -1
  235. package/src/comments/commentsrepository.d.ts +1 -1
  236. package/src/comments/commentsrepository.js +1 -1
  237. package/src/comments/commentsui.js +1 -1
  238. package/src/comments/integrations/clipboard.js +1 -1
  239. package/src/comments/integrations/commentsrestrictededitingmode.js +1 -1
  240. package/src/comments/integrations/importword.js +1 -1
  241. package/src/comments/ui/commenteditor/commenteditor.js +1 -1
  242. package/src/comments/ui/commenteditor/commenteditorui.js +1 -1
  243. package/src/comments/ui/commenteditor/commenteditoruiview.js +1 -1
  244. package/src/comments/ui/commentthreadcontroller.js +1 -1
  245. package/src/comments/ui/view/basecommentthreadview.js +1 -1
  246. package/src/comments/ui/view/basecommentview.js +1 -1
  247. package/src/comments/ui/view/collapsedcommentsview.js +1 -1
  248. package/src/comments/ui/view/commentcontentview.js +1 -1
  249. package/src/comments/ui/view/commentinputview.js +1 -1
  250. package/src/comments/ui/view/commentsarchiveview.js +1 -1
  251. package/src/comments/ui/view/commentslistview.js +1 -1
  252. package/src/comments/ui/view/commentthreadheaderview.js +1 -1
  253. package/src/comments/ui/view/commentthreadinputview.js +1 -1
  254. package/src/comments/ui/view/commentthreadview.js +1 -1
  255. package/src/comments/ui/view/commentview.js +1 -1
  256. package/src/comments.js +1 -1
  257. package/src/commentsonly.js +1 -1
  258. package/src/index.js +1 -1
  259. package/src/utils/common-translations.js +1 -1
  260. package/src/utils/createmutationobserver.js +1 -1
  261. package/theme/annotation.css +13 -0
  262. package/theme/comment.css +4 -0
  263. package/theme/commentinput.css +4 -0
  264. package/theme/commentthread.css +8 -0
  265. package/theme/sidebar.css +8 -0
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ *
4
+ *
5
+ *
6
+ *
7
+ * +---------------------------------------------------------------------------------+
8
+ * | |
9
+ * | Hello stranger! |
10
+ * | |
11
+ * | |
12
+ * | What you're currently looking at is the source code of a legally protected, |
13
+ * | proprietary software. Any attempts to deobfuscate / disassemble this code |
14
+ * | are forbidden and will result in legal consequences. |
15
+ * | |
16
+ * | |
17
+ * +---------------------------------------------------------------------------------+
18
+ *
19
+ *
20
+ *
21
+ *
22
+ */
23
+ export default{'zh':{'dictionary':{'Comment\x20editor':'留言編輯器','NUMBER_OF_COMMENTS':'%0\x20則留言','TOO_LONG_COMMENT_ALERT':'留言內容太長。你的留言有\x20%0\x20個字,上限字數為\x20%1。','Reply...':'回覆...','Reply\x20to\x20reopen\x20discussion...':'回覆以重新開啟討論...','Write\x20a\x20comment...':'撰寫留言...','Comment\x20was\x20made\x20on\x20an\x20element':'對元件進行的留言','Edit':'編輯','Resolve':'解決','Reopen':'重新開啟','Remove':'刪除','Reply':'回覆','Delete\x20comment?':'刪除留言?','Delete\x20comment\x20thread?':'刪除討論串?','Marked\x20as\x20resolved':'已標記為解決','Comment':'留言','ENTER_COMMENT_ANNOUNCEMENT':'正在進入留言。','LEAVE_COMMENT_ANNOUNCEMENT':'正在留下留言。','PENDING_ACTION_COMMENT_THREAD':'討論串尚未儲存。','EXTERNAL_COMMENT':'此留言來自外部來源。','EXTERNAL_IMPORT_WORD_COMMENT':'此留言來自匯入的\x20Word\x20檔案。','EXTERNAL_AVATAR':'顯示的作者名稱來自外部來源(由\x20%0\x20新增)','EXTERNAL_IMPORT_WORD_AVATAR':'顯示的作者名稱來自由\x20%0\x20匯入的\x20Word\x20文件','COMMENTS_ARCHIVE':'留言封存紀錄','EMPTY_COMMENTS_ARCHIVE':'無封存的留言串。'},'getPluralForm':_0x346ee1=>0x0}};
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ *
4
+ *
5
+ *
6
+ *
7
+ * +---------------------------------------------------------------------------------+
8
+ * | |
9
+ * | Hello stranger! |
10
+ * | |
11
+ * | |
12
+ * | What you're currently looking at is the source code of a legally protected, |
13
+ * | proprietary software. Any attempts to deobfuscate / disassemble this code |
14
+ * | are forbidden and will result in legal consequences. |
15
+ * | |
16
+ * | |
17
+ * +---------------------------------------------------------------------------------+
18
+ *
19
+ *
20
+ *
21
+ *
22
+ */
23
+ (_0x2027e6=>{const {zh:{dictionary:_0xdf3b1e,getPluralForm:_0x1ca23c}}={'zh':{'dictionary':{'Comment\x20editor':'留言編輯器','NUMBER_OF_COMMENTS':'%0\x20則留言','TOO_LONG_COMMENT_ALERT':'留言內容太長。你的留言有\x20%0\x20個字,上限字數為\x20%1。','Reply...':'回覆...','Reply\x20to\x20reopen\x20discussion...':'回覆以重新開啟討論...','Write\x20a\x20comment...':'撰寫留言...','Comment\x20was\x20made\x20on\x20an\x20element':'對元件進行的留言','Edit':'編輯','Resolve':'解決','Reopen':'重新開啟','Remove':'刪除','Reply':'回覆','Delete\x20comment?':'刪除留言?','Delete\x20comment\x20thread?':'刪除討論串?','Marked\x20as\x20resolved':'已標記為解決','Comment':'留言','ENTER_COMMENT_ANNOUNCEMENT':'正在進入留言。','LEAVE_COMMENT_ANNOUNCEMENT':'正在留下留言。','PENDING_ACTION_COMMENT_THREAD':'討論串尚未儲存。','EXTERNAL_COMMENT':'此留言來自外部來源。','EXTERNAL_IMPORT_WORD_COMMENT':'此留言來自匯入的\x20Word\x20檔案。','EXTERNAL_AVATAR':'顯示的作者名稱來自外部來源(由\x20%0\x20新增)','EXTERNAL_IMPORT_WORD_AVATAR':'顯示的作者名稱來自由\x20%0\x20匯入的\x20Word\x20文件','COMMENTS_ARCHIVE':'留言封存紀錄','EMPTY_COMMENTS_ARCHIVE':'無封存的留言串。'},'getPluralForm':_0x10d2f8=>0x0}};_0x2027e6['zh']||={'dictionary':{},'getPluralForm':null},_0x2027e6['zh']['dictionary']=Object['assign'](_0x2027e6['zh']['dictionary'],_0xdf3b1e),_0x2027e6['zh']['getPluralForm']=_0x1ca23c;})(window['CKEDITOR_TRANSLATIONS']||={});
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module comments/annotations/annotation
11
+ * @publicApi
12
+ */
13
+ import { Rect, Collection } from 'ckeditor5/src/utils.js';
14
+ import type { View } from 'ckeditor5/src/ui.js';
15
+ import type AnnotationView from './view/annotationview.js';
16
+ import type { AnnotationOptions } from './annotations.js';
17
+ declare const Annotation_base: {
18
+ new (): import("ckeditor5/src/utils.js").Observable;
19
+ prototype: import("ckeditor5/src/utils.js").Observable;
20
+ };
21
+ /**
22
+ * Represents an annotation.
23
+ *
24
+ * Annotation is an entity that combines an {@link module:comments/annotations/view/annotationview~AnnotationView}
25
+ * and an annotation target (a DOM element or a {@link module:utils/dom/rect~Rect}) to which the annotation is bound.
26
+ */
27
+ export default class Annotation extends Annotation_base {
28
+ /**
29
+ * The visibility of the annotation. Annotations that are not visible, are filtered from Annotation UI collections.
30
+ *
31
+ * @observable
32
+ */
33
+ isVisible: boolean;
34
+ /**
35
+ * The annotation view.
36
+ */
37
+ view: AnnotationView;
38
+ /**
39
+ * A collection of DOM elements which, when focused, make the annotation active.
40
+ *
41
+ * By default, this collection only contains the annotation view element.
42
+ * It can be extended with custom targets that will be tracked by the annotation focus tracking system.
43
+ */
44
+ focusableElements: Collection<HTMLElement>;
45
+ /**
46
+ * Creates an instance of the {@link module:comments/annotations/annotation~Annotation}.
47
+ */
48
+ constructor({ view, target, type, isVisible }: AnnotationOptions);
49
+ /**
50
+ * The type of the annotation.
51
+ */
52
+ get type(): string;
53
+ /**
54
+ * The annotation inner view.
55
+ *
56
+ * It is the view that is wrapped by the annotation view.*
57
+ */
58
+ get innerView(): View;
59
+ /**
60
+ * The annotation target to which the annotation view should be pinned.
61
+ *
62
+ * It can be an array of DOM elements or {@link module:utils/dom/rect~Rect a rect instance} or `null`.
63
+ */
64
+ get target(): Rect | Array<HTMLElement> | null;
65
+ /**
66
+ * The position and dimensions of the annotation target to which the annotation is bound.
67
+ */
68
+ get targetRect(): Rect | null;
69
+ /**
70
+ * The state of the annotation.
71
+ */
72
+ get isActive(): boolean;
73
+ set isActive(value: boolean);
74
+ /**
75
+ * Updates the target rect in the annotation view instance.
76
+ */
77
+ updateTargetRect(): void;
78
+ /**
79
+ * Clears all event listeners and internal collections.
80
+ */
81
+ destroy(): void;
82
+ /**
83
+ * Refreshes the visibility of the annotation based on the visibility of the annotation target.
84
+ *
85
+ * It sets the {@link #isVisible} property when the target is not attached to DOM or if the target or its descendant has
86
+ * set the `display` attribute to `none`.
87
+ *
88
+ * This method only updates an annotation if the annotation target is an HTML Element.
89
+ */
90
+ refreshVisibility(): void;
91
+ }
92
+ type Target = Rect | HTMLElement | null;
93
+ export type AnnotationTarget = Target | (() => Target | Array<Target>);
94
+ export {};
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module comments/annotations/annotationcollection
11
+ * @publicApi
12
+ */
13
+ import { Collection } from 'ckeditor5/src/utils.js';
14
+ import type { View } from 'ckeditor5/src/ui.js';
15
+ import type Annotation from './annotation.js';
16
+ /**
17
+ * A collection of {@link module:comments/annotations/annotation~Annotation annotations}.
18
+ *
19
+ * It implements methods for managing annotations and creates a focus tracker for them to make it easier to manage
20
+ * the focus for all annotations.
21
+ *
22
+ * `AnnotationCollection` fires {@link module:comments/annotations/annotationcollection~AnnotationCollection#event:focus} when an annotation
23
+ * becomes focused and {@link module:comments/annotations/annotationcollection~AnnotationCollection#event:blur} when all annotations
24
+ * lose focus.
25
+ */
26
+ export default class AnnotationCollection extends Collection<Annotation> {
27
+ /**
28
+ * @param annotations Initial annotations.
29
+ */
30
+ constructor(annotations?: Iterable<Annotation>);
31
+ /**
32
+ * Equals to `true` when one of the annotation in the collection is focused.
33
+ */
34
+ get isFocused(): boolean;
35
+ /**
36
+ * Adds an annotation to the collection.
37
+ */
38
+ add(annotation: Annotation): this;
39
+ /**
40
+ * Removes the annotation from the collection.
41
+ */
42
+ remove(annotation: Annotation): Annotation;
43
+ /**
44
+ * Gets the annotation for a given annotation view's inner view.
45
+ */
46
+ getByInnerView(innerView: View): Annotation | undefined;
47
+ /**
48
+ * Gets the annotation for a given annotation view.
49
+ */
50
+ getByView(view: View): Annotation | undefined;
51
+ /**
52
+ * Destroys all bindings and clears the collection.
53
+ */
54
+ destroy(): void;
55
+ /**
56
+ * Refreshes the positioning of all annotations and sorts them topmost and leftmost.
57
+ */
58
+ refreshPositioning(): void;
59
+ }
60
+ /**
61
+ * Fired when an annotation becomes active.
62
+ *
63
+ * @eventName ~AnnotationCollection#focus
64
+ * @param annotation An annotation that was focused.
65
+ */
66
+ export type AnnotationFocusEvent = {
67
+ name: 'focus';
68
+ args: [annotation: Annotation];
69
+ };
70
+ /**
71
+ * Fired when all annotations become blurred.
72
+ *
73
+ * @eventName ~AnnotationCollection#blur
74
+ */
75
+ export type AnnotationBlurEvent = {
76
+ name: 'blur';
77
+ args: [];
78
+ };
79
+ /**
80
+ * A helper function that binds two {@link module:comments/annotations/annotationcollection~AnnotationCollection AnnotationCollection}s
81
+ * and allows filtering items based on the passed callback.
82
+ *
83
+ * Since {@link module:comments/annotations/annotationcollection~AnnotationCollection#refreshPositioning}
84
+ * sorts the annotations by removing and inserting items, the binding implemented by the `bindTo()` method is lost. This is why
85
+ * this helper needs to be used.
86
+ *
87
+ * This helper is used by the annotations UIs to filter which annotations from the
88
+ * {@link module:comments/annotations/annotations~Annotations#collection main annotation collection} should be handled by
89
+ * a given annotations UI.
90
+ *
91
+ * @param `options.source` The source collection
92
+ * from which the annotations will be taken.
93
+ * @param `options.target` The target collection
94
+ * that will be synced to the source collection.
95
+ * @param options.filter Filtering function that gets an annotation and should return `true` if the annotation should be
96
+ * copied to the `target` collection.
97
+ */
98
+ export declare function bindAnnotationCollections({ source, target, filter }: {
99
+ source: AnnotationCollection;
100
+ target: AnnotationCollection;
101
+ filter: (annotation: Annotation) => boolean;
102
+ }): void;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module comments/annotations/annotations
11
+ * @publicApi
12
+ */
13
+ import { ContextPlugin, type Context, type Editor } from 'ckeditor5/src/core.js';
14
+ import type { View } from 'ckeditor5/src/ui.js';
15
+ import { type Locale } from 'ckeditor5/src/utils.js';
16
+ import Annotation, { type AnnotationTarget } from './annotation.js';
17
+ import AnnotationCollection from './annotationcollection.js';
18
+ import AnnotationView, { type AnnotationMainView } from './view/annotationview.js';
19
+ /**
20
+ * Stores and manages all {@link module:comments/annotations/annotation~Annotation annotations} created
21
+ * for the entire {@link module:core/context~Context} or {@link module:core/editor/editor~Editor}.
22
+ *
23
+ * It allows for {@link module:comments/annotations/annotations~Annotations#add adding} and
24
+ * {@link module:comments/annotations/annotations~Annotations#remove removing} annotations.
25
+ *
26
+ * It manages {@link module:comments/annotations/annotations~Annotations#activate activating} and
27
+ * {@link module:comments/annotations/annotations~Annotations#deactivateAll deactivating} annotations. Using those methods will
28
+ * result in setting {@link module:comments/annotations/annotationsuis~AnnotationUI#activeAnnotation} in the appropriate
29
+ * {@link module:comments/annotations/annotationsuis~AnnotationsUI annotations UI} plugins.
30
+ *
31
+ * All active annotations are stored in {@link module:comments/annotations/annotations~Annotations#activeAnnotations}.
32
+ *
33
+ * `Annotations` is linked with {@link module:comments/annotations/annotationsuis~AnnotationsUIs}, which listens to events fired by
34
+ * `Annotations` and propagates information to and from annotations UI plugins.
35
+ */
36
+ export default class Annotations extends ContextPlugin {
37
+ /**
38
+ * A set of currently active annotations.
39
+ *
40
+ * @observable
41
+ */
42
+ activeAnnotations: Set<Annotation>;
43
+ /**
44
+ * A collection of all annotations. It should not be operated on directly.
45
+ */
46
+ readonly collection: AnnotationCollection;
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ static get pluginName(): "Annotations";
51
+ /**
52
+ * @inheritDoc
53
+ */
54
+ constructor(context: Context | Editor);
55
+ /**
56
+ * Adds an annotation to the collection.
57
+ */
58
+ add(annotation: Annotation): void;
59
+ /**
60
+ * Removes the given annotation from the collection.
61
+ */
62
+ remove(annotation: Annotation): void;
63
+ /**
64
+ * Refreshes the visibility of annotations based on the visibility of their annotation targets.
65
+ *
66
+ * This method should be called when one or more annotations' targets changed their visibility,
67
+ * for example when one of the editors was shown or hidden.
68
+ *
69
+ * This method recalculates all annotations' {@link module:comments/annotations/annotation~Annotation#isVisible `isVisible`} property.
70
+ */
71
+ refreshVisibility(): void;
72
+ /**
73
+ * Refreshes the positioning of all visible annotations and sorts them topmost and leftmost.
74
+ */
75
+ refreshPositioning(): void;
76
+ /**
77
+ * Returns the annotation that "contains" the given annotation view's inner view.
78
+ */
79
+ getByInnerView(innerView: View): Annotation | undefined;
80
+ /**
81
+ * Deactivates all active annotations.
82
+ *
83
+ * @fires _deactivateAllAnnotations
84
+ */
85
+ deactivateAll(): void;
86
+ /**
87
+ * @inheritDoc
88
+ */
89
+ destroy(): void;
90
+ /**
91
+ * Activates the given annotation.
92
+ *
93
+ * If annotations UI that handles the given annotation already has an active annotation,
94
+ * then it deactivates it and activates the provided one.
95
+ *
96
+ * @fires _activateAnnotation
97
+ */
98
+ activate(annotation: Annotation): void;
99
+ /**
100
+ * Creates an annotation.
101
+ *
102
+ * ```ts
103
+ * const annotationView = annotations.createAnnotationView( editor.locale, innerView );
104
+ *
105
+ * const annotation = annotations.createAnnotation( {
106
+ * view: annotationView,
107
+ * target: document.getElementById( 'target' ),
108
+ * type: 'comment'
109
+ * } );
110
+ * ```
111
+ *
112
+ * @returns An annotation.
113
+ */
114
+ createAnnotation(options: AnnotationOptions): Annotation;
115
+ /**
116
+ * Creates an annotation view wrapper for the annotation content.
117
+ *
118
+ * ```ts
119
+ * const innerView = createCustomView();
120
+ * const annotationView = annotations.createAnnotationView( editor.locale, innerView );
121
+ * ```
122
+ *
123
+ * @returns An annotation view.
124
+ */
125
+ createAnnotationView(locale: Locale, view: AnnotationMainView): AnnotationView;
126
+ }
127
+ /**
128
+ * The configuration options which are used to create new {@link module:comments/annotations/annotation~Annotation annotations}.
129
+ *
130
+ * @param view The annotation view.
131
+ * @param target The annotation target.
132
+ * @param type The annotation type.
133
+ * @param isVisible The initial visibility of the annotation.
134
+ */
135
+ export interface AnnotationOptions {
136
+ view: AnnotationView;
137
+ target: AnnotationTarget;
138
+ type: string | (() => string);
139
+ isVisible?: boolean;
140
+ }
141
+ /**
142
+ * An internal event that fires when the annotation should be activated.
143
+ *
144
+ * @eventName ~Annotations#_activateAnnotation
145
+ */
146
+ export type ActivateAnnotationEvent = {
147
+ name: '_activateAnnotation';
148
+ args: [annotation: Annotation];
149
+ };
150
+ /**
151
+ * An internal event that fires when all annotations should be deactivated.
152
+ *
153
+ * @eventName ~Annotations#_deactivateAllAnnotations
154
+ */
155
+ export type DeactivateAllAnnotationsEvent = {
156
+ name: '_deactivateAllAnnotations';
157
+ args: [];
158
+ };
@@ -0,0 +1,236 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module comments/annotations/annotationsuis
11
+ * @publicApi
12
+ */
13
+ import { ContextPlugin, type Plugin, type Editor, type Context } from 'ckeditor5/src/core.js';
14
+ import { type Emitter } from 'ckeditor5/src/utils.js';
15
+ import AnnotationCollection from './annotationcollection.js';
16
+ import Annotations from './annotations.js';
17
+ import type Annotation from './annotation.js';
18
+ /**
19
+ * A repository of annotations UIs.
20
+ *
21
+ * The main entry point for {@link module:comments/annotations/annotationsuis~AnnotationsUIs#register registering} UIs
22
+ * and activating the annotations UI(s), which display annotation views.
23
+ *
24
+ * To register a custom annotations UI use following code in the annotations UI plugin `init()` function:
25
+ *
26
+ * ```ts
27
+ * const annotationsUIs = editor.plugins.get( 'annotationsUIs' );
28
+ *
29
+ * annotationsUIs.register( customAnnotationsUIPlugin );
30
+ * ```
31
+ *
32
+ * Note that the custom annotations UI must implement {@link module:comments/annotations/annotationsuis~AnnotationsUI
33
+ * the `AnnotationsUI` interface}.
34
+ *
35
+ * To activate an annotations UI, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#switchTo
36
+ * `switchTo( uiName )`} method. This method activates the given UI and deactivates all the other UIs.
37
+ * All annotations will be handled by the activated UI.
38
+ *
39
+ * It is also possible to activate multiple annotations UIs at the same time and make the UIs handle different sets of annotations.
40
+ * To do that, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate `activate( uiName, filter )`} method.
41
+ *
42
+ * ```ts
43
+ * // Suggestions annotations are shown inline in a balloon:
44
+ * annotationsUIs.activate( 'inline', annotation => annotation.type.startsWith( 'suggestion' ) );
45
+ *
46
+ * // At the same time, comments annotations are shown in a sidebar:
47
+ * annotationsUIs.activate( 'wideSidebar', annotation => annotation.type === 'comment' );
48
+ * ```
49
+ *
50
+ * Limitations:
51
+ *
52
+ * * Some annotations UI plugins might collide with each other (like {@link module:comments/annotations/narrowsidebar~NarrowSidebar} and
53
+ * {@link module:comments/annotations/widesidebar~WideSidebar} that operates on the same sidebar). They cannot be activated at the same
54
+ * time.
55
+ * * It is not possible to display the same annotation in two different annotations UIs. In this scenario an error will be thrown.
56
+ */
57
+ export default class AnnotationsUIs extends ContextPlugin {
58
+ /**
59
+ * A set of names of the active annotations UIs.
60
+ *
61
+ * To activate the annotations UI, use {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate}
62
+ * or {@link #switchTo} methods.
63
+ */
64
+ activeUIs: Set<string>;
65
+ /**
66
+ * @inheritDoc
67
+ */
68
+ static get requires(): readonly [typeof Annotations];
69
+ /**
70
+ * @inheritDoc
71
+ */
72
+ static get pluginName(): "AnnotationsUIs";
73
+ /**
74
+ * @inheritDoc
75
+ */
76
+ constructor(context: Context | Editor);
77
+ /**
78
+ * @inheritDoc
79
+ */
80
+ init(): void;
81
+ /**
82
+ * Returns `true` if at least one registered UI is active.
83
+ */
84
+ hasActive(): boolean;
85
+ /**
86
+ * Returns `true` if the given UI is active.
87
+ */
88
+ isActive(uiName: string): boolean;
89
+ /**
90
+ * Activates an annotations UI.
91
+ *
92
+ * Note that the custom annotations UI should be {@link #register registered} before the activation.
93
+ *
94
+ * The `filter` parameter can be used to display on some of the annotations in the given annotations UI. Thanks to that,
95
+ * all annotations can be split into various annotations UIs.
96
+ *
97
+ * The `filter` function takes an {@link module:comments/annotations/annotation~Annotation} instance as the first and only parameter,
98
+ * and should return `true` if that annotation should be placed in the given annotations UI.
99
+ *
100
+ * @param uiName The name of the annotations UI to activate.
101
+ * @param filter The annotation filter function. If not specified, the UI will use all annotations.
102
+ */
103
+ activate(uiName: string, filter?: () => boolean): void;
104
+ /**
105
+ * Deactivates annotations UI with given name.
106
+ *
107
+ * @param uiName The name of the annotations UI to deactivate.
108
+ */
109
+ deactivate(uiName: string): void;
110
+ /**
111
+ * Switches the annotations UI to the one with given name.
112
+ *
113
+ * It preserves the currently active annotation.
114
+ *
115
+ * @param uiName The name of the annotations UI to switch to.
116
+ */
117
+ switchTo(uiName: string): void;
118
+ /**
119
+ * Deactivates all annotations UIs.
120
+ */
121
+ deactivateAll(): void;
122
+ /**
123
+ * Registers an annotations UI. It might be one of:
124
+ *
125
+ * * {@link module:comments/annotations/widesidebar~WideSidebar},
126
+ * * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
127
+ * * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
128
+ *
129
+ * It is possible to provide your own, custom annotations UI plugin. It has to implement
130
+ * {@link module:comments/annotations/annotationsuis~AnnotationsUI the `AnnotationsUI` interface}.
131
+ *
132
+ * @param uiName Annotations UI name.
133
+ * @param annotationsUI Annotations UI plugin instance.
134
+ */
135
+ register(uiName: string, annotationsUI: AnnotationsUI<ContextPlugin | Plugin>): void;
136
+ /**
137
+ * Refilters annotations to proper UIs based on filters provided earlier during the
138
+ * {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate annotations UIs activation}.
139
+ *
140
+ * This method should be used if the annotations UIs filtering functions return different results than before
141
+ * for some annotations. It only reattaches these annotations, which should change their UIs.
142
+ */
143
+ refilterAnnotations(): void;
144
+ /**
145
+ * @inheritDoc
146
+ */
147
+ destroy(): void;
148
+ }
149
+ /**
150
+ * An interface for the annotations UI plugin class.
151
+ *
152
+ * The annotations UI class handles displaying, focusing, activating and hiding annotations views.
153
+ *
154
+ * The annotations UI class must be a plugin, so it has to extend the {@link module:core/plugin~Plugin} or
155
+ * {@link module:core/contextplugin~ContextPlugin} class.
156
+ *
157
+ * Examples of `AnnotationsUI` are:
158
+ *
159
+ * * {@link module:comments/annotations/widesidebar~WideSidebar},
160
+ * * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
161
+ * * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
162
+ *
163
+ * You can use the following snippet as a base for your own annotations UI:
164
+ *
165
+ * ```ts
166
+ * class MyAnnotationsUI extends ContextPlugin {
167
+ * constructor( ...args ) {
168
+ * super( ...args );
169
+ *
170
+ * this.set( 'activeAnnotation', null );
171
+ * }
172
+ *
173
+ * attach( annotations ) {
174
+ * // Do something when an annotation is added.
175
+ * this.listenTo( annotations, 'add', ( evt, annotation ) => { ... } );
176
+ *
177
+ * // Do something when an annotation is removed.
178
+ * this.listenTo( annotations, 'remove', ( evt, annotation ) => { ... } );
179
+ * }
180
+ *
181
+ * detach() {
182
+ * this.stopListening();
183
+ * }
184
+ *
185
+ * setActiveAnnotation( annotation ) {
186
+ * if ( this.activeAnnotation ) {
187
+ * this.activeAnnotation.isActive = false;
188
+ *
189
+ * // You can do something in your UI with the annotation that is no longer active.
190
+ * }
191
+ *
192
+ * this.activeAnnotation = annotation;
193
+ * this.activeAnnotation.isActive = true;
194
+ *
195
+ * // You can do something in your UI to highlight the active annotation.
196
+ * }
197
+ * }
198
+ * ```
199
+ */
200
+ export interface AnnotationUI {
201
+ /**
202
+ * Observable `activeAnnotation` property. {@link module:comments/annotations/annotationsuis~AnnotationsUIs} listens to changes on that
203
+ * property.
204
+ *
205
+ * To make this property observable use `this.set( 'activeAnnotation', null )` in the constructor.
206
+ */
207
+ activeAnnotation: Annotation | null;
208
+ /**
209
+ * Creates everything needed for the UI and attaches all listeners. This method is called when the UI is activated.
210
+ *
211
+ * The observable collection of annotations is passed as the first argument,
212
+ * and the annotations UI is responsible for reacting to its changes.
213
+ */
214
+ attach: (annotationCollection: AnnotationCollection) => void;
215
+ /**
216
+ * Destroys the UI and removes all listeners. This method is called when the UI is deactivated.
217
+ */
218
+ detach: () => void;
219
+ /**
220
+ * Sets or unsets the active annotation. This method is called when an annotation is activated, for example, user puts their
221
+ * selection into a marker connected with given annotation.
222
+ *
223
+ * This method should change the UI so the new active annotation is differentiated from other annotations.
224
+ *
225
+ * This method should set the
226
+ * {@link #activeAnnotation `AnnotationUI#activeAnnotation`} property.
227
+ *
228
+ * It also should set {@link module:comments/annotations/annotation~Annotation#isActive `Annotation#isActive`} of the deactivated
229
+ * and the activated annotation.
230
+ *
231
+ * @param annotation The new active annotation or null when no annotation is active.
232
+ */
233
+ setActiveAnnotation: (annotation: Annotation | null) => void;
234
+ _setSelectedAnnotations?: (annotations: Array<Annotation>) => void;
235
+ }
236
+ export type AnnotationsUI<T extends Emitter> = T & AnnotationUI;