@ckeditor/ckeditor5-mention 44.1.0 → 44.2.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": "44.1.0",
3
+ "version": "44.2.0-alpha.0",
4
4
  "description": "Mention feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,11 +13,11 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "44.1.0",
17
- "@ckeditor/ckeditor5-typing": "44.1.0",
18
- "@ckeditor/ckeditor5-ui": "44.1.0",
19
- "@ckeditor/ckeditor5-utils": "44.1.0",
20
- "ckeditor5": "44.1.0",
16
+ "@ckeditor/ckeditor5-core": "44.2.0-alpha.0",
17
+ "@ckeditor/ckeditor5-typing": "44.2.0-alpha.0",
18
+ "@ckeditor/ckeditor5-ui": "44.2.0-alpha.0",
19
+ "@ckeditor/ckeditor5-utils": "44.2.0-alpha.0",
20
+ "ckeditor5": "44.2.0-alpha.0",
21
21
  "lodash-es": "4.17.21"
22
22
  },
23
23
  "author": "CKSource (http://cksource.com/)",
@@ -39,5 +39,26 @@
39
39
  "ckeditor5-metadata.json",
40
40
  "CHANGELOG.md"
41
41
  ],
42
- "types": "src/index.d.ts"
42
+ "types": "src/index.d.ts",
43
+ "exports": {
44
+ ".": {
45
+ "types": "./src/index.d.ts",
46
+ "import": "./src/index.js",
47
+ "default": "./src/index.js"
48
+ },
49
+ "./dist/*": {
50
+ "types": "./src/index.d.ts",
51
+ "import": "./dist/*",
52
+ "default": "./dist/*"
53
+ },
54
+ "./src/*": {
55
+ "types": "./src/*.d.ts",
56
+ "import": "./src/*",
57
+ "default": "./src/*"
58
+ },
59
+ "./build/*": "./build/*",
60
+ "./theme/*": "./theme/*",
61
+ "./ckeditor5-metadata.json": "./ckeditor5-metadata.json",
62
+ "./package.json": "./package.json"
63
+ }
43
64
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  import type { MentionConfig, Mention, MentionEditing, MentionUI, MentionCommand } from './index.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  export {};
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
package/src/mention.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
package/src/mention.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -92,23 +92,9 @@ export default class MentionCommand extends Command {
92
92
  }
93
93
  const mentionText = options.text || mentionID;
94
94
  const mention = _addMentionAttributes({ _text: mentionText, id: mentionID }, mentionData);
