@ckeditor/ckeditor5-link 41.3.0-alpha.3 → 41.3.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/build/link.js +1 -1
- package/package.json +3 -4
- package/src/index.d.ts +1 -1
- package/src/linkui.d.ts +4 -0
- package/src/linkui.js +29 -14
- package/dist/content-index.css +0 -4
- package/dist/editor-index.css +0 -43
- package/dist/index.css +0 -147
- package/dist/index.css.map +0 -1
- package/dist/translations/ar.d.ts +0 -8
- package/dist/translations/ar.js +0 -5
- package/dist/translations/ast.d.ts +0 -8
- package/dist/translations/ast.js +0 -5
- package/dist/translations/az.d.ts +0 -8
- package/dist/translations/az.js +0 -5
- package/dist/translations/bg.d.ts +0 -8
- package/dist/translations/bg.js +0 -5
- package/dist/translations/bn.d.ts +0 -8
- package/dist/translations/bn.js +0 -5
- package/dist/translations/ca.d.ts +0 -8
- package/dist/translations/ca.js +0 -5
- package/dist/translations/cs.d.ts +0 -8
- package/dist/translations/cs.js +0 -5
- package/dist/translations/da.d.ts +0 -8
- package/dist/translations/da.js +0 -5
- package/dist/translations/de-ch.d.ts +0 -8
- package/dist/translations/de-ch.js +0 -5
- package/dist/translations/de.d.ts +0 -8
- package/dist/translations/de.js +0 -5
- package/dist/translations/el.d.ts +0 -8
- package/dist/translations/el.js +0 -5
- package/dist/translations/en-au.d.ts +0 -8
- package/dist/translations/en-au.js +0 -5
- package/dist/translations/en-gb.d.ts +0 -8
- package/dist/translations/en-gb.js +0 -5
- package/dist/translations/en.d.ts +0 -8
- package/dist/translations/en.js +0 -5
- package/dist/translations/eo.d.ts +0 -8
- package/dist/translations/eo.js +0 -5
- package/dist/translations/es.d.ts +0 -8
- package/dist/translations/es.js +0 -5
- package/dist/translations/et.d.ts +0 -8
- package/dist/translations/et.js +0 -5
- package/dist/translations/eu.d.ts +0 -8
- package/dist/translations/eu.js +0 -5
- package/dist/translations/fa.d.ts +0 -8
- package/dist/translations/fa.js +0 -5
- package/dist/translations/fi.d.ts +0 -8
- package/dist/translations/fi.js +0 -5
- package/dist/translations/fr.d.ts +0 -8
- package/dist/translations/fr.js +0 -5
- package/dist/translations/gl.d.ts +0 -8
- package/dist/translations/gl.js +0 -5
- package/dist/translations/he.d.ts +0 -8
- package/dist/translations/he.js +0 -5
- package/dist/translations/hi.d.ts +0 -8
- package/dist/translations/hi.js +0 -5
- package/dist/translations/hr.d.ts +0 -8
- package/dist/translations/hr.js +0 -5
- package/dist/translations/hu.d.ts +0 -8
- package/dist/translations/hu.js +0 -5
- package/dist/translations/hy.d.ts +0 -8
- package/dist/translations/hy.js +0 -5
- package/dist/translations/id.d.ts +0 -8
- package/dist/translations/id.js +0 -5
- package/dist/translations/it.d.ts +0 -8
- package/dist/translations/it.js +0 -5
- package/dist/translations/ja.d.ts +0 -8
- package/dist/translations/ja.js +0 -5
- package/dist/translations/km.d.ts +0 -8
- package/dist/translations/km.js +0 -5
- package/dist/translations/kn.d.ts +0 -8
- package/dist/translations/kn.js +0 -5
- package/dist/translations/ko.d.ts +0 -8
- package/dist/translations/ko.js +0 -5
- package/dist/translations/ku.d.ts +0 -8
- package/dist/translations/ku.js +0 -5
- package/dist/translations/lt.d.ts +0 -8
- package/dist/translations/lt.js +0 -5
- package/dist/translations/lv.d.ts +0 -8
- package/dist/translations/lv.js +0 -5
- package/dist/translations/ms.d.ts +0 -8
- package/dist/translations/ms.js +0 -5
- package/dist/translations/nb.d.ts +0 -8
- package/dist/translations/nb.js +0 -5
- package/dist/translations/ne.d.ts +0 -8
- package/dist/translations/ne.js +0 -5
- package/dist/translations/nl.d.ts +0 -8
- package/dist/translations/nl.js +0 -5
- package/dist/translations/no.d.ts +0 -8
- package/dist/translations/no.js +0 -5
- package/dist/translations/pl.d.ts +0 -8
- package/dist/translations/pl.js +0 -5
- package/dist/translations/pt-br.d.ts +0 -8
- package/dist/translations/pt-br.js +0 -5
- package/dist/translations/pt.d.ts +0 -8
- package/dist/translations/pt.js +0 -5
- package/dist/translations/ro.d.ts +0 -8
- package/dist/translations/ro.js +0 -5
- package/dist/translations/ru.d.ts +0 -8
- package/dist/translations/ru.js +0 -5
- package/dist/translations/sk.d.ts +0 -8
- package/dist/translations/sk.js +0 -5
- package/dist/translations/sq.d.ts +0 -8
- package/dist/translations/sq.js +0 -5
- package/dist/translations/sr-latn.d.ts +0 -8
- package/dist/translations/sr-latn.js +0 -5
- package/dist/translations/sr.d.ts +0 -8
- package/dist/translations/sr.js +0 -5
- package/dist/translations/sv.d.ts +0 -8
- package/dist/translations/sv.js +0 -5
- package/dist/translations/th.d.ts +0 -8
- package/dist/translations/th.js +0 -5
- package/dist/translations/tk.d.ts +0 -8
- package/dist/translations/tk.js +0 -5
- package/dist/translations/tr.d.ts +0 -8
- package/dist/translations/tr.js +0 -5
- package/dist/translations/tt.d.ts +0 -8
- package/dist/translations/tt.js +0 -5
- package/dist/translations/ug.d.ts +0 -8
- package/dist/translations/ug.js +0 -5
- package/dist/translations/uk.d.ts +0 -8
- package/dist/translations/uk.js +0 -5
- package/dist/translations/ur.d.ts +0 -8
- package/dist/translations/ur.js +0 -5
- package/dist/translations/uz.d.ts +0 -8
- package/dist/translations/uz.js +0 -5
- package/dist/translations/vi.d.ts +0 -8
- package/dist/translations/vi.js +0 -5
- package/dist/translations/zh-cn.d.ts +0 -8
- package/dist/translations/zh-cn.js +0 -5
- package/dist/translations/zh.d.ts +0 -8
- package/dist/translations/zh.js +0 -5
- package/dist/types/augmentation.d.ts +0 -34
- package/dist/types/autolink.d.ts +0 -79
- package/dist/types/index.d.ts +0 -22
- package/dist/types/link.d.ts +0 -31
- package/dist/types/linkcommand.d.ts +0 -136
- package/dist/types/linkconfig.d.ts +0 -294
- package/dist/types/linkediting.d.ts +0 -74
- package/dist/types/linkimage.d.ts +0 -31
- package/dist/types/linkimageediting.d.ts +0 -43
- package/dist/types/linkimageui.d.ts +0 -44
- package/dist/types/linkui.d.ts +0 -169
- package/dist/types/ui/linkactionsview.d.ts +0 -107
- package/dist/types/ui/linkformview.d.ts +0 -145
- package/dist/types/unlinkcommand.d.ts +0 -35
- package/dist/types/utils/automaticdecorators.d.ts +0 -49
- package/dist/types/utils/manualdecorator.d.ts +0 -76
- package/dist/types/utils.d.ts +0 -84
package/dist/types/link.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module link/link
|
|
11
|
-
*/
|
|
12
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
13
|
-
import LinkEditing from './linkediting.js';
|
|
14
|
-
import LinkUI from './linkui.js';
|
|
15
|
-
import AutoLink from './autolink.js';
|
|
16
|
-
/**
|
|
17
|
-
* The link plugin.
|
|
18
|
-
*
|
|
19
|
-
* This is a "glue" plugin that loads the {@link module:link/linkediting~LinkEditing link editing feature}
|
|
20
|
-
* and {@link module:link/linkui~LinkUI link UI feature}.
|
|
21
|
-
*/
|
|
22
|
-
export default class Link extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get requires(): readonly [typeof LinkEditing, typeof LinkUI, typeof AutoLink];
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get pluginName(): "Link";
|
|
31
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module link/linkcommand
|
|
11
|
-
*/
|
|
12
|
-
import { Command } from 'ckeditor5/src/core.js';
|
|
13
|
-
import { Collection } from 'ckeditor5/src/utils.js';
|
|
14
|
-
import AutomaticDecorators from './utils/automaticdecorators.js';
|
|
15
|
-
import type ManualDecorator from './utils/manualdecorator.js';
|
|
16
|
-
/**
|
|
17
|
-
* The link command. It is used by the {@link module:link/link~Link link feature}.
|
|
18
|
-
*/
|
|
19
|
-
export default class LinkCommand extends Command {
|
|
20
|
-
/**
|
|
21
|
-
* The value of the `'linkHref'` attribute if the start of the selection is located in a node with this attribute.
|
|
22
|
-
*
|
|
23
|
-
* @observable
|
|
24
|
-
* @readonly
|
|
25
|
-
*/
|
|
26
|
-
value: string | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* A collection of {@link module:link/utils/manualdecorator~ManualDecorator manual decorators}
|
|
29
|
-
* corresponding to the {@link module:link/linkconfig~LinkConfig#decorators decorator configuration}.
|
|
30
|
-
*
|
|
31
|
-
* You can consider it a model with states of manual decorators added to the currently selected link.
|
|
32
|
-
*/
|
|
33
|
-
readonly manualDecorators: Collection<ManualDecorator>;
|
|
34
|
-
/**
|
|
35
|
-
* An instance of the helper that ties together all {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition}
|
|
36
|
-
* that are used by the {@glink features/link link} and the {@glink features/images/images-linking linking images} features.
|
|
37
|
-
*/
|
|
38
|
-
readonly automaticDecorators: AutomaticDecorators;
|
|
39
|
-
/**
|
|
40
|
-
* Synchronizes the state of {@link #manualDecorators} with the currently present elements in the model.
|
|
41
|
-
*/
|
|
42
|
-
restoreManualDecoratorStates(): void;
|
|
43
|
-
/**
|
|
44
|
-
* @inheritDoc
|
|
45
|
-
*/
|
|
46
|
-
refresh(): void;
|
|
47
|
-
/**
|
|
48
|
-
* Executes the command.
|
|
49
|
-
*
|
|
50
|
-
* When the selection is non-collapsed, the `linkHref` attribute will be applied to nodes inside the selection, but only to
|
|
51
|
-
* those nodes where the `linkHref` attribute is allowed (disallowed nodes will be omitted).
|
|
52
|
-
*
|
|
53
|
-
* When the selection is collapsed and is not inside the text with the `linkHref` attribute, a
|
|
54
|
-
* new {@link module:engine/model/text~Text text node} with the `linkHref` attribute will be inserted in place of the caret, but
|
|
55
|
-
* only if such element is allowed in this place. The `_data` of the inserted text will equal the `href` parameter.
|
|
56
|
-
* The selection will be updated to wrap the just inserted text node.
|
|
57
|
-
*
|
|
58
|
-
* When the selection is collapsed and inside the text with the `linkHref` attribute, the attribute value will be updated.
|
|
59
|
-
*
|
|
60
|
-
* # Decorators and model attribute management
|
|
61
|
-
*
|
|
62
|
-
* There is an optional argument to this command that applies or removes model
|
|
63
|
-
* {@glink framework/architecture/editing-engine#text-attributes text attributes} brought by
|
|
64
|
-
* {@link module:link/utils/manualdecorator~ManualDecorator manual link decorators}.
|
|
65
|
-
*
|
|
66
|
-
* Text attribute names in the model correspond to the entries in the {@link module:link/linkconfig~LinkConfig#decorators
|
|
67
|
-
* configuration}.
|
|
68
|
-
* For every decorator configured, a model text attribute exists with the "link" prefix. For example, a `'linkMyDecorator'` attribute
|
|
69
|
-
* corresponds to `'myDecorator'` in the configuration.
|
|
70
|
-
*
|
|
71
|
-
* To learn more about link decorators, check out the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`}
|
|
72
|
-
* documentation.
|
|
73
|
-
*
|
|
74
|
-
* Here is how to manage decorator attributes with the link command:
|
|
75
|
-
*
|
|
76
|
-
* ```ts
|
|
77
|
-
* const linkCommand = editor.commands.get( 'link' );
|
|
78
|
-
*
|
|
79
|
-
* // Adding a new decorator attribute.
|
|
80
|
-
* linkCommand.execute( 'http://example.com', {
|
|
81
|
-
* linkIsExternal: true
|
|
82
|
-
* } );
|
|
83
|
-
*
|
|
84
|
-
* // Removing a decorator attribute from the selection.
|
|
85
|
-
* linkCommand.execute( 'http://example.com', {
|
|
86
|
-
* linkIsExternal: false
|
|
87
|
-
* } );
|
|
88
|
-
*
|
|
89
|
-
* // Adding multiple decorator attributes at the same time.
|
|
90
|
-
* linkCommand.execute( 'http://example.com', {
|
|
91
|
-
* linkIsExternal: true,
|
|
92
|
-
* linkIsDownloadable: true,
|
|
93
|
-
* } );
|
|
94
|
-
*
|
|
95
|
-
* // Removing and adding decorator attributes at the same time.
|
|
96
|
-
* linkCommand.execute( 'http://example.com', {
|
|
97
|
-
* linkIsExternal: false,
|
|
98
|
-
* linkFoo: true,
|
|
99
|
-
* linkIsDownloadable: false,
|
|
100
|
-
* } );
|
|
101
|
-
* ```
|
|
102
|
-
*
|
|
103
|
-
* **Note**: If the decorator attribute name is not specified, its state remains untouched.
|
|
104
|
-
*
|
|
105
|
-
* **Note**: {@link module:link/unlinkcommand~UnlinkCommand#execute `UnlinkCommand#execute()`} removes all
|
|
106
|
-
* decorator attributes.
|
|
107
|
-
*
|
|
108
|
-
* @fires execute
|
|
109
|
-
* @param href Link destination.
|
|
110
|
-
* @param manualDecoratorIds The information about manual decorator attributes to be applied or removed upon execution.
|
|
111
|
-
*/
|
|
112
|
-
execute(href: string, manualDecoratorIds?: Record<string, boolean>): void;
|
|
113
|
-
/**
|
|
114
|
-
* Provides information whether a decorator with a given name is present in the currently processed selection.
|
|
115
|
-
*
|
|
116
|
-
* @param decoratorName The name of the manual decorator used in the model
|
|
117
|
-
* @returns The information whether a given decorator is currently present in the selection.
|
|
118
|
-
*/
|
|
119
|
-
private _getDecoratorStateFromModel;
|
|
120
|
-
/**
|
|
121
|
-
* Checks whether specified `range` is inside an element that accepts the `linkHref` attribute.
|
|
122
|
-
*
|
|
123
|
-
* @param range A range to check.
|
|
124
|
-
* @param allowedRanges An array of ranges created on elements where the attribute is accepted.
|
|
125
|
-
*/
|
|
126
|
-
private _isRangeToUpdate;
|
|
127
|
-
/**
|
|
128
|
-
* Updates selected link with a new value as its content and as its href attribute.
|
|
129
|
-
*
|
|
130
|
-
* @param model Model is need to insert content.
|
|
131
|
-
* @param writer Writer is need to create text element in model.
|
|
132
|
-
* @param range A range where should be inserted content.
|
|
133
|
-
* @param href A link value which should be in the href attribute and in the content.
|
|
134
|
-
*/
|
|
135
|
-
private _updateLinkContent;
|
|
136
|
-
}
|
|
@@ -1,294 +0,0 @@
|
|
|
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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module link/linkconfig
|
|
11
|
-
*/
|
|
12
|
-
import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
13
|
-
/**
|
|
14
|
-
* The configuration of the {@link module:link/link~Link link feature}.
|
|
15
|
-
*
|
|
16
|
-
* ```ts
|
|
17
|
-
* ClassicEditor
|
|
18
|
-
* .create( editorElement, {
|
|
19
|
-
* link: ... // Link feature configuration.
|
|
20
|
-
* } )
|
|
21
|
-
* .then( ... )
|
|
22
|
-
* .catch( ... );
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
26
|
-
*/
|
|
27
|
-
export interface LinkConfig {
|
|
28
|
-
/**
|
|
29
|
-
* When set, the editor will add the given protocol to the link when the user creates a link without one.
|
|
30
|
-
* For example, when the user is creating a link and types `ckeditor.com` in the link form input, during link submission
|
|
31
|
-
* the editor will automatically add the `http://` protocol, so the link will look as follows: `http://ckeditor.com`.
|
|
32
|
-
*
|
|
33
|
-
* The feature also provides email address auto-detection. When you submit `hello@example.com`,
|
|
34
|
-
* the plugin will automatically change it to `mailto:hello@example.com`.
|
|
35
|
-
*
|
|
36
|
-
* ```ts
|
|
37
|
-
* ClassicEditor
|
|
38
|
-
* .create( editorElement, {
|
|
39
|
-
* link: {
|
|
40
|
-
* defaultProtocol: 'http://'
|
|
41
|
-
* }
|
|
42
|
-
* } )
|
|
43
|
-
* .then( ... )
|
|
44
|
-
* .catch( ... );
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* **NOTE:** If no configuration is provided, the editor will not auto-fix the links.
|
|
48
|
-
*/
|
|
49
|
-
defaultProtocol?: string;
|
|
50
|
-
/**
|
|
51
|
-
* This is a protocols whitelist that can be used in links, defined as an array of strings.
|
|
52
|
-
* When not set, the editor will use a default list of allowed protocols.
|
|
53
|
-
*
|
|
54
|
-
* **Note:** Use this with caution and at your own risk - adding unsafe protocols like `javascript:`
|
|
55
|
-
* can result in serious security vulnerabilities!
|
|
56
|
-
*
|
|
57
|
-
* ```ts
|
|
58
|
-
* ClassicEditor
|
|
59
|
-
* .create( editorElement, {
|
|
60
|
-
* link: {
|
|
61
|
-
* allowedProtocols: [ 'http', 'https', 'ftp', 'tel', 'mailto', 'ssh' ]
|
|
62
|
-
* }
|
|
63
|
-
* } )
|
|
64
|
-
* .then( ... )
|
|
65
|
-
* .catch( ... );
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
*/
|
|
69
|
-
allowedProtocols?: Array<string>;
|
|
70
|
-
/**
|
|
71
|
-
* When set to `true`, the form will accept an empty value in the URL field, creating a link with an empty `href` (`<a href="">`).
|
|
72
|
-
*
|
|
73
|
-
* ```ts
|
|
74
|
-
* ClassicEditor
|
|
75
|
-
* .create( editorElement, {
|
|
76
|
-
* link: {
|
|
77
|
-
* allowCreatingEmptyLinks: true
|
|
78
|
-
* }
|
|
79
|
-
* } )
|
|
80
|
-
* .then( ... )
|
|
81
|
-
* .catch( ... );
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* **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.
|
|
85
|
-
*
|
|
86
|
-
* @default false
|
|
87
|
-
*/
|
|
88
|
-
allowCreatingEmptyLinks?: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* When set to `true`, the `target="blank"` and `rel="noopener noreferrer"` attributes are automatically added to all external links
|
|
91
|
-
* in the editor. "External links" are all links in the editor content starting with `http`, `https`, or `//`.
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* ClassicEditor
|
|
95
|
-
* .create( editorElement, {
|
|
96
|
-
* link: {
|
|
97
|
-
* addTargetToExternalLinks: true
|
|
98
|
-
* }
|
|
99
|
-
* } )
|
|
100
|
-
* .then( ... )
|
|
101
|
-
* .catch( ... );
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* Internally, this option activates a predefined {@link module:link/linkconfig~LinkConfig#decorators automatic link decorator}
|
|
105
|
-
* that extends all external links with the `target` and `rel` attributes.
|
|
106
|
-
*
|
|
107
|
-
* **Note**: To control the `target` and `rel` attributes of specific links in the edited content, a dedicated
|
|
108
|
-
* {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} decorator must be defined in the
|
|
109
|
-
* {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} array. In such scenario,
|
|
110
|
-
* the `config.link.addTargetToExternalLinks` option should remain `undefined` or `false` to not interfere with the manual decorator.
|
|
111
|
-
*
|
|
112
|
-
* It is possible to add other {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic}
|
|
113
|
-
* or {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} link decorators when this option is active.
|
|
114
|
-
*
|
|
115
|
-
* More information about decorators can be found in the {@link module:link/linkconfig~LinkConfig#decorators decorators configuration}
|
|
116
|
-
* reference.
|
|
117
|
-
*
|
|
118
|
-
* @default false
|
|
119
|
-
*/
|
|
120
|
-
addTargetToExternalLinks?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Decorators provide an easy way to configure and manage additional link attributes in the editor content. There are
|
|
123
|
-
* two types of link decorators:
|
|
124
|
-
*
|
|
125
|
-
* * {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition Automatic} – They match links against pre–defined rules and
|
|
126
|
-
* manage their attributes based on the results.
|
|
127
|
-
* * {@link module:link/linkconfig~LinkDecoratorManualDefinition Manual} – They allow users to control link attributes
|
|
128
|
-
* individually, using the editor UI.
|
|
129
|
-
*
|
|
130
|
-
* Link decorators are defined as objects with key-value pairs, where the key is the name provided for a given decorator and the
|
|
131
|
-
* value is the decorator definition.
|
|
132
|
-
*
|
|
133
|
-
* The name of the decorator also corresponds to the {@glink framework/architecture/editing-engine#text-attributes text
|
|
134
|
-
* attribute} in the model. For instance, the `isExternal` decorator below is represented as a `linkIsExternal` attribute in the model.
|
|
135
|
-
*
|
|
136
|
-
* ```ts
|
|
137
|
-
* ClassicEditor
|
|
138
|
-
* .create( editorElement, {
|
|
139
|
-
* link: {
|
|
140
|
-
* decorators: {
|
|
141
|
-
* isExternal: {
|
|
142
|
-
* mode: 'automatic',
|
|
143
|
-
* callback: url => url.startsWith( 'http://' ),
|
|
144
|
-
* attributes: {
|
|
145
|
-
* target: '_blank',
|
|
146
|
-
* rel: 'noopener noreferrer'
|
|
147
|
-
* }
|
|
148
|
-
* },
|
|
149
|
-
* isDownloadable: {
|
|
150
|
-
* mode: 'manual',
|
|
151
|
-
* label: 'Downloadable',
|
|
152
|
-
* attributes: {
|
|
153
|
-
* download: 'file.png',
|
|
154
|
-
* }
|
|
155
|
-
* },
|
|
156
|
-
* // ...
|
|
157
|
-
* }
|
|
158
|
-
* }
|
|
159
|
-
* } )
|
|
160
|
-
* .then( ... )
|
|
161
|
-
* .catch( ... );
|
|
162
|
-
* ```
|
|
163
|
-
*
|
|
164
|
-
* To learn more about the configuration syntax, check out the {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic}
|
|
165
|
-
* and {@link module:link/linkconfig~LinkDecoratorManualDefinition manual} decorator option reference.
|
|
166
|
-
*
|
|
167
|
-
* **Warning:** Currently, link decorators work independently of one another and no conflict resolution mechanism exists.
|
|
168
|
-
* For example, configuring the `target` attribute using both an automatic and a manual decorator at the same time could end up with
|
|
169
|
-
* quirky results. The same applies if multiple manual or automatic decorators were defined for the same attribute.
|
|
170
|
-
*
|
|
171
|
-
* **Note**: Since the `target` attribute management for external links is a common use case, there is a predefined automatic decorator
|
|
172
|
-
* dedicated for that purpose which can be enabled by turning a single option on. Check out the
|
|
173
|
-
* {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}
|
|
174
|
-
* configuration description to learn more.
|
|
175
|
-
*
|
|
176
|
-
* See also the {@glink features/link#custom-link-attributes-decorators link feature guide} for more information.
|
|
177
|
-
*/
|
|
178
|
-
decorators?: Record<string, LinkDecoratorDefinition>;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* A link decorator definition. Two types implement this definition:
|
|
182
|
-
*
|
|
183
|
-
* * {@link module:link/linkconfig~LinkDecoratorManualDefinition}
|
|
184
|
-
* * {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition}
|
|
185
|
-
*
|
|
186
|
-
* Refer to their document for more information about available options or to the
|
|
187
|
-
* {@glink features/link#custom-link-attributes-decorators link feature guide} for general information.
|
|
188
|
-
*/
|
|
189
|
-
export type LinkDecoratorDefinition = LinkDecoratorAutomaticDefinition | LinkDecoratorManualDefinition;
|
|
190
|
-
/**
|
|
191
|
-
* Describes an automatic {@link module:link/linkconfig~LinkConfig#decorators link decorator}. This decorator type matches
|
|
192
|
-
* all links in the editor content against a function that decides whether the link should receive a pre–defined set of attributes.
|
|
193
|
-
*
|
|
194
|
-
* 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
|
|
195
|
-
* `href` (URL). When the callback returns `true`, attributes are applied to the link.
|
|
196
|
-
*
|
|
197
|
-
* For example, to add the `target="_blank"` attribute to all links in the editor starting with `http://`, the
|
|
198
|
-
* configuration could look like this:
|
|
199
|
-
*
|
|
200
|
-
* ```ts
|
|
201
|
-
* {
|
|
202
|
-
* mode: 'automatic',
|
|
203
|
-
* callback: url => url.startsWith( 'http://' ),
|
|
204
|
-
* attributes: {
|
|
205
|
-
* target: '_blank'
|
|
206
|
-
* }
|
|
207
|
-
* }
|
|
208
|
-
* ```
|
|
209
|
-
*
|
|
210
|
-
* **Note**: Since the `target` attribute management for external links is a common use case, there is a predefined automatic decorator
|
|
211
|
-
* dedicated for that purpose that can be enabled by turning a single option on. Check out the
|
|
212
|
-
* {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}
|
|
213
|
-
* configuration description to learn more.
|
|
214
|
-
*/
|
|
215
|
-
export interface LinkDecoratorAutomaticDefinition {
|
|
216
|
-
/**
|
|
217
|
-
* Link decorator type. It is `'automatic'` for all automatic decorators.
|
|
218
|
-
*/
|
|
219
|
-
mode: 'automatic';
|
|
220
|
-
/**
|
|
221
|
-
* Takes a `url` as a parameter and returns `true` if the `attributes` should be applied to the link.
|
|
222
|
-
*/
|
|
223
|
-
callback: (url: string | null) => boolean;
|
|
224
|
-
/**
|
|
225
|
-
* Key-value pairs used as link attributes added to the output during the
|
|
226
|
-
* {@glink framework/architecture/editing-engine#conversion downcasting}.
|
|
227
|
-
* Attributes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
|
|
228
|
-
*/
|
|
229
|
-
attributes?: Record<string, string>;
|
|
230
|
-
/**
|
|
231
|
-
* Key-value pairs used as link styles added to the output during the
|
|
232
|
-
* {@glink framework/architecture/editing-engine#conversion downcasting}.
|
|
233
|
-
* Styles should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
|
|
234
|
-
*/
|
|
235
|
-
styles?: Record<string, string>;
|
|
236
|
-
/**
|
|
237
|
-
* Class names used as link classes added to the output during the
|
|
238
|
-
* {@glink framework/architecture/editing-engine#conversion downcasting}.
|
|
239
|
-
* Classes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
|
|
240
|
-
*/
|
|
241
|
-
classes?: ArrayOrItem<string>;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Describes a manual {@link module:link/linkconfig~LinkConfig#decorators link decorator}. This decorator type is represented in
|
|
245
|
-
* the link feature's {@link module:link/linkui user interface} as a switch that the user can use to control the presence
|
|
246
|
-
* of a predefined set of attributes.
|
|
247
|
-
*
|
|
248
|
-
* For instance, to allow the users to manually control the presence of the `target="_blank"` and
|
|
249
|
-
* `rel="noopener noreferrer"` attributes on specific links, the decorator could look as follows:
|
|
250
|
-
*
|
|
251
|
-
* ```ts
|
|
252
|
-
* {
|
|
253
|
-
* mode: 'manual',
|
|
254
|
-
* label: 'Open in a new tab',
|
|
255
|
-
* defaultValue: true,
|
|
256
|
-
* attributes: {
|
|
257
|
-
* target: '_blank',
|
|
258
|
-
* rel: 'noopener noreferrer'
|
|
259
|
-
* }
|
|
260
|
-
* }
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
export interface LinkDecoratorManualDefinition {
|
|
264
|
-
/**
|
|
265
|
-
* Link decorator type. It is `'manual'` for all manual decorators.
|
|
266
|
-
*/
|
|
267
|
-
mode: 'manual';
|
|
268
|
-
/**
|
|
269
|
-
* The label of the UI button that the user can use to control the presence of link attributes.
|
|
270
|
-
*/
|
|
271
|
-
label: string;
|
|
272
|
-
/**
|
|
273
|
-
* Key-value pairs used as link attributes added to the output during the
|
|
274
|
-
* {@glink framework/architecture/editing-engine#conversion downcasting}.
|
|
275
|
-
* Attributes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
|
|
276
|
-
*/
|
|
277
|
-
attributes?: Record<string, string>;
|
|
278
|
-
/**
|
|
279
|
-
* Key-value pairs used as link styles added to the output during the
|
|
280
|
-
* {@glink framework/architecture/editing-engine#conversion downcasting}.
|
|
281
|
-
* Styles should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
|
|
282
|
-
*/
|
|
283
|
-
styles?: Record<string, string>;
|
|
284
|
-
/**
|
|
285
|
-
* Class names used as link classes added to the output during the
|
|
286
|
-
* {@glink framework/architecture/editing-engine#conversion downcasting}.
|
|
287
|
-
* Classes should follow the {@link module:engine/view/elementdefinition~ElementDefinition} syntax.
|
|
288
|
-
*/
|
|
289
|
-
classes?: ArrayOrItem<string>;
|
|
290
|
-
/**
|
|
291
|
-
* Controls whether the decorator is "on" by default.
|
|
292
|
-
*/
|
|
293
|
-
defaultValue?: boolean;
|
|
294
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module link/linkediting
|
|
11
|
-
*/
|
|
12
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
13
|
-
import { Input, TwoStepCaretMovement } from 'ckeditor5/src/typing.js';
|
|
14
|
-
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
15
|
-
import '../theme/link.css';
|
|
16
|
-
/**
|
|
17
|
-
* The link engine feature.
|
|
18
|
-
*
|
|
19
|
-
* It introduces the `linkHref="url"` attribute in the model which renders to the view as a `<a href="url">` element
|
|
20
|
-
* as well as `'link'` and `'unlink'` commands.
|
|
21
|
-
*/
|
|
22
|
-
export default class LinkEditing extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName(): "LinkEditing";
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get requires(): readonly [typeof TwoStepCaretMovement, typeof Input, typeof ClipboardPipeline];
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
constructor(editor: Editor);
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
init(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Processes an array of configured {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators}
|
|
41
|
-
* and registers a {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher downcast dispatcher}
|
|
42
|
-
* for each one of them. Downcast dispatchers are obtained using the
|
|
43
|
-
* {@link module:link/utils/automaticdecorators~AutomaticDecorators#getDispatcher} method.
|
|
44
|
-
*
|
|
45
|
-
* **Note**: This method also activates the automatic external link decorator if enabled with
|
|
46
|
-
* {@link module:link/linkconfig~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`}.
|
|
47
|
-
*/
|
|
48
|
-
private _enableAutomaticDecorators;
|
|
49
|
-
/**
|
|
50
|
-
* Processes an array of configured {@link module:link/linkconfig~LinkDecoratorManualDefinition manual decorators},
|
|
51
|
-
* transforms them into {@link module:link/utils/manualdecorator~ManualDecorator} instances and stores them in the
|
|
52
|
-
* {@link module:link/linkcommand~LinkCommand#manualDecorators} collection (a model for manual decorators state).
|
|
53
|
-
*
|
|
54
|
-
* Also registers an {@link module:engine/conversion/downcasthelpers~DowncastHelpers#attributeToElement attribute-to-element}
|
|
55
|
-
* converter for each manual decorator and extends the {@link module:engine/model/schema~Schema model's schema}
|
|
56
|
-
* with adequate model attributes.
|
|
57
|
-
*/
|
|
58
|
-
private _enableManualDecorators;
|
|
59
|
-
/**
|
|
60
|
-
* Attaches handlers for {@link module:engine/view/document~Document#event:enter} and
|
|
61
|
-
* {@link module:engine/view/document~Document#event:click} to enable link following.
|
|
62
|
-
*/
|
|
63
|
-
private _enableLinkOpen;
|
|
64
|
-
/**
|
|
65
|
-
* Watches the DocumentSelection attribute changes and removes link decorator attributes when the linkHref attribute is removed.
|
|
66
|
-
*
|
|
67
|
-
* This is to ensure that there is no left-over link decorator attributes on the document selection that is no longer in a link.
|
|
68
|
-
*/
|
|
69
|
-
private _enableSelectionAttributesFixer;
|
|
70
|
-
/**
|
|
71
|
-
* Enables URL fixing on pasting.
|
|
72
|
-
*/
|
|
73
|
-
private _enableClipboardIntegration;
|
|
74
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module link/linkimage
|
|
11
|
-
*/
|
|
12
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
13
|
-
import LinkImageEditing from './linkimageediting.js';
|
|
14
|
-
import LinkImageUI from './linkimageui.js';
|
|
15
|
-
import '../theme/linkimage.css';
|
|
16
|
-
/**
|
|
17
|
-
* The `LinkImage` plugin.
|
|
18
|
-
*
|
|
19
|
-
* This is a "glue" plugin that loads the {@link module:link/linkimageediting~LinkImageEditing link image editing feature}
|
|
20
|
-
* and {@link module:link/linkimageui~LinkImageUI link image UI feature}.
|
|
21
|
-
*/
|
|
22
|
-
export default class LinkImage extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get requires(): readonly [typeof LinkImageEditing, typeof LinkImageUI];
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get pluginName(): "LinkImage";
|
|
31
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module link/linkimageediting
|
|
11
|
-
*/
|
|
12
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
13
|
-
import LinkEditing from './linkediting.js';
|
|
14
|
-
/**
|
|
15
|
-
* The link image engine feature.
|
|
16
|
-
*
|
|
17
|
-
* It accepts the `linkHref="url"` attribute in the model for the {@link module:image/image~Image `<imageBlock>`} element
|
|
18
|
-
* which allows linking images.
|
|
19
|
-
*/
|
|
20
|
-
export default class LinkImageEditing extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires(): readonly ["ImageEditing", "ImageUtils", typeof LinkEditing];
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
static get pluginName(): "LinkImageEditing";
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
afterInit(): void;
|
|
33
|
-
/**
|
|
34
|
-
* Processes {@link module:link/linkconfig~LinkDecoratorAutomaticDefinition automatic decorators} definitions and
|
|
35
|
-
* attaches proper converters that will work when linking an image.`
|
|
36
|
-
*/
|
|
37
|
-
private _enableAutomaticDecorators;
|
|
38
|
-
/**
|
|
39
|
-
* Processes transformed {@link module:link/utils/manualdecorator~ManualDecorator} instances and attaches proper converters
|
|
40
|
-
* that will work when linking an image.
|
|
41
|
-
*/
|
|
42
|
-
private _enableManualDecorators;
|
|
43
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
-
import LinkUI from './linkui.js';
|
|
11
|
-
import LinkEditing from './linkediting.js';
|
|
12
|
-
/**
|
|
13
|
-
* The link image UI plugin.
|
|
14
|
-
*
|
|
15
|
-
* This plugin provides the `'linkImage'` button that can be displayed in the {@link module:image/imagetoolbar~ImageToolbar}.
|
|
16
|
-
* It can be used to wrap images in links.
|
|
17
|
-
*/
|
|
18
|
-
export default class LinkImageUI extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get requires(): readonly [typeof LinkEditing, typeof LinkUI, "ImageBlockEditing"];
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get pluginName(): "LinkImageUI";
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
init(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a `LinkImageUI` button view.
|
|
33
|
-
*
|
|
34
|
-
* Clicking this button shows a {@link module:link/linkui~LinkUI#_balloon} attached to the selection.
|
|
35
|
-
* When an image is already linked, the view shows {@link module:link/linkui~LinkUI#actionsView} or
|
|
36
|
-
* {@link module:link/linkui~LinkUI#formView} if it is not.
|
|
37
|
-
*/
|
|
38
|
-
private _createToolbarLinkImageButton;
|
|
39
|
-
/**
|
|
40
|
-
* Returns true if a linked image (either block or inline) is the only selected element
|
|
41
|
-
* in the model document.
|
|
42
|
-
*/
|
|
43
|
-
private _isSelectedLinkedImage;
|
|
44
|
-
}
|