@ckeditor/ckeditor5-link 39.0.2 → 40.0.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.map +1 -0
- package/build/translations/hy.js +1 -0
- package/build/translations/pt-br.js +1 -1
- package/lang/translations/hy.po +54 -0
- package/lang/translations/pt-br.po +2 -2
- package/package.json +3 -3
- package/src/augmentation.d.ts +30 -30
- package/src/augmentation.js +5 -5
- package/src/autolink.d.ts +60 -60
- package/src/autolink.js +216 -216
- package/src/index.d.ts +18 -18
- package/src/index.js +17 -17
- package/src/link.d.ts +27 -27
- package/src/link.js +31 -31
- package/src/linkcommand.d.ts +132 -132
- package/src/linkcommand.js +285 -285
- package/src/linkconfig.d.ts +251 -251
- package/src/linkconfig.js +5 -5
- package/src/linkediting.d.ts +106 -106
- package/src/linkediting.js +547 -547
- package/src/linkimage.d.ts +27 -27
- package/src/linkimage.js +31 -31
- package/src/linkimageediting.d.ts +39 -39
- package/src/linkimageediting.js +245 -245
- package/src/linkimageui.d.ts +40 -40
- package/src/linkimageui.js +96 -96
- package/src/linkui.d.ts +165 -165
- package/src/linkui.js +581 -581
- package/src/ui/linkactionsview.d.ts +101 -101
- package/src/ui/linkactionsview.js +156 -156
- package/src/ui/linkformview.d.ts +141 -141
- package/src/ui/linkformview.js +232 -232
- package/src/unlinkcommand.d.ts +31 -31
- package/src/unlinkcommand.js +66 -66
- package/src/utils/automaticdecorators.d.ts +45 -45
- package/src/utils/automaticdecorators.js +140 -140
- package/src/utils/manualdecorator.d.ts +72 -72
- package/src/utils/manualdecorator.js +47 -47
- package/src/utils.d.ts +80 -80
- package/src/utils.js +128 -128
package/src/linkcommand.d.ts
CHANGED
|
@@ -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
|
+
}
|