@ckeditor/ckeditor5-link 41.2.0 → 41.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.
@@ -0,0 +1,30 @@
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
+ import type { LinkConfig, AutoLink, Link, LinkEditing, LinkImage, LinkImageEditing, LinkImageUI, LinkUI, LinkCommand, UnlinkCommand } from './index.js';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the {@link module:link/link~Link} feature.
10
+ *
11
+ * Read more in {@link module:link/linkconfig~LinkConfig}.
12
+ */
13
+ link?: LinkConfig;
14
+ }
15
+ interface PluginsMap {
16
+ [AutoLink.pluginName]: AutoLink;
17
+ [Link.pluginName]: Link;
18
+ [LinkEditing.pluginName]: LinkEditing;
19
+ [LinkImage.pluginName]: LinkImage;
20
+ [LinkImageEditing.pluginName]: LinkImageEditing;
21
+ [LinkImageUI.pluginName]: LinkImageUI;
22
+ [LinkUI.pluginName]: LinkUI;
23
+ }
24
+ interface CommandsMap {
25
+ link: LinkCommand;
26
+ }
27
+ interface CommandsMap {
28
+ unlink: UnlinkCommand;
29
+ }
30
+ }
@@ -0,0 +1,75 @@
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
+ * @module link/autolink
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import { Delete } from 'ckeditor5/src/typing.js';
10
+ import LinkEditing from './linkediting.js';
11
+ /**
12
+ * The autolink plugin.
13
+ */
14
+ export default class AutoLink extends Plugin {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ static get requires(): readonly [typeof Delete, typeof LinkEditing];
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "AutoLink";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ init(): void;
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ afterInit(): void;
31
+ /**
32
+ * For given position, returns a range that includes the whole link that contains the position.
33
+ *
34
+ * If position is not inside a link, returns `null`.
35
+ */
36
+ private _expandLinkRange;
37
+ /**
38
+ * Extends the document selection to includes all links that intersects with given `selectedRange`.
39
+ */
40
+ private _selectEntireLinks;
41
+ /**
42
+ * Enables autolinking on pasting a URL when some content is selected.
43
+ */
44
+ private _enablePasteLinking;
45
+ /**
46
+ * Enables autolinking on typing.
47
+ */
48
+ private _enableTypingHandling;
49
+ /**
50
+ * Enables autolinking on the <kbd>Enter</kbd> key.
51
+ */
52
+ private _enableEnterHandling;
53
+ /**
54
+ * Enables autolinking on the <kbd>Shift</kbd>+<kbd>Enter</kbd> keyboard shortcut.
55
+ */
56
+ private _enableShiftEnterHandling;
57
+ /**
58
+ * Checks if the passed range contains a linkable text.
59
+ */
60
+ private _checkAndApplyAutoLinkOnRange;
61
+ /**
62
+ * Applies a link on a given range if the link should be applied.
63
+ *
64
+ * @param url The URL to link.
65
+ * @param range The text range to apply the link attribute to.
66
+ */
67
+ private _applyAutoLink;
68
+ /**
69
+ * Enqueues autolink changes in the model.
70
+ *
71
+ * @param url The URL to link.
72
+ * @param range The text range to apply the link attribute to.
73
+ */
74
+ private _persistAutoLink;
75
+ }
@@ -0,0 +1,18 @@
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
+ * @module link
7
+ */
8
+ export { default as Link } from './link.js';
9
+ export { default as LinkEditing } from './linkediting.js';
10
+ export { default as LinkUI } from './linkui.js';
11
+ export { default as LinkImage } from './linkimage.js';
12
+ export { default as LinkImageEditing } from './linkimageediting.js';
13
+ export { default as LinkImageUI } from './linkimageui.js';
14
+ export { default as AutoLink } from './autolink.js';
15
+ export type { LinkConfig, LinkDecoratorDefinition } from './linkconfig.js';
16
+ export { default as LinkCommand } from './linkcommand.js';
17
+ export { default as UnlinkCommand } from './unlinkcommand.js';
18
+ import './augmentation.js';
@@ -0,0 +1,27 @@
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
+ * @module link/link
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import LinkEditing from './linkediting.js';
10
+ import LinkUI from './linkui.js';
11
+ import AutoLink from './autolink.js';
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
+ }
@@ -0,0 +1,132 @@
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
+ * @module link/linkcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ import { Collection } from 'ckeditor5/src/utils.js';
10
+ import AutomaticDecorators from './utils/automaticdecorators.js';
11
+ import type ManualDecorator from './utils/manualdecorator.js';
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
+ }
@@ -0,0 +1,290 @@
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
+ * @module link/linkconfig
7
+ */
8
+ import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
9
+ /**
10
+ * The configuration of the {@link module:link/link~Link link feature}.
11
+ *
12
+ * ```ts
13
+ * ClassicEditor
14
+ * .create( editorElement, {
15
+ * link: ... // Link feature configuration.
16
+ * } )
17
+ * .then( ... )
18
+ * .catch( ... );
19
+ * ```
20
+ *
21
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
22
+ */
23
+ export interface LinkConfig {
24
+ /**
25
+ * When set, the editor will add the given protocol to the link when the user creates a link without one.
26
+ * For example, when the user is creating a link and types `ckeditor.com` in the link form input, during link submission
27
+ * the editor will automatically add the `http://` protocol, so the link will look as follows: `http://ckeditor.com`.
28
+ *
29
+ * The feature also provides email address auto-detection. When you submit `hello@example.com`,
30
+ * the plugin will automatically change it to `mailto:hello@example.com`.
31
+ *
32
+ * ```ts
33
+ * ClassicEditor
34
+ * .create( editorElement, {
35
+ * link: {
36
+ * defaultProtocol: 'http://'
37
+ * }
38
+ * } )
39
+ * .then( ... )
40
+ * .catch( ... );
41
+ * ```
42
+ *
43
+ * **NOTE:** If no configuration is provided, the editor will not auto-fix the links.
44
+ */
45
+ defaultProtocol?: string;
46
+ /**
47
+ * This is a protocols whitelist that can be used in links, defined as an array of strings.
48
+ * When not set, the editor will use a default list of allowed protocols.
49
+ *
50
+ * **Note:** Use this with caution and at your own risk - adding unsafe protocols like `javascript:`
51
+ * can result in serious security vulnerabilities!
52
+ *
53
+ * ```ts
54
+ * ClassicEditor
55
+ * .create( editorElement, {
56
+ * link: {
57
+ * allowedProtocols: [ 'http', 'https', 'ftp', 'tel', 'mailto', 'ssh' ]
58
+ * }
59
+ * } )
60
+ * .then( ... )
61
+ * .catch( ... );
62
+ * ```
63
+ *
64
+ */
65
+ allowedProtocols?: Array<string>;
66
+ /**
67
+ * When set to `true`, the form will accept an empty value in the URL field, creating a link with an empty `href` (`<a href="">`).
68
+ *
69
+ * ```ts
70
+ * ClassicEditor
71
+ * .create( editorElement, {
72
+ * link: {
73
+ * allowCreatingEmptyLinks: true
74
+ * }
75
+ * } )
76
+ * .then( ... )
77
+ * .catch( ... );
78
+ * ```
79
+ *
80
+ * **NOTE:** This option only adds form validation. If a link with an empty `href` is loaded into the editor, it will be left as-is.
81
+ *
82
+ * @default false
83
+ */
84
+ allowCreatingEmptyLinks?: boolean;
85
+ /**
86
+ * When set to `true`, the `target="blank"` and `rel="noopener noreferrer"` attributes are automatically added to all external links
87
+ * in the editor. "External links" are all links in the editor content starting with `http`, `https`, or `//`.
88
+ *
89
+ * ```ts
90
+ * ClassicEditor
91
+ * .create( editorElement, {
92
+ * link: {
93
+ * addTargetToExternalLinks: true
94
+ * }
95
+ * } )
96
+ * .then( ... )
97
+ * .catch( ... );
98
+ * ```
99
+ *
100
+ * Internally, this option activates a predefined {@link module:link/linkconfig~LinkConfig#decorators automatic link decorator}
101
+ * that extends all external links with the `target` and `rel` attributes.
102
+ *
103
+ * **Note**: To control the `target` and `rel` attributes of specific links in the edited content, a dedicated
104
+ * {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} decorator must be defined in the
105
+ * {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} array. In such scenario,
106
+ * the `config.link.addTargetToExternalLinks` option should remain `undefined` or `false` to not interfere with the manual decorator.
107
+ *
108
+ * It is possible to add other {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic}
109
+ * or {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} link decorators when this option is active.
110
+ *
111
+ * More information about decorators can be found in the {@link module:link/linkconfig~LinkConfig#decorators decorators configuration}
112
+ * reference.
113
+ *
114
+ * @default false
115
+ */
116
+ addTargetToExternalLinks?: boolean;
117
+ /**
118
+ * Decorators provide an easy way to configure and manage additional link attributes in the editor content. There are
119
+ * two types of link decorators:
120
+ *
121
+ * * {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition Automatic} &ndash; They match links against pre–defined rules and
122
+ * manage their attributes based on the results.
123
+ * * {@link module:link/linkconfig~LinkDecoratorManualDefinition Manual} &ndash; They allow users to control link attributes
124
+ * individually, using the editor UI.
125
+ *
126
+ * Link decorators are defined as objects with key-value pairs, where the key is the name provided for a given decorator and the
127
+ * value is the decorator definition.
128
+ *
129
+ * The name of the decorator also corresponds to the {@glink framework/architecture/editing-engine#text-attributes text
130
+ * attribute} in the model. For instance, the `isExternal` decorator below is represented as a `linkIsExternal` attribute in the model.
131
+ *
132
+ * ```ts
133
+ * ClassicEditor
134
+ * .create( editorElement, {
135
+ * link: {
136
+ * decorators: {
137
+ * isExternal: {
138
+ * mode: 'automatic',
139
+ * callback: url => url.startsWith( 'http://' ),
140
+ * attributes: {
141
+ * target: '_blank',
142
+ * rel: 'noopener noreferrer'
143
+ * }
144
+ * },
145
+ * isDownloadable: {
146
+ * mode: 'manual',
147
+ * label: 'Downloadable',
148
+ * attributes: {
149
+ * download: 'file.png',
150
+ * }
151
+ * },
152
+ * // ...
153
+ * }
154
+ * }
155
+ * } )
156
+ * .then( ... )
157
+ * .catch( ... );
158
+ * ```
159
+ *
160
+ * To learn more about the configuration syntax, check out the {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic}
161
+ * and {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} decorator option reference.
162
+ *
163
+ * **Warning:** Currently, link decorators work independently of one another and no conflict resolution mechanism exists.
164
+ * For example, configuring the `target` attribute using both an automatic and a manual decorator at the same time could end up with
165
+ * quirky results. The same applies if multiple manual or automatic decorators were defined for the same attribute.
166
+ *
167
+ * **Note**: Since the `target` attribute management for external links is a common use case, there is a predefined automatic decorator
168
+ * dedicated for that purpose which can be enabled by turning a single option on. Check out the
169
+ * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}
170
+ * configuration description to learn more.
171
+ *
172
+ * See also the {@glink features/link#custom-link-attributes-decorators link feature guide} for more information.
173
+ */
174
+ decorators?: Record<string, LinkDecoratorDefinition>;
175
+ }
176
+ /**
177
+ * A link decorator definition. Two types implement this definition:
178
+ *
179
+ * * {@link module:link/linkconfig~LinkDecoratorManualDefinition}
180
+ * * {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition}
181
+ *
182
+ * Refer to their document for more information about available options or to the
183
+ * {@glink features/link#custom-link-attributes-decorators link feature guide} for general information.
184
+ */
185
+ export type LinkDecoratorDefinition = LinkDecoratorAutomaticDefinition | LinkDecoratorManualDefinition;
186
+ /**
187
+ * Describes an automatic {@link module:link/linkconfig~LinkConfig#decorators link decorator}. This decorator type matches
188
+ * all links in the editor content against a function that decides whether the link should receive a pre–defined set of attributes.
189
+ *
190
+ * It takes an object with key-value pairs of attributes and a callback function that must return a Boolean value based on the link's
191
+ * `href` (URL). When the callback returns `true`, attributes are applied to the link.
192
+ *
193
+ * For example, to add the `target="_blank"` attribute to all links in the editor starting with `http://`, the
194
+ * configuration could look like this:
195
+ *
196
+ * ```ts
197
+ * {
198
+ * mode: 'automatic',
199
+ * callback: url => url.startsWith( 'http://' ),
200
+ * attributes: {
201
+ * target: '_blank'
202
+ * }
203
+ * }
204
+ * ```
205
+ *
206
+ * **Note**: Since the `target` attribute management for external links is a common use case, there is a predefined automatic decorator
207
+ * dedicated for that purpose that can be enabled by turning a single option on. Check out the
208
+ * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}
209
+ * configuration description to learn more.
210
+ */
211
+ export interface LinkDecoratorAutomaticDefinition {
212
+ /**
213
+ * Link decorator type. It is `'automatic'` for all automatic decorators.
214
+ */
215
+ mode: 'automatic';
216
+ /**
217
+ * Takes a `url` as a parameter and returns `true` if the `attributes` should be applied to the link.
218
+ */
219
+ callback: (url: string | null) => boolean;
220
+ /**
221
+ * Key-value pairs used as link attributes added to the output during the
222
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
223
+ * Attributes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
224
+ */
225
+ attributes?: Record<string, string>;
226
+ /**
227
+ * Key-value pairs used as link styles added to the output during the
228
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
229
+ * Styles should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
230
+ */
231
+ styles?: Record<string, string>;
232
+ /**
233
+ * Class names used as link classes added to the output during the
234
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
235
+ * Classes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
236
+ */
237
+ classes?: ArrayOrItem<string>;
238
+ }
239
+ /**
240
+ * Describes a manual {@link module:link/linkconfig~LinkConfig#decorators link decorator}. This decorator type is represented in
241
+ * the link feature's {@link module:link/linkui user interface} as a switch that the user can use to control the presence
242
+ * of a predefined set of attributes.
243
+ *
244
+ * For instance, to allow the users to manually control the presence of the `target="_blank"` and
245
+ * `rel="noopener noreferrer"` attributes on specific links, the decorator could look as follows:
246
+ *
247
+ * ```ts
248
+ * {
249
+ * mode: 'manual',
250
+ * label: 'Open in a new tab',
251
+ * defaultValue: true,
252
+ * attributes: {
253
+ * target: '_blank',
254
+ * rel: 'noopener noreferrer'
255
+ * }
256
+ * }
257
+ * ```
258
+ */
259
+ export interface LinkDecoratorManualDefinition {
260
+ /**
261
+ * Link decorator type. It is `'manual'` for all manual decorators.
262
+ */
263
+ mode: 'manual';
264
+ /**
265
+ * The label of the UI button that the user can use to control the presence of link attributes.
266
+ */
267
+ label: string;
268
+ /**
269
+ * Key-value pairs used as link attributes added to the output during the
270
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
271
+ * Attributes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
272
+ */
273
+ attributes?: Record<string, string>;
274
+ /**
275
+ * Key-value pairs used as link styles added to the output during the
276
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
277
+ * Styles should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
278
+ */
279
+ styles?: Record<string, string>;
280
+ /**
281
+ * Class names used as link classes added to the output during the
282
+ * {@glink framework/architecture/editing-engine#conversion downcasting}.
283
+ * Classes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
284
+ */
285
+ classes?: ArrayOrItem<string>;
286
+ /**
287
+ * Controls whether the decorator is "on" by default.
288
+ */
289
+ defaultValue?: boolean;
290
+ }
@@ -0,0 +1,70 @@
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
+ * @module link/linkediting
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9
+ import { Input, TwoStepCaretMovement } from 'ckeditor5/src/typing.js';
10
+ import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
11
+ import '../theme/link.css';
12
+ /**
13
+ * The link engine feature.
14
+ *
15
+ * It introduces the `linkHref="url"` attribute in the model which renders to the view as a `<a href="url">` element
16
+ * as well as `'link'` and `'unlink'` commands.
17
+ */
18
+ export default class LinkEditing extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "LinkEditing";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get requires(): readonly [typeof TwoStepCaretMovement, typeof Input, typeof ClipboardPipeline];
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ constructor(editor: Editor);
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ init(): void;
35
+ /**
36
+ * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}
37
+ * and registers a {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher downcast dispatcher}
38
+ * for each one of them. Downcast dispatchers are obtained using the
39
+ * {@link module:link/utils/automaticdecorators~AutomaticDecorators#getDispatcher} method.
40
+ *
41
+ * **Note**: This method also activates the automatic external link decorator if enabled with
42
+ * {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}.
43
+ */
44
+ private _enableAutomaticDecorators;
45
+ /**
46
+ * Processes an array of configured {@link module:link/linkconfig~LinkDecoratorManualDefinition manual decorators},
47
+ * transforms them into {@link module:link/utils/manualdecorator~ManualDecorator} instances and stores them in the
48
+ * {@link module:link/linkcommand~LinkCommand#manualDecorators} collection (a model for manual decorators state).
49
+ *
50
+ * Also registers an {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement attribute-to-element}
51
+ * converter for each manual decorator and extends the {@link module:engine/model/schema~Schema model's schema}
52
+ * with adequate model attributes.
53
+ */
54
+ private _enableManualDecorators;
55
+ /**
56
+ * Attaches handlers for {@link module:engine/view/document~Document#event:enter} and
57
+ * {@link module:engine/view/document~Document#event:click} to enable link following.
58
+ */
59
+ private _enableLinkOpen;
60
+ /**
61
+ * Watches the DocumentSelection attribute changes and removes link decorator attributes when the linkHref attribute is removed.
62
+ *
63
+ * This is to ensure that there is no left-over link decorator attributes on the document selection that is no longer in a link.
64
+ */
65
+ private _enableSelectionAttributesFixer;
66
+ /**
67
+ * Enables URL fixing on pasting.
68
+ */
69
+ private _enableClipboardIntegration;
70
+ }
@@ -0,0 +1,27 @@
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
+ * @module link/linkimage
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import LinkImageEditing from './linkimageediting.js';
10
+ import LinkImageUI from './linkimageui.js';
11
+ import '../theme/linkimage.css';
12
+ /**
13
+ * The `LinkImage` plugin.
14
+ *
15
+ * This is a "glue" plugin that loads the {@link module:link/linkimageediting~LinkImageEditing link image editing feature}
16
+ * and {@link module:link/linkimageui~LinkImageUI link image UI feature}.
17
+ */
18
+ export default class LinkImage extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): readonly [typeof LinkImageEditing, typeof LinkImageUI];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): "LinkImage";
27
+ }