@ckeditor/ckeditor5-mention 45.2.1 → 46.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-mention",
3
- "version": "45.2.1",
3
+ "version": "46.0.0-alpha.0",
4
4
  "description": "Mention feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,12 +13,12 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "45.2.1",
17
- "@ckeditor/ckeditor5-typing": "45.2.1",
18
- "@ckeditor/ckeditor5-ui": "45.2.1",
19
- "@ckeditor/ckeditor5-utils": "45.2.1",
20
- "ckeditor5": "45.2.1",
21
- "es-toolkit": "1.32.0"
16
+ "@ckeditor/ckeditor5-core": "46.0.0-alpha.0",
17
+ "@ckeditor/ckeditor5-typing": "46.0.0-alpha.0",
18
+ "@ckeditor/ckeditor5-ui": "46.0.0-alpha.0",
19
+ "@ckeditor/ckeditor5-utils": "46.0.0-alpha.0",
20
+ "ckeditor5": "46.0.0-alpha.0",
21
+ "es-toolkit": "1.39.5"
22
22
  },
23
23
  "author": "CKSource (http://cksource.com/)",
24
24
  "license": "SEE LICENSE IN LICENSE.md",
package/src/index.d.ts CHANGED
@@ -5,12 +5,14 @@
5
5
  /**
6
6
  * @module mention
7
7
  */
8
- export { default as Mention } from './mention.js';
9
- export { default as MentionEditing } from './mentionediting.js';
10
- export { default as MentionUI } from './mentionui.js';
11
- export { default as MentionsView } from './ui/mentionsview.js';
12
- export { default as MentionListItemView } from './ui/mentionlistitemview.js';
13
- export { default as DomWrapperView } from './ui/domwrapperview.js';
14
- export type { MentionConfig, MentionFeed, ItemRenderer, MentionFeedObjectItem } from './mentionconfig.js';
15
- export type { default as MentionCommand } from './mentioncommand.js';
8
+ export { Mention, type MentionAttribute } from './mention.js';
9
+ export { MentionEditing } from './mentionediting.js';
10
+ export { MentionUI } from './mentionui.js';
11
+ export { MentionsView } from './ui/mentionsview.js';
12
+ export { MentionListItemView } from './ui/mentionlistitemview.js';
13
+ export { MentionDomWrapperView } from './ui/domwrapperview.js';
14
+ export { MentionCommand } from './mentioncommand.js';
15
+ export type { MentionConfig, MentionFeed, MentionFeedItem, MentionItemRenderer, MentionFeedObjectItem, MentionFeedbackCallback } from './mentionconfig.js';
16
+ export { createRegExp as _createMentionMarkerRegExp } from './mentionui.js';
17
+ export { _addMentionAttributes as _addMentionAttributes, _toMentionAttribute as _toMentionAttribute } from './mentionediting.js';
16
18
  import './augmentation.js';
package/src/index.js CHANGED
@@ -5,10 +5,13 @@
5
5
  /**
6
6
  * @module mention
7
7
  */
8
- export { default as Mention } from './mention.js';
9
- export { default as MentionEditing } from './mentionediting.js';
10
- export { default as MentionUI } from './mentionui.js';
11
- export { default as MentionsView } from './ui/mentionsview.js';
12
- export { default as MentionListItemView } from './ui/mentionlistitemview.js';
13
- export { default as DomWrapperView } from './ui/domwrapperview.js';
8
+ export { Mention } from './mention.js';
9
+ export { MentionEditing } from './mentionediting.js';
10
+ export { MentionUI } from './mentionui.js';
11
+ export { MentionsView } from './ui/mentionsview.js';
12
+ export { MentionListItemView } from './ui/mentionlistitemview.js';
13
+ export { MentionDomWrapperView } from './ui/domwrapperview.js';
14
+ export { MentionCommand } from './mentioncommand.js';
15
+ export { createRegExp as _createMentionMarkerRegExp } from './mentionui.js';
16
+ export { _addMentionAttributes as _addMentionAttributes, _toMentionAttribute as _toMentionAttribute } from './mentionediting.js';
14
17
  import './augmentation.js';
package/src/mention.d.ts CHANGED
@@ -6,16 +6,16 @@
6
6
  * @module mention/mention
7
7
  */
8
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';
9
+ import type { ModelElement } from 'ckeditor5/src/engine.js';
10
+ import { MentionEditing } from './mentionediting.js';
11
+ import { MentionUI } from './mentionui.js';
12
12
  import '../theme/mention.css';
13
13
  /**
14
14
  * The mention plugin.
15
15
  *
16
16
  * For a detailed overview, check the {@glink features/mentions Mention feature} guide.
17
17
  */
