@ckeditor/ckeditor5-mention 38.1.0 → 38.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/build/mention.js +1 -1
- package/build/mention.js.map +1 -0
- package/package.json +2 -2
- package/src/augmentation.d.ts +23 -23
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +13 -13
- package/src/index.js +11 -11
- package/src/mention.d.ts +66 -66
- package/src/mention.js +47 -47
- package/src/mentioncommand.d.ts +75 -75
- package/src/mentioncommand.js +145 -145
- package/src/mentionconfig.d.ts +265 -265
- package/src/mentionconfig.js +5 -5
- package/src/mentionediting.d.ts +40 -40
- package/src/mentionediting.js +231 -231
- package/src/mentionui.d.ts +102 -102
- package/src/mentionui.js +618 -618
- package/src/ui/domwrapperview.d.ts +37 -37
- package/src/ui/domwrapperview.js +51 -51
- package/src/ui/mentionlistitemview.d.ts +15 -15
- package/src/ui/mentionlistitemview.js +18 -18
- package/src/ui/mentionsview.d.ts +60 -60
- package/src/ui/mentionsview.js +104 -104
package/src/mention.d.ts
CHANGED
@@ -1,66 +1,66 @@
|
|
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 mention/mention
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import type { Element } from 'ckeditor5/src/engine';
|
10
|
-
import MentionEditing from './mentionediting';
|
11
|
-
import MentionUI from './mentionui';
|
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 optional 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 viewElement
|
31
|
-
* @param data Additional data to be stored in the mention attribute.
|
32
|
-
*/
|
33
|
-
toMentionAttribute(viewElement: Element, data?: MentionAttribute): MentionAttribute | undefined;
|
34
|
-
/**
|
35
|
-
* @inheritDoc
|
36
|
-
*/
|
37
|
-
static get pluginName(): "Mention";
|
38
|
-
/**
|
39
|
-
* @inheritDoc
|
40
|
-
*/
|
41
|
-
static get requires(): readonly [typeof MentionEditing, typeof MentionUI];
|
42
|
-
}
|
43
|
-
/**
|
44
|
-
* Represents a mention in the model.
|
45
|
-
*
|
46
|
-
* See {@link module:mention/mention~Mention#toMentionAttribute `Mention#toMentionAttribute()`}.
|
47
|
-
*/
|
48
|
-
export type MentionAttribute = {
|
49
|
-
/**
|
50
|
-
* The ID of a mention. It identifies the mention item in the mention feed. There can be multiple mentions
|
51
|
-
* in the document with the same ID (e.g. the same hashtag being mentioned).
|
52
|
-
*/
|
53
|
-
id: string;
|
54
|
-
/**
|
55
|
-
* A unique ID of this mention instance. Should be passed as an `option.id` when using
|
56
|
-
* {@link module:engine/view/downcastwriter~DowncastWriter#createAttributeElement writer.createAttributeElement()}.
|
57
|
-
*/
|
58
|
-
uid?: string;
|
59
|
-
/**
|
60
|
-
* Helper property that stores the text of the inserted mention. Used for detecting a broken mention
|
61
|
-
* in the editing area.
|
62
|
-
*
|
63
|
-
* @internal
|
64
|
-
*/
|
65
|
-
_text?: string;
|
66
|
-
};
|
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 mention/mention
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import type { Element } from 'ckeditor5/src/engine';
|
10
|
+
import MentionEditing from './mentionediting';
|
11
|
+
import MentionUI from './mentionui';
|
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 optional 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 viewElement
|
31
|
+
* @param data Additional data to be stored in the mention attribute.
|
32
|
+
*/
|
33
|
+
toMentionAttribute(viewElement: Element, data?: MentionAttribute): MentionAttribute | undefined;
|
34
|
+
/**
|
35
|
+
* @inheritDoc
|
36
|
+
*/
|
37
|
+
static get pluginName(): "Mention";
|
38
|
+
/**
|
39
|
+
* @inheritDoc
|
40
|
+
*/
|
41
|
+
static get requires(): readonly [typeof MentionEditing, typeof MentionUI];
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* Represents a mention in the model.
|
45
|
+
*
|
46
|
+
* See {@link module:mention/mention~Mention#toMentionAttribute `Mention#toMentionAttribute()`}.
|
47
|
+
*/
|
48
|
+
export type MentionAttribute = {
|
49
|
+
/**
|
50
|
+
* The ID of a mention. It identifies the mention item in the mention feed. There can be multiple mentions
|
51
|
+
* in the document with the same ID (e.g. the same hashtag being mentioned).
|
52
|
+
*/
|
53
|
+
id: string;
|
54
|
+
/**
|
55
|
+
* A unique ID of this mention instance. Should be passed as an `option.id` when using
|
56
|
+
* {@link module:engine/view/downcastwriter~DowncastWriter#createAttributeElement writer.createAttributeElement()}.
|
57
|
+
*/
|
58
|
+
uid?: string;
|
59
|
+
/**
|
60
|
+
* Helper property that stores the text of the inserted mention. Used for detecting a broken mention
|
61
|
+
* in the editing area.
|
62
|
+
*
|
63
|
+
* @internal
|
64
|
+
*/
|
65
|
+
_text?: string;
|
66
|
+
};
|
package/src/mention.js
CHANGED
@@ -1,47 +1,47 @@
|
|
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 mention/mention
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import MentionEditing, { _toMentionAttribute } from './mentionediting';
|
10
|
-
import MentionUI from './mentionui';
|
11
|
-
import '../theme/mention.css';
|
12
|
-
/**
|
13
|
-
* The mention plugin.
|
14
|
-
*
|
15
|
-
* For a detailed overview, check the {@glink features/mentions Mention feature} guide.
|
16
|
-
*/
|
17
|
-
export default class Mention extends Plugin {
|
18
|
-
/**
|
19
|
-
* Creates a mention attribute value from the provided view element and optional data.
|
20
|
-
*
|
21
|
-
* ```ts
|
22
|
-
* editor.plugins.get( 'Mention' ).toMentionAttribute( viewElement, { userId: '1234' } );
|
23
|
-
*
|
24
|
-
* // For a view element: <span data-mention="@joe">@John Doe</span>
|
25
|
-
* // it will return:
|
26
|
-
* // { id: '@joe', userId: '1234', uid: '7a7bc7...', _text: '@John Doe' }
|
27
|
-
* ```
|
28
|
-
*
|
29
|
-
* @param viewElement
|
30
|
-
* @param data Additional data to be stored in the mention attribute.
|
31
|
-
*/
|
32
|
-
toMentionAttribute(viewElement, data) {
|
33
|
-
return _toMentionAttribute(viewElement, data);
|
34
|
-
}
|
35
|
-
/**
|
36
|
-
* @inheritDoc
|
37
|
-
*/
|
38
|
-
static get pluginName() {
|
39
|
-
return 'Mention';
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* @inheritDoc
|
43
|
-
*/
|
44
|
-
static get requires() {
|
45
|
-
return [MentionEditing, MentionUI];
|
46
|
-
}
|
47
|
-
}
|
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 mention/mention
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import MentionEditing, { _toMentionAttribute } from './mentionediting';
|
10
|
+
import MentionUI from './mentionui';
|
11
|
+
import '../theme/mention.css';
|
12
|
+
/**
|
13
|
+
* The mention plugin.
|
14
|
+
*
|
15
|
+
* For a detailed overview, check the {@glink features/mentions Mention feature} guide.
|
16
|
+
*/
|
17
|
+
export default class Mention extends Plugin {
|
18
|
+
/**
|
19
|
+
* Creates a mention attribute value from the provided view element and optional data.
|
20
|
+
*
|
21
|
+
* ```ts
|
22
|
+
* editor.plugins.get( 'Mention' ).toMentionAttribute( viewElement, { userId: '1234' } );
|
23
|
+
*
|
24
|
+
* // For a view element: <span data-mention="@joe">@John Doe</span>
|
25
|
+
* // it will return:
|
26
|
+
* // { id: '@joe', userId: '1234', uid: '7a7bc7...', _text: '@John Doe' }
|
27
|
+
* ```
|
28
|
+
*
|
29
|
+
* @param viewElement
|
30
|
+
* @param data Additional data to be stored in the mention attribute.
|
31
|
+
*/
|
32
|
+
toMentionAttribute(viewElement, data) {
|
33
|
+
return _toMentionAttribute(viewElement, data);
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
static get pluginName() {
|
39
|
+
return 'Mention';
|
40
|
+
}
|
41
|
+
/**
|
42
|
+
* @inheritDoc
|
43
|
+
*/
|
44
|
+
static get requires() {
|
45
|
+
return [MentionEditing, MentionUI];
|
46
|
+
}
|
47
|
+
}
|
package/src/mentioncommand.d.ts
CHANGED
@@ -1,75 +1,75 @@
|
|
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 mention/mentioncommand
|
7
|
-
*/
|
8
|
-
import { Command, type Editor } from 'ckeditor5/src/core';
|
9
|
-
import type { Range } from 'ckeditor5/src/engine';
|
10
|
-
import type { MentionAttribute } from './mention';
|
11
|
-
/**
|
12
|
-
* The mention command.
|
13
|
-
*
|
14
|
-
* The command is registered by {@link module:mention/mentionediting~MentionEditing} as `'mention'`.
|
15
|
-
*
|
16
|
-
* To insert a mention into a range, execute the command and specify a mention object with a range to replace:
|
17
|
-
*
|
18
|
-
* ```ts
|
19
|
-
* const focus = editor.model.document.selection.focus;
|
20
|
-
*
|
21
|
-
* // It will replace one character before the selection focus with the '#1234' text
|
22
|
-
* // with the mention attribute filled with passed attributes.
|
23
|
-
* editor.execute( 'mention', {
|
24
|
-
* marker: '#',
|
25
|
-
* mention: {
|
26
|
-
* id: '#1234',
|
27
|
-
* name: 'Foo',
|
28
|
-
* title: 'Big Foo'
|
29
|
-
* },
|
30
|
-
* range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
|
31
|
-
* } );
|
32
|
-
*
|
33
|
-
* // It will replace one character before the selection focus with the 'The "Big Foo"' text
|
34
|
-
* // with the mention attribute filled with passed attributes.
|
35
|
-
* editor.execute( 'mention', {
|
36
|
-
* marker: '#',
|
37
|
-
* mention: {
|
38
|
-
* id: '#1234',
|
39
|
-
* name: 'Foo',
|
40
|
-
* title: 'Big Foo'
|
41
|
-
* },
|
42
|
-
* text: 'The "Big Foo"',
|
43
|
-
* range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
|
44
|
-
* } );
|
45
|
-
* ```
|
46
|
-
*/
|
47
|
-
export default class MentionCommand extends Command {
|
48
|
-
/**
|
49
|
-
* @inheritDoc
|
50
|
-
*/
|
51
|
-
constructor(editor: Editor);
|
52
|
-
/**
|
53
|
-
* @inheritDoc
|
54
|
-
*/
|
55
|
-
refresh(): void;
|
56
|
-
/**
|
57
|
-
* Executes the command.
|
58
|
-
*
|
59
|
-
* @param options Options for the executed command.
|
60
|
-
* @param options.mention The mention object to insert. When a string is passed, it will be used to create a plain
|
61
|
-
* object with the name attribute that equals the passed string.
|
62
|
-
* @param options.marker The marker character (e.g. `'@'`).
|
63
|
-
* @param options.text The text of the inserted mention. Defaults to the full mention string composed from `marker` and
|
64
|
-
* `mention` string or `mention.id` if an object is passed.
|
65
|
-
* @param options.range The range to replace.
|
66
|
-
* Note that the replaced range might be shorter than the inserted text with the mention attribute.
|
67
|
-
* @fires execute
|
68
|
-
*/
|
69
|
-
execute(options: {
|
70
|
-
mention: string | MentionAttribute;
|
71
|
-
marker: string;
|
72
|
-
text?: string;
|
73
|
-
range?: Range;
|
74
|
-
}): void;
|
75
|
-
}
|
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 mention/mentioncommand
|
7
|
+
*/
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
9
|
+
import type { Range } from 'ckeditor5/src/engine';
|
10
|
+
import type { MentionAttribute } from './mention';
|
11
|
+
/**
|
12
|
+
* The mention command.
|
13
|
+
*
|
14
|
+
* The command is registered by {@link module:mention/mentionediting~MentionEditing} as `'mention'`.
|
15
|
+
*
|
16
|
+
* To insert a mention into a range, execute the command and specify a mention object with a range to replace:
|
17
|
+
*
|
18
|
+
* ```ts
|
19
|
+
* const focus = editor.model.document.selection.focus;
|
20
|
+
*
|
21
|
+
* // It will replace one character before the selection focus with the '#1234' text
|
22
|
+
* // with the mention attribute filled with passed attributes.
|
23
|
+
* editor.execute( 'mention', {
|
24
|
+
* marker: '#',
|
25
|
+
* mention: {
|
26
|
+
* id: '#1234',
|
27
|
+
* name: 'Foo',
|
28
|
+
* title: 'Big Foo'
|
29
|
+
* },
|
30
|
+
* range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
|
31
|
+
* } );
|
32
|
+
*
|
33
|
+
* // It will replace one character before the selection focus with the 'The "Big Foo"' text
|
34
|
+
* // with the mention attribute filled with passed attributes.
|
35
|
+
* editor.execute( 'mention', {
|
36
|
+
* marker: '#',
|
37
|
+
* mention: {
|
38
|
+
* id: '#1234',
|
39
|
+
* name: 'Foo',
|
40
|
+
* title: 'Big Foo'
|
41
|
+
* },
|
42
|
+
* text: 'The "Big Foo"',
|
43
|
+
* range: editor.model.createRange( focus.getShiftedBy( -1 ), focus )
|
44
|
+
* } );
|
45
|
+
* ```
|
46
|
+
*/
|
47
|
+
export default class MentionCommand extends Command {
|
48
|
+
/**
|
49
|
+
* @inheritDoc
|
50
|
+
*/
|
51
|
+
constructor(editor: Editor);
|
52
|
+
/**
|
53
|
+
* @inheritDoc
|
54
|
+
*/
|
55
|
+
refresh(): void;
|
56
|
+
/**
|
57
|
+
* Executes the command.
|
58
|
+
*
|
59
|
+
* @param options Options for the executed command.
|
60
|
+
* @param options.mention The mention object to insert. When a string is passed, it will be used to create a plain
|
61
|
+
* object with the name attribute that equals the passed string.
|
62
|
+
* @param options.marker The marker character (e.g. `'@'`).
|
63
|
+
* @param options.text The text of the inserted mention. Defaults to the full mention string composed from `marker` and
|
64
|
+
* `mention` string or `mention.id` if an object is passed.
|
65
|
+
* @param options.range The range to replace.
|
66
|
+
* Note that the replaced range might be shorter than the inserted text with the mention attribute.
|
67
|
+
* @fires execute
|
68
|
+
*/
|
69
|
+
execute(options: {
|
70
|
+
mention: string | MentionAttribute;
|
71
|
+
marker: string;
|
72
|
+
text?: string;
|
73
|
+
range?: Range;
|
74
|
+
}): void;
|
75
|
+
}
|