@ckeditor/ckeditor5-comments 36.0.1 → 37.0.0-rc.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 (202) hide show
  1. package/build/comments.js +2 -2
  2. package/build/translations/af.js +1 -1
  3. package/build/translations/ar.js +1 -1
  4. package/build/translations/bg.js +1 -1
  5. package/build/translations/bn.js +1 -1
  6. package/build/translations/bs.js +1 -1
  7. package/build/translations/ca.js +1 -1
  8. package/build/translations/cs.js +1 -1
  9. package/build/translations/da.js +1 -1
  10. package/build/translations/de-ch.js +1 -1
  11. package/build/translations/de.js +1 -1
  12. package/build/translations/el.js +1 -1
  13. package/build/translations/en-au.js +1 -1
  14. package/build/translations/es-co.js +1 -1
  15. package/build/translations/es.js +1 -1
  16. package/build/translations/et.js +1 -1
  17. package/build/translations/fa.js +1 -1
  18. package/build/translations/fi.js +1 -1
  19. package/build/translations/fr.js +1 -1
  20. package/build/translations/gl.js +1 -1
  21. package/build/translations/he.js +1 -1
  22. package/build/translations/hi.js +1 -1
  23. package/build/translations/hr.js +1 -1
  24. package/build/translations/hu.js +1 -1
  25. package/build/translations/id.js +1 -1
  26. package/build/translations/it.js +1 -1
  27. package/build/translations/ja.js +1 -1
  28. package/build/translations/jv.js +1 -1
  29. package/build/translations/ko.js +1 -1
  30. package/build/translations/lt.js +1 -1
  31. package/build/translations/lv.js +1 -1
  32. package/build/translations/ms.js +1 -1
  33. package/build/translations/nl.js +1 -1
  34. package/build/translations/no.js +1 -1
  35. package/build/translations/pl.js +1 -1
  36. package/build/translations/pt-br.js +1 -1
  37. package/build/translations/pt.js +1 -1
  38. package/build/translations/ro.js +1 -1
  39. package/build/translations/ru.js +1 -1
  40. package/build/translations/sk.js +1 -1
  41. package/build/translations/sr-latn.js +1 -1
  42. package/build/translations/sr.js +1 -1
  43. package/build/translations/sv.js +1 -1
  44. package/build/translations/th.js +1 -1
  45. package/build/translations/tk.js +1 -1
  46. package/build/translations/tr.js +1 -1
  47. package/build/translations/tt.js +1 -1
  48. package/build/translations/ug.js +1 -1
  49. package/build/translations/uk.js +1 -1
  50. package/build/translations/ur.js +1 -1
  51. package/build/translations/vi.js +1 -1
  52. package/build/translations/zh-cn.js +1 -1
  53. package/build/translations/zh.js +1 -1
  54. package/lang/contexts.json +8 -1
  55. package/lang/translations/af.po +28 -0
  56. package/lang/translations/ar.po +28 -0
  57. package/lang/translations/bg.po +28 -0
  58. package/lang/translations/bn.po +28 -0
  59. package/lang/translations/bs.po +28 -0
  60. package/lang/translations/ca.po +28 -0
  61. package/lang/translations/cs.po +28 -0
  62. package/lang/translations/da.po +28 -0
  63. package/lang/translations/de-ch.po +28 -0
  64. package/lang/translations/de.po +28 -0
  65. package/lang/translations/el.po +28 -0
  66. package/lang/translations/en-au.po +28 -0
  67. package/lang/translations/en.po +28 -0
  68. package/lang/translations/es-co.po +28 -0
  69. package/lang/translations/es.po +28 -0
  70. package/lang/translations/et.po +28 -0
  71. package/lang/translations/fa.po +28 -0
  72. package/lang/translations/fi.po +28 -0
  73. package/lang/translations/fr.po +28 -0
  74. package/lang/translations/gl.po +28 -0
  75. package/lang/translations/he.po +28 -0
  76. package/lang/translations/hi.po +28 -0
  77. package/lang/translations/hr.po +28 -0
  78. package/lang/translations/hu.po +28 -0
  79. package/lang/translations/id.po +28 -0
  80. package/lang/translations/it.po +28 -0
  81. package/lang/translations/ja.po +28 -0
  82. package/lang/translations/jv.po +28 -0
  83. package/lang/translations/ko.po +28 -0
  84. package/lang/translations/lt.po +28 -0
  85. package/lang/translations/lv.po +28 -0
  86. package/lang/translations/ms.po +28 -0
  87. package/lang/translations/nl.po +28 -0
  88. package/lang/translations/no.po +28 -0
  89. package/lang/translations/pl.po +28 -0
  90. package/lang/translations/pt-br.po +28 -0
  91. package/lang/translations/pt.po +28 -0
  92. package/lang/translations/ro.po +28 -0
  93. package/lang/translations/ru.po +28 -0
  94. package/lang/translations/sk.po +28 -0
  95. package/lang/translations/sr-latn.po +28 -0
  96. package/lang/translations/sr.po +29 -1
  97. package/lang/translations/sv.po +28 -0
  98. package/lang/translations/th.po +28 -0
  99. package/lang/translations/tk.po +28 -0
  100. package/lang/translations/tr.po +28 -0
  101. package/lang/translations/tt.po +28 -0
  102. package/lang/translations/ug.po +28 -0
  103. package/lang/translations/uk.po +28 -0
  104. package/lang/translations/ur.po +28 -0
  105. package/lang/translations/vi.po +28 -0
  106. package/lang/translations/zh-cn.po +28 -0
  107. package/lang/translations/zh.po +28 -0
  108. package/package.json +19 -3
  109. package/src/annotations/annotation.d.ts +86 -0
  110. package/src/annotations/annotation.js +1 -1
  111. package/src/annotations/annotationcollection.d.ts +94 -0
  112. package/src/annotations/annotationcollection.js +1 -1
  113. package/src/annotations/annotations.d.ts +150 -0
  114. package/src/annotations/annotations.js +1 -1
  115. package/src/annotations/annotationsuis.d.ts +227 -0
  116. package/src/annotations/annotationsuis.js +1 -1
  117. package/src/annotations/editorannotations.d.ts +62 -0
  118. package/src/annotations/editorannotations.js +1 -1
  119. package/src/annotations/inlineannotations.d.ts +84 -0
  120. package/src/annotations/inlineannotations.js +1 -1
  121. package/src/annotations/narrowsidebar.d.ts +80 -0
  122. package/src/annotations/narrowsidebar.js +1 -1
  123. package/src/annotations/sidebar.d.ts +96 -0
  124. package/src/annotations/sidebar.js +1 -1
  125. package/src/annotations/view/annotationcounterbuttonview.d.ts +25 -0
  126. package/src/annotations/view/annotationcounterbuttonview.js +1 -1
  127. package/src/annotations/view/annotationview.d.ts +86 -0
  128. package/src/annotations/view/annotationview.js +1 -1
  129. package/src/annotations/view/sidebaritemview.d.ts +51 -0
  130. package/src/annotations/view/sidebaritemview.js +1 -1
  131. package/src/annotations/view/sidebarview.d.ts +28 -0
  132. package/src/annotations/view/sidebarview.js +1 -1
  133. package/src/annotations/widesidebar.d.ts +72 -0
  134. package/src/annotations/widesidebar.js +1 -1
  135. package/src/augmentation.d.ts +54 -0
  136. package/src/augmentation.js +23 -0
  137. package/src/comments/addcommentthreadcommand.d.ts +31 -0
  138. package/src/comments/addcommentthreadcommand.js +1 -1
  139. package/src/comments/commentsarchive.d.ts +25 -0
  140. package/src/comments/commentsarchive.js +23 -0
  141. package/src/comments/commentsarchiveui.d.ts +32 -0
  142. package/src/comments/commentsarchiveui.js +23 -0
  143. package/src/comments/commentsediting.d.ts +71 -0
  144. package/src/comments/commentsediting.js +1 -1
  145. package/src/comments/commentsrepository.d.ts +1009 -0
  146. package/src/comments/commentsrepository.js +1 -1
  147. package/src/comments/commentsui.d.ts +25 -0
  148. package/src/comments/commentsui.js +1 -1
  149. package/src/comments/integrations/commentsrestrictededitingmode.d.ts +13 -0
  150. package/src/comments/integrations/commentsrestrictededitingmode.js +1 -1
  151. package/src/comments/integrations/importword.d.ts +17 -0
  152. package/src/comments/integrations/importword.js +1 -1
  153. package/src/comments/ui/commenteditor/commenteditor.d.ts +32 -0
  154. package/src/comments/ui/commenteditor/commenteditor.js +1 -1
  155. package/src/comments/ui/commenteditor/commenteditorui.d.ts +27 -0
  156. package/src/comments/ui/commenteditor/commenteditorui.js +1 -1
  157. package/src/comments/ui/commenteditor/commenteditoruiview.d.ts +32 -0
  158. package/src/comments/ui/commenteditor/commenteditoruiview.js +1 -1
  159. package/src/comments/ui/commentthreadcontroller.d.ts +64 -0
  160. package/src/comments/ui/commentthreadcontroller.js +1 -1
  161. package/src/comments/ui/view/basecommentthreadview.d.ts +108 -0
  162. package/src/comments/ui/view/basecommentthreadview.js +1 -1
  163. package/src/comments/ui/view/basecommentview.d.ts +108 -0
  164. package/src/comments/ui/view/basecommentview.js +1 -1
  165. package/src/comments/ui/view/collapsedcommentsview.d.ts +9 -0
  166. package/src/comments/ui/view/collapsedcommentsview.js +1 -1
  167. package/src/comments/ui/view/commentcontentview.d.ts +10 -0
  168. package/src/comments/ui/view/commentcontentview.js +1 -1
  169. package/src/comments/ui/view/commentinputview.d.ts +76 -0
  170. package/src/comments/ui/view/commentinputview.js +1 -1
  171. package/src/comments/ui/view/commentsarchiveview.d.ts +34 -0
  172. package/src/comments/ui/view/commentsarchiveview.js +23 -0
  173. package/src/comments/ui/view/commentslistview.d.ts +96 -0
  174. package/src/comments/ui/view/commentslistview.js +1 -1
  175. package/src/comments/ui/view/commentthreadheaderview.d.ts +46 -0
  176. package/src/comments/ui/view/commentthreadheaderview.js +23 -0
  177. package/src/comments/ui/view/commentthreadinputview.d.ts +37 -0
  178. package/src/comments/ui/view/commentthreadinputview.js +1 -1
  179. package/src/comments/ui/view/commentthreadview.d.ts +108 -0
  180. package/src/comments/ui/view/commentthreadview.js +1 -1
  181. package/src/comments/ui/view/commentview.d.ts +231 -0
  182. package/src/comments/ui/view/commentview.js +1 -1
  183. package/src/comments.d.ts +22 -0
  184. package/src/comments.js +1 -1
  185. package/src/commentsonly.d.ts +28 -0
  186. package/src/commentsonly.js +1 -1
  187. package/src/config.d.ts +172 -0
  188. package/src/config.js +23 -0
  189. package/src/index.d.ts +19 -0
  190. package/src/index.js +1 -1
  191. package/src/utils/common-translations.d.ts +5 -0
  192. package/src/utils/common-translations.js +1 -1
  193. package/src/utils/createmutationobserver.d.ts +13 -0
  194. package/src/utils/createmutationobserver.js +1 -1
  195. package/theme/annotation.css +1 -0
  196. package/theme/comment.css +31 -0
  197. package/theme/commentsarchive.css +40 -0
  198. package/theme/commentthread.css +68 -1
  199. package/theme/icons/add-comment.svg +1 -1
  200. package/theme/icons/comments-archive.svg +11 -0
  201. package/theme/icons/undo.svg +1 -0
  202. package/theme/sidebar.css +4 -0
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @module comments/annotations/annotations
3
+ * @publicApi
4
+ */
5
+ import { ContextPlugin, type Context, type Editor } from 'ckeditor5/src/core';
6
+ import type { View } from 'ckeditor5/src/ui';
7
+ import { type Locale } from 'ckeditor5/src/utils';
8
+ import Annotation, { type AnnotationTarget } from './annotation';
9
+ import AnnotationCollection from './annotationcollection';
10
+ import AnnotationView, { type AnnotationMainView } from './view/annotationview';
11
+ /**
12
+ * Stores and manages all {@link module:comments/annotations/annotation~Annotation annotations} created
13
+ * for the entire {@link module:core/context~Context} or {@link module:core/editor/editor~Editor}.
14
+ *
15
+ * It allows for {@link module:comments/annotations/annotations~Annotations#add adding} and
16
+ * {@link module:comments/annotations/annotations~Annotations#remove removing} annotations.
17
+ *
18
+ * It manages {@link module:comments/annotations/annotations~Annotations#activate activating} and
19
+ * {@link module:comments/annotations/annotations~Annotations#deactivateAll deactivating} annotations. Using those methods will
20
+ * result in setting {@link module:comments/annotations/annotationsuis~AnnotationUI#activeAnnotation} in the appropriate
21
+ * {@link module:comments/annotations/annotationsuis~AnnotationsUI annotations UI} plugins.
22
+ *
23
+ * All active annotations are stored in {@link module:comments/annotations/annotations~Annotations#activeAnnotations}.
24
+ *
25
+ * `Annotations` is linked with {@link module:comments/annotations/annotationsuis~AnnotationsUIs}, which listens to events fired by
26
+ * `Annotations` and propagates information to and from annotations UI plugins.
27
+ */
28
+ export default class Annotations extends ContextPlugin {
29
+ /**
30
+ * A set of currently active annotations.
31
+ *
32
+ * @observable
33
+ */
34
+ activeAnnotations: Set<Annotation>;
35
+ /**
36
+ * A collection of all annotations. It should not be operated on directly.
37
+ */
38
+ readonly collection: AnnotationCollection;
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ static get pluginName(): 'Annotations';
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ constructor(context: Context | Editor);
47
+ /**
48
+ * Adds an annotation to the collection.
49
+ */
50
+ add(annotation: Annotation): void;
51
+ /**
52
+ * Removes the given annotation from the collection.
53
+ */
54
+ remove(annotation: Annotation): void;
55
+ /**
56
+ * Refreshes the visibility of annotations based on the visibility of their annotation targets.
57
+ *
58
+ * This method should be called when one or more annotations' targets changed their visibility,
59
+ * for example when one of the editors was shown or hidden.
60
+ *
61
+ * This method recalculates all annotations' {@link module:comments/annotations/annotation~Annotation#isVisible `isVisible`} property.
62
+ */
63
+ refreshVisibility(): void;
64
+ /**
65
+ * Refreshes the positioning of all visible annotations and sorts them topmost and leftmost.
66
+ */
67
+ refreshPositioning(): void;
68
+ /**
69
+ * Returns the annotation that "contains" the given annotation view's inner view.
70
+ */
71
+ getByInnerView(innerView: View): Annotation | undefined;
72
+ /**
73
+ * Deactivates all active annotations.
74
+ *
75
+ * @fires _deactivateAllAnnotations
76
+ */
77
+ deactivateAll(): void;
78
+ /**
79
+ * @inheritDoc
80
+ */
81
+ destroy(): void;
82
+ /**
83
+ * Activates the given annotation.
84
+ *
85
+ * If annotations UI that handles the given annotation already has an active annotation,
86
+ * then it deactivates it and activates the provided one.
87
+ *
88
+ * @fires _activateAnnotation
89
+ */
90
+ activate(annotation: Annotation): void;
91
+ /**
92
+ * Creates an annotation.
93
+ *
94
+ * ```ts
95
+ * const annotationView = annotations.createAnnotationView( editor.locale, innerView );
96
+ *
97
+ * const annotation = annotations.createAnnotation( {
98
+ * view: annotationView,
99
+ * target: document.getElementById( 'target' ),
100
+ * type: 'comment'
101
+ * } );
102
+ * ```
103
+ *
104
+ * @returns An annotation.
105
+ */
106
+ createAnnotation(options: AnnotationOptions): Annotation;
107
+ /**
108
+ * Creates an annotation view wrapper for the annotation content.
109
+ *
110
+ * ```ts
111
+ * const innerView = createCustomView();
112
+ * const annotationView = annotations.createAnnotationView( editor.locale, innerView );
113
+ * ```
114
+ *
115
+ * @returns An annotation view.
116
+ */
117
+ createAnnotationView(locale: Locale, view: AnnotationMainView): AnnotationView;
118
+ }
119
+ /**
120
+ * The configuration options which are used to create new {@link module:comments/annotations/annotation~Annotation annotations}.
121
+ *
122
+ * @param view The annotation view.
123
+ * @param target The annotation target.
124
+ * @param type The annotation type.
125
+ * @param isVisible The initial visibility of the annotation.
126
+ */
127
+ export interface AnnotationOptions {
128
+ view: AnnotationView;
129
+ target: AnnotationTarget;
130
+ type: string | (() => string);
131
+ isVisible?: boolean;
132
+ }
133
+ /**
134
+ * An internal event that fires when the annotation should be activated.
135
+ *
136
+ * @eventName ~Annotations#_activateAnnotation
137
+ */
138
+ export type ActivateAnnotationEvent = {
139
+ name: '_activateAnnotation';
140
+ args: [annotation: Annotation];
141
+ };
142
+ /**
143
+ * An internal event that fires when all annotations should be deactivated.
144
+ *
145
+ * @eventName ~Annotations#_deactivateAllAnnotations
146
+ */
147
+ export type DeactivateAllAnnotationsEvent = {
148
+ name: '_deactivateAllAnnotations';
149
+ args: [];
150
+ };
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x3adf=['_bindAnnotationsToVisibleAnnotations','_visibleAnnotations','add','getByInnerView','remove','activeAnnotations','_removeActiveAnnotation','_addActiveAnnotation','createAnnotationView','collection','refreshVisibility','fire','activate','destroy','_activateAnnotation','change:isVisible','isVisible','has','createAnnotation','_deactivateAllAnnotations','Annotations','deactivateAll','delete','listenTo','source','stopListening','pluginName','refreshPositioning'];(function(_0x4168a3,_0x3adf9b){const _0x744091=function(_0x39873e){while(--_0x39873e){_0x4168a3['push'](_0x4168a3['shift']());}};_0x744091(++_0x3adf9b);}(_0x3adf,0x75));const _0x7440=function(_0x4168a3,_0x3adf9b){_0x4168a3=_0x4168a3-0x0;let _0x744091=_0x3adf[_0x4168a3];return _0x744091;};import{ContextPlugin as _0x9e3f0a}from'ckeditor5/src/core';import _0x309f3b from'./annotation';import _0x117566 from'./annotationcollection';import _0x3af509 from'./view/annotationview';export default class V extends _0x9e3f0a{static get[_0x7440('0x15')](){return _0x7440('0xf');}constructor(_0x270c31){super(_0x270c31),this[_0x7440('0x4')]=new _0x117566(),this[_0x7440('0x18')]=new _0x117566(),this['set'](_0x7440('0x0'),new Set()),this[_0x7440('0x17')]();}['add'](_0x68a5f3){this[_0x7440('0x4')][_0x7440('0x19')](_0x68a5f3);}['remove'](_0x2e8e78){this['collection']['remove'](_0x2e8e78),_0x2e8e78[_0x7440('0x8')]();}[_0x7440('0x5')](){for(const _0x1adea4 of this['collection'])_0x1adea4[_0x7440('0x5')]();}['refreshPositioning'](){this['_visibleAnnotations'][_0x7440('0x16')]();}[_0x7440('0x1a')](_0x3c0812){return this[_0x7440('0x4')][_0x7440('0x1a')](_0x3c0812);}[_0x7440('0x10')](){this[_0x7440('0x6')](_0x7440('0xe'));}[_0x7440('0x8')](){for(const _0x292b28 of this[_0x7440('0x4')])_0x292b28[_0x7440('0x8')]();this[_0x7440('0x18')][_0x7440('0x8')](),this[_0x7440('0x4')][_0x7440('0x8')](),super[_0x7440('0x8')]();}[_0x7440('0x7')](_0x45178c){this[_0x7440('0x6')](_0x7440('0x9'),_0x45178c);}[_0x7440('0xd')](_0x35dd1e){return new _0x309f3b(_0x35dd1e);}[_0x7440('0x3')](_0x1aa5aa,_0x560848){return new _0x3af509(_0x1aa5aa,_0x560848);}[_0x7440('0x2')](_0x5f2348){const _0xb08fc7=new Set(this[_0x7440('0x0')]);_0xb08fc7[_0x7440('0x19')](_0x5f2348),this['activeAnnotations']=_0xb08fc7;}[_0x7440('0x1')](_0x237cf6){const _0x39c553=new Set(this[_0x7440('0x0')]);_0x39c553[_0x7440('0x11')](_0x237cf6),this['activeAnnotations']=_0x39c553;}[_0x7440('0x17')](){const _0x489d79=this[_0x7440('0x4')],_0x4b5ced=this[_0x7440('0x18')];function _0x1708b5(_0x4b5342){const _0x5dbefb=_0x4b5342[_0x7440('0x13')];_0x5dbefb[_0x7440('0xb')]&&!_0x4b5ced[_0x7440('0xc')](_0x5dbefb)?_0x4b5ced['add'](_0x5dbefb):!_0x5dbefb[_0x7440('0xb')]&&_0x4b5ced['has'](_0x5dbefb)&&_0x4b5ced[_0x7440('0x1b')](_0x5dbefb);}this['listenTo'](_0x489d79,'add',(_0x1be9ac,_0x4b449c)=>{_0x4b449c['isVisible']&&_0x4b5ced['add'](_0x4b449c),this[_0x7440('0x12')](_0x4b449c,_0x7440('0xa'),_0x1708b5);}),this['listenTo'](_0x489d79,_0x7440('0x1b'),(_0x2e0d9c,_0x515146)=>{_0x4b5ced[_0x7440('0xc')](_0x515146)&&_0x4b5ced[_0x7440('0x1b')](_0x515146),this[_0x7440('0x14')](_0x515146,_0x7440('0xa'),_0x1708b5);});}}
23
+ const _0x491a=['pluginName','refreshVisibility','remove','Annotations','_removeActiveAnnotation','deactivateAll','stopListening','add','change:isVisible','refreshPositioning','_visibleAnnotations','isVisible','element','_addActiveAnnotation','_activateAnnotation','fire','view','destroy','listenTo','_deactivateAllAnnotations','collection','getByInnerView','source','has','activate','activeAnnotations'];(function(_0x53a3b9,_0x491ac8){const _0x3b9b09=function(_0x4a29ea){while(--_0x4a29ea){_0x53a3b9['push'](_0x53a3b9['shift']());}};_0x3b9b09(++_0x491ac8);}(_0x491a,0x1c3));const _0x3b9b=function(_0x53a3b9,_0x491ac8){_0x53a3b9=_0x53a3b9-0x0;let _0x3b9b09=_0x491a[_0x53a3b9];return _0x3b9b09;};import{ContextPlugin as _0x59d1ff}from'ckeditor5/src/core';import _0x1d2878 from'./annotation';import _0x1e97db from'./annotationcollection';import _0x5c4aad from'./view/annotationview';export default class b extends _0x59d1ff{static get[_0x3b9b('0x11')](){return _0x3b9b('0x14');}constructor(_0x11b7eb){super(_0x11b7eb),this[_0x3b9b('0xb')]=new _0x1e97db(),this[_0x3b9b('0x1')]=new _0x1e97db(),this['set'](_0x3b9b('0x10'),new Set()),this['_bindAnnotationsToVisibleAnnotations']();}[_0x3b9b('0x18')](_0x57984f){this[_0x3b9b('0xb')][_0x3b9b('0x18')](_0x57984f);}['remove'](_0x2f6e91){this['collection'][_0x3b9b('0x13')](_0x2f6e91),_0x2f6e91[_0x3b9b('0x8')]();}['refreshVisibility'](){for(const _0x168c0a of this[_0x3b9b('0xb')])_0x168c0a[_0x3b9b('0x12')]();}[_0x3b9b('0x0')](){this[_0x3b9b('0x1')][_0x3b9b('0x0')]();}[_0x3b9b('0xc')](_0x324fd0){return this[_0x3b9b('0xb')][_0x3b9b('0xc')](_0x324fd0);}[_0x3b9b('0x16')](){this[_0x3b9b('0x6')](_0x3b9b('0xa'));}['destroy'](){for(const _0x2d1640 of this[_0x3b9b('0xb')])_0x2d1640[_0x3b9b('0x8')]();this[_0x3b9b('0x1')][_0x3b9b('0x8')](),this['collection'][_0x3b9b('0x8')](),super['destroy']();}[_0x3b9b('0xf')](_0x239c19){this[_0x3b9b('0x6')](_0x3b9b('0x5'),_0x239c19);}['createAnnotation'](_0x26acfc){return new _0x1d2878(_0x26acfc);}['createAnnotationView'](_0x17b921,_0x226db9){return new _0x5c4aad(_0x17b921,_0x226db9);}[_0x3b9b('0x4')](_0x58829b){const _0x25059d=new Set(this[_0x3b9b('0x10')]);_0x25059d[_0x3b9b('0x18')](_0x58829b),this[_0x3b9b('0x10')]=_0x25059d;}[_0x3b9b('0x15')](_0x78bbf3){const _0x575cec=new Set(this[_0x3b9b('0x10')]);_0x575cec['delete'](_0x78bbf3),this['activeAnnotations']=_0x575cec;}['_bindAnnotationsToVisibleAnnotations'](){const _0x42900b=this[_0x3b9b('0xb')],_0x29f9e9=this[_0x3b9b('0x1')];function _0x560870(_0x1ff2a0){const _0x14fa66=_0x1ff2a0[_0x3b9b('0xd')];_0x14fa66[_0x3b9b('0x2')]&&!_0x29f9e9[_0x3b9b('0xe')](_0x14fa66)?_0x29f9e9[_0x3b9b('0x18')](_0x14fa66):!_0x14fa66[_0x3b9b('0x2')]&&_0x29f9e9[_0x3b9b('0xe')](_0x14fa66)&&_0x29f9e9[_0x3b9b('0x13')](_0x14fa66),_0x14fa66['view']['focusTracker'][_0x3b9b('0x13')](_0x14fa66[_0x3b9b('0x7')][_0x3b9b('0x3')]),_0x14fa66[_0x3b9b('0x7')]['focusTracker']['add'](_0x14fa66['view'][_0x3b9b('0x3')]);}this['listenTo'](_0x42900b,_0x3b9b('0x18'),(_0x1f7d0d,_0x2c75b5)=>{_0x2c75b5['isVisible']&&_0x29f9e9[_0x3b9b('0x18')](_0x2c75b5),this['listenTo'](_0x2c75b5,_0x3b9b('0x19'),_0x560870);}),this[_0x3b9b('0x9')](_0x42900b,_0x3b9b('0x13'),(_0x4ed42b,_0x200467)=>{_0x29f9e9['has'](_0x200467)&&_0x29f9e9[_0x3b9b('0x13')](_0x200467),this[_0x3b9b('0x17')](_0x200467,_0x3b9b('0x19'),_0x560870);});}}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * @module comments/annotations/annotationsuis
3
+ * @publicApi
4
+ */
5
+ import { ContextPlugin, type Plugin, type PluginDependencies, type Editor, type Context } from 'ckeditor5/src/core';
6
+ import { type Emitter } from 'ckeditor5/src/utils';
7
+ import AnnotationCollection from './annotationcollection';
8
+ import type Annotation from './annotation';
9
+ /**
10
+ * A repository of annotations UIs.
11
+ *
12
+ * The main entry point for {@link module:comments/annotations/annotationsuis~AnnotationsUIs#register registering} UIs
13
+ * and activating the annotations UI(s), which display annotation views.
14
+ *
15
+ * To register a custom annotations UI use following code in the annotations UI plugin `init()` function:
16
+ *
17
+ * ```ts
18
+ * const annotationsUIs = editor.plugins.get( 'annotationsUIs' );
19
+ *
20
+ * annotationsUIs.register( customAnnotationsUIPlugin );
21
+ * ```
22
+ *
23
+ * Note that the custom annotations UI must implement {@link module:comments/annotations/annotationsuis~AnnotationsUI
24
+ * the `AnnotationsUI` interface}.
25
+ *
26
+ * To activate an annotations UI, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#switchTo
27
+ * `switchTo( uiName )`} method. This method activates the given UI and deactivates all the other UIs.
28
+ * All annotations will be handled by the activated UI.
29
+ *
30
+ * It is also possible to activate multiple annotations UIs at the same time and make the UIs handle different sets of annotations.
31
+ * To do that, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate `activate( uiName, filter )`} method.
32
+ *
33
+ * ```ts
34
+ * // Suggestions annotations are shown inline in a balloon:
35
+ * annotationsUIs.activate( 'inline', annotation => annotation.type.startsWith( 'suggestion' ) );
36
+ *
37
+ * // At the same time, comments annotations are shown in a sidebar:
38
+ * annotationsUIs.activate( 'wideSidebar', annotation => annotation.type === 'comment' );
39
+ * ```
40
+ *
41
+ * Limitations:
42
+ *
43
+ * * Some annotations UI plugins might collide with each other (like {@link module:comments/annotations/narrowsidebar~NarrowSidebar} and
44
+ * {@link module:comments/annotations/widesidebar~WideSidebar} that operates on the same sidebar). They cannot be activated at the same
45
+ * time.
46
+ * * It is not possible to display the same annotation in two different annotations UIs. In this scenario an error will be thrown.
47
+ */
48
+ export default class AnnotationsUIs extends ContextPlugin {
49
+ /**
50
+ * A set of names of the active annotations UIs.
51
+ *
52
+ * To activate the annotations UI, use {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate}
53
+ * or {@link #switchTo} methods.
54
+ */
55
+ activeUIs: Set<string>;
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ static get requires(): PluginDependencies<Context | Editor>;
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ static get pluginName(): 'AnnotationsUIs';
64
+ /**
65
+ * @inheritDoc
66
+ */
67
+ constructor(context: Context | Editor);
68
+ /**
69
+ * @inheritDoc
70
+ */
71
+ init(): void;
72
+ /**
73
+ * Returns `true` if at least one registered UI is active.
74
+ */
75
+ hasActive(): boolean;
76
+ /**
77
+ * Returns `true` if the given UI is active.
78
+ */
79
+ isActive(uiName: string): boolean;
80
+ /**
81
+ * Activates an annotations UI.
82
+ *
83
+ * Note that the custom annotations UI should be {@link #register registered} before the activation.
84
+ *
85
+ * The `filter` parameter can be used to display on some of the annotations in the given annotations UI. Thanks to that,
86
+ * all annotations can be split into various annotations UIs.
87
+ *
88
+ * The `filter` function takes an {@link module:comments/annotations/annotation~Annotation} instance as the first and only parameter,
89
+ * and should return `true` if that annotation should be placed in the given annotations UI.
90
+ *
91
+ * @param uiName The name of the annotations UI to activate.
92
+ * @param filter The annotation filter function. If not specified, the UI will use all annotations.
93
+ */
94
+ activate(uiName: string, filter?: () => boolean): void;
95
+ /**
96
+ * Deactivates annotations UI with given name.
97
+ *
98
+ * @param uiName The name of the annotations UI to deactivate.
99
+ */
100
+ deactivate(uiName: string): void;
101
+ /**
102
+ * Switches the annotations UI to the one with given name.
103
+ *
104
+ * It preserves the currently active annotation.
105
+ *
106
+ * @param uiName The name of the annotations UI to switch to.
107
+ */
108
+ switchTo(uiName: string): void;
109
+ /**
110
+ * Deactivates all annotations UIs.
111
+ */
112
+ deactivateAll(): void;
113
+ /**
114
+ * Registers an annotations UI. It might be one of:
115
+ *
116
+ * * {@link module:comments/annotations/widesidebar~WideSidebar},
117
+ * * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
118
+ * * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
119
+ *
120
+ * It is possible to provide your own, custom annotations UI plugin. It has to implement
121
+ * {@link module:comments/annotations/annotationsuis~AnnotationsUI the `AnnotationsUI` interface}.
122
+ *
123
+ * @param uiName Annotations UI name.
124
+ * @param annotationsUI Annotations UI plugin instance.
125
+ */
126
+ register(uiName: string, annotationsUI: AnnotationsUI<ContextPlugin | Plugin>): void;
127
+ /**
128
+ * Refilters annotations to proper UIs based on filters provided earlier during the
129
+ * {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate annotations UIs activation}.
130
+ *
131
+ * This method should be used if the annotations UIs filtering functions return different results than before
132
+ * for some annotations. It only reattaches these annotations, which should change their UIs.
133
+ */
134
+ refilterAnnotations(): void;
135
+ /**
136
+ * @inheritDoc
137
+ */
138
+ destroy(): void;
139
+ }
140
+ /**
141
+ * An interface for the annotations UI plugin class.
142
+ *
143
+ * The annotations UI class handles displaying, focusing, activating and hiding annotations views.
144
+ *
145
+ * The annotations UI class must be a plugin, so it has to extend the {@link module:core/plugin~Plugin} or
146
+ * {@link module:core/contextplugin~ContextPlugin} class.
147
+ *
148
+ * Examples of `AnnotationsUI` are:
149
+ *
150
+ * * {@link module:comments/annotations/widesidebar~WideSidebar},
151
+ * * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
152
+ * * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
153
+ *
154
+ * You can use the following snippet as a base for your own annotations UI:
155
+ *
156
+ * ```ts
157
+ * class MyAnnotationsUI extends ContextPlugin {
158
+ * constructor( ...args ) {
159
+ * super( ...args );
160
+ *
161
+ * this.set( 'activeAnnotation', null );
162
+ * }
163
+ *
164
+ * attach( annotations ) {
165
+ * // Do something when an annotation is added.
166
+ * this.listenTo( annotations, 'add', ( evt, annotation ) => { ... } );
167
+ *
168
+ * // Do something when an annotation is removed.
169
+ * this.listenTo( annotations, 'remove', ( evt, annotation ) => { ... } );
170
+ * }
171
+ *
172
+ * detach() {
173
+ * this.stopListening();
174
+ * }
175
+ *
176
+ * setActiveAnnotation( annotation ) {
177
+ * if ( this.activeAnnotation ) {
178
+ * this.activeAnnotation.isActive = false;
179
+ *
180
+ * // You can do something in your UI with the annotation that is no longer active.
181
+ * }
182
+ *
183
+ * this.activeAnnotation = annotation;
184
+ * this.activeAnnotation.isActive = true;
185
+ *
186
+ * // You can do something in your UI to highlight the active annotation.
187
+ * }
188
+ * }
189
+ * ```
190
+ */
191
+ export interface AnnotationUI {
192
+ /**
193
+ * Observable `activeAnnotation` property. {@link module:comments/annotations/annotationsuis~AnnotationsUIs} listens to changes on that
194
+ * property.
195
+ *
196
+ * To make this property observable use `this.set( 'activeAnnotation', null )` in the constructor.
197
+ */
198
+ activeAnnotation: Annotation | null;
199
+ /**
200
+ * Creates everything needed for the UI and attaches all listeners. This method is called when the UI is activated.
201
+ *
202
+ * The observable collection of annotations is passed as the first argument,
203
+ * and the annotations UI is responsible for reacting to its changes.
204
+ */
205
+ attach: (annotationCollection: AnnotationCollection) => void;
206
+ /**
207
+ * Destroys the UI and removes all listeners. This method is called when the UI is deactivated.
208
+ */
209
+ detach: () => void;
210
+ /**
211
+ * Sets or unsets the active annotation. This method is called when an annotation is activated, for example, user puts their
212
+ * selection into a marker connected with given annotation.
213
+ *
214
+ * This method should change the UI so the new active annotation is differentiated from other annotations.
215
+ *
216
+ * This method should set the
217
+ * {@link #activeAnnotation `AnnotationUI#activeAnnotation`} property.
218
+ *
219
+ * It also should set {@link module:comments/annotations/annotation~Annotation#isActive `Annotation#isActive`} of the deactivated
220
+ * and the activated annotation.
221
+ *
222
+ * @param annotation The new active annotation or null when no annotation is active.
223
+ */
224
+ setActiveAnnotation: (annotation: Annotation | null) => void;
225
+ _setSelectedAnnotations?: (annotations: Array<Annotation>) => void;
226
+ }
227
+ export type AnnotationsUI<T extends Emitter> = T & AnnotationUI;
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x5b78=['register','has','deactivateAll','length','listenTo','get','isActive','attach','requires','push','_assertAnnotationDoesNotBelongToMultipleUIs','setActiveAnnotation','_activateAnnotation','add','context','delete','_addActiveAnnotation','activeUIs','detach','plugins','_removeActiveAnnotation','set','function','annotationsuis-activate-missing-ui','annotationsuis-register-already-registered','AnnotationsUIs','switchTo','_uisData','deactivate','_setSelectedAnnotations','activate','type','destroy','pluginName','change:activeAnnotation','size','init','remove','find','filter','from','activeAnnotations','stopListening','collection','refilterAnnotations','_visibleAnnotations','_uis','_deactivateAllAnnotations'];(function(_0xc0a410,_0x5b7869){const _0x400af0=function(_0xa50125){while(--_0xa50125){_0xc0a410['push'](_0xc0a410['shift']());}};_0x400af0(++_0x5b7869);}(_0x5b78,0x96));const _0x400a=function(_0xc0a410,_0x5b7869){_0xc0a410=_0xc0a410-0x0;let _0x400af0=_0x5b78[_0xc0a410];return _0x400af0;};import{ContextPlugin as _0xd5e16e}from'ckeditor5/src/core';import{CKEditorError as _0x1e737f}from'ckeditor5/src/utils';import _0x26ac75,{bindAnnotationCollections as _0x5a5e12}from'./annotationcollection';import _0x406659 from'./annotations';export default class I extends _0xd5e16e{static get[_0x400a('0x2')](){return[_0x406659];}static get[_0x400a('0x1b')](){return _0x400a('0x13');}constructor(_0x103d5b){super(_0x103d5b),this[_0x400a('0xb')]=new Set(),this[_0x400a('0x28')]=new Map(),this[_0x400a('0x15')]=new Map();}[_0x400a('0x1e')](){const _0x2a3408=this[_0x400a('0x8')]['plugins']['get'](_0x406659);this['listenTo'](_0x2a3408,_0x400a('0x6'),(_0x1c92f7,_0x538f65)=>{for(const _0x3d121b of this['activeUIs']){const _0x15aa49=this[_0x400a('0x28')][_0x400a('0x2f')](_0x3d121b);(0x0,this[_0x400a('0x15')][_0x400a('0x2f')](_0x3d121b)[_0x400a('0x21')])(_0x538f65)&&_0x15aa49['setActiveAnnotation'](_0x538f65);}}),this[_0x400a('0x2e')](_0x2a3408,_0x400a('0x29'),()=>{for(const _0x3ffb63 of this['activeUIs']){this['_uis'][_0x400a('0x2f')](_0x3ffb63)[_0x400a('0x5')](null);}}),this[_0x400a('0x2e')](_0x2a3408[_0x400a('0x27')],_0x400a('0x7'),(_0x1d2dc9,_0x5e2e66)=>{this['_assertAnnotationDoesNotBelongToMultipleUIs'](_0x5e2e66);});}['hasActive'](){return this[_0x400a('0xb')][_0x400a('0x1d')]>0x0;}[_0x400a('0x0')](_0x3acbc1){return this['activeUIs'][_0x400a('0x2b')](_0x3acbc1);}[_0x400a('0x18')](_0x3806a2,_0x5e9d00=()=>!0x0){const _0x513841=this[_0x400a('0x8')]['plugins']['get'](_0x406659);if(!this[_0x400a('0x28')][_0x400a('0x2b')](_0x3806a2))throw new _0x1e737f(_0x400a('0x11'),this,{'uiName':_0x3806a2});this[_0x400a('0x0')](_0x3806a2)&&this[_0x400a('0x16')](_0x3806a2),this[_0x400a('0xb')][_0x400a('0x7')](_0x3806a2);const _0xdbeebd=new _0x26ac75(),_0x349cd6=_0x513841['_visibleAnnotations'];_0x5a5e12({'source':_0x349cd6,'target':_0xdbeebd,'filter':_0x5e9d00}),this[_0x400a('0x15')]['set'](_0x3806a2,{'collection':_0xdbeebd,'filter':_0x5e9d00});const _0x16077c=this[_0x400a('0x28')][_0x400a('0x2f')](_0x3806a2);_0x16077c['attach'](_0xdbeebd),this[_0x400a('0x2e')](_0x16077c,_0x400a('0x1c'),(_0x767fb4,_0x235c7e,_0x4e7dbe,_0x2ee220)=>{_0x2ee220&&_0x513841[_0x400a('0xe')](_0x2ee220),_0x4e7dbe&&_0x513841[_0x400a('0xa')](_0x4e7dbe);});}[_0x400a('0x16')](_0x137afd){this[_0x400a('0xb')][_0x400a('0x9')](_0x137afd);const _0xb8f7c8=this[_0x400a('0x28')][_0x400a('0x2f')](_0x137afd);_0xb8f7c8[_0x400a('0xc')](),this[_0x400a('0x24')](_0xb8f7c8),this[_0x400a('0x15')][_0x400a('0x2f')](_0x137afd)[_0x400a('0x25')][_0x400a('0x1a')](),this[_0x400a('0x15')]['delete'](_0x137afd);}[_0x400a('0x14')](_0x3af3b5){const _0x95e586=this[_0x400a('0x8')][_0x400a('0xd')][_0x400a('0x2f')](_0x406659),_0xa6f2c2=Array['from'](_0x95e586[_0x400a('0x23')])[0x0]||null;this[_0x400a('0x2c')](),this[_0x400a('0x18')](_0x3af3b5);const _0x3cd7e4=this[_0x400a('0x28')][_0x400a('0x2f')](_0x3af3b5);_0x3cd7e4['setActiveAnnotation'](_0xa6f2c2),_0x3cd7e4[_0x400a('0x17')]&&_0xa6f2c2&&_0x3cd7e4[_0x400a('0x17')]([_0xa6f2c2]);}['deactivateAll'](){for(const _0x36a712 of this[_0x400a('0xb')])this[_0x400a('0x16')](_0x36a712);}[_0x400a('0x2a')](_0x1c2ca9,_0x31901f){if(this[_0x400a('0x28')]['has'](_0x1c2ca9))throw new _0x1e737f(_0x400a('0x12'));if(_0x400a('0x10')!=typeof _0x31901f[_0x400a('0x1')]||_0x400a('0x10')!=typeof _0x31901f[_0x400a('0xc')]||'function'!=typeof _0x31901f[_0x400a('0x5')])throw new _0x1e737f('annotationsuis-register-invalid-interface',null);this[_0x400a('0x28')][_0x400a('0xf')](_0x1c2ca9,_0x31901f);}[_0x400a('0x26')](){const _0x34b1d0=this[_0x400a('0x8')][_0x400a('0xd')][_0x400a('0x2f')](_0x406659)[_0x400a('0x25')],_0x208903=new Map(),_0x39b9ce=Array[_0x400a('0x22')](this[_0x400a('0xb')]);for(const _0x43c1a6 of this['activeUIs']){const _0x394db2=this[_0x400a('0x15')]['get'](_0x43c1a6)['collection'];for(const _0x28298a of _0x394db2)_0x208903[_0x400a('0xf')](_0x28298a,_0x43c1a6);}for(const _0x528585 of _0x34b1d0){const _0x516f50=_0x208903[_0x400a('0x2f')](_0x528585);this[_0x400a('0x4')](_0x528585);const _0x3e5531=_0x39b9ce[_0x400a('0x20')](_0x3290b2=>this[_0x400a('0x15')]['get'](_0x3290b2)[_0x400a('0x21')](_0x528585));_0x516f50!==_0x3e5531&&(_0x516f50&&this[_0x400a('0x15')][_0x400a('0x2f')](_0x516f50)['collection'][_0x400a('0x1f')](_0x528585),_0x3e5531&&this[_0x400a('0x15')]['get'](_0x3e5531)[_0x400a('0x25')][_0x400a('0x7')](_0x528585));}}[_0x400a('0x1a')](){this['deactivateAll'](),super[_0x400a('0x1a')]();}[_0x400a('0x4')](_0xfcb97d){const _0x142cff=[];for(const _0x15e543 of this[_0x400a('0xb')]){(0x0,this[_0x400a('0x15')][_0x400a('0x2f')](_0x15e543)[_0x400a('0x21')])(_0xfcb97d)&&_0x142cff[_0x400a('0x3')](_0x15e543);}if(_0x142cff[_0x400a('0x2d')]>0x1)throw new _0x1e737f('annotationsuis-annotation-mismatch',null,{'matchedUIs':_0x142cff,'annotationType':_0xfcb97d[_0x400a('0x19')]});}}
23
+ const _0x3e8c=['change:activeAnnotation','get','annotationsuis-annotation-mismatch','AnnotationsUIs','annotationsuis-register-invalid-interface','isActive','refilterAnnotations','_visibleAnnotations','find','listenTo','setActiveAnnotation','size','deactivateAll','filter','hasActive','activeAnnotations','_activateAnnotation','_uis','from','activate','annotationsuis-missing-ui','init','function','push','annotationsuis-register-already-registered','stopListening','collection','deactivate','pluginName','attach','length','destroy','has','activeUIs','set','type','add','context','detach','delete','_assertAnnotationDoesNotBelongToMultipleUIs','plugins','_setSelectedAnnotations','register','_deactivateAllAnnotations','_uisData'];(function(_0x6f9690,_0x3e8c82){const _0x5d7eac=function(_0xe605da){while(--_0xe605da){_0x6f9690['push'](_0x6f9690['shift']());}};_0x5d7eac(++_0x3e8c82);}(_0x3e8c,0x81));const _0x5d7e=function(_0x6f9690,_0x3e8c82){_0x6f9690=_0x6f9690-0x0;let _0x5d7eac=_0x3e8c[_0x6f9690];return _0x5d7eac;};import{ContextPlugin as _0x1e9bb8}from'ckeditor5/src/core';import{CKEditorError as _0x1a45d6}from'ckeditor5/src/utils';import _0xee8372,{bindAnnotationCollections as _0x4f41d9}from'./annotationcollection';import _0x442de0 from'./annotations';export default class M extends _0x1e9bb8{static get['requires'](){return[_0x442de0];}static get[_0x5d7e('0x25')](){return _0x5d7e('0xc');}constructor(_0x489912){super(_0x489912),this[_0x5d7e('0x2a')]=new Set(),this['_uis']=new Map(),this[_0x5d7e('0x8')]=new Map();}[_0x5d7e('0x1e')](){const _0x34abec=this[_0x5d7e('0x0')]['plugins'][_0x5d7e('0xa')](_0x442de0);this[_0x5d7e('0x12')](_0x34abec,_0x5d7e('0x19'),(_0xc79007,_0x42a938)=>{for(const _0x5f03ee of this[_0x5d7e('0x2a')]){const _0x3ad975=this[_0x5d7e('0x1a')][_0x5d7e('0xa')](_0x5f03ee);(0x0,this[_0x5d7e('0x8')][_0x5d7e('0xa')](_0x5f03ee)['filter'])(_0x42a938)&&_0x3ad975[_0x5d7e('0x13')](_0x42a938);}}),this['listenTo'](_0x34abec,_0x5d7e('0x7'),()=>{for(const _0x2f0040 of this['activeUIs']){this['_uis'][_0x5d7e('0xa')](_0x2f0040)[_0x5d7e('0x13')](null);}}),this['listenTo'](_0x34abec['_visibleAnnotations'],_0x5d7e('0x2d'),(_0x58db70,_0x33535f)=>{this[_0x5d7e('0x3')](_0x33535f);});}[_0x5d7e('0x17')](){return this[_0x5d7e('0x2a')][_0x5d7e('0x14')]>0x0;}[_0x5d7e('0xe')](_0x175a83){return this[_0x5d7e('0x2a')][_0x5d7e('0x29')](_0x175a83);}[_0x5d7e('0x1c')](_0x58a41e,_0x26923f=()=>!0x0){const _0x12d253=this[_0x5d7e('0x0')][_0x5d7e('0x4')][_0x5d7e('0xa')](_0x442de0);if(!this[_0x5d7e('0x1a')][_0x5d7e('0x29')](_0x58a41e))throw new _0x1a45d6(_0x5d7e('0x1d'),this,{'uiName':_0x58a41e});this[_0x5d7e('0xe')](_0x58a41e)&&this[_0x5d7e('0x24')](_0x58a41e),this['activeUIs']['add'](_0x58a41e);const _0x26b739=new _0xee8372(),_0x17715f=_0x12d253[_0x5d7e('0x10')];_0x4f41d9({'source':_0x17715f,'target':_0x26b739,'filter':_0x26923f}),this[_0x5d7e('0x8')][_0x5d7e('0x2b')](_0x58a41e,{'collection':_0x26b739,'filter':_0x26923f});const _0x56c9cb=this[_0x5d7e('0x1a')][_0x5d7e('0xa')](_0x58a41e);_0x56c9cb[_0x5d7e('0x26')](_0x26b739),this['listenTo'](_0x56c9cb,_0x5d7e('0x9'),(_0x230199,_0x1ab1c7,_0x3758d8,_0x51ef7f)=>{_0x51ef7f&&_0x12d253['_removeActiveAnnotation'](_0x51ef7f),_0x3758d8&&_0x12d253['_addActiveAnnotation'](_0x3758d8);});}[_0x5d7e('0x24')](_0x5c435f){if(this['activeUIs'][_0x5d7e('0x2')](_0x5c435f),!this[_0x5d7e('0x1a')][_0x5d7e('0x29')](_0x5c435f))throw new _0x1a45d6(_0x5d7e('0x1d'),this,{'uiName':_0x5c435f});const _0xc4cc3a=this['_uis'][_0x5d7e('0xa')](_0x5c435f);_0xc4cc3a['detach'](),this[_0x5d7e('0x22')](_0xc4cc3a),this[_0x5d7e('0x8')][_0x5d7e('0xa')](_0x5c435f)[_0x5d7e('0x23')][_0x5d7e('0x28')](),this['_uisData'][_0x5d7e('0x2')](_0x5c435f);}['switchTo'](_0x27eada){if(!this[_0x5d7e('0x1a')][_0x5d7e('0x29')](_0x27eada))throw new _0x1a45d6('annotationsuis-missing-ui',this,{'uiName':_0x27eada});const _0x677ac1=this[_0x5d7e('0x0')][_0x5d7e('0x4')][_0x5d7e('0xa')](_0x442de0),_0x531df0=Array[_0x5d7e('0x1b')](_0x677ac1[_0x5d7e('0x18')])[0x0]||null;this[_0x5d7e('0x15')](),this[_0x5d7e('0x1c')](_0x27eada);const _0x13b440=this[_0x5d7e('0x1a')]['get'](_0x27eada);_0x13b440[_0x5d7e('0x13')](_0x531df0),_0x13b440[_0x5d7e('0x5')]&&_0x531df0&&_0x13b440[_0x5d7e('0x5')]([_0x531df0]);}['deactivateAll'](){for(const _0x3a3efa of this[_0x5d7e('0x2a')])this[_0x5d7e('0x24')](_0x3a3efa);}[_0x5d7e('0x6')](_0x1b1c66,_0x129b90){if(this[_0x5d7e('0x1a')][_0x5d7e('0x29')](_0x1b1c66))throw new _0x1a45d6(_0x5d7e('0x21'));if(_0x5d7e('0x1f')!=typeof _0x129b90[_0x5d7e('0x26')]||_0x5d7e('0x1f')!=typeof _0x129b90[_0x5d7e('0x1')]||_0x5d7e('0x1f')!=typeof _0x129b90['setActiveAnnotation'])throw new _0x1a45d6(_0x5d7e('0xd'),null);this[_0x5d7e('0x1a')]['set'](_0x1b1c66,_0x129b90);}[_0x5d7e('0xf')](){const _0x34a016=this[_0x5d7e('0x0')]['plugins']['get'](_0x442de0)[_0x5d7e('0x23')],_0x1f213a=new Map(),_0x566e2c=Array[_0x5d7e('0x1b')](this[_0x5d7e('0x2a')]);for(const _0x3fade1 of this[_0x5d7e('0x2a')]){const _0x28e03c=this[_0x5d7e('0x8')]['get'](_0x3fade1)[_0x5d7e('0x23')];for(const _0x2a0638 of _0x28e03c)_0x1f213a[_0x5d7e('0x2b')](_0x2a0638,_0x3fade1);}for(const _0x1a7c71 of _0x34a016){const _0x5c01c8=_0x1f213a[_0x5d7e('0xa')](_0x1a7c71);this[_0x5d7e('0x3')](_0x1a7c71);const _0x117b02=_0x566e2c[_0x5d7e('0x11')](_0x57d67c=>this[_0x5d7e('0x8')][_0x5d7e('0xa')](_0x57d67c)[_0x5d7e('0x16')](_0x1a7c71));_0x5c01c8!==_0x117b02&&(_0x5c01c8&&this[_0x5d7e('0x8')]['get'](_0x5c01c8)['collection']['remove'](_0x1a7c71),_0x117b02&&this[_0x5d7e('0x8')][_0x5d7e('0xa')](_0x117b02)[_0x5d7e('0x23')][_0x5d7e('0x2d')](_0x1a7c71));}}[_0x5d7e('0x28')](){this[_0x5d7e('0x15')](),super[_0x5d7e('0x28')]();}[_0x5d7e('0x3')](_0x2e025b){const _0x266aec=[];for(const _0x330883 of this[_0x5d7e('0x2a')]){(0x0,this[_0x5d7e('0x8')]['get'](_0x330883)['filter'])(_0x2e025b)&&_0x266aec[_0x5d7e('0x20')](_0x330883);}if(_0x266aec[_0x5d7e('0x27')]>0x1)throw new _0x1a45d6(_0x5d7e('0xb'),null,{'matchedUIs':_0x266aec,'annotationType':_0x2e025b[_0x5d7e('0x2c')]});}}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @module comments/annotations/editorannotations
3
+ * @publicApi
4
+ */
5
+ import { Plugin, type PluginDependencies, type Editor } from 'ckeditor5/src/core';
6
+ import type Annotation from './annotation';
7
+ import type AnnotationCollection from './annotationcollection';
8
+ /**
9
+ * Integrates {@link module:comments/annotations/annotations~Annotations annotations} with the editor to provide proper behavior
10
+ * for annotations created through the editor features.
11
+ *
12
+ * *Note: The API of this class might change in the near future.*
13
+ *
14
+ * Collects all types of the annotations created through the editor features and their markers and decides which annotation is currently
15
+ * selected by the selection.
16
+ *
17
+ * Every editor plugin that adds an annotation should also
18
+ * {@link module:comments/annotations/editorannotations~EditorAnnotations#addSourceCollector register a callback}
19
+ * in which it will check whether given annotation should be marked as selected.
20
+ */
21
+ export default class EditorAnnotations extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires(): PluginDependencies;
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get pluginName(): 'EditorAnnotations';
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ constructor(editor: Editor);
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ init(): void;
38
+ /**
39
+ * Registers given annotation as an editor annotation, that is an annotation that is linked with a target inside the editor content.
40
+ */
41
+ registerAnnotation(annotation: Annotation): void;
42
+ hasDomSelection(): boolean;
43
+ /**
44
+ * Registers a callback that collects annotations and their markers.
45
+ */
46
+ addSourceCollector(callback: Function): void;
47
+ /**
48
+ * Finds all annotations selected by the editor selection and marks the most inner one as the active annotation.
49
+ */
50
+ refreshSelectedViews(): void;
51
+ /**
52
+ * Finds all annotations for selected markers in order from the most inner marker to the most outer marker.
53
+ *
54
+ * @param options.annotations The collection of annotations for given UI.
55
+ * @param options.activeAnnotation The given UI active annotation.
56
+ * It is used to determine the order if the selection contains the active annotation's marker.
57
+ */
58
+ getOrderedSelectedAnnotations({ activeAnnotation, annotations }: {
59
+ activeAnnotation: Annotation | null;
60
+ annotations: AnnotationCollection;
61
+ }): Array<Annotation>;
62
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x4e1d=['editorannotations-invalid-source-callback','element','init','_dataCollectors','selection','change:isFocused','isCollapsed','listenTo','isReadOnly','delete','plugins','annotation','getRanges','editing','from','getByInnerView','focusTracker','directChange','model','document','hasDomSelection','uiUpdate','cancel','view','set','range','update','_editorAnnotationsData','editor','add','fire','has','addSourceCollector','isEqual','push','refresh','_editorAnnotations','getOrderedSelectedAnnotations','containsRange','innerView','sort'];(function(_0x43ca6b,_0x4e1d5b){const _0x5c79a7=function(_0xa31a7b){while(--_0xa31a7b){_0x43ca6b['push'](_0x43ca6b['shift']());}};_0x5c79a7(++_0x4e1d5b);}(_0x4e1d,0x181));const _0x5c79=function(_0x43ca6b,_0x4e1d5b){_0x43ca6b=_0x43ca6b-0x0;let _0x5c79a7=_0x4e1d[_0x43ca6b];return _0x5c79a7;};import{Plugin as _0x278680}from'ckeditor5/src/core';import{CKEditorError as _0x472294}from'ckeditor5/src/utils';import{debounce as _0x5d444a}from'lodash-es';import _0xbc40e5 from'./annotations';export default class k extends _0x278680{static get['requires'](){return[_0xbc40e5];}static get['pluginName'](){return'EditorAnnotations';}constructor(_0x3a5217){super(_0x3a5217),this[_0x5c79('0x1c')]=new Set(),this[_0x5c79('0x14')]=new Set();}[_0x5c79('0x1b')](){const _0x2aeadf=this[_0x5c79('0xc')],_0xf1d4e8=_0x2aeadf[_0x5c79('0x2')][_0x5c79('0x3')][_0x5c79('0x1d')],_0x2c9bd4=_0x5d444a(()=>this['refreshSelectedViews'](),0xa);_0xf1d4e8['on']('change:range',(_0xa37be5,_0x409c67)=>{_0x409c67[_0x5c79('0x1')]&&(_0x2c9bd4[_0x5c79('0x6')](),this['refreshSelectedViews']());}),this[_0x5c79('0x20')](_0x2aeadf[_0x5c79('0x26')]['view'][_0x5c79('0x3')],_0x5c79('0x1e'),(_0x449060,_0x53ea19,_0x48e8ec)=>{_0x48e8ec&&_0x2c9bd4();}),this[_0x5c79('0x20')](_0x2aeadf['ui']['focusTracker'],_0x5c79('0x1e'),(_0x3a5339,_0x3658a3,_0x40731c)=>{_0x40731c||_0x2aeadf[_0x5c79('0x21')]||this[_0x5c79('0xe')]('blur',{'isAnnotationTracked':_0x30630e=>this['_editorAnnotationsData'][_0x5c79('0xf')](_0x30630e[_0x5c79('0x17')])});}),this[_0x5c79('0x20')](this[_0x5c79('0xc')]['ui'],_0x5c79('0xa'),()=>this[_0x5c79('0xe')](_0x5c79('0x5')));}['registerAnnotation'](_0x41d767){if(this[_0x5c79('0x14')][_0x5c79('0xf')](_0x41d767))return;this['_editorAnnotations'][_0x5c79('0xd')](_0x41d767[_0x5c79('0x7')]),this[_0x5c79('0xc')]['ui'][_0x5c79('0x0')][_0x5c79('0xd')](_0x41d767[_0x5c79('0x7')][_0x5c79('0x1a')]);const _0x6ec069=this[_0x5c79('0xc')][_0x5c79('0x23')]['get'](_0xbc40e5);this['listenTo'](_0x6ec069['collection'],'remove',(_0x4c82c6,_0x14a565)=>{this[_0x5c79('0xc')]['ui'][_0x5c79('0x0')]['remove'](_0x14a565[_0x5c79('0x7')][_0x5c79('0x1a')]),this[_0x5c79('0x14')][_0x5c79('0x22')](_0x14a565['view']);});}['hasDomSelection'](){return this[_0x5c79('0xc')][_0x5c79('0x26')][_0x5c79('0x7')][_0x5c79('0x4')];}[_0x5c79('0x10')](_0x54e2af){if('function'!=typeof _0x54e2af)throw new _0x472294(_0x5c79('0x19'));this[_0x5c79('0x1c')][_0x5c79('0xd')](_0x54e2af);}['refreshSelectedViews'](){this[_0x5c79('0xe')](_0x5c79('0x13'));}[_0x5c79('0x15')]({activeAnnotation:_0x337a89,annotations:_0x110093}){const _0x2822d1=[],_0x57d36e=this[_0x5c79('0xc')][_0x5c79('0x2')]['document']['selection'],_0x3c01ec=Array[_0x5c79('0x27')](_0x57d36e[_0x5c79('0x25')]());for(const [_0xe17208,_0x4d8261]of this['_editorAnnotationsData']){const _0x576c1c=_0xbd5876(_0x4d8261),_0x2d8f4d=_0x110093[_0x5c79('0x28')](_0xe17208);_0x576c1c&&_0x2d8f4d&&_0x2822d1[_0x5c79('0x12')]({'annotation':_0x2d8f4d,'range':_0x576c1c});}function _0xbd5876(_0x5663d0){for(const _0x26c4ab of _0x5663d0)for(const _0x59050d of _0x3c01ec)if(_0x26c4ab[_0x5c79('0x16')](_0x59050d,!_0x57d36e[_0x5c79('0x1f')]))return _0x26c4ab;return null;}return _0x2822d1[_0x5c79('0x18')]((_0x4686b1,_0x4ff8a0)=>{const _0x22f224=_0x4686b1[_0x5c79('0x9')],_0x519a00=_0x4ff8a0[_0x5c79('0x9')];if(!_0x22f224[_0x5c79('0x11')](_0x519a00)){if(_0x22f224[_0x5c79('0x16')](_0x519a00,!0x0))return 0x1;if(_0x519a00[_0x5c79('0x16')](_0x22f224,!0x0))return-0x1;}return _0x4686b1[_0x5c79('0x24')]==_0x337a89?-0x1:_0x4ff8a0['annotation']==_0x337a89?0x1:0x0;})['map'](_0x2406ab=>_0x2406ab[_0x5c79('0x24')]);}get[_0x5c79('0xb')](){const _0x375cb7=new Map();for(const _0x1fdcfe of Array[_0x5c79('0x27')](this[_0x5c79('0x1c')]))for(const [_0x2930f7,_0xd24a53]of _0x1fdcfe())_0x375cb7[_0x5c79('0x8')](_0x2930f7,_0xd24a53);return _0x375cb7;}}
23
+ const _0x4cdb=['getRanges','model','annotation','hasDomSelection','refreshSelectedViews','pluginName','change:range','remove','requires','registerAnnotation','directChange','addSourceCollector','uiUpdate','selection','cancel','listenTo','editorannotations-invalid-source-callback','sort','fire','document','_dataCollectors','view','delete','collection','refresh','isCollapsed','element','init','has','range','_editorAnnotations','editor','update','EditorAnnotations','function','editing','blur','isEqual','from','containsRange','focusTracker','_editorAnnotationsData','plugins','add'];(function(_0x10e3ff,_0x4cdb8a){const _0x2076cf=function(_0x3839c4){while(--_0x3839c4){_0x10e3ff['push'](_0x10e3ff['shift']());}};_0x2076cf(++_0x4cdb8a);}(_0x4cdb,0xaa));const _0x2076=function(_0x10e3ff,_0x4cdb8a){_0x10e3ff=_0x10e3ff-0x0;let _0x2076cf=_0x4cdb[_0x10e3ff];return _0x2076cf;};import{Plugin as _0x42a95c}from'ckeditor5/src/core';import{CKEditorError as _0x16c200}from'ckeditor5/src/utils';import{debounce as _0x1d3262}from'lodash-es';import _0x16e8f6 from'./annotations';export default class k extends _0x42a95c{static get[_0x2076('0xe')](){return[_0x16e8f6];}static get[_0x2076('0xb')](){return _0x2076('0x27');}constructor(_0x53a8c3){super(_0x53a8c3),this['_dataCollectors']=new Set(),this[_0x2076('0x24')]=new Set();}[_0x2076('0x21')](){const _0x21708d=this[_0x2076('0x25')],_0x5af893=_0x21708d[_0x2076('0x7')]['document'][_0x2076('0x13')],_0x464bcd=_0x1d3262(()=>this[_0x2076('0xa')](),0xa);_0x5af893['on'](_0x2076('0xc'),(_0x3d4405,_0x349840)=>{_0x349840[_0x2076('0x10')]&&(_0x464bcd[_0x2076('0x14')](),this[_0x2076('0xa')]());}),this[_0x2076('0x15')](_0x21708d[_0x2076('0x29')][_0x2076('0x1b')]['document'],'change:isFocused',(_0x30632b,_0x5604e1,_0x2b1c5c)=>{_0x2b1c5c&&_0x464bcd();}),this[_0x2076('0x15')](_0x21708d['ui'][_0x2076('0x2')],'change:isFocused',(_0x178971,_0x236be2,_0x1cca44)=>{_0x1cca44||_0x21708d['isReadOnly']||this['fire'](_0x2076('0x2a'),{'isAnnotationTracked':_0x572f5d=>this[_0x2076('0x3')][_0x2076('0x22')](_0x572f5d['innerView'])});}),this[_0x2076('0x15')](this['editor']['ui'],_0x2076('0x26'),()=>this[_0x2076('0x18')](_0x2076('0x12')));}[_0x2076('0xf')](_0x2c3985){if(this['_editorAnnotations'][_0x2076('0x22')](_0x2c3985[_0x2076('0x1b')]))return;this['_editorAnnotations'][_0x2076('0x5')](_0x2c3985['view']),this['editor']['ui'][_0x2076('0x2')][_0x2076('0x5')](_0x2c3985[_0x2076('0x1b')]['element']);const _0x50acab=this[_0x2076('0x25')][_0x2076('0x4')]['get'](_0x16e8f6);this[_0x2076('0x15')](_0x50acab[_0x2076('0x1d')],_0x2076('0xd'),(_0x241f98,_0x40705f)=>{this[_0x2076('0x25')]['ui'][_0x2076('0x2')][_0x2076('0xd')](_0x40705f['view'][_0x2076('0x20')]),this[_0x2076('0x24')][_0x2076('0x1c')](_0x40705f[_0x2076('0x1b')]);});}[_0x2076('0x9')](){return this[_0x2076('0x25')]['editing'][_0x2076('0x1b')]['hasDomSelection'];}[_0x2076('0x11')](_0x444108){if(_0x2076('0x28')!=typeof _0x444108)throw new _0x16c200(_0x2076('0x16'));this[_0x2076('0x1a')][_0x2076('0x5')](_0x444108);}['refreshSelectedViews'](){this[_0x2076('0x18')](_0x2076('0x1e'));}['getOrderedSelectedAnnotations']({activeAnnotation:_0x2bc608,annotations:_0x259879}){const _0x23137d=[],_0x39b943=this[_0x2076('0x25')]['model'][_0x2076('0x19')]['selection'],_0x22f6ed=Array[_0x2076('0x0')](_0x39b943[_0x2076('0x6')]());for(const [_0x1ab604,_0xd83149]of this[_0x2076('0x3')]){const _0x4b3e54=_0xcdfd55(_0xd83149),_0x1ae01e=_0x259879['getByInnerView'](_0x1ab604);_0x4b3e54&&_0x1ae01e&&_0x23137d['push']({'annotation':_0x1ae01e,'range':_0x4b3e54});}function _0xcdfd55(_0x5d28bd){for(const _0x588a52 of _0x5d28bd)for(const _0x35596b of _0x22f6ed)if(_0x588a52['containsRange'](_0x35596b,!_0x39b943[_0x2076('0x1f')]))return _0x588a52;return null;}return _0x23137d[_0x2076('0x17')]((_0x2e4f90,_0x124436)=>{const _0x38abf0=_0x2e4f90[_0x2076('0x23')],_0x48b3fb=_0x124436[_0x2076('0x23')];if(!_0x38abf0[_0x2076('0x2b')](_0x48b3fb)){if(_0x38abf0[_0x2076('0x1')](_0x48b3fb,!0x0))return 0x1;if(_0x48b3fb[_0x2076('0x1')](_0x38abf0,!0x0))return-0x1;}return _0x2e4f90[_0x2076('0x8')]==_0x2bc608?-0x1:_0x124436[_0x2076('0x8')]==_0x2bc608?0x1:0x0;})['map'](_0x1e3ca2=>_0x1e3ca2[_0x2076('0x8')]);}get[_0x2076('0x3')](){const _0x465407=new Map();for(const _0x28df52 of Array[_0x2076('0x0')](this[_0x2076('0x1a')]))for(const [_0x1da194,_0xa3df59]of _0x28df52())_0x465407['set'](_0x1da194,_0xa3df59);return _0x465407;}}