@ckeditor/ckeditor5-basic-styles 40.0.0 → 40.2.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +25 -25
  2. package/LICENSE.md +2 -2
  3. package/package.json +2 -2
  4. package/src/attributecommand.d.ts +74 -74
  5. package/src/attributecommand.js +105 -105
  6. package/src/augmentation.d.ts +40 -40
  7. package/src/augmentation.js +5 -5
  8. package/src/bold/boldediting.d.ts +24 -24
  9. package/src/bold/boldediting.js +62 -62
  10. package/src/bold/boldui.d.ts +21 -21
  11. package/src/bold/boldui.js +47 -47
  12. package/src/bold.d.ts +29 -29
  13. package/src/bold.js +33 -33
  14. package/src/code/codeediting.d.ts +29 -29
  15. package/src/code/codeediting.js +59 -59
  16. package/src/code/codeui.d.ts +22 -22
  17. package/src/code/codeui.js +48 -48
  18. package/src/code.d.ts +30 -30
  19. package/src/code.js +34 -34
  20. package/src/index.d.ts +30 -30
  21. package/src/index.js +29 -29
  22. package/src/italic/italicediting.d.ts +24 -24
  23. package/src/italic/italicediting.js +52 -52
  24. package/src/italic/italicui.d.ts +21 -21
  25. package/src/italic/italicui.js +48 -48
  26. package/src/italic.d.ts +29 -29
  27. package/src/italic.js +33 -33
  28. package/src/strikethrough/strikethroughediting.d.ts +25 -25
  29. package/src/strikethrough/strikethroughediting.js +54 -54
  30. package/src/strikethrough/strikethroughui.d.ts +21 -21
  31. package/src/strikethrough/strikethroughui.js +48 -48
  32. package/src/strikethrough.d.ts +29 -29
  33. package/src/strikethrough.js +33 -33
  34. package/src/subscript/subscriptediting.d.ts +24 -24
  35. package/src/subscript/subscriptediting.js +50 -50
  36. package/src/subscript/subscriptui.d.ts +21 -21
  37. package/src/subscript/subscriptui.js +47 -47
  38. package/src/subscript.d.ts +26 -26
  39. package/src/subscript.js +30 -30
  40. package/src/superscript/superscriptediting.d.ts +24 -24
  41. package/src/superscript/superscriptediting.js +50 -50
  42. package/src/superscript/superscriptui.d.ts +21 -21
  43. package/src/superscript/superscriptui.js +47 -47
  44. package/src/superscript.d.ts +26 -26
  45. package/src/superscript.js +30 -30
  46. package/src/underline/underlineediting.d.ts +24 -24
  47. package/src/underline/underlineediting.js +49 -49
  48. package/src/underline/underlineui.d.ts +21 -21
  49. package/src/underline/underlineui.js +48 -48
  50. package/src/underline.d.ts +29 -29
  51. package/src/underline.js +33 -33
  52. package/build/basic-styles.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,17 +5,17 @@ All changes in the package are documented in the main repository. See: https://g
5
5
 
6
6
  Changes for the past releases are available below.
7
7
 
8
- ## [19.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v18.0.0...v19.0.0) (2020-04-29)
8
+ ## [19.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v18.0.0...v19.0.0) (April 29, 2020)
9
9
 
10
10
  Internal changes only (updated dependencies, documentation, etc.).
11
11
 
12
12
 
13
- ## [18.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v17.0.0...v18.0.0) (2020-03-19)
13
+ ## [18.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v17.0.0...v18.0.0) (March 19, 2020)
14
14
 
15
15
  Internal changes only (updated dependencies, documentation, etc.).
16
16
 
17
17
 
18
- ## [17.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v16.0.0...v17.0.0) (2020-02-18)
18
+ ## [17.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v16.0.0...v17.0.0) (February 18, 2020)
19
19
 
20
20
  ### Bug fixes
21
21
 
