@ckeditor/ckeditor5-link 48.2.0 → 48.3.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/dist/link.d.ts CHANGED
@@ -1,31 +1,31 @@
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 link/link
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import { LinkEditing } from './linkediting.js';
10
- import { LinkUI } from './linkui.js';
11
- import { AutoLink } from './autolink.js';
6
+ * @module link/link
7
+ */
8
+ import { Plugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
9
+ import { LinkEditing } from "./linkediting.js";
10
+ import { LinkUI } from "./linkui.js";
11
+ import { AutoLink } from "./autolink.js";
12
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
- */
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
18
  export declare 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
- /**
28
- * @inheritDoc
29
- */
30
- static get isOfficialPlugin(): true;
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): PluginDependenciesOf<[LinkEditing, LinkUI, AutoLink]>;
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): "Link";
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static override get isOfficialPlugin(): true;
31
31
  }
@@ -1,139 +1,139 @@
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 link/linkcommand
7
- */
8
- import { Command } from '@ckeditor/ckeditor5-core';
9
- import { Collection } from '@ckeditor/ckeditor5-utils';
10
- import { AutomaticLinkDecorators } from './utils/automaticdecorators.js';
11
- import { type LinkManualDecorator } from './utils/manualdecorator.js';
6
+ * @module link/linkcommand
7
+ */
8
+ import { Command } from "@ckeditor/ckeditor5-core";
9
+ import { Collection } from "@ckeditor/ckeditor5-utils";
10
+ import { AutomaticLinkDecorators } from "./utils/automaticdecorators.js";
11
+ import { type LinkManualDecorator } from "./utils/manualdecorator.js";
12
12
  /**
13
- * The link command. It is used by the {@link module:link/link~Link link feature}.
14
- */
13
+ * The link command. It is used by the {@link module:link/link~Link link feature}.
14
+ */
15
15
  export declare 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~LinkManualDecorator 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<LinkManualDecorator>;
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: AutomaticLinkDecorators;
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~ModelText 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~LinkManualDecorator 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
- * An optional parameter called `displayedText` is to add or update text of the link that represents the `href`. For example:
105
- *
106
- * ```ts
107
- * const linkCommand = editor.commands.get( 'link' );
108
- *
109
- * // Adding a new link with `displayedText` attribute.
110
- * linkCommand.execute( 'http://example.com', {}, 'Example' );
111
- * ```
112
- *
113
- * The above code will create an anchor like this:
114
- *
115
- * ```html
116
- * <a href="http://example.com">Example</a>
117
- * ```
118
- *
119
- * @fires execute
120
- * @param href Link destination.
121
- * @param manualDecoratorIds The information about manual decorator attributes to be applied or removed upon execution.
122
- * @param displayedText Text of the link.
123
- */
124
- execute(href: string, manualDecoratorIds?: Record<string, boolean>, displayedText?: string): void;
125
- /**
126
- * Provides information whether a decorator with a given name is present in the currently processed selection.
127
- *
128
- * @param decoratorName The name of the manual decorator used in the model
129
- * @returns The information whether a given decorator is currently present in the selection.
130
- */
131
- private _getDecoratorStateFromModel;
132
- /**
133
- * Checks whether specified `range` is inside an element that accepts the `linkHref` attribute.
134
- *
135
- * @param range A range to check.
136
- * @param allowedRanges An array of ranges created on elements where the attribute is accepted.
137
- */
138
- private _isRangeToUpdate;
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~LinkManualDecorator 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<LinkManualDecorator>;
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: AutomaticLinkDecorators;
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
+ override 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~ModelText 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~LinkManualDecorator 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
+ * An optional parameter called `displayedText` is to add or update text of the link that represents the `href`. For example:
105
+ *
106
+ * ```ts
107
+ * const linkCommand = editor.commands.get( 'link' );
108
+ *
109
+ * // Adding a new link with `displayedText` attribute.
110
+ * linkCommand.execute( 'http://example.com', {}, 'Example' );
111
+ * ```
112
+ *
113
+ * The above code will create an anchor like this:
114
+ *
115
+ * ```html
116
+ * <a href="http://example.com">Example</a>
117
+ * ```
118
+ *
119
+ * @fires execute
120
+ * @param href Link destination.
121
+ * @param manualDecoratorIds The information about manual decorator attributes to be applied or removed upon execution.
122
+ * @param displayedText Text of the link.
123
+ */
124
+ override execute(href: string, manualDecoratorIds?: Record<string, boolean>, displayedText?: string): void;
125
+ /**
126
+ * Provides information whether a decorator with a given name is present in the currently processed selection.
127
+ *
128
+ * @param decoratorName The name of the manual decorator used in the model
129
+ * @returns The information whether a given decorator is currently present in the selection.
130
+ */
131
+ private _getDecoratorStateFromModel;
132
+ /**
133
+ * Checks whether specified `range` is inside an element that accepts the `linkHref` attribute.
134
+ *
135
+ * @param range A range to check.
136
+ * @param allowedRanges An array of ranges created on elements where the attribute is accepted.
137
+ */
138
+ private _isRangeToUpdate;
139
139
  }