@ckeditor/ckeditor5-link 38.1.0 → 38.1.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/src/index.js CHANGED
@@ -1,17 +1,17 @@
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 link
7
- */
8
- export { default as Link } from './link';
9
- export { default as LinkEditing } from './linkediting';
10
- export { default as LinkUI } from './linkui';
11
- export { default as LinkImage } from './linkimage';
12
- export { default as LinkImageEditing } from './linkimageediting';
13
- export { default as LinkImageUI } from './linkimageui';
14
- export { default as AutoLink } from './autolink';
15
- export { default as LinkCommand } from './linkcommand';
16
- export { default as UnlinkCommand } from './unlinkcommand';
17
- import './augmentation';
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 link
7
+ */
8
+ export { default as Link } from './link';
9
+ export { default as LinkEditing } from './linkediting';
10
+ export { default as LinkUI } from './linkui';
11
+ export { default as LinkImage } from './linkimage';
12
+ export { default as LinkImageEditing } from './linkimageediting';
13
+ export { default as LinkImageUI } from './linkimageui';
14
+ export { default as AutoLink } from './autolink';
15
+ export { default as LinkCommand } from './linkcommand';
16
+ export { default as UnlinkCommand } from './unlinkcommand';
17
+ import './augmentation';
package/src/link.d.ts CHANGED
@@ -1,27 +1,27 @@
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 link/link
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import LinkEditing from './linkediting';
10
- import LinkUI from './linkui';
11
- import AutoLink from './autolink';
12
- /**
13
- * The link plugin.
14
- *
15
- * This is a "glue" plugin that loads the {@link module:link/linkediting~LinkEditing link editing feature}
16
- * and {@link module:link/linkui~LinkUI link UI feature}.
17
- */
18
- export default class Link extends Plugin {
19
- /**
20
- * @inheritDoc
21
- */
22
- static get requires(): readonly [typeof LinkEditing, typeof LinkUI, typeof AutoLink];
23
- /**
24
- * @inheritDoc
25
- */
26
- static get pluginName(): "Link";
27
- }
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 link/link
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import LinkEditing from './linkediting';
10
+ import LinkUI from './linkui';
11
+ import AutoLink from './autolink';
12
+ /**
13
+ * The link plugin.
14
+ *
15
+ * This is a "glue" plugin that loads the {@link module:link/linkediting~LinkEditing link editing feature}
16
+ * and {@link module:link/linkui~LinkUI link UI feature}.
17
+ */
18
+ export default class Link extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): readonly [typeof LinkEditing, typeof LinkUI, typeof AutoLink];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): "Link";
27
+ }
package/src/link.js CHANGED
@@ -1,31 +1,31 @@
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 link/link
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import LinkEditing from './linkediting';
10
- import LinkUI from './linkui';
11
- import AutoLink from './autolink';
12
- /**
13
- * The link plugin.
14
- *
15
- * This is a "glue" plugin that loads the {@link module:link/linkediting~LinkEditing link editing feature}
16
- * and {@link module:link/linkui~LinkUI link UI feature}.
17
- */
18
- export default class Link extends Plugin {
19
- /**
20
- * @inheritDoc
21
- */
22
- static get requires() {
23
- return [LinkEditing, LinkUI, AutoLink];
24
- }
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName() {
29
- return 'Link';
30
- }
31
- }
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 link/link
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import LinkEditing from './linkediting';
10
+ import LinkUI from './linkui';
11
+ import AutoLink from './autolink';
12
+ /**
13
+ * The link plugin.
14
+ *
15
+ * This is a "glue" plugin that loads the {@link module:link/linkediting~LinkEditing link editing feature}
16
+ * and {@link module:link/linkui~LinkUI link UI feature}.
17
+ */
18
+ export default class Link extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires() {
23
+ return [LinkEditing, LinkUI, AutoLink];
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName() {
29
+ return 'Link';
30
+ }
31
+ }
@@ -1,132 +1,132 @@
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 link/linkcommand
7
- */
8
- import { Command } from 'ckeditor5/src/core';
9
- import { Collection } from 'ckeditor5/src/utils';
10
- import AutomaticDecorators from './utils/automaticdecorators';
11
- import type ManualDecorator from './utils/manualdecorator';
12
- /**
13
- * The link command. It is used by the {@link module:link/link~Link link feature}.
14
- */
15
- export default class LinkCommand extends Command {
16
- /**
17
- * The value of the `'linkHref'` attribute if the start of the selection is located in a node with this attribute.
18
- *
19
- * @observable
20
- * @readonly
21
- */
22
- value: string | undefined;
23
- /**
24
- * A collection of {@link module:link/utils/manualdecorator~ManualDecorator manual decorators}
25
- * corresponding to the {@link module:link/linkconfig~LinkConfig#decorators decorator configuration}.
26
- *
27
- * You can consider it a model with states of manual decorators added to the currently selected link.
28
- */
29
- readonly manualDecorators: Collection<ManualDecorator>;
30
- /**
31
- * An instance of the helper that ties together all {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition}
32
- * that are used by the {@glink features/link link} and the {@glink features/images/images-linking linking images} features.
33
- */
34
- readonly automaticDecorators: AutomaticDecorators;
35
- /**
36
- * Synchronizes the state of {@link #manualDecorators} with the currently present elements in the model.
37
- */
38
- restoreManualDecoratorStates(): void;
39
- /**
40
- * @inheritDoc
41
- */
42
- refresh(): void;
43
- /**
44
- * Executes the command.
45
- *
46
- * When the selection is non-collapsed, the `linkHref` attribute will be applied to nodes inside the selection, but only to
47
- * those nodes where the `linkHref` attribute is allowed (disallowed nodes will be omitted).
48
- *
49
- * When the selection is collapsed and is not inside the text with the `linkHref` attribute, a
50
- * new {@link module:engine/model/text~Text text node} with the `linkHref` attribute will be inserted in place of the caret, but
51
- * only if such element is allowed in this place. The `_data` of the inserted text will equal the `href` parameter.
52
- * The selection will be updated to wrap the just inserted text node.
53
- *
54
- * When the selection is collapsed and inside the text with the `linkHref` attribute, the attribute value will be updated.
55
- *
56
- * # Decorators and model attribute management
57
- *
58
- * There is an optional argument to this command that applies or removes model
59
- * {@glink framework/architecture/editing-engine#text-attributes text attributes} brought by
60
- * {@link module:link/utils/manualdecorator~ManualDecorator manual link decorators}.
61
- *
62
- * Text attribute names in the model correspond to the entries in the {@link module:link/linkconfig~LinkConfig#decorators
63
- * configuration}.
64
- * For every decorator configured, a model text attribute exists with the "link" prefix. For example, a `'linkMyDecorator'` attribute
65
- * corresponds to `'myDecorator'` in the configuration.
66
- *
67
- * To learn more about link decorators, check out the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`}
68
- * documentation.
69
- *
70
- * Here is how to manage decorator attributes with the link command:
71
- *
72
- * ```ts
73
- * const linkCommand = editor.commands.get( 'link' );
74
- *
75
- * // Adding a new decorator attribute.
76
- * linkCommand.execute( 'http://example.com', {
77
- * linkIsExternal: true
78
- * } );
79
- *
80
- * // Removing a decorator attribute from the selection.
81
- * linkCommand.execute( 'http://example.com', {
82
- * linkIsExternal: false
83
- * } );
84
- *
85
- * // Adding multiple decorator attributes at the same time.
86
- * linkCommand.execute( 'http://example.com', {
87
- * linkIsExternal: true,
88
- * linkIsDownloadable: true,
89
- * } );
90
- *
91
- * // Removing and adding decorator attributes at the same time.
92
- * linkCommand.execute( 'http://example.com', {
93
- * linkIsExternal: false,
94
- * linkFoo: true,
95
- * linkIsDownloadable: false,
96
- * } );
97
- * ```
98
- *
99
- * **Note**: If the decorator attribute name is not specified, its state remains untouched.
100
- *
101
- * **Note**: {@link module:link/unlinkcommand~UnlinkCommand#execute `UnlinkCommand#execute()`} removes all
102
- * decorator attributes.
103
- *
104
- * @fires execute
105
- * @param href Link destination.
106
- * @param manualDecoratorIds The information about manual decorator attributes to be applied or removed upon execution.
107
- */
108
- execute(href: string, manualDecoratorIds?: Record<string, boolean>): void;
109
- /**
110
- * Provides information whether a decorator with a given name is present in the currently processed selection.
111
- *
112
- * @param decoratorName The name of the manual decorator used in the model
113
- * @returns The information whether a given decorator is currently present in the selection.
114
- */
115
- private _getDecoratorStateFromModel;
116
- /**
117
- * Checks whether specified `range` is inside an element that accepts the `linkHref` attribute.
118
- *
119
- * @param range A range to check.
120
- * @param allowedRanges An array of ranges created on elements where the attribute is accepted.
121
- */
122
- private _isRangeToUpdate;
123
- /**
124
- * Updates selected link with a new value as its content and as its href attribute.
125
- *
126
- * @param model Model is need to insert content.
127
- * @param writer Writer is need to create text element in model.
128
- * @param range A range where should be inserted content.
129
- * @param href A link value which should be in the href attribute and in the content.
130
- */
131
- private _updateLinkContent;
132
- }
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 link/linkcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core';
9
+ import { Collection } from 'ckeditor5/src/utils';
10
+ import AutomaticDecorators from './utils/automaticdecorators';
11
+ import type ManualDecorator from './utils/manualdecorator';
12
+ /**
13
+ * The link command. It is used by the {@link module:link/link~Link link feature}.
14
+ */
15
+ export default class LinkCommand extends Command {
16
+ /**
17
+ * The value of the `'linkHref'` attribute if the start of the selection is located in a node with this attribute.
18
+ *
19
+ * @observable
20
+ * @readonly
21
+ */
22
+ value: string | undefined;
23
+ /**
24
+ * A collection of {@link module:link/utils/manualdecorator~ManualDecorator manual decorators}
25
+ * corresponding to the {@link module:link/linkconfig~LinkConfig#decorators decorator configuration}.
26
+ *
27
+ * You can consider it a model with states of manual decorators added to the currently selected link.
28
+ */
29
+ readonly manualDecorators: Collection<ManualDecorator>;
30
+ /**
31
+ * An instance of the helper that ties together all {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition}
32
+ * that are used by the {@glink features/link link} and the {@glink features/images/images-linking linking images} features.
33
+ */
34
+ readonly automaticDecorators: AutomaticDecorators;
35
+ /**
36
+ * Synchronizes the state of {@link #manualDecorators} with the currently present elements in the model.
37
+ */
38
+ restoreManualDecoratorStates(): void;
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ refresh(): void;
43
+ /**
44
+ * Executes the command.
45
+ *
46
+ * When the selection is non-collapsed, the `linkHref` attribute will be applied to nodes inside the selection, but only to
47
+ * those nodes where the `linkHref` attribute is allowed (disallowed nodes will be omitted).
48
+ *
49
+ * When the selection is collapsed and is not inside the text with the `linkHref` attribute, a
50
+ * new {@link module:engine/model/text~Text text node} with the `linkHref` attribute will be inserted in place of the caret, but
51
+ * only if such element is allowed in this place. The `_data` of the inserted text will equal the `href` parameter.
52
+ * The selection will be updated to wrap the just inserted text node.
53
+ *
54
+ * When the selection is collapsed and inside the text with the `linkHref` attribute, the attribute value will be updated.
55
+ *
56
+ * # Decorators and model attribute management
57
+ *
58
+ * There is an optional argument to this command that applies or removes model
59
+ * {@glink framework/architecture/editing-engine#text-attributes text attributes} brought by
60
+ * {@link module:link/utils/manualdecorator~ManualDecorator manual link decorators}.
61
+ *
62
+ * Text attribute names in the model correspond to the entries in the {@link module:link/linkconfig~LinkConfig#decorators
63
+ * configuration}.
64
+ * For every decorator configured, a model text attribute exists with the "link" prefix. For example, a `'linkMyDecorator'` attribute
65
+ * corresponds to `'myDecorator'` in the configuration.
66
+ *
67
+ * To learn more about link decorators, check out the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`}
68
+ * documentation.
69
+ *
70
+ * Here is how to manage decorator attributes with the link command:
71
+ *
72
+ * ```ts
73
+ * const linkCommand = editor.commands.get( 'link' );
74
+ *
75
+ * // Adding a new decorator attribute.
76
+ * linkCommand.execute( 'http://example.com', {
77
+ * linkIsExternal: true
78
+ * } );
79
+ *
80
+ * // Removing a decorator attribute from the selection.
81
+ * linkCommand.execute( 'http://example.com', {
82
+ * linkIsExternal: false
83
+ * } );
84
+ *
85
+ * // Adding multiple decorator attributes at the same time.
86
+ * linkCommand.execute( 'http://example.com', {
87
+ * linkIsExternal: true,
88
+ * linkIsDownloadable: true,
89
+ * } );
90
+ *
91
+ * // Removing and adding decorator attributes at the same time.
92
+ * linkCommand.execute( 'http://example.com', {
93
+ * linkIsExternal: false,
94
+ * linkFoo: true,
95
+ * linkIsDownloadable: false,
96
+ * } );
97
+ * ```
98
+ *
99
+ * **Note**: If the decorator attribute name is not specified, its state remains untouched.
100
+ *
101
+ * **Note**: {@link module:link/unlinkcommand~UnlinkCommand#execute `UnlinkCommand#execute()`} removes all
102
+ * decorator attributes.
103
+ *
104
+ * @fires execute
105
+ * @param href Link destination.
106
+ * @param manualDecoratorIds The information about manual decorator attributes to be applied or removed upon execution.
107
+ */
108
+ execute(href: string, manualDecoratorIds?: Record<string, boolean>): void;
109
+ /**
110
+ * Provides information whether a decorator with a given name is present in the currently processed selection.
111
+ *
112
+ * @param decoratorName The name of the manual decorator used in the model
113
+ * @returns The information whether a given decorator is currently present in the selection.
114
+ */
115
+ private _getDecoratorStateFromModel;
116
+ /**
117
+ * Checks whether specified `range` is inside an element that accepts the `linkHref` attribute.
118
+ *
119
+ * @param range A range to check.
120
+ * @param allowedRanges An array of ranges created on elements where the attribute is accepted.
121
+ */
122
+ private _isRangeToUpdate;
123
+ /**
124
+ * Updates selected link with a new value as its content and as its href attribute.
125
+ *
126
+ * @param model Model is need to insert content.
127
+ * @param writer Writer is need to create text element in model.
128
+ * @param range A range where should be inserted content.
129
+ * @param href A link value which should be in the href attribute and in the content.
130
+ */
131
+ private _updateLinkContent;
132
+ }