@ckeditor/ckeditor5-comments 39.0.1 → 40.0.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.
- package/CHANGELOG.md +2 -2
- package/LICENSE.md +6 -6
- package/README.md +14 -14
- package/build/comments.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/lang/translations/af.po +1 -0
- package/lang/translations/ar.po +1 -0
- package/lang/translations/bg.po +1 -0
- package/lang/translations/bn.po +1 -0
- package/lang/translations/bs.po +1 -0
- package/lang/translations/ca.po +1 -0
- package/lang/translations/cs.po +1 -0
- package/lang/translations/da.po +1 -0
- package/lang/translations/de-ch.po +1 -0
- package/lang/translations/de.po +1 -0
- package/lang/translations/el.po +1 -0
- package/lang/translations/en-au.po +1 -0
- package/lang/translations/en.po +1 -0
- package/lang/translations/es-co.po +1 -0
- package/lang/translations/es.po +1 -0
- package/lang/translations/et.po +1 -0
- package/lang/translations/fa.po +10 -9
- package/lang/translations/fi.po +1 -0
- package/lang/translations/fr.po +1 -0
- package/lang/translations/gl.po +1 -0
- package/lang/translations/he.po +1 -0
- package/lang/translations/hi.po +1 -0
- package/lang/translations/hr.po +1 -0
- package/lang/translations/hu.po +1 -0
- package/lang/translations/id.po +1 -0
- package/lang/translations/it.po +1 -0
- package/lang/translations/ja.po +1 -0
- package/lang/translations/jv.po +1 -0
- package/lang/translations/ko.po +1 -0
- package/lang/translations/lt.po +1 -0
- package/lang/translations/lv.po +1 -0
- package/lang/translations/ms.po +1 -0
- package/lang/translations/nl.po +1 -0
- package/lang/translations/no.po +1 -0
- package/lang/translations/pl.po +1 -0
- package/lang/translations/pt-br.po +4 -3
- package/lang/translations/pt.po +1 -0
- package/lang/translations/ro.po +1 -0
- package/lang/translations/ru.po +1 -0
- package/lang/translations/sk.po +1 -0
- package/lang/translations/sq.po +1 -0
- package/lang/translations/sr-latn.po +1 -0
- package/lang/translations/sr.po +1 -0
- package/lang/translations/sv.po +1 -0
- package/lang/translations/th.po +1 -0
- package/lang/translations/tk.po +1 -0
- package/lang/translations/tr.po +1 -0
- package/lang/translations/tt.po +1 -0
- package/lang/translations/ug.po +1 -0
- package/lang/translations/uk.po +1 -0
- package/lang/translations/ur.po +1 -0
- package/lang/translations/vi.po +1 -0
- package/lang/translations/zh-cn.po +1 -0
- package/lang/translations/zh.po +1 -0
- package/package.json +3 -7
- package/src/annotations/annotation.d.ts +90 -90
- package/src/annotations/annotation.js +1 -1
- package/src/annotations/annotationcollection.d.ts +98 -98
- package/src/annotations/annotationcollection.js +1 -1
- package/src/annotations/annotations.d.ts +154 -154
- package/src/annotations/annotations.js +1 -1
- package/src/annotations/annotationsuis.d.ts +232 -232
- package/src/annotations/annotationsuis.js +1 -1
- package/src/annotations/editorannotations.d.ts +67 -67
- package/src/annotations/editorannotations.js +1 -1
- package/src/annotations/inlineannotations.d.ts +90 -90
- package/src/annotations/inlineannotations.js +1 -1
- package/src/annotations/narrowsidebar.d.ts +85 -85
- package/src/annotations/narrowsidebar.js +1 -1
- package/src/annotations/sidebar.d.ts +100 -100
- package/src/annotations/sidebar.js +1 -1
- package/src/annotations/view/annotationcounterbuttonview.d.ts +29 -29
- package/src/annotations/view/annotationcounterbuttonview.js +1 -1
- package/src/annotations/view/annotationview.d.ts +90 -90
- package/src/annotations/view/annotationview.js +1 -1
- package/src/annotations/view/sidebaritemview.d.ts +55 -55
- package/src/annotations/view/sidebaritemview.js +1 -1
- package/src/annotations/view/sidebarview.d.ts +32 -32
- package/src/annotations/view/sidebarview.js +1 -1
- package/src/annotations/widesidebar.d.ts +77 -77
- package/src/annotations/widesidebar.js +1 -1
- package/src/augmentation.d.ts +52 -52
- package/src/comments/addcommentthreadcommand.d.ts +35 -35
- package/src/comments/addcommentthreadcommand.js +1 -1
- package/src/comments/commentsarchive.d.ts +31 -31
- package/src/comments/commentsarchive.js +1 -1
- package/src/comments/commentsarchiveui.d.ts +38 -38
- package/src/comments/commentsarchiveui.js +1 -1
- package/src/comments/commentsediting.d.ts +79 -79
- package/src/comments/commentsediting.js +1 -1
- package/src/comments/commentsrepository.d.ts +1129 -1105
- package/src/comments/commentsrepository.js +1 -1
- package/src/comments/commentsui.d.ts +33 -33
- package/src/comments/commentsui.js +1 -1
- package/src/comments/integrations/commentsrestrictededitingmode.d.ts +17 -17
- package/src/comments/integrations/commentsrestrictededitingmode.js +1 -1
- package/src/comments/integrations/importword.d.ts +21 -21
- package/src/comments/integrations/importword.js +1 -1
- package/src/comments/ui/commenteditor/commenteditor.d.ts +36 -36
- package/src/comments/ui/commenteditor/commenteditor.js +1 -1
- package/src/comments/ui/commenteditor/commenteditorui.d.ts +31 -31
- package/src/comments/ui/commenteditor/commenteditorui.js +1 -1
- package/src/comments/ui/commenteditor/commenteditoruiview.d.ts +36 -36
- package/src/comments/ui/commenteditor/commenteditoruiview.js +1 -1
- package/src/comments/ui/commentthreadcontroller.d.ts +64 -64
- package/src/comments/ui/commentthreadcontroller.js +1 -1
- package/src/comments/ui/view/basecommentthreadview.d.ts +119 -112
- package/src/comments/ui/view/basecommentthreadview.js +1 -1
- package/src/comments/ui/view/basecommentview.d.ts +112 -112
- package/src/comments/ui/view/basecommentview.js +1 -1
- package/src/comments/ui/view/collapsedcommentsview.d.ts +13 -13
- package/src/comments/ui/view/collapsedcommentsview.js +1 -1
- package/src/comments/ui/view/commentcontentview.d.ts +14 -14
- package/src/comments/ui/view/commentcontentview.js +1 -1
- package/src/comments/ui/view/commentinputview.d.ts +86 -86
- package/src/comments/ui/view/commentinputview.js +1 -1
- package/src/comments/ui/view/commentsarchiveview.d.ts +38 -38
- package/src/comments/ui/view/commentsarchiveview.js +1 -1
- package/src/comments/ui/view/commentslistview.d.ts +100 -100
- package/src/comments/ui/view/commentslistview.js +1 -1
- package/src/comments/ui/view/commentthreadheaderview.d.ts +50 -50
- package/src/comments/ui/view/commentthreadheaderview.js +1 -1
- package/src/comments/ui/view/commentthreadinputview.d.ts +41 -41
- package/src/comments/ui/view/commentthreadinputview.js +1 -1
- package/src/comments/ui/view/commentthreadview.d.ts +118 -117
- package/src/comments/ui/view/commentthreadview.js +1 -1
- package/src/comments/ui/view/commentview.d.ts +243 -243
- package/src/comments/ui/view/commentview.js +1 -1
- package/src/comments.d.ts +35 -35
- package/src/comments.js +1 -1
- package/src/commentsonly.d.ts +33 -33
- package/src/commentsonly.js +1 -1
- package/src/config.d.ts +176 -176
- package/src/index.d.ts +24 -24
- package/src/utils/common-translations.d.ts +9 -9
- package/src/utils/common-translations.js +1 -1
- package/src/utils/createmutationobserver.d.ts +14 -14
- package/src/utils/createmutationobserver.js +1 -1
- package/theme/annotation-inline.css +2 -1
- package/theme/annotation.css +2 -3
- package/theme/comment.css +39 -38
- package/theme/commentinput.css +2 -1
- package/theme/commentmarker.css +7 -6
- package/theme/commentsarchive.css +2 -1
- package/theme/commentthread.css +68 -57
- package/theme/icons/add-comment.svg +1 -1
- package/theme/icons/comments-archive.svg +1 -1
- package/theme/icons/edit-comment.svg +1 -1
- package/theme/icons/remove-comment.svg +1 -1
- package/theme/sidebar-narrow.css +4 -3
- package/theme/sidebar.css +13 -12
|
@@ -1,232 +1,232 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, 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
|
-
* @module comments/annotations/annotationsuis
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { ContextPlugin, type Plugin, type Editor, type Context } from 'ckeditor5/src/core';
|
|
10
|
-
import { type Emitter } from 'ckeditor5/src/utils';
|
|
11
|
-
import AnnotationCollection from './annotationcollection';
|
|
12
|
-
import Annotations from './annotations';
|
|
13
|
-
import type Annotation from './annotation';
|
|
14
|
-
/**
|
|
15
|
-
* A repository of annotations UIs.
|
|
16
|
-
*
|
|
17
|
-
* The main entry point for {@link module:comments/annotations/annotationsuis~AnnotationsUIs#register registering} UIs
|
|
18
|
-
* and activating the annotations UI(s), which display annotation views.
|
|
19
|
-
*
|
|
20
|
-
* To register a custom annotations UI use following code in the annotations UI plugin `init()` function:
|
|
21
|
-
*
|
|
22
|
-
* ```ts
|
|
23
|
-
* const annotationsUIs = editor.plugins.get( 'annotationsUIs' );
|
|
24
|
-
*
|
|
25
|
-
* annotationsUIs.register( customAnnotationsUIPlugin );
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* Note that the custom annotations UI must implement {@link module:comments/annotations/annotationsuis~AnnotationsUI
|
|
29
|
-
* the `AnnotationsUI` interface}.
|
|
30
|
-
*
|
|
31
|
-
* To activate an annotations UI, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#switchTo
|
|
32
|
-
* `switchTo( uiName )`} method. This method activates the given UI and deactivates all the other UIs.
|
|
33
|
-
* All annotations will be handled by the activated UI.
|
|
34
|
-
*
|
|
35
|
-
* It is also possible to activate multiple annotations UIs at the same time and make the UIs handle different sets of annotations.
|
|
36
|
-
* To do that, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate `activate( uiName, filter )`} method.
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* // Suggestions annotations are shown inline in a balloon:
|
|
40
|
-
* annotationsUIs.activate( 'inline', annotation => annotation.type.startsWith( 'suggestion' ) );
|
|
41
|
-
*
|
|
42
|
-
* // At the same time, comments annotations are shown in a sidebar:
|
|
43
|
-
* annotationsUIs.activate( 'wideSidebar', annotation => annotation.type === 'comment' );
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* Limitations:
|
|
47
|
-
*
|
|
48
|
-
* * Some annotations UI plugins might collide with each other (like {@link module:comments/annotations/narrowsidebar~NarrowSidebar} and
|
|
49
|
-
* {@link module:comments/annotations/widesidebar~WideSidebar} that operates on the same sidebar). They cannot be activated at the same
|
|
50
|
-
* time.
|
|
51
|
-
* * It is not possible to display the same annotation in two different annotations UIs. In this scenario an error will be thrown.
|
|
52
|
-
*/
|
|
53
|
-
export default class AnnotationsUIs extends ContextPlugin {
|
|
54
|
-
/**
|
|
55
|
-
* A set of names of the active annotations UIs.
|
|
56
|
-
*
|
|
57
|
-
* To activate the annotations UI, use {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate}
|
|
58
|
-
* or {@link #switchTo} methods.
|
|
59
|
-
*/
|
|
60
|
-
activeUIs: Set<string>;
|
|
61
|
-
/**
|
|
62
|
-
* @inheritDoc
|
|
63
|
-
*/
|
|
64
|
-
static get requires(): readonly [typeof Annotations];
|
|
65
|
-
/**
|
|
66
|
-
* @inheritDoc
|
|
67
|
-
*/
|
|
68
|
-
static get pluginName(): "AnnotationsUIs";
|
|
69
|
-
/**
|
|
70
|
-
* @inheritDoc
|
|
71
|
-
*/
|
|
72
|
-
constructor(context: Context | Editor);
|
|
73
|
-
/**
|
|
74
|
-
* @inheritDoc
|
|
75
|
-
*/
|
|
76
|
-
init(): void;
|
|
77
|
-
/**
|
|
78
|
-
* Returns `true` if at least one registered UI is active.
|
|
79
|
-
*/
|
|
80
|
-
hasActive(): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Returns `true` if the given UI is active.
|
|
83
|
-
*/
|
|
84
|
-
isActive(uiName: string): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Activates an annotations UI.
|
|
87
|
-
*
|
|
88
|
-
* Note that the custom annotations UI should be {@link #register registered} before the activation.
|
|
89
|
-
*
|
|
90
|
-
* The `filter` parameter can be used to display on some of the annotations in the given annotations UI. Thanks to that,
|
|
91
|
-
* all annotations can be split into various annotations UIs.
|
|
92
|
-
*
|
|
93
|
-
* The `filter` function takes an {@link module:comments/annotations/annotation~Annotation} instance as the first and only parameter,
|
|
94
|
-
* and should return `true` if that annotation should be placed in the given annotations UI.
|
|
95
|
-
*
|
|
96
|
-
* @param uiName The name of the annotations UI to activate.
|
|
97
|
-
* @param filter The annotation filter function. If not specified, the UI will use all annotations.
|
|
98
|
-
*/
|
|
99
|
-
activate(uiName: string, filter?: () => boolean): void;
|
|
100
|
-
/**
|
|
101
|
-
* Deactivates annotations UI with given name.
|
|
102
|
-
*
|
|
103
|
-
* @param uiName The name of the annotations UI to deactivate.
|
|
104
|
-
*/
|
|
105
|
-
deactivate(uiName: string): void;
|
|
106
|
-
/**
|
|
107
|
-
* Switches the annotations UI to the one with given name.
|
|
108
|
-
*
|
|
109
|
-
* It preserves the currently active annotation.
|
|
110
|
-
*
|
|
111
|
-
* @param uiName The name of the annotations UI to switch to.
|
|
112
|
-
*/
|
|
113
|
-
switchTo(uiName: string): void;
|
|
114
|
-
/**
|
|
115
|
-
* Deactivates all annotations UIs.
|
|
116
|
-
*/
|
|
117
|
-
deactivateAll(): void;
|
|
118
|
-
/**
|
|
119
|
-
* Registers an annotations UI. It might be one of:
|
|
120
|
-
*
|
|
121
|
-
* * {@link module:comments/annotations/widesidebar~WideSidebar},
|
|
122
|
-
* * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
|
|
123
|
-
* * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
|
|
124
|
-
*
|
|
125
|
-
* It is possible to provide your own, custom annotations UI plugin. It has to implement
|
|
126
|
-
* {@link module:comments/annotations/annotationsuis~AnnotationsUI the `AnnotationsUI` interface}.
|
|
127
|
-
*
|
|
128
|
-
* @param uiName Annotations UI name.
|
|
129
|
-
* @param annotationsUI Annotations UI plugin instance.
|
|
130
|
-
*/
|
|
131
|
-
register(uiName: string, annotationsUI: AnnotationsUI<ContextPlugin | Plugin>): void;
|
|
132
|
-
/**
|
|
133
|
-
* Refilters annotations to proper UIs based on filters provided earlier during the
|
|
134
|
-
* {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate annotations UIs activation}.
|
|
135
|
-
*
|
|
136
|
-
* This method should be used if the annotations UIs filtering functions return different results than before
|
|
137
|
-
* for some annotations. It only reattaches these annotations, which should change their UIs.
|
|
138
|
-
*/
|
|
139
|
-
refilterAnnotations(): void;
|
|
140
|
-
/**
|
|
141
|
-
* @inheritDoc
|
|
142
|
-
*/
|
|
143
|
-
destroy(): void;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* An interface for the annotations UI plugin class.
|
|
147
|
-
*
|
|
148
|
-
* The annotations UI class handles displaying, focusing, activating and hiding annotations views.
|
|
149
|
-
*
|
|
150
|
-
* The annotations UI class must be a plugin, so it has to extend the {@link module:core/plugin~Plugin} or
|
|
151
|
-
* {@link module:core/contextplugin~ContextPlugin} class.
|
|
152
|
-
*
|
|
153
|
-
* Examples of `AnnotationsUI` are:
|
|
154
|
-
*
|
|
155
|
-
* * {@link module:comments/annotations/widesidebar~WideSidebar},
|
|
156
|
-
* * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
|
|
157
|
-
* * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
|
|
158
|
-
*
|
|
159
|
-
* You can use the following snippet as a base for your own annotations UI:
|
|
160
|
-
*
|
|
161
|
-
* ```ts
|
|
162
|
-
* class MyAnnotationsUI extends ContextPlugin {
|
|
163
|
-
* constructor( ...args ) {
|
|
164
|
-
* super( ...args );
|
|
165
|
-
*
|
|
166
|
-
* this.set( 'activeAnnotation', null );
|
|
167
|
-
* }
|
|
168
|
-
*
|
|
169
|
-
* attach( annotations ) {
|
|
170
|
-
* // Do something when an annotation is added.
|
|
171
|
-
* this.listenTo( annotations, 'add', ( evt, annotation ) => { ... } );
|
|
172
|
-
*
|
|
173
|
-
* // Do something when an annotation is removed.
|
|
174
|
-
* this.listenTo( annotations, 'remove', ( evt, annotation ) => { ... } );
|
|
175
|
-
* }
|
|
176
|
-
*
|
|
177
|
-
* detach() {
|
|
178
|
-
* this.stopListening();
|
|
179
|
-
* }
|
|
180
|
-
*
|
|
181
|
-
* setActiveAnnotation( annotation ) {
|
|
182
|
-
* if ( this.activeAnnotation ) {
|
|
183
|
-
* this.activeAnnotation.isActive = false;
|
|
184
|
-
*
|
|
185
|
-
* // You can do something in your UI with the annotation that is no longer active.
|
|
186
|
-
* }
|
|
187
|
-
*
|
|
188
|
-
* this.activeAnnotation = annotation;
|
|
189
|
-
* this.activeAnnotation.isActive = true;
|
|
190
|
-
*
|
|
191
|
-
* // You can do something in your UI to highlight the active annotation.
|
|
192
|
-
* }
|
|
193
|
-
* }
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
export interface AnnotationUI {
|
|
197
|
-
/**
|
|
198
|
-
* Observable `activeAnnotation` property. {@link module:comments/annotations/annotationsuis~AnnotationsUIs} listens to changes on that
|
|
199
|
-
* property.
|
|
200
|
-
*
|
|
201
|
-
* To make this property observable use `this.set( 'activeAnnotation', null )` in the constructor.
|
|
202
|
-
*/
|
|
203
|
-
activeAnnotation: Annotation | null;
|
|
204
|
-
/**
|
|
205
|
-
* Creates everything needed for the UI and attaches all listeners. This method is called when the UI is activated.
|
|
206
|
-
*
|
|
207
|
-
* The observable collection of annotations is passed as the first argument,
|
|
208
|
-
* and the annotations UI is responsible for reacting to its changes.
|
|
209
|
-
*/
|
|
210
|
-
attach: (annotationCollection: AnnotationCollection) => void;
|
|
211
|
-
/**
|
|
212
|
-
* Destroys the UI and removes all listeners. This method is called when the UI is deactivated.
|
|
213
|
-
*/
|
|
214
|
-
detach: () => void;
|
|
215
|
-
/**
|
|
216
|
-
* Sets or unsets the active annotation. This method is called when an annotation is activated, for example, user puts their
|
|
217
|
-
* selection into a marker connected with given annotation.
|
|
218
|
-
*
|
|
219
|
-
* This method should change the UI so the new active annotation is differentiated from other annotations.
|
|
220
|
-
*
|
|
221
|
-
* This method should set the
|
|
222
|
-
* {@link #activeAnnotation `AnnotationUI#activeAnnotation`} property.
|
|
223
|
-
*
|
|
224
|
-
* It also should set {@link module:comments/annotations/annotation~Annotation#isActive `Annotation#isActive`} of the deactivated
|
|
225
|
-
* and the activated annotation.
|
|
226
|
-
*
|
|
227
|
-
* @param annotation The new active annotation or null when no annotation is active.
|
|
228
|
-
*/
|
|
229
|
-
setActiveAnnotation: (annotation: Annotation | null) => void;
|
|
230
|
-
_setSelectedAnnotations?: (annotations: Array<Annotation>) => void;
|
|
231
|
-
}
|
|
232
|
-
export type AnnotationsUI<T extends Emitter> = T & AnnotationUI;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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
|
+
* @module comments/annotations/annotationsuis
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { ContextPlugin, type Plugin, type Editor, type Context } from 'ckeditor5/src/core';
|
|
10
|
+
import { type Emitter } from 'ckeditor5/src/utils';
|
|
11
|
+
import AnnotationCollection from './annotationcollection';
|
|
12
|
+
import Annotations from './annotations';
|
|
13
|
+
import type Annotation from './annotation';
|
|
14
|
+
/**
|
|
15
|
+
* A repository of annotations UIs.
|
|
16
|
+
*
|
|
17
|
+
* The main entry point for {@link module:comments/annotations/annotationsuis~AnnotationsUIs#register registering} UIs
|
|
18
|
+
* and activating the annotations UI(s), which display annotation views.
|
|
19
|
+
*
|
|
20
|
+
* To register a custom annotations UI use following code in the annotations UI plugin `init()` function:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const annotationsUIs = editor.plugins.get( 'annotationsUIs' );
|
|
24
|
+
*
|
|
25
|
+
* annotationsUIs.register( customAnnotationsUIPlugin );
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Note that the custom annotations UI must implement {@link module:comments/annotations/annotationsuis~AnnotationsUI
|
|
29
|
+
* the `AnnotationsUI` interface}.
|
|
30
|
+
*
|
|
31
|
+
* To activate an annotations UI, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#switchTo
|
|
32
|
+
* `switchTo( uiName )`} method. This method activates the given UI and deactivates all the other UIs.
|
|
33
|
+
* All annotations will be handled by the activated UI.
|
|
34
|
+
*
|
|
35
|
+
* It is also possible to activate multiple annotations UIs at the same time and make the UIs handle different sets of annotations.
|
|
36
|
+
* To do that, use the {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate `activate( uiName, filter )`} method.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* // Suggestions annotations are shown inline in a balloon:
|
|
40
|
+
* annotationsUIs.activate( 'inline', annotation => annotation.type.startsWith( 'suggestion' ) );
|
|
41
|
+
*
|
|
42
|
+
* // At the same time, comments annotations are shown in a sidebar:
|
|
43
|
+
* annotationsUIs.activate( 'wideSidebar', annotation => annotation.type === 'comment' );
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Limitations:
|
|
47
|
+
*
|
|
48
|
+
* * Some annotations UI plugins might collide with each other (like {@link module:comments/annotations/narrowsidebar~NarrowSidebar} and
|
|
49
|
+
* {@link module:comments/annotations/widesidebar~WideSidebar} that operates on the same sidebar). They cannot be activated at the same
|
|
50
|
+
* time.
|
|
51
|
+
* * It is not possible to display the same annotation in two different annotations UIs. In this scenario an error will be thrown.
|
|
52
|
+
*/
|
|
53
|
+
export default class AnnotationsUIs extends ContextPlugin {
|
|
54
|
+
/**
|
|
55
|
+
* A set of names of the active annotations UIs.
|
|
56
|
+
*
|
|
57
|
+
* To activate the annotations UI, use {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate}
|
|
58
|
+
* or {@link #switchTo} methods.
|
|
59
|
+
*/
|
|
60
|
+
activeUIs: Set<string>;
|
|
61
|
+
/**
|
|
62
|
+
* @inheritDoc
|
|
63
|
+
*/
|
|
64
|
+
static get requires(): readonly [typeof Annotations];
|
|
65
|
+
/**
|
|
66
|
+
* @inheritDoc
|
|
67
|
+
*/
|
|
68
|
+
static get pluginName(): "AnnotationsUIs";
|
|
69
|
+
/**
|
|
70
|
+
* @inheritDoc
|
|
71
|
+
*/
|
|
72
|
+
constructor(context: Context | Editor);
|
|
73
|
+
/**
|
|
74
|
+
* @inheritDoc
|
|
75
|
+
*/
|
|
76
|
+
init(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Returns `true` if at least one registered UI is active.
|
|
79
|
+
*/
|
|
80
|
+
hasActive(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Returns `true` if the given UI is active.
|
|
83
|
+
*/
|
|
84
|
+
isActive(uiName: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Activates an annotations UI.
|
|
87
|
+
*
|
|
88
|
+
* Note that the custom annotations UI should be {@link #register registered} before the activation.
|
|
89
|
+
*
|
|
90
|
+
* The `filter` parameter can be used to display on some of the annotations in the given annotations UI. Thanks to that,
|
|
91
|
+
* all annotations can be split into various annotations UIs.
|
|
92
|
+
*
|
|
93
|
+
* The `filter` function takes an {@link module:comments/annotations/annotation~Annotation} instance as the first and only parameter,
|
|
94
|
+
* and should return `true` if that annotation should be placed in the given annotations UI.
|
|
95
|
+
*
|
|
96
|
+
* @param uiName The name of the annotations UI to activate.
|
|
97
|
+
* @param filter The annotation filter function. If not specified, the UI will use all annotations.
|
|
98
|
+
*/
|
|
99
|
+
activate(uiName: string, filter?: () => boolean): void;
|
|
100
|
+
/**
|
|
101
|
+
* Deactivates annotations UI with given name.
|
|
102
|
+
*
|
|
103
|
+
* @param uiName The name of the annotations UI to deactivate.
|
|
104
|
+
*/
|
|
105
|
+
deactivate(uiName: string): void;
|
|
106
|
+
/**
|
|
107
|
+
* Switches the annotations UI to the one with given name.
|
|
108
|
+
*
|
|
109
|
+
* It preserves the currently active annotation.
|
|
110
|
+
*
|
|
111
|
+
* @param uiName The name of the annotations UI to switch to.
|
|
112
|
+
*/
|
|
113
|
+
switchTo(uiName: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Deactivates all annotations UIs.
|
|
116
|
+
*/
|
|
117
|
+
deactivateAll(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Registers an annotations UI. It might be one of:
|
|
120
|
+
*
|
|
121
|
+
* * {@link module:comments/annotations/widesidebar~WideSidebar},
|
|
122
|
+
* * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
|
|
123
|
+
* * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
|
|
124
|
+
*
|
|
125
|
+
* It is possible to provide your own, custom annotations UI plugin. It has to implement
|
|
126
|
+
* {@link module:comments/annotations/annotationsuis~AnnotationsUI the `AnnotationsUI` interface}.
|
|
127
|
+
*
|
|
128
|
+
* @param uiName Annotations UI name.
|
|
129
|
+
* @param annotationsUI Annotations UI plugin instance.
|
|
130
|
+
*/
|
|
131
|
+
register(uiName: string, annotationsUI: AnnotationsUI<ContextPlugin | Plugin>): void;
|
|
132
|
+
/**
|
|
133
|
+
* Refilters annotations to proper UIs based on filters provided earlier during the
|
|
134
|
+
* {@link module:comments/annotations/annotationsuis~AnnotationsUIs#activate annotations UIs activation}.
|
|
135
|
+
*
|
|
136
|
+
* This method should be used if the annotations UIs filtering functions return different results than before
|
|
137
|
+
* for some annotations. It only reattaches these annotations, which should change their UIs.
|
|
138
|
+
*/
|
|
139
|
+
refilterAnnotations(): void;
|
|
140
|
+
/**
|
|
141
|
+
* @inheritDoc
|
|
142
|
+
*/
|
|
143
|
+
destroy(): void;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* An interface for the annotations UI plugin class.
|
|
147
|
+
*
|
|
148
|
+
* The annotations UI class handles displaying, focusing, activating and hiding annotations views.
|
|
149
|
+
*
|
|
150
|
+
* The annotations UI class must be a plugin, so it has to extend the {@link module:core/plugin~Plugin} or
|
|
151
|
+
* {@link module:core/contextplugin~ContextPlugin} class.
|
|
152
|
+
*
|
|
153
|
+
* Examples of `AnnotationsUI` are:
|
|
154
|
+
*
|
|
155
|
+
* * {@link module:comments/annotations/widesidebar~WideSidebar},
|
|
156
|
+
* * {@link module:comments/annotations/narrowsidebar~NarrowSidebar},
|
|
157
|
+
* * {@link module:comments/annotations/inlineannotations~InlineAnnotations}.
|
|
158
|
+
*
|
|
159
|
+
* You can use the following snippet as a base for your own annotations UI:
|
|
160
|
+
*
|
|
161
|
+
* ```ts
|
|
162
|
+
* class MyAnnotationsUI extends ContextPlugin {
|
|
163
|
+
* constructor( ...args ) {
|
|
164
|
+
* super( ...args );
|
|
165
|
+
*
|
|
166
|
+
* this.set( 'activeAnnotation', null );
|
|
167
|
+
* }
|
|
168
|
+
*
|
|
169
|
+
* attach( annotations ) {
|
|
170
|
+
* // Do something when an annotation is added.
|
|
171
|
+
* this.listenTo( annotations, 'add', ( evt, annotation ) => { ... } );
|
|
172
|
+
*
|
|
173
|
+
* // Do something when an annotation is removed.
|
|
174
|
+
* this.listenTo( annotations, 'remove', ( evt, annotation ) => { ... } );
|
|
175
|
+
* }
|
|
176
|
+
*
|
|
177
|
+
* detach() {
|
|
178
|
+
* this.stopListening();
|
|
179
|
+
* }
|
|
180
|
+
*
|
|
181
|
+
* setActiveAnnotation( annotation ) {
|
|
182
|
+
* if ( this.activeAnnotation ) {
|
|
183
|
+
* this.activeAnnotation.isActive = false;
|
|
184
|
+
*
|
|
185
|
+
* // You can do something in your UI with the annotation that is no longer active.
|
|
186
|
+
* }
|
|
187
|
+
*
|
|
188
|
+
* this.activeAnnotation = annotation;
|
|
189
|
+
* this.activeAnnotation.isActive = true;
|
|
190
|
+
*
|
|
191
|
+
* // You can do something in your UI to highlight the active annotation.
|
|
192
|
+
* }
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export interface AnnotationUI {
|
|
197
|
+
/**
|
|
198
|
+
* Observable `activeAnnotation` property. {@link module:comments/annotations/annotationsuis~AnnotationsUIs} listens to changes on that
|
|
199
|
+
* property.
|
|
200
|
+
*
|
|
201
|
+
* To make this property observable use `this.set( 'activeAnnotation', null )` in the constructor.
|
|
202
|
+
*/
|
|
203
|
+
activeAnnotation: Annotation | null;
|
|
204
|
+
/**
|
|
205
|
+
* Creates everything needed for the UI and attaches all listeners. This method is called when the UI is activated.
|
|
206
|
+
*
|
|
207
|
+
* The observable collection of annotations is passed as the first argument,
|
|
208
|
+
* and the annotations UI is responsible for reacting to its changes.
|
|
209
|
+
*/
|
|
210
|
+
attach: (annotationCollection: AnnotationCollection) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Destroys the UI and removes all listeners. This method is called when the UI is deactivated.
|
|
213
|
+
*/
|
|
214
|
+
detach: () => void;
|
|
215
|
+
/**
|
|
216
|
+
* Sets or unsets the active annotation. This method is called when an annotation is activated, for example, user puts their
|
|
217
|
+
* selection into a marker connected with given annotation.
|
|
218
|
+
*
|
|
219
|
+
* This method should change the UI so the new active annotation is differentiated from other annotations.
|
|
220
|
+
*
|
|
221
|
+
* This method should set the
|
|
222
|
+
* {@link #activeAnnotation `AnnotationUI#activeAnnotation`} property.
|
|
223
|
+
*
|
|
224
|
+
* It also should set {@link module:comments/annotations/annotation~Annotation#isActive `Annotation#isActive`} of the deactivated
|
|
225
|
+
* and the activated annotation.
|
|
226
|
+
*
|
|
227
|
+
* @param annotation The new active annotation or null when no annotation is active.
|
|
228
|
+
*/
|
|
229
|
+
setActiveAnnotation: (annotation: Annotation | null) => void;
|
|
230
|
+
_setSelectedAnnotations?: (annotations: Array<Annotation>) => void;
|
|
231
|
+
}
|
|
232
|
+
export type AnnotationsUI<T extends Emitter> = T & AnnotationUI;
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x4fec=['add','context','_removeActiveAnnotation','listenTo','has','_activateAnnotation','length','switchTo','filter','annotationsuis-missing-ui','plugins','init','activate','push','size','setActiveAnnotation','requires','hasActive','_assertAnnotationDoesNotBelongToMultipleUIs','refilterAnnotations','attach','isActive','remove','destroy','annotationsuis-register-invalid-interface','register','change:activeAnnotation','_addActiveAnnotation','pluginName','set','annotationsuis-annotation-mismatch','_deactivateAllAnnotations','function','_uisData','AnnotationsUIs','_setSelectedAnnotations','activeAnnotations','type','_visibleAnnotations','get','delete','stopListening','activeUIs','collection','_uis','detach','deactivateAll','from','deactivate'];(function(_0x1f9613,_0x4fece1){const _0x4fb494=function(_0x490230){while(--_0x490230){_0x1f9613['push'](_0x1f9613['shift']());}};_0x4fb494(++_0x4fece1);}(_0x4fec,0xe8));const _0x4fb4=function(_0x1f9613,_0x4fece1){_0x1f9613=_0x1f9613-0x0;let _0x4fb494=_0x4fec[_0x1f9613];return _0x4fb494;};import{ContextPlugin as _0x18fe70}from'ckeditor5/src/core';import{CKEditorError as _0x105095}from'ckeditor5/src/utils';import _0xf65751,{bindAnnotationCollections as _0x163537}from'./annotationcollection';import _0x377632 from'./annotations';export default class M extends _0x18fe70{static get[_0x4fb4('0x1d')](){return[_0x377632];}static get[_0x4fb4('0x29')](){return _0x4fb4('0x2f');}constructor(_0x556b35){super(_0x556b35),this[_0x4fb4('0x6')]=new Set(),this[_0x4fb4('0x8')]=new Map(),this[_0x4fb4('0x2e')]=new Map();}[_0x4fb4('0x18')](){const _0x168c72=this['context'][_0x4fb4('0x17')]['get'](_0x377632);this[_0x4fb4('0x10')](_0x168c72,_0x4fb4('0x12'),(_0x1fce01,_0xf1c841)=>{for(const _0x1c6f6e of this['activeUIs']){const _0x541eb6=this[_0x4fb4('0x8')]['get'](_0x1c6f6e);(0x0,this[_0x4fb4('0x2e')][_0x4fb4('0x3')](_0x1c6f6e)[_0x4fb4('0x15')])(_0xf1c841)&&_0x541eb6['setActiveAnnotation'](_0xf1c841);}}),this[_0x4fb4('0x10')](_0x168c72,_0x4fb4('0x2c'),()=>{for(const _0x209a2b of this[_0x4fb4('0x6')]){this['_uis'][_0x4fb4('0x3')](_0x209a2b)[_0x4fb4('0x1c')](null);}}),this[_0x4fb4('0x10')](_0x168c72[_0x4fb4('0x2')],_0x4fb4('0xd'),(_0x35ff2b,_0x5e1c83)=>{this[_0x4fb4('0x1f')](_0x5e1c83);});}[_0x4fb4('0x1e')](){return this[_0x4fb4('0x6')][_0x4fb4('0x1b')]>0x0;}[_0x4fb4('0x22')](_0x36aba8){return this[_0x4fb4('0x6')][_0x4fb4('0x11')](_0x36aba8);}[_0x4fb4('0x19')](_0x29f44a,_0xc743aa=()=>!0x0){const _0x671386=this[_0x4fb4('0xe')][_0x4fb4('0x17')][_0x4fb4('0x3')](_0x377632);if(!this[_0x4fb4('0x8')][_0x4fb4('0x11')](_0x29f44a))throw new _0x105095(_0x4fb4('0x16'),this,{'uiName':_0x29f44a});this['isActive'](_0x29f44a)&&this[_0x4fb4('0xc')](_0x29f44a),this[_0x4fb4('0x6')][_0x4fb4('0xd')](_0x29f44a);const _0x45ee0d=new _0xf65751(),_0x4f5bec=_0x671386[_0x4fb4('0x2')];_0x163537({'source':_0x4f5bec,'target':_0x45ee0d,'filter':_0xc743aa}),this[_0x4fb4('0x2e')][_0x4fb4('0x2a')](_0x29f44a,{'collection':_0x45ee0d,'filter':_0xc743aa});const _0x121a34=this[_0x4fb4('0x8')][_0x4fb4('0x3')](_0x29f44a);_0x121a34[_0x4fb4('0x21')](_0x45ee0d),this['listenTo'](_0x121a34,_0x4fb4('0x27'),(_0x2609ca,_0x29447e,_0x444313,_0x4775bb)=>{_0x4775bb&&_0x671386[_0x4fb4('0xf')](_0x4775bb),_0x444313&&_0x671386[_0x4fb4('0x28')](_0x444313);});}[_0x4fb4('0xc')](_0x115807){if(this[_0x4fb4('0x6')][_0x4fb4('0x4')](_0x115807),!this[_0x4fb4('0x8')][_0x4fb4('0x11')](_0x115807))throw new _0x105095('annotationsuis-missing-ui',this,{'uiName':_0x115807});const _0x3d5651=this[_0x4fb4('0x8')][_0x4fb4('0x3')](_0x115807);_0x3d5651['detach'](),this[_0x4fb4('0x5')](_0x3d5651),this['_uisData'][_0x4fb4('0x3')](_0x115807)[_0x4fb4('0x7')][_0x4fb4('0x24')](),this[_0x4fb4('0x2e')]['delete'](_0x115807);}[_0x4fb4('0x14')](_0x465745){if(!this['_uis'][_0x4fb4('0x11')](_0x465745))throw new _0x105095(_0x4fb4('0x16'),this,{'uiName':_0x465745});const _0x10bde0=this[_0x4fb4('0xe')][_0x4fb4('0x17')]['get'](_0x377632),_0x1e8c9e=Array['from'](_0x10bde0[_0x4fb4('0x0')])[0x0]||null;this[_0x4fb4('0xa')](),this[_0x4fb4('0x19')](_0x465745);const _0xf20f4b=this[_0x4fb4('0x8')][_0x4fb4('0x3')](_0x465745);_0xf20f4b[_0x4fb4('0x1c')](_0x1e8c9e),_0xf20f4b[_0x4fb4('0x30')]&&_0x1e8c9e&&_0xf20f4b['_setSelectedAnnotations']([_0x1e8c9e]);}[_0x4fb4('0xa')](){for(const _0x435759 of this[_0x4fb4('0x6')])this[_0x4fb4('0xc')](_0x435759);}[_0x4fb4('0x26')](_0x561730,_0x4ea4a4){if(this[_0x4fb4('0x8')][_0x4fb4('0x11')](_0x561730))throw new _0x105095('annotationsuis-register-already-registered');if(_0x4fb4('0x2d')!=typeof _0x4ea4a4[_0x4fb4('0x21')]||_0x4fb4('0x2d')!=typeof _0x4ea4a4[_0x4fb4('0x9')]||_0x4fb4('0x2d')!=typeof _0x4ea4a4[_0x4fb4('0x1c')])throw new _0x105095(_0x4fb4('0x25'),null);this[_0x4fb4('0x8')][_0x4fb4('0x2a')](_0x561730,_0x4ea4a4);}[_0x4fb4('0x20')](){const _0x128ea1=this[_0x4fb4('0xe')][_0x4fb4('0x17')][_0x4fb4('0x3')](_0x377632)[_0x4fb4('0x7')],_0x5ad5e3=new Map(),_0x51d9db=Array[_0x4fb4('0xb')](this['activeUIs']);for(const _0x2be9f0 of this[_0x4fb4('0x6')]){const _0x342344=this[_0x4fb4('0x2e')][_0x4fb4('0x3')](_0x2be9f0)[_0x4fb4('0x7')];for(const _0x5153c5 of _0x342344)_0x5ad5e3[_0x4fb4('0x2a')](_0x5153c5,_0x2be9f0);}for(const _0x340beb of _0x128ea1){const _0x23395e=_0x5ad5e3[_0x4fb4('0x3')](_0x340beb);this['_assertAnnotationDoesNotBelongToMultipleUIs'](_0x340beb);const _0x5136ff=_0x51d9db['find'](_0x245be7=>this[_0x4fb4('0x2e')][_0x4fb4('0x3')](_0x245be7)['filter'](_0x340beb));_0x23395e!==_0x5136ff&&(_0x23395e&&this['_uisData']['get'](_0x23395e)[_0x4fb4('0x7')][_0x4fb4('0x23')](_0x340beb),_0x5136ff&&this[_0x4fb4('0x2e')][_0x4fb4('0x3')](_0x5136ff)[_0x4fb4('0x7')][_0x4fb4('0xd')](_0x340beb));}}[_0x4fb4('0x24')](){this[_0x4fb4('0xa')](),super[_0x4fb4('0x24')]();}['_assertAnnotationDoesNotBelongToMultipleUIs'](_0x9467c8){const _0xc2a974=[];for(const _0x31a650 of this[_0x4fb4('0x6')]){(0x0,this[_0x4fb4('0x2e')][_0x4fb4('0x3')](_0x31a650)[_0x4fb4('0x15')])(_0x9467c8)&&_0xc2a974[_0x4fb4('0x1a')](_0x31a650);}if(_0xc2a974[_0x4fb4('0x13')]>0x1)throw new _0x105095(_0x4fb4('0x2b'),null,{'matchedUIs':_0xc2a974,'annotationType':_0x9467c8[_0x4fb4('0x1')]});}}
|