18
- export default class Mention extends Plugin {
18
+ export declare class Mention extends Plugin {
19
19
  /**
20
20
  * Creates a mention attribute value from the provided view element and additional data.
21
21
  *
@@ -29,7 +29,7 @@ export default class Mention extends Plugin {
29
29
  *
30
30
  * @param data Additional data to be stored in the mention attribute.
31
31
  */
32
- toMentionAttribute<MentionData extends Record<string, unknown>>(viewElement: Element, data: MentionData): (MentionAttribute & MentionData) | undefined;
32
+ toMentionAttribute<MentionData extends Record<string, unknown>>(viewElement: ModelElement, data: MentionData): (MentionAttribute & MentionData) | undefined;
33
33
  /**
34
34
  * Creates a mention attribute value from the provided view element.
35
35
  *
@@ -41,7 +41,7 @@ export default class Mention extends Plugin {
41
41
  * // { id: '@joe', uid: '7a7bc7...', _text: '@John Doe' }
42
42
  * ```
43
43
  */
44
- toMentionAttribute(viewElement: Element): MentionAttribute | undefined;
44
+ toMentionAttribute(viewElement: ModelElement): MentionAttribute | undefined;
45
45
  /**
46
46
  * @inheritDoc
47
47
  */
@@ -68,7 +68,7 @@ export type MentionAttribute = {
68
68
  id: string;
69
69
  /**
70
70
  * A unique ID of this mention instance. Should be passed as an `option.id` when using
71
- * {@link module:engine/view/downcastwriter~DowncastWriter#createAttributeElement writer.createAttributeElement()}.
71
+ * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createAttributeElement writer.createAttributeElement()}.
72
72
  */
73
73
  uid: string;
74
74
  /**
package/src/mention.js CHANGED
@@ -6,15 +6,15 @@
6
6
  * @module mention/mention
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import MentionEditing, { _toMentionAttribute } from './mentionediting.js';
10
- import MentionUI from './mentionui.js';
9
+ import { MentionEditing, _toMentionAttribute } from './mentionediting.js';
10
+ import { MentionUI } from './mentionui.js';
11
11
  import '../theme/mention.css';
12
12
  /**
13
13
  * The mention plugin.
14
14
  *
15
15
  * For a detailed overview, check the {@glink features/mentions Mention feature} guide.
16
16
  */
17
- export default class Mention extends Plugin {
17
+ export class Mention extends Plugin {
18
18
  toMentionAttribute(viewElement, data) {
19
19
  return _toMentionAttribute(viewElement, data);
20
20
  }
@@ -6,7 +6,7 @@
6
6
  * @module mention/mentioncommand
7
7
  */
8
8
  import { Command, type Editor } from 'ckeditor5/src/core.js';
9
- import type { Range } from 'ckeditor5/src/engine.js';
9
+ import type { ModelRange } from 'ckeditor5/src/engine.js';
10
10
  /**
11
11
  * The mention command.
12
12
  *
@@ -43,7 +43,7 @@ import type { Range } from 'ckeditor5/src/engine.js';
43
43
  * } );
44
44
  * ```
45
45
  */
46
- export default class MentionCommand extends Command {
46
+ export declare class MentionCommand extends Command {
47
47
  /**
48
48
  * @inheritDoc
49
49
  */
@@ -72,6 +72,6 @@ export default class MentionCommand extends Command {
72
72
  };
73
73
  marker: string;
74
74
  text?: string;
75
- range?: Range;
75
+ range?: ModelRange;
76
76
  }): void;
77
77
  }
@@ -49,7 +49,7 @@ const BRACKET_PAIRS = {
49
49
  * } );
50
50
  * ```
51
51
  */
52
- export default class MentionCommand extends Command {
52
+ export class MentionCommand extends Command {
53
53
  /**
54
54
  * @inheritDoc
55
55
  */
@@ -172,7 +172,7 @@ export interface MentionFeed {
172
172
  * a static configuration (the mention feature will show matching items automatically) or a function which returns an array of
173
173
  * matching items (directly, or via a promise). If a function is passed, it is executed in the context of the editor instance.
174
174
  */
175
- feed: Array<MentionFeedItem> | FeedCallback;
175
+ feed: Array<MentionFeedItem> | MentionFeedbackCallback;
176
176
  /**
177
177
  * Specifies after how many characters the autocomplete panel should be shown.
178
178
  *
@@ -183,7 +183,7 @@ export interface MentionFeed {
183
183
  * A function that renders a {@link module:mention/mentionconfig~MentionFeedItem}
184
184
  * to the autocomplete panel.
185
185
  */
186
- itemRenderer?: ItemRenderer;
186
+ itemRenderer?: MentionItemRenderer;
187
187
  /**
188
188
  * Specify how many available elements per feeds will the users be able to see in the dropdown list.
189
189
  * If it not set, limit is inherited from {@link module:mention/mentionconfig~MentionConfig#dropdownLimit MentionConfig}.
@@ -193,11 +193,11 @@ export interface MentionFeed {
193
193
  /**
194
194
  * Function that renders an array of {@link module:mention/mentionconfig~MentionFeedItem} based on string input.
195
195
  */
196
- export type FeedCallback = (searchString: string) => Array<MentionFeedItem> | Promise<Array<MentionFeedItem>>;
196
+ export type MentionFeedbackCallback = (searchString: string) => Array<MentionFeedItem> | Promise<Array<MentionFeedItem>>;
197
197
  /**
198
198
  * Function that takes renders a {@link module:mention/mentionconfig~MentionFeedObjectItem} as HTMLElement.
199
199
  */
200
- export type ItemRenderer = (item: MentionFeedObjectItem) => HTMLElement | string;
200
+ export type MentionItemRenderer = (item: MentionFeedObjectItem) => HTMLElement | string;
201
201
  /**
202
202
  * The mention feed item. It may be defined as a string or a plain object.
203
203
  *
@@ -6,7 +6,7 @@
6
6
  * @module mention/mentionediting
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import type { Element } from 'ckeditor5/src/engine.js';
9
+ import type { ModelElement } from 'ckeditor5/src/engine.js';
10
10
  import type { MentionAttribute } from './mention.js';
11
11
  /**
12
12
  * The mention editing feature.
@@ -15,7 +15,7 @@ import type { MentionAttribute } from './mention.js';
15
15
  * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
16
16
  * as a `<span class="mention" data-mention="@mention">`.
17
17
  */
18
- export default class MentionEditing extends Plugin {
18
+ export declare class MentionEditing extends Plugin {
19
19
  /**
20
20
  * @inheritDoc
21
21
  */
@@ -44,4 +44,4 @@ export declare function _addMentionAttributes(baseMentionData: {
44
44
  *
45
45
  * @internal
46
46
  */
47
- export declare function _toMentionAttribute(viewElementOrMention: Element, data?: Record<string, unknown>): MentionAttribute | undefined;
47
+ export declare function _toMentionAttribute(viewElementOrMention: ModelElement, data?: Record<string, unknown>): MentionAttribute | undefined;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
9
  import { uid } from 'ckeditor5/src/utils.js';
10
- import MentionCommand from './mentioncommand.js';
10
+ import { MentionCommand } from './mentioncommand.js';
11
11
  /**
12
12
  * The mention editing feature.
13
13
  *
@@ -15,7 +15,7 @@ import MentionCommand from './mentioncommand.js';
15
15
  * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
16
16
  * as a `<span class="mention" data-mention="@mention">`.
17
17
  */
18
- export default class MentionEditing extends Plugin {
18
+ export class MentionEditing extends Plugin {
19
19
  /**
20
20
  * @inheritDoc
21
21
  */
@@ -10,7 +10,7 @@ import { ContextualBalloon } from 'ckeditor5/src/ui.js';
10
10
  /**
11
11
  * The mention UI feature.
12
12
  */
13
- export default class MentionUI extends Plugin {
13
+ export declare class MentionUI extends Plugin {
14
14
  /**
15
15
  * The mention view.
16
16
  */
@@ -102,5 +102,7 @@ export default class MentionUI extends Plugin {
102
102
  * Creates a RegExp pattern for the marker.
103
103
  *
104
104
  * Function has to be exported to achieve 100% code coverage.
105
+ *
106
+ * @internal
105
107
  */
106
108
  export declare function createRegExp(marker: string, minimumCharacters: number): RegExp;
package/src/mentionui.js CHANGED
@@ -10,9 +10,9 @@ import { ButtonView, ContextualBalloon, clickOutsideHandler } from 'ckeditor5/sr
10
10
  import { CKEditorError, Collection, Rect, env, keyCodes, logWarning } from 'ckeditor5/src/utils.js';
11
11
  import { TextWatcher } from 'ckeditor5/src/typing.js';
12
12
  import { debounce } from 'es-toolkit/compat';
13
- import MentionsView from './ui/mentionsview.js';
14
- import DomWrapperView from './ui/domwrapperview.js';
15
- import MentionListItemView from './ui/mentionlistitemview.js';
13
+ import { MentionsView } from './ui/mentionsview.js';
14
+ import { MentionDomWrapperView } from './ui/domwrapperview.js';
15
+ import { MentionListItemView } from './ui/mentionlistitemview.js';
16
16
  const VERTICAL_SPACING = 3;
17
17
  // The key codes that mention UI handles when it is open (without commit keys).
18
18
  const defaultHandledKeyCodes = [
@@ -28,7 +28,7 @@ const defaultCommitKeyCodes = [
28
28
  /**
29
29
  * The mention UI feature.
30
30
  */
31
- export default class MentionUI extends Plugin {
31
+ export class MentionUI extends Plugin {
32
32
  /**
33
33
  * The mention view.
34
34
  */
@@ -384,7 +384,7 @@ export default class MentionUI extends Plugin {
384
384
  if (renderer) {
385
385
  const renderResult = renderer(item);
386
386
  if (typeof renderResult != 'string') {
387
- view = new DomWrapperView(editor.locale, renderResult);
387
+ view = new MentionDomWrapperView(editor.locale, renderResult);
388
388
  }
389
389
  else {
390
390
  label = renderResult;
@@ -544,6 +544,8 @@ function getLastValidMarkerInText(feedsWithPattern, text) {
544
544
  * Creates a RegExp pattern for the marker.
545
545
  *
546
546
  * Function has to be exported to achieve 100% code coverage.
547
+ *
548
+ * @internal
547
549
  */
548
550
  export function createRegExp(marker, minimumCharacters) {
549
551
  const numberOfCharacters = minimumCharacters == 0 ? '*' : `{${minimumCharacters},}`;
@@ -12,7 +12,7 @@ import type { Locale } from 'ckeditor5/src/utils.js';
12
12
  *
13
13
  * It allows to render any DOM element and use it in mentions list.
14
14
  */
15
- export default class DomWrapperView extends View {
15
+ export declare class MentionDomWrapperView extends View {
16
16
  /**
17
17
  * The DOM element for which wrapper was created.
18
18
  */
@@ -25,7 +25,7 @@ export default class DomWrapperView extends View {
25
25
  */
26
26
  isOn: boolean;
27
27
  /**
28
- * Creates an instance of {@link module:mention/ui/domwrapperview~DomWrapperView} class.
28
+ * Creates an instance of {@link module:mention/ui/domwrapperview~MentionDomWrapperView} class.
29
29
  *
30
30
  * Also see {@link #render}.
31
31
  */
@@ -11,13 +11,13 @@ import { View } from 'ckeditor5/src/ui.js';
11
11
  *
12
12
  * It allows to render any DOM element and use it in mentions list.
13
13
  */
14
- export default class DomWrapperView extends View {
14
+ export class MentionDomWrapperView extends View {
15
15
  /**
16
16
  * The DOM element for which wrapper was created.
17
17
  */
18
18
  domElement;
19
19
  /**
20
- * Creates an instance of {@link module:mention/ui/domwrapperview~DomWrapperView} class.
20
+ * Creates an instance of {@link module:mention/ui/domwrapperview~MentionDomWrapperView} class.
21
21
  *
22
22
  * Also see {@link #render}.
23
23
  */
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { ListItemView } from 'ckeditor5/src/ui.js';
9
9
  import type { MentionFeedItem } from '../mentionconfig.js';
10
- export default class MentionListItemView extends ListItemView {
10
+ export declare class MentionListItemView extends ListItemView {
11
11
  item: MentionFeedItem;
12
12
  marker: string;
13
13
  highlight(): void;
@@ -6,7 +6,7 @@
6
6
  * @module mention/ui/mentionlistitemview
7
7
  */
8
8
  import { ListItemView } from 'ckeditor5/src/ui.js';
9
- export default class MentionListItemView extends ListItemView {
9
+ export class MentionListItemView extends ListItemView {
10
10
  item;
11
11
  marker;
12
12
  highlight() {
@@ -7,12 +7,12 @@
7
7
  */
8
8
  import { ListView } from 'ckeditor5/src/ui.js';
9
9
  import { type Locale } from 'ckeditor5/src/utils.js';
10
- import type MentionListItemView from './mentionlistitemview.js';
10
+ import { type MentionListItemView } from './mentionlistitemview.js';
11
11
  import '../../theme/mentionui.css';
12
12
  /**
13
13
  * The mention ui view.
14
14
  */
15
- export default class MentionsView extends ListView {
15
+ export declare class MentionsView extends ListView {
16
16
  selected: MentionListItemView | undefined;
17
17
  position: string | undefined;
18
18
  /**
@@ -11,7 +11,7 @@ import '../../theme/mentionui.css';
11
11
  /**
12
12
  * The mention ui view.
13
13
  */
14
- export default class MentionsView extends ListView {
14
+ export class MentionsView extends ListView {
15
15
  selected;
16
16
  position;
17
17
  /**