@ckeditor/ckeditor5-mention 48.2.0 → 48.3.0-alpha.1

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/dist/mention.d.ts CHANGED
@@ -1,81 +1,81 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module mention/mention
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import type { ModelElement } from '@ckeditor/ckeditor5-engine';
10
- import { MentionEditing } from './mentionediting.js';
11
- import { MentionUI } from './mentionui.js';
12
- import '../theme/mention.css';
6
+ * @module mention/mention
7
+ */
8
+ import { Plugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
9
+ import type { ModelElement } from "@ckeditor/ckeditor5-engine";
10
+ import { MentionEditing } from "./mentionediting.js";
11
+ import { MentionUI } from "./mentionui.js";
12
+ import "../theme/mention.css";
13
13
  /**
14
- * The mention plugin.
15
- *
16
- * For a detailed overview, check the {@glink features/mentions Mention feature} guide.
17
- */
14
+ * The mention plugin.
15
+ *
16
+ * For a detailed overview, check the {@glink features/mentions Mention feature} guide.
17
+ */
18
18
  export declare 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: ModelElement, 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: ModelElement): MentionAttribute | undefined;
45
- /**
46
- * @inheritDoc
47
- */
48
- static get pluginName(): "Mention";
49
- /**
50
- * @inheritDoc
51
- */
52
- static get isOfficialPlugin(): true;
53
- /**
54
- * @inheritDoc
55
- */
56
- static get requires(): readonly [typeof MentionEditing, typeof MentionUI];
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: ModelElement, 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: ModelElement): MentionAttribute | undefined;
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ static get pluginName(): "Mention";
49
+ /**
50
+ * @inheritDoc
51
+ */
52
+ static override get isOfficialPlugin(): true;
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ static get requires(): PluginDependenciesOf<[MentionEditing, MentionUI]>;
57
57
  }
58
58
  /**
59
- * Represents a mention in the model.
60
- *
61
- * See {@link module:mention/mention~Mention#toMentionAttribute `Mention#toMentionAttribute()`}.
62
- */
59
+ * Represents a mention in the model.
60
+ *
61
+ * See {@link module:mention/mention~Mention#toMentionAttribute `Mention#toMentionAttribute()`}.
62
+ */
63
63
  export type MentionAttribute = {
64
- /**
65
- * The ID of a mention. It identifies the mention item in the mention feed. There can be multiple mentions
66
- * in the document with the same ID (e.g. the same hashtag being mentioned).
67
- */
68
- id: string;
69
- /**
70
- * A unique ID of this mention instance. Should be passed as an `option.id` when using
71
- * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createAttributeElement writer.createAttributeElement()}.
72
- */
73
- uid: string;
74
- /**
75
- * Helper property that stores the text of the inserted mention. Used for detecting a broken mention
76
- * in the editing area.
77
- *
78
- * @internal
79
- */
80
- _text: string;
64
+ /**
65
+ * The ID of a mention. It identifies the mention item in the mention feed. There can be multiple mentions
66
+ * in the document with the same ID (e.g. the same hashtag being mentioned).
67
+ */
68
+ id: string;
69
+ /**
70
+ * A unique ID of this mention instance. Should be passed as an `option.id` when using
71
+ * {@link module:engine/view/downcastwriter~ViewDowncastWriter#createAttributeElement writer.createAttributeElement()}.
72
+ */
73
+ uid: string;
74
+ /**
75
+ * Helper property that stores the text of the inserted mention. Used for detecting a broken mention
76
+ * in the editing area.
77
+ *
78
+ * @internal
79
+ */
80
+ _text: string;
81
81
  };
@@ -1,77 +1,77 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module mention/mentioncommand
7
- */
8
- import { Command, type Editor } from '@ckeditor/ckeditor5-core';
9
- import type { ModelRange } from '@ckeditor/ckeditor5-engine';
6
+ * @module mention/mentioncommand
7
+ */
8
+ import { Command, type Editor } from "@ckeditor/ckeditor5-core";
9
+ import type { ModelRange } from "@ckeditor/ckeditor5-engine";
10
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
- */
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
46
  export declare 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?: ModelRange;
76
- }): void;
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ constructor(editor: Editor);
51
+ /**
52
+ * @inheritDoc
53
+ */
54
+ override 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
+ override execute(options: {
69
+ mention: string | {
70
+ id: string;
71
+ [key: string]: unknown;
72
+ };
73
+ marker: string;
74
+ text?: string;
75
+ range?: ModelRange;
76
+ }): void;
77
77
  }