@ckeditor/ckeditor5-mention 41.1.0 → 41.3.0-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/mention
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import type { Element } from 'ckeditor5/src/engine.js';
10
+ import MentionEditing from './mentionediting.js';
11
+ import MentionUI from './mentionui.js';
12
+ import '../theme/mention.css';
13
+ /**
14
+ * The mention plugin.
15
+ *
16
+ * For a detailed overview, check the {@glink features/mentions Mention feature} guide.
17
+ */
18
+ export default class Mention extends Plugin {
19
+ /**
20
+ * Creates a mention attribute value from the provided view element and additional data.
21
+ *
22
+ * ```ts
23
+ * editor.plugins.get( 'Mention' ).toMentionAttribute( viewElement, { userId: '1234' } );
24
+ *
25
+ * // For a view element: <span data-mention="@joe">@John Doe</span>
26
+ * // it will return:
27
+ * // { id: '@joe', userId: '1234', uid: '7a7bc7...', _text: '@John Doe' }
28
+ * ```
29
+ *
30
+ * @param data Additional data to be stored in the mention attribute.
31
+ */
32
+ toMentionAttribute<MentionData extends Record<string, unknown>>(viewElement: Element, data: MentionData): (MentionAttribute & MentionData) | undefined;
33
+ /**
34
+ * Creates a mention attribute value from the provided view element.
35
+ *
36
+ * ```ts
37
+ * editor.plugins.get( 'Mention' ).toMentionAttribute( viewElement );
38
+ *
39
+ * // For a view element: <span data-mention="@joe">@John Doe</span>
40
+ * // it will return:
41
+ * // { id: '@joe', uid: '7a7bc7...', _text: '@John Doe' }
42
+ * ```
43
+ */
44
+ toMentionAttribute(viewElement: Element): MentionAttribute | undefined;
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ static get pluginName(): "Mention";
49
+ /**
50
+ * @inheritDoc
51
+ */
52
+ static get requires(): readonly [typeof MentionEditing, typeof MentionUI];
53
+ }
54
+ /**
55
+ * Represents a mention in the model.
56
+ *
57
+ * See {@link module:mention/mention~Mention#toMentionAttribute `Mention#toMentionAttribute()`}.
58
+ */
59
+ export type MentionAttribute = {
60
+ /**
61
+ * The ID of a mention. It identifies the mention item in the mention feed. There can be multiple mentions
62
+ * in the document with the same ID (e.g. the same hashtag being mentioned).
63
+ */
64
+ id: string;
65
+ /**
66
+ * A unique ID of this mention instance. Should be passed as an `option.id` when using
67
+ * {@link module:engine/view/downcastwriter~DowncastWriter#createAttributeElement writer.createAttributeElement()}.
68
+ */
69
+ uid: string;
70
+ /**
71
+ * Helper property that stores the text of the inserted mention. Used for detecting a broken mention
72
+ * in the editing area.
73
+ *
74
+ * @internal
75
+ */
76
+ _text: string;
77
+ };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/mentioncommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
9
+ import type { Range } from 'ckeditor5/src/engine.js';
10
+ /**
11
+ * The mention command.
12
+ *
13
+ * The command is registered by {@link module:mention/mentionediting~MentionEditing} as `'mention'`.
14
+ *
15
+ * To insert a mention into a range, execute the command and specify a mention object with a range to replace:
16
+ *
17
+ * ```ts
18
+ * const focus = editor.model.document.selection.focus;
19
+ *
20
+ * // It will replace one character before the selection focus with the '#1234' text
21
+ * // with the mention attribute filled with passed attributes.
22
+ * editor.execute( 'mention', {
23
+ * marker: '#',
24
+ * mention: {
25
+ * id: '#1234',
26
+ * name: 'Foo',
27
+ * title: 'Big Foo'
28
+ * },
29
+ * range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
30
+ * } );
31
+ *
32
+ * // It will replace one character before the selection focus with the 'The "Big Foo"' text
33
+ * // with the mention attribute filled with passed attributes.
34
+ * editor.execute( 'mention', {
35
+ * marker: '#',
36
+ * mention: {
37
+ * id: '#1234',
38
+ * name: 'Foo',
39
+ * title: 'Big Foo'
40
+ * },
41
+ * text: 'The "Big Foo"',
42
+ * range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
43
+ * } );
44
+ * ```
45
+ */
46
+ export default class MentionCommand extends Command {
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ constructor(editor: Editor);
51
+ /**
52
+ * @inheritDoc
53
+ */
54
+ refresh(): void;
55
+ /**
56
+ * Executes the command.
57
+ *
58
+ * @param options Options for the executed command.
59
+ * @param options.mention The mention object to insert. When a string is passed, it will be used to create a plain
60
+ * object with the name attribute that equals the passed string.
61
+ * @param options.marker The marker character (e.g. `'@'`).
62
+ * @param options.text The text of the inserted mention. Defaults to the full mention string composed from `marker` and
63
+ * `mention` string or `mention.id` if an object is passed.
64
+ * @param options.range The range to replace.
65
+ * Note that the replaced range might be shorter than the inserted text with the mention attribute.
66
+ * @fires execute
67
+ */
68
+ execute(options: {
69
+ mention: string | {
70
+ id: string;
71
+ [key: string]: unknown;
72
+ };
73
+ marker: string;
74
+ text?: string;
75
+ range?: Range;
76
+ }): void;
77
+ }
@@ -0,0 +1,265 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/mentionconfig
7
+ */
8
+ /**
9
+ * The configuration of the mention feature.
10
+ *
11
+ * Read more about {@glink features/mentions#configuration configuring the mention feature}.
12
+ *
13
+ * ```ts
14
+ * ClassicEditor
15
+ * .create( editorElement, {
16
+ * mention: ... // Mention feature options.
17
+ * } )
18
+ * .then( ... )
19
+ * .catch( ... );
20
+ * ```
21
+ *
22
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
23
+ */
24
+ export interface MentionConfig {
25
+ /**
26
+ * The list of mention feeds supported by the editor.
27
+ *
28
+ * ```ts
29
+ * ClassicEditor
30
+ * .create( editorElement, {
31
+ * plugins: [ Mention, ... ],
32
+ * mention: {
33
+ * feeds: [
34
+ * {
35
+ * marker: '@',
36
+ * feed: [ '@Barney', '@Lily', '@Marshall', '@Robin', '@Ted' ]
37
+ * },
38
+ * ...
39
+ * ]
40
+ * }
41
+ * } )
42
+ * .then( ... )
43
+ * .catch( ... );
44
+ * ```
45
+ *
46
+ * You can provide many mention feeds but they must use different `marker`s.
47
+ * For example, you can use `'@'` to autocomplete people and `'#'` to autocomplete tags.
48
+ */
49
+ feeds: Array<MentionFeed>;
50
+ /**
51
+ * The configuration of the custom commit keys supported by the editor.
52
+ *
53
+ * ```ts
54
+ * ClassicEditor
55
+ * .create( editorElement, {
56
+ * plugins: [ Mention, ... ],
57
+ * mention: {
58
+ * // [ Enter, Space ]
59
+ * commitKeys: [ 13, 32 ]
60
+ * feeds: [
61
+ * { ... }
62
+ * ...
63
+ * ]
64
+ * }
65
+ * } )
66
+ * .then( ... )
67
+ * .catch( ... );
68
+ * ```
69
+ *
70
+ * Custom commit keys configuration allows you to customize how users will confirm the selection of mentions from the dropdown list.
71
+ * You can add as many mention commit keys as you need. For instance, in the snippet above new mentions will be committed by pressing
72
+ * either <kbd>Enter</kbd> or <kbd>Space</kbd> (13 and 32 key codes respectively).
73
+ *
74
+ * @default [ 13, 9 ] // [ Enter, Tab ]
75
+ */
76
+ commitKeys?: Array<number>;
77
+ /**
78
+ * The configuration of the custom number of visible mentions.
79
+ *
80
+ * Customizing the number of visible mentions allows you to specify how many available elements will the users be able to see
81
+ * in the dropdown list. You can specify any number you see fit. For example, in the snippets below you will find the
82
+ * dropdownLimit set to `20` and `Infinity` (the latter will result in showing all available mentions).
83
+ *
84
+ * ```ts
85
+ * ClassicEditor
86
+ * .create( editorElement, {
87
+ * plugins: [ Mention, ... ],
88
+ * mention: {
89
+ * dropdownLimit: 20,
90
+ * feeds: [
91
+ * { ... }
92
+ * ...
93
+ * ]
94
+ * }
95
+ * } )
96
+ * .then( ... )
97
+ * .catch( ... );
98
+ *
99
+ * ClassicEditor
100
+ * .create( editorElement, {
101
+ * plugins: [ Mention, ... ],
102
+ * mention: {
103
+ * dropdownLimit: Infinity,
104
+ * feeds: [
105
+ * { ... }
106
+ * ...
107
+ * ]
108
+ * }
109
+ * } )
110
+ * .then( ... )
111
+ * .catch( ... );
112
+ * ```
113
+ *
114
+ * @default 10
115
+ */
116
+ dropdownLimit?: number;
117
+ }
118
+ /**
119
+ * The mention feed descriptor. Used in {@link module:mention/mentionconfig~MentionConfig `config.mention`}.
120
+ *
121
+ * See {@link module:mention/mentionconfig~MentionConfig} to learn more.
122
+ *
123
+ * ```ts
124
+ * // Static configuration.
125
+ * const mentionFeedPeople = {
126
+ * marker: '@',
127
+ * feed: [ '@Alice', '@Bob', ... ],
128
+ * minimumCharacters: 2
129
+ * };
130
+ *
131
+ * // Simple synchronous callback.
132
+ * const mentionFeedTags = {
133
+ * marker: '#',
134
+ * feed: ( searchString: string ) => {
135
+ * return tags
136
+ * // Filter the tags list.
137
+ * .filter( tag => {
138
+ * return tag.toLowerCase().includes( queryText.toLowerCase() );
139
+ * } )
140
+ * }
141
+ * };
142
+ *
143
+ * const tags = [ 'wysiwyg', 'rte', 'rich-text-edior', 'collaboration', 'real-time', ... ];
144
+ *
145
+ * // Asynchronous callback.
146
+ * const mentionFeedPlaceholders = {
147
+ * marker: '$',
148
+ * feed: ( searchString: string ) => {
149
+ * return getMatchingPlaceholders( searchString );
150
+ * }
151
+ * };
152
+ *
153
+ * function getMatchingPlaceholders( searchString: string ) {
154
+ * return new Promise<Array<MentionFeedItem>>( resolve => {
155
+ * doSomeXHRQuery( result => {
156
+ * // console.log( result );
157
+ * // -> [ '$name', '$surname', '$postal', ... ]
158
+ *
159
+ * resolve( result );
160
+ * } );
161
+ * } );
162
+ * }
163
+ * ```
164
+ */
165
+ export interface MentionFeed {
166
+ /**
167
+ * The character which triggers autocompletion for mention. It must be a single character.
168
+ */
169
+ marker: string;
170
+ /**
171
+ * Autocomplete items. Provide an array for
172
+ * a static configuration (the mention feature will show matching items automatically) or a function which returns an array of
173
+ * matching items (directly, or via a promise). If a function is passed, it is executed in the context of the editor instance.
174
+ */
175
+ feed: Array<MentionFeedItem> | FeedCallback;
176
+ /**
177
+ * Specifies after how many characters the autocomplete panel should be shown.
178
+ *
179
+ * @default 0
180
+ */
181
+ minimumCharacters?: number;
182
+ /**
183
+ * A function that renders a {@link module:mention/mentionconfig~MentionFeedItem}
184
+ * to the autocomplete panel.
185
+ */
186
+ itemRenderer?: ItemRenderer;
187
+ /**
188
+ * Specify how many available elements per feeds will the users be able to see in the dropdown list.
189
+ * If it not set, limit is inherited from {@link module:mention/mentionconfig~MentionConfig#dropdownLimit MentionConfig}.
190
+ */
191
+ dropdownLimit?: number;
192
+ }
193
+ /**
194
+ * Function that renders an array of {@link module:mention/mentionconfig~MentionFeedItem} based on string input.
195
+ */
196
+ export type FeedCallback = (searchString: string) => Array<MentionFeedItem> | Promise<Array<MentionFeedItem>>;
197
+ /**
198
+ * Function that takes renders a {@link module:mention/mentionconfig~MentionFeedObjectItem} as HTMLElement.
199
+ */
200
+ export type ItemRenderer = (item: MentionFeedObjectItem) => HTMLElement | string;
201
+ /**
202
+ * The mention feed item. It may be defined as a string or a plain object.
203
+ *
204
+ * When defining a feed item as a plain object, the `id` property is obligatory. Additional properties
205
+ * can be used when customizing the mention feature bahavior
206
+ * (see {@glink features/mentions#customizing-the-autocomplete-list "Customizing the autocomplete list"}
207
+ * and {@glink features/mentions#customizing-the-output "Customizing the output"} sections).
208
+ *
209
+ * ```ts
210
+ * ClassicEditor
211
+ * .create( editorElement, {
212
+ * plugins: [ Mention, ... ],
213
+ * mention: {
214
+ * feeds: [
215
+ * // Feed items as objects.
216
+ * {
217
+ * marker: '@',
218
+ * feed: [
219
+ * {
220
+ * id: '@Barney',
221
+ * fullName: 'Barney Bloom'
222
+ * },
223
+ * {
224
+ * id: '@Lily',
225
+ * fullName: 'Lily Smith'
226
+ * },
227
+ * {
228
+ * id: '@Marshall',
229
+ * fullName: 'Marshall McDonald'
230
+ * },
231
+ * {
232
+ * id: '@Robin',
233
+ * fullName: 'Robin Hood'
234
+ * },
235
+ * {
236
+ * id: '@Ted',
237
+ * fullName: 'Ted Cruze'
238
+ * },
239
+ * // ...
240
+ * ]
241
+ * },
242
+ *
243
+ * // Feed items as plain strings.
244
+ * {
245
+ * marker: '#',
246
+ * feed: [ 'wysiwyg', 'rte', 'rich-text-edior', 'collaboration', 'real-time', ... ]
247
+ * },
248
+ * ]
249
+ * }
250
+ * } )
251
+ * .then( ... )
252
+ * .catch( ... );
253
+ * ```
254
+ */
255
+ export type MentionFeedItem = string | MentionFeedObjectItem;
256
+ export type MentionFeedObjectItem = {
257
+ /**
258
+ * A unique ID of the mention. It must start with the marker character.
259
+ */
260
+ id: string;
261
+ /**
262
+ * Text inserted into the editor when creating a mention.
263
+ */
264
+ text?: string;
265
+ };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/mentionediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import type { Element } from 'ckeditor5/src/engine.js';
10
+ import type { MentionAttribute } from './mention.js';
11
+ /**
12
+ * The mention editing feature.
13
+ *
14
+ * It introduces the {@link module:mention/mentioncommand~MentionCommand command} and the `mention`
15
+ * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
16
+ * as a `<span class="mention" data-mention="@mention">`.
17
+ */
18
+ export default class MentionEditing extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "MentionEditing";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ init(): void;
27
+ }
28
+ /**
29
+ * @internal
30
+ */
31
+ export declare function _addMentionAttributes(baseMentionData: {
32
+ id: string;
33
+ _text: string;
34
+ }, data?: Record<string, unknown>): MentionAttribute;
35
+ /**
36
+ * Creates a mention attribute value from the provided view element and optional data.
37
+ *
38
+ * This function is exposed as
39
+ * {@link module:mention/mention~Mention#toMentionAttribute `editor.plugins.get( 'Mention' ).toMentionAttribute()`}.
40
+ *
41
+ * @internal
42
+ */
43
+ export declare function _toMentionAttribute(viewElementOrMention: Element, data?: Record<string, unknown>): MentionAttribute | undefined;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/mentionui
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9
+ import { ContextualBalloon } from 'ckeditor5/src/ui.js';
10
+ /**
11
+ * The mention UI feature.
12
+ */
13
+ export default class MentionUI extends Plugin {
14
+ /**
15
+ * The mention view.
16
+ */
17
+ private readonly _mentionsView;
18
+ /**
19
+ * Stores mention feeds configurations.
20
+ */
21
+ private _mentionsConfigurations;
22
+ /**
23
+ * The contextual balloon plugin instance.
24
+ */
25
+ private _balloon;
26
+ private _items;
27
+ private _lastRequested?;
28
+ /**
29
+ * Debounced feed requester. It uses `lodash#debounce` method to delay function call.
30
+ */
31
+ private _requestFeedDebounced;
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ static get pluginName(): "MentionUI";
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ static get requires(): readonly [typeof ContextualBalloon];
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ constructor(editor: Editor);
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ init(): void;
48
+ /**
49
+ * @inheritDoc
50
+ */
51
+ destroy(): void;
52
+ /**
53
+ * Returns true when {@link #_mentionsView} is in the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon} and it is
54
+ * currently visible.
55
+ */
56
+ private get _isUIVisible();
57
+ /**
58
+ * Creates the {@link #_mentionsView}.
59
+ */
60
+ private _createMentionView;
61
+ /**
62
+ * Returns item renderer for the marker.
63
+ */
64
+ private _getItemRenderer;
65
+ /**
66
+ * Requests a feed from a configured callbacks.
67
+ */
68
+ private _requestFeed;
69
+ /**
70
+ * Registers a text watcher for the marker.
71
+ */
72
+ private _setupTextWatcher;
73
+ /**
74
+ * Handles the feed response event data.
75
+ */
76
+ private _handleFeedResponse;
77
+ /**
78
+ * Shows the mentions balloon. If the panel is already visible, it will reposition it.
79
+ */
80
+ private _showOrUpdateUI;
81
+ /**
82
+ * Hides the mentions balloon and removes the 'mention' marker from the markers collection.
83
+ */
84
+ private _hideUIAndRemoveMarker;
85
+ /**
86
+ * Renders a single item in the autocomplete list.
87
+ */
88
+ private _renderItem;
89
+ /**
90
+ * Creates a position options object used to position the balloon panel.
91
+ *
92
+ * @param mentionMarker
93
+ * @param preferredPosition The name of the last matched position name.
94
+ */
95
+ private _getBalloonPanelPositionData;
96
+ }
97
+ /**
98
+ * Creates a RegExp pattern for the marker.
99
+ *
100
+ * Function has to be exported to achieve 100% code coverage.
101
+ */
102
+ export declare function createRegExp(marker: string, minimumCharacters: number): RegExp;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/ui/domwrapperview
7
+ */
8
+ import { View } from 'ckeditor5/src/ui.js';
9
+ import type { Locale } from 'ckeditor5/src/utils.js';
10
+ /**
11
+ * This class wraps DOM element as a CKEditor5 UI View.
12
+ *
13
+ * It allows to render any DOM element and use it in mentions list.
14
+ */
15
+ export default class DomWrapperView extends View {
16
+ /**
17
+ * The DOM element for which wrapper was created.
18
+ */
19
+ domElement: HTMLElement;
20
+ /**
21
+ * Controls whether the dom wrapper view is "on". This is in line with {@link module:ui/button/button~Button#isOn} property.
22
+ *
23
+ * @observable
24
+ * @default true
25
+ */
26
+ isOn: boolean;
27
+ /**
28
+ * Creates an instance of {@link module:mention/ui/domwrapperview~DomWrapperView} class.
29
+ *
30
+ * Also see {@link #render}.
31
+ */
32
+ constructor(locale: Locale, domElement: HTMLElement);
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ render(): void;
37
+ /**
38
+ * Focuses the DOM element.
39
+ */
40
+ focus(): void;
41
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/ui/mentionlistitemview
7
+ */
8
+ import { ListItemView } from 'ckeditor5/src/ui.js';
9
+ import type { MentionFeedItem } from '../mentionconfig.js';
10
+ export default class MentionListItemView extends ListItemView {
11
+ item: MentionFeedItem;
12
+ marker: string;
13
+ highlight(): void;
14
+ removeHighlight(): void;
15
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module mention/ui/mentionsview
7
+ */
8
+ import { ListView } from 'ckeditor5/src/ui.js';
9
+ import { type Locale } from 'ckeditor5/src/utils.js';
10
+ import type MentionListItemView from './mentionlistitemview.js';
11
+ import '../../theme/mentionui.css';
12
+ /**
13
+ * The mention ui view.
14
+ */
15
+ export default class MentionsView extends ListView {
16
+ selected: MentionListItemView | undefined;
17
+ position: string | undefined;
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ constructor(locale: Locale);
22
+ /**
23
+ * {@link #select Selects} the first item.
24
+ */
25
+ selectFirst(): void;
26
+ /**
27
+ * Selects next item to the currently {@link #select selected}.
28
+ *
29
+ * If the last item is already selected, it will select the first item.
30
+ */
31
+ selectNext(): void;
32
+ /**
33
+ * Selects previous item to the currently {@link #select selected}.
34
+ *
35
+ * If the first item is already selected, it will select the last item.
36
+ */
37
+ selectPrevious(): void;
38
+ /**
39
+ * Marks item at a given index as selected.
40
+ *
41
+ * Handles selection cycling when passed index is out of bounds:
42
+ * - if the index is lower than 0, it will select the last item,
43
+ * - if the index is higher than the last item index, it will select the first item.
44
+ *
45
+ * @param index Index of an item to be marked as selected.
46
+ */
47
+ select(index: number): void;
48
+ /**
49
+ * Triggers the `execute` event on the {@link #select selected} item.
50
+ */
51
+ executeSelected(): void;
52
+ /**
53
+ * Checks if an item is visible in the scrollable area.
54
+ *
55
+ * The item is considered visible when:
56
+ * - its top boundary is inside the scrollable rect
57
+ * - its bottom boundary is inside the scrollable rect (the whole item must be visible)
58
+ */
59
+ private _isItemVisibleInScrolledArea;
60
+ }