@@ -26,14 +26,14 @@ Internal changes only (updated dependencies, documentation, etc.).
26
26
  * Updated translations. ([4def017](https://github.com/ckeditor/ckeditor5-basic-styles/commit/4def017))
27
27
 
28
28
 
29
- ## [16.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v15.0.0...v16.0.0) (2019-12-04)
29
+ ## [16.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v15.0.0...v16.0.0) (December 4, 2019)
30
30
 
31
31
  ### Other changes
32
32
 
33
33
  * Updated translations. ([9dfd52c](https://github.com/ckeditor/ckeditor5-basic-styles/commit/9dfd52c))
34
34
 
35
35
 
36
- ## [15.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.4...v15.0.0) (2019-10-23)
36
+ ## [15.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.4...v15.0.0) (October 23, 2019)
37
37
 
38
38
  ### Features
39
39
 
@@ -45,7 +45,7 @@ Internal changes only (updated dependencies, documentation, etc.).
45
45
  * Updated translations. ([56d6060](https://github.com/ckeditor/ckeditor5-basic-styles/commit/56d6060))
46
46
 
47
47
 
48
- ## [11.1.4](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.3...v11.1.4) (2019-08-26)
48
+ ## [11.1.4](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.3...v11.1.4) (August 26, 2019)
49
49
 
50
50
  ### Bug fixes
51
51
 
@@ -58,26 +58,26 @@ Internal changes only (updated dependencies, documentation, etc.).
58
58
  * Updated translations. ([52de3fe](https://github.com/ckeditor/ckeditor5-basic-styles/commit/52de3fe))
59
59
 
60
60
 
61
- ## [11.1.3](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.2...v11.1.3) (2019-07-10)
61
+ ## [11.1.3](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.2...v11.1.3) (July 10, 2019)
62
62
 
63
63
  Internal changes only (updated dependencies, documentation, etc.).
64
64
 
65
65
 
66
- ## [11.1.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.1...v11.1.2) (2019-07-04)
66
+ ## [11.1.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.1...v11.1.2) (July 4, 2019)
67
67
 
68
68
  ### Other changes
69
69
 
70
70
  * Updated translations. ([8914cfc](https://github.com/ckeditor/ckeditor5-basic-styles/commit/8914cfc)) ([fb07a45](https://github.com/ckeditor/ckeditor5-basic-styles/commit/fb07a45))
71
71
 
72
72
 
73
- ## [11.1.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.0...v11.1.1) (2019-06-05)
73
+ ## [11.1.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.1.0...v11.1.1) (June 6, 2019)
74
74
 
75
75
  ### Other changes
76
76
 
77
77
  * Updated translations. ([c9cdc44](https://github.com/ckeditor/ckeditor5-basic-styles/commit/c9cdc44))
78
78
 
79
79
 
80
- ## [11.1.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.0.0...v11.1.0) (2019-04-10)
80
+ ## [11.1.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v11.0.0...v11.1.0) (April 4, 2019)
81
81
 
82
82
  ### Features
83
83
 
@@ -89,7 +89,7 @@ Internal changes only (updated dependencies, documentation, etc.).
89
89
  * Updated translations. ([4365251](https://github.com/ckeditor/ckeditor5-basic-styles/commit/4365251))
90
90
 
91
91
 
92
- ## [11.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.1.0...v11.0.0) (2019-02-28)
92
+ ## [11.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.1.0...v11.0.0) (February 28, 2019)
93
93
 
94
94
  ### Other changes
95
95
 
@@ -100,7 +100,7 @@ Internal changes only (updated dependencies, documentation, etc.).
100
100
  * Upgraded minimal versions of Node to `8.0.0` and npm to `5.7.1`. See: [ckeditor/ckeditor5#1507](https://github.com/ckeditor/ckeditor5/issues/1507). ([612ea3c](https://github.com/ckeditor/ckeditor5-cloud-services/commit/612ea3c))
101
101
 
102
102
 
103
- ## [10.1.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.3...v10.1.0) (2018-12-05)
103
+ ## [10.1.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.3...v10.1.0) (December 5, 2018)
104
104
 
105
105
  ### Features
106
106
 
@@ -114,14 +114,14 @@ Internal changes only (updated dependencies, documentation, etc.).
114
114
  * Updated translations. ([f9d3d07](https://github.com/ckeditor/ckeditor5-basic-styles/commit/f9d3d07)) ([67fb2e2](https://github.com/ckeditor/ckeditor5-basic-styles/commit/67fb2e2))
115
115
 
116
116
 
117
- ## [10.0.3](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.2...v10.0.3) (2018-10-08)
117
+ ## [10.0.3](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.2...v10.0.3) (October 8, 2018)
118
118
 
119
119
  ### Other changes
120
120
 
121
121
  * Updated translations. ([cf4e657](https://github.com/ckeditor/ckeditor5-basic-styles/commit/cf4e657))
122
122
 
123
123
 
124
- ## [10.0.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.1...v10.0.2) (2018-07-18)
124
+ ## [10.0.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.1...v10.0.2) (July 18, 2018)
125
125
 
126
126
  ### Bug fixes
127
127
 
@@ -132,14 +132,14 @@ Internal changes only (updated dependencies, documentation, etc.).
132
132
  * Updated translations. ([df8bcc4](https://github.com/ckeditor/ckeditor5-basic-styles/commit/df8bcc4))
133
133
 
134
134
 
135
- ## [10.0.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.0...v10.0.1) (2018-06-21)
135
+ ## [10.0.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v10.0.0...v10.0.1) (June 21, 2018)
136
136
 
137
137
  ### Other changes
138
138
 
139
139
  * Updated translations.
140
140
 
141
141
 
142
- ## [10.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-beta.4...v10.0.0) (2018-04-25)
142
+ ## [10.0.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-beta.4...v10.0.0) (April 25, 2018)
143
143
 
144
144
  ### Other changes
145
145
 
@@ -151,7 +151,7 @@ Internal changes only (updated dependencies, documentation, etc.).
151
151
  * The license under which CKEditor 5 is released has been changed from a triple GPL, LGPL and MPL license to a GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991) for more information.
152
152
 
153
153
 
154
- ## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018-04-19)
154
+ ## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-beta.2...v1.0.0-beta.4) (April 19, 2018)
155
155
 
156
156
  ### Other changes
157
157
 
@@ -159,12 +159,12 @@ Internal changes only (updated dependencies, documentation, etc.).
159
159
  * Updated translations. ([b4c8419](https://github.com/ckeditor/ckeditor5-basic-styles/commit/b4c8419))
160
160
 
161
161
 
162
- ## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018-04-10)
162
+ ## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-beta.1...v1.0.0-beta.2) (April 10, 2018)
163
163
 
164
164
  Internal changes only (updated dependencies, documentation, etc.).
165
165
 
166
166
 
167
- ## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (2018-03-15)
167
+ ## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (March 15, 2018)
168
168
 
169
169
  ### Features
170
170
 
@@ -180,21 +180,21 @@ Internal changes only (updated dependencies, documentation, etc.).
180
180
  * Updated translations. ([1ff4312](https://github.com/ckeditor/ckeditor5-basic-styles/commit/1ff4312))
181
181
 
182
182
 
183
- ## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017-11-14)
183
+ ## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (November 14, 2017)
184
184
 
185
185
  ### Other changes
186
186
 
187
187
  * Updated translations. ([398054d](https://github.com/ckeditor/ckeditor5-basic-styles/commit/398054d))
188
188
 
189
189
 
190
- ## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.9.0...v1.0.0-alpha.1) (2017-10-03)
190
+ ## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.9.0...v1.0.0-alpha.1) (October 3, 2017)
191
191
 
192
192
  ### Features
193
193
 
194
194
  * Introduced the `Code` plugin. Closes [#52](https://github.com/ckeditor/ckeditor5-basic-styles/issues/52). ([d720cb9](https://github.com/ckeditor/ckeditor5-basic-styles/commit/d720cb9))
195
195
 
196
196
 
197
- ## [0.9.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.8.1...v0.9.0) (2017-09-03)
197
+ ## [0.9.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.8.1...v0.9.0) (September 3, 2017)
198
198
 
199
199
  ### Bug fixes
200
200
 
@@ -218,7 +218,7 @@ Internal changes only (updated dependencies, documentation, etc.).
218
218
  * The command API has been changed.
219
219
 
220
220
 
221
- ## [0.8.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.8.0...v0.8.1) (2017-05-07)
221
+ ## [0.8.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.8.0...v0.8.1) (May 7, 2017)
222
222
 
223
223
  ### Bug fixes
224
224
 
@@ -229,7 +229,7 @@ Internal changes only (updated dependencies, documentation, etc.).
229
229
  * Updated translations. ([5250bec](https://github.com/ckeditor/ckeditor5-basic-styles/commit/5250bec))
230
230
 
231
231
 
232
- ## [0.8.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.7.1...v0.8.0) (2017-04-05)
232
+ ## [0.8.0](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.7.1...v0.8.0) (April 5, 2017)
233
233
 
234
234
  ### Features
235
235
 
@@ -240,7 +240,7 @@ Internal changes only (updated dependencies, documentation, etc.).
240
240
  * Updated translations. ([2aa33fd](https://github.com/ckeditor/ckeditor5-basic-styles/commit/2aa33fd))
241
241
 
242
242
 
243
- ## [0.7.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.7.0...v0.7.1) (2017-03-06)
243
+ ## [0.7.1](https://github.com/ckeditor/ckeditor5-basic-styles/compare/v0.7.0...v0.7.1) (March 6, 2017)
244
244
 
245
245
  ### Other changes
246
246
 
package/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor&nbsp;5 basic styles feature** – https://github.com/ckeditor/ckeditor5-basic-styles <br>
5
- Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 20032023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
14
14
  Trademarks
15
15
  ----------
16
16
 
17
- **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
17
+ **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-basic-styles",
3
- "version": "40.0.0",
3
+ "version": "40.2.0",
4
4
  "description": "Basic styles feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "40.0.0"
15
+ "ckeditor5": "40.2.0"
16
16
  },
17
17
  "author": "CKSource (http://cksource.com/)",
18
18
  "license": "GPL-2.0-or-later",
@@ -1,74 +1,74 @@
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 basic-styles/attributecommand
7
- */
8
- import { Command, type Editor } from 'ckeditor5/src/core';
9
- /**
10
- * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
- * that toggles a single attribute on a text or an element.
12
- *
13
- * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
- * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
- *
16
- * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
- * for the current selection and to which nodes the attribute can be applied.
18
- */
19
- export default class AttributeCommand extends Command {
20
- /**
21
- * Flag indicating whether the command is active. The command is active when the
22
- * {@link module:engine/model/selection~Selection#hasAttribute selection has the attribute} which means that:
23
- *
24
- * * If the selection is not empty &ndash; That the attribute is set on the first node in the selection that allows this attribute.
25
- * * If the selection is empty &ndash; That the selection has the attribute itself (which means that newly typed
26
- * text will have this attribute, too).
27
- *
28
- * @observable
29
- * @readonly
30
- */
31
- value: boolean;
32
- /**
33
- * The attribute that will be set by the command.
34
- */
35
- readonly attributeKey: string;
36
- /**
37
- * @param attributeKey Attribute that will be set by the command.
38
- */
39
- constructor(editor: Editor, attributeKey: string);
40
- /**
41
- * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
42
- */
43
- refresh(): void;
44
- /**
45
- * Executes the command &mdash; applies the attribute to the selection or removes it from the selection.
46
- *
47
- * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
48
- *
49
- * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
50
- *
51
- * * If the selection is on a range, the command applies the attribute to all nodes in that range
52
- * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
53
- * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
54
- * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
55
- * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
56
- * that the selection inherits all attributes from a node if it is in an empty node).
57
- *
58
- * @fires execute
59
- * @param options Command options.
60
- * @param options.forceValue If set, it will force the command behavior. If `true`,
61
- * the command will apply the attribute, otherwise the command will remove the attribute.
62
- * If not set, the command will look for its current value to decide what it should do.
63
- */
64
- execute(options?: {
65
- forceValue?: boolean;
66
- }): void;
67
- /**
68
- * Checks the attribute value of the first node in the selection that allows the attribute.
69
- * For the collapsed selection returns the selection attribute.
70
- *
71
- * @returns The attribute value.
72
- */
73
- private _getValueFromFirstAllowedNode;
74
- }
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 basic-styles/attributecommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core';
9
+ /**
10
+ * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
+ * that toggles a single attribute on a text or an element.
12
+ *
13
+ * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
+ * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
+ *
16
+ * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
+ * for the current selection and to which nodes the attribute can be applied.
18
+ */
19
+ export default class AttributeCommand extends Command {
20
+ /**
21
+ * Flag indicating whether the command is active. The command is active when the
22
+ * {@link module:engine/model/selection~Selection#hasAttribute selection has the attribute} which means that:
23
+ *
24
+ * * If the selection is not empty &ndash; That the attribute is set on the first node in the selection that allows this attribute.
25
+ * * If the selection is empty &ndash; That the selection has the attribute itself (which means that newly typed
26
+ * text will have this attribute, too).
27
+ *
28
+ * @observable
29
+ * @readonly
30
+ */
31
+ value: boolean;
32
+ /**
33
+ * The attribute that will be set by the command.
34
+ */
35
+ readonly attributeKey: string;
36
+ /**
37
+ * @param attributeKey Attribute that will be set by the command.
38
+ */
39
+ constructor(editor: Editor, attributeKey: string);
40
+ /**
41
+ * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
42
+ */
43
+ refresh(): void;
44
+ /**
45
+ * Executes the command &ndash; applies the attribute to the selection or removes it from the selection.
46
+ *
47
+ * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
48
+ *
49
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
50
+ *
51
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
52
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
53
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
54
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
55
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
56
+ * that the selection inherits all attributes from a node if it is in an empty node).
57
+ *
58
+ * @fires execute
59
+ * @param options Command options.
60
+ * @param options.forceValue If set, it will force the command behavior. If `true`,
61
+ * the command will apply the attribute, otherwise the command will remove the attribute.
62
+ * If not set, the command will look for its current value to decide what it should do.
63
+ */
64
+ execute(options?: {
65
+ forceValue?: boolean;
66
+ }): void;
67
+ /**
68
+ * Checks the attribute value of the first node in the selection that allows the attribute.
69
+ * For the collapsed selection returns the selection attribute.
70
+ *
71
+ * @returns The attribute value.
72
+ */
73
+ private _getValueFromFirstAllowedNode;
74
+ }
@@ -1,105 +1,105 @@
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 basic-styles/attributecommand
7
- */
8
- import { Command } from 'ckeditor5/src/core';
9
- /**
10
- * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
- * that toggles a single attribute on a text or an element.
12
- *
13
- * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
- * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
- *
16
- * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
- * for the current selection and to which nodes the attribute can be applied.
18
- */
19
- export default class AttributeCommand extends Command {
20
- /**
21
- * @param attributeKey Attribute that will be set by the command.
22
- */
23
- constructor(editor, attributeKey) {
24
- super(editor);
25
- this.attributeKey = attributeKey;
26
- }
27
- /**
28
- * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
29
- */
30
- refresh() {
31
- const model = this.editor.model;
32
- const doc = model.document;
33
- this.value = this._getValueFromFirstAllowedNode();
34
- this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
35
- }
36
- /**
37
- * Executes the command &mdash; applies the attribute to the selection or removes it from the selection.
38
- *
39
- * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
40
- *
41
- * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
42
- *
43
- * * If the selection is on a range, the command applies the attribute to all nodes in that range
44
- * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
45
- * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
46
- * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
47
- * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
48
- * that the selection inherits all attributes from a node if it is in an empty node).
49
- *
50
- * @fires execute
51
- * @param options Command options.
52
- * @param options.forceValue If set, it will force the command behavior. If `true`,
53
- * the command will apply the attribute, otherwise the command will remove the attribute.
54
- * If not set, the command will look for its current value to decide what it should do.
55
- */
56
- execute(options = {}) {
57
- const model = this.editor.model;
58
- const doc = model.document;
59
- const selection = doc.selection;
60
- const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
61
- model.change(writer => {
62
- if (selection.isCollapsed) {
63
- if (value) {
64
- writer.setSelectionAttribute(this.attributeKey, true);
65
- }
66
- else {
67
- writer.removeSelectionAttribute(this.attributeKey);
68
- }
69
- }
70
- else {
71
- const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
72
- for (const range of ranges) {
73
- if (value) {
74
- writer.setAttribute(this.attributeKey, value, range);
75
- }
76
- else {
77
- writer.removeAttribute(this.attributeKey, range);
78
- }
79
- }
80
- }
81
- });
82
- }
83
- /**
84
- * Checks the attribute value of the first node in the selection that allows the attribute.
85
- * For the collapsed selection returns the selection attribute.
86
- *
87
- * @returns The attribute value.
88
- */
89
- _getValueFromFirstAllowedNode() {
90
- const model = this.editor.model;
91
- const schema = model.schema;
92
- const selection = model.document.selection;
93
- if (selection.isCollapsed) {
94
- return selection.hasAttribute(this.attributeKey);
95
- }
96
- for (const range of selection.getRanges()) {
97
- for (const item of range.getItems()) {
98
- if (schema.checkAttribute(item, this.attributeKey)) {
99
- return item.hasAttribute(this.attributeKey);
100
- }
101
- }
102
- }
103
- return false;
104
- }
105
- }
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 basic-styles/attributecommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core';
9
+ /**
10
+ * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
+ * that toggles a single attribute on a text or an element.
12
+ *
13
+ * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
+ * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
+ *
16
+ * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
+ * for the current selection and to which nodes the attribute can be applied.
18
+ */
19
+ export default class AttributeCommand extends Command {
20
+ /**
21
+ * @param attributeKey Attribute that will be set by the command.
22
+ */
23
+ constructor(editor, attributeKey) {
24
+ super(editor);
25
+ this.attributeKey = attributeKey;
26
+ }
27
+ /**
28
+ * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
29
+ */
30
+ refresh() {
31
+ const model = this.editor.model;
32
+ const doc = model.document;
33
+ this.value = this._getValueFromFirstAllowedNode();
34
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
35
+ }
36
+ /**
37
+ * Executes the command &ndash; applies the attribute to the selection or removes it from the selection.
38
+ *
39
+ * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
40
+ *
41
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
42
+ *
43
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
44
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
45
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
46
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
47
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
48
+ * that the selection inherits all attributes from a node if it is in an empty node).
49
+ *
50
+ * @fires execute
51
+ * @param options Command options.
52
+ * @param options.forceValue If set, it will force the command behavior. If `true`,
53
+ * the command will apply the attribute, otherwise the command will remove the attribute.
54
+ * If not set, the command will look for its current value to decide what it should do.
55
+ */
56
+ execute(options = {}) {
57
+ const model = this.editor.model;
58
+ const doc = model.document;
59
+ const selection = doc.selection;
60
+ const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
61
+ model.change(writer => {
62
+ if (selection.isCollapsed) {
63
+ if (value) {
64
+ writer.setSelectionAttribute(this.attributeKey, true);
65
+ }
66
+ else {
67
+ writer.removeSelectionAttribute(this.attributeKey);
68
+ }
69
+ }
70
+ else {
71
+ const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
72
+ for (const range of ranges) {
73
+ if (value) {
74
+ writer.setAttribute(this.attributeKey, value, range);
75
+ }
76
+ else {
77
+ writer.removeAttribute(this.attributeKey, range);
78
+ }
79
+ }
80
+ }
81
+ });
82
+ }
83
+ /**
84
+ * Checks the attribute value of the first node in the selection that allows the attribute.
85
+ * For the collapsed selection returns the selection attribute.
86
+ *
87
+ * @returns The attribute value.
88
+ */
89
+ _getValueFromFirstAllowedNode() {
90
+ const model = this.editor.model;
91
+ const schema = model.schema;
92
+ const selection = model.document.selection;
93
+ if (selection.isCollapsed) {
94
+ return selection.hasAttribute(this.attributeKey);
95
+ }
96
+ for (const range of selection.getRanges()) {
97
+ for (const item of range.getItems()) {
98
+ if (schema.checkAttribute(item, this.attributeKey)) {
99
+ return item.hasAttribute(this.attributeKey);
100
+ }
101
+ }
102
+ }
103
+ return false;
104
+ }
105
+ }