95
- if (options.marker.length != 1) {
95
+ if (!mentionID.startsWith(options.marker)) {
96
96
  /**
97
- * The marker must be a single character.
98
- *
99
- * Correct markers: `'@'`, `'#'`.
100
- *
101
- * Incorrect markers: `'@@'`, `'[@'`.
102
- *
103
- * See {@link module:mention/mentionconfig~MentionConfig}.
104
- *
105
- * @error mentioncommand-incorrect-marker
106
- */
107
- throw new CKEditorError('mentioncommand-incorrect-marker', this);
108
- }
109
- if (mentionID.charAt(0) != options.marker) {
110
- /**
111
- * The feed item ID must start with the marker character.
97
+ * The feed item ID must start with the marker character(s).
112
98
  *
113
99
  * Correct mention feed setting:
114
100
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
package/src/mentionui.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -539,12 +539,12 @@ export function createRegExp(marker, minimumCharacters) {
539
539
  // The pattern consists of 3 groups:
540
540
  //
541
541
  // - 0 (non-capturing): Opening sequence - start of the line, space or an opening punctuation character like "(" or "\"",
542
- // - 1: The marker character,
542
+ // - 1: The marker character(s),
543
543
  // - 2: Mention input (taking the minimal length into consideration to trigger the UI),
544
544
  //
545
545
  // The pattern matches up to the caret (end of string switch - $).
546
- // (0: opening sequence )(1: marker )(2: typed mention )$
547
- const pattern = `(?:^|[ ${openAfterCharacters}])([${marker}])(${mentionCharacters}${numberOfCharacters})$`;
546
+ // (0: opening sequence )(1: marker )(2: typed mention )$
547
+ const pattern = `(?:^|[ ${openAfterCharacters}])(${marker})(${mentionCharacters}${numberOfCharacters})$`;
548
548
  return new RegExp(pattern, 'u');
549
549
  }
550
550
  /**
@@ -620,7 +620,7 @@ function isMarkerInExistingMention(markerPosition) {
620
620
  * Checks if string is a valid mention marker.
621
621
  */
622
622
  function isValidMentionMarker(marker) {
623
- return marker && marker.length == 1;
623
+ return !!marker;
624
624
  }
625
625
  /**
626
626
  * Checks the mention plugins is in completion mode (e.g. when typing is after a valid mention string like @foo).
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
package/theme/mention.css CHANGED
@@ -1,4 +1,4 @@
1
1
  /*
2
- * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
 
@@ -1,27 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- import type { MentionConfig, Mention, MentionEditing, MentionUI, MentionCommand } from './index.js';
10
- declare module '@ckeditor/ckeditor5-core' {
11
- interface EditorConfig {
12
- /**
13
- * The configuration of the {@link module:mention/mention~Mention} feature.
14
- *
15
- * Read more in {@link module:mention/mentionconfig~MentionConfig}.
16
- */
17
- mention?: MentionConfig;
18
- }
19
- interface PluginsMap {
20
- [Mention.pluginName]: Mention;
21
- [MentionEditing.pluginName]: MentionEditing;
22
- [MentionUI.pluginName]: MentionUI;
23
- }
24
- interface CommandsMap {
25
- mention: MentionCommand;
26
- }
27
- }
package/dist/index.d.ts DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module mention
11
- */
12
- export { default as Mention } from './mention.js';
13
- export { default as MentionEditing } from './mentionediting.js';
14
- export { default as MentionUI } from './mentionui.js';
15
- export { default as MentionsView } from './ui/mentionsview.js';
16
- export { default as MentionListItemView } from './ui/mentionlistitemview.js';
17
- export { default as DomWrapperView } from './ui/domwrapperview.js';
18
- export type { MentionConfig, MentionFeed, ItemRenderer, MentionFeedObjectItem } from './mentionconfig.js';
19
- export type { default as MentionCommand } from './mentioncommand.js';
20
- import './augmentation.js';
package/dist/mention.d.ts DELETED
@@ -1,85 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module mention/mention
11
- */
12
- import { Plugin } from 'ckeditor5/src/core.js';
13
- import type { Element } from 'ckeditor5/src/engine.js';
14
- import MentionEditing from './mentionediting.js';
15
- import MentionUI from './mentionui.js';
16
- import '../theme/mention.css';
17
- /**
18
- * The mention plugin.
19
- *
20
- * For a detailed overview, check the {@glink features/mentions Mention feature} guide.
21
- */
22
- export default class Mention extends Plugin {
23
- /**
24
- * Creates a mention attribute value from the provided view element and additional data.
25
- *
26
- * ```ts
27
- * editor.plugins.get( 'Mention' ).toMentionAttribute( viewElement, { userId: '1234' } );
28
- *
29
- * // For a view element: <span data-mention="@joe">@John Doe</span>
30
- * // it will return:
31
- * // { id: '@joe', userId: '1234', uid: '7a7bc7...', _text: '@John Doe' }
32
- * ```
33
- *
34
- * @param data Additional data to be stored in the mention attribute.
35
- */
36
- toMentionAttribute<MentionData extends Record<string, unknown>>(viewElement: Element, data: MentionData): (MentionAttribute & MentionData) | undefined;
37
- /**
38
- * Creates a mention attribute value from the provided view element.
39
- *
40
- * ```ts
41
- * editor.plugins.get( 'Mention' ).toMentionAttribute( viewElement );
42
- *
43
- * // For a view element: <span data-mention="@joe">@John Doe</span>
44
- * // it will return:
45
- * // { id: '@joe', uid: '7a7bc7...', _text: '@John Doe' }
46
- * ```
47
- */
48
- toMentionAttribute(viewElement: Element): MentionAttribute | undefined;
49
- /**
50
- * @inheritDoc
51
- */
52
- static get pluginName(): "Mention";
53
- /**
54
- * @inheritDoc
55
- */
56
- static get isOfficialPlugin(): true;
57
- /**
58
- * @inheritDoc
59
- */
60
- static get requires(): readonly [typeof MentionEditing, typeof MentionUI];
61
- }
62
- /**
63
- * Represents a mention in the model.
64
- *
65
- * See {@link module:mention/mention~Mention#toMentionAttribute `Mention#toMentionAttribute()`}.
66
- */
67
- export type MentionAttribute = {
68
- /**
69
- * The ID of a mention. It identifies the mention item in the mention feed. There can be multiple mentions
70
- * in the document with the same ID (e.g. the same hashtag being mentioned).
71
- */
72
- id: string;
73
- /**
74
- * A unique ID of this mention instance. Should be passed as an `option.id` when using
75
- * {@link module:engine/view/downcastwriter~DowncastWriter#createAttributeElement writer.createAttributeElement()}.
76
- */
77
- uid: string;
78
- /**
79
- * Helper property that stores the text of the inserted mention. Used for detecting a broken mention
80
- * in the editing area.
81
- *
82
- * @internal
83
- */
84
- _text: string;
85
- };
@@ -1,81 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module mention/mentioncommand
11
- */
12
- import { Command, type Editor } from 'ckeditor5/src/core.js';
13
- import type { Range } from 'ckeditor5/src/engine.js';
14
- /**
15
- * The mention command.
16
- *
17
- * The command is registered by {@link module:mention/mentionediting~MentionEditing} as `'mention'`.
18
- *
19
- * To insert a mention into a range, execute the command and specify a mention object with a range to replace:
20
- *
21
- * ```ts
22
- * const focus = editor.model.document.selection.focus;
23
- *
24
- * // It will replace one character before the selection focus with the '#1234' text
25
- * // with the mention attribute filled with passed attributes.
26
- * editor.execute( 'mention', {
27
- * marker: '#',
28
- * mention: {
29
- * id: '#1234',
30
- * name: 'Foo',
31
- * title: 'Big Foo'
32
- * },
33
- * range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
34
- * } );
35
- *
36
- * // It will replace one character before the selection focus with the 'The "Big Foo"' text
37
- * // with the mention attribute filled with passed attributes.
38
- * editor.execute( 'mention', {
39
- * marker: '#',
40
- * mention: {
41
- * id: '#1234',
42
- * name: 'Foo',
43
- * title: 'Big Foo'
44
- * },
45
- * text: 'The "Big Foo"',
46
- * range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
47
- * } );
48
- * ```
49
- */
50
- export default class MentionCommand extends Command {
51
- /**
52
- * @inheritDoc
53
- */
54
- constructor(editor: Editor);
55
- /**
56
- * @inheritDoc
57
- */
58
- refresh(): void;
59
- /**
60
- * Executes the command.
61
- *
62
- * @param options Options for the executed command.
63
- * @param options.mention The mention object to insert. When a string is passed, it will be used to create a plain
64
- * object with the name attribute that equals the passed string.
65
- * @param options.marker The marker character (e.g. `'@'`).
66
- * @param options.text The text of the inserted mention. Defaults to the full mention string composed from `marker` and
67
- * `mention` string or `mention.id` if an object is passed.
68
- * @param options.range The range to replace.
69
- * Note that the replaced range might be shorter than the inserted text with the mention attribute.
70
- * @fires execute
71
- */
72
- execute(options: {
73
- mention: string | {
74
- id: string;
75
- [key: string]: unknown;
76
- };
77
- marker: string;
78
- text?: string;
79
- range?: Range;
80
- }): void;
81
- }