@ckeditor/ckeditor5-alignment 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.
- package/CHANGELOG.md +19 -19
- package/LICENSE.md +2 -2
- package/package.json +2 -2
- package/src/alignment.d.ts +29 -29
- package/src/alignment.js +33 -33
- package/src/alignmentcommand.d.ts +43 -43
- package/src/alignmentcommand.js +88 -88
- package/src/alignmentconfig.d.ts +72 -72
- package/src/alignmentconfig.js +5 -5
- package/src/alignmentediting.d.ts +26 -26
- package/src/alignmentediting.js +147 -147
- package/src/alignmentui.d.ts +45 -45
- package/src/alignmentui.js +124 -124
- package/src/augmentation.d.ts +23 -23
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +13 -13
- package/src/index.js +11 -11
- package/src/utils.d.ts +39 -39
- package/src/utils.js +118 -118
- package/build/alignment.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,19 +5,19 @@ 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-alignment/compare/v18.0.0...v19.0.0) (2020
|
|
8
|
+
## [19.0.0](https://github.com/ckeditor/ckeditor5-alignment/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-alignment/compare/v17.0.0...v18.0.0) (2020
|
|
13
|
+
## [18.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v17.0.0...v18.0.0) (March 19, 2020)
|
|
14
14
|
|
|
15
15
|
### Other changes
|
|
16
16
|
|
|
17
17
|
* Updated translations. ([f1beaaa](https://github.com/ckeditor/ckeditor5-alignment/commit/f1beaaa))
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
## [17.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v16.0.0...v17.0.0) (2020
|
|
20
|
+
## [17.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v16.0.0...v17.0.0) (February 18, 2020)
|
|
21
21
|
|
|
22
22
|
### MAJOR BREAKING CHANGES
|
|
23
23
|
|
|
@@ -29,14 +29,14 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
29
29
|
* Updated translations. ([288672f](https://github.com/ckeditor/ckeditor5-alignment/commit/288672f))
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
## [16.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v15.0.0...v16.0.0) (2019
|
|
32
|
+
## [16.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v15.0.0...v16.0.0) (December 4, 2019)
|
|
33
33
|
|
|
34
34
|
### Other changes
|
|
35
35
|
|
|
36
36
|
* Updated translations. ([9085f7b](https://github.com/ckeditor/ckeditor5-alignment/commit/9085f7b))
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
## [15.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.2.0...v15.0.0) (2019
|
|
39
|
+
## [15.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.2.0...v15.0.0) (October 23, 2019)
|
|
40
40
|
|
|
41
41
|
### Other changes
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
44
44
|
* Added `pluginName` to the editor plugin part of the feature. ([3b42798](https://github.com/ckeditor/ckeditor5-alignment/commit/3b42798))
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
## [11.2.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.3...v11.2.0) (2019
|
|
47
|
+
## [11.2.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.3...v11.2.0) (August 26, 2019)
|
|
48
48
|
|
|
49
49
|
### Features
|
|
50
50
|
|
|
@@ -61,26 +61,26 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
61
61
|
* Updated translations. ([feb4ab3](https://github.com/ckeditor/ckeditor5-alignment/commit/feb4ab3))
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
## [11.1.3](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.2...v11.1.3) (2019
|
|
64
|
+
## [11.1.3](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.2...v11.1.3) (July 10, 2019)
|
|
65
65
|
|
|
66
66
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
## [11.1.2](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.1...v11.1.2) (2019
|
|
69
|
+
## [11.1.2](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.1...v11.1.2) (July 4, 2019)
|
|
70
70
|
|
|
71
71
|
### Other changes
|
|
72
72
|
|
|
73
73
|
* Updated translations. ([bb7f494](https://github.com/ckeditor/ckeditor5-alignment/commit/bb7f494))
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
## [11.1.1](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.0...v11.1.1) (2019
|
|
76
|
+
## [11.1.1](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.1.0...v11.1.1) (June 6, 2019)
|
|
77
77
|
|
|
78
78
|
### Other changes
|
|
79
79
|
|
|
80
80
|
* Updated translations. ([32c32c1](https://github.com/ckeditor/ckeditor5-alignment/commit/32c32c1))
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
## [11.1.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.0.0...v11.1.0) (2019
|
|
83
|
+
## [11.1.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v11.0.0...v11.1.0) (April 4, 2019)
|
|
84
84
|
|
|
85
85
|
### Features
|
|
86
86
|
|
|
@@ -91,7 +91,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
91
91
|
* Updated translations. ([78bfc40](https://github.com/ckeditor/ckeditor5-alignment/commit/78bfc40))
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
## [11.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.4...v11.0.0) (2019
|
|
94
|
+
## [11.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.4...v11.0.0) (February 28, 2019)
|
|
95
95
|
|
|
96
96
|
### Other changes
|
|
97
97
|
|
|
@@ -102,7 +102,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
102
102
|
* 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))
|
|
103
103
|
|
|
104
104
|
|
|
105
|
-
## [10.0.4](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.3...v10.0.4) (2018
|
|
105
|
+
## [10.0.4](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.3...v10.0.4) (December 5, 2018)
|
|
106
106
|
|
|
107
107
|
### Other changes
|
|
108
108
|
|
|
@@ -110,28 +110,28 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
110
110
|
* Updated translations. ([547f8d8](https://github.com/ckeditor/ckeditor5-alignment/commit/547f8d8)) ([43d8225](https://github.com/ckeditor/ckeditor5-alignment/commit/43d8225))
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
## [10.0.3](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.2...v10.0.3) (2018
|
|
113
|
+
## [10.0.3](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.2...v10.0.3) (October 8, 2018)
|
|
114
114
|
|
|
115
115
|
### Other changes
|
|
116
116
|
|
|
117
117
|
* Updated translations. ([5b30202](https://github.com/ckeditor/ckeditor5-alignment/commit/5b30202))
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
## [10.0.2](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.1...v10.0.2) (2018
|
|
120
|
+
## [10.0.2](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.1...v10.0.2) (July 18, 2018)
|
|
121
121
|
|
|
122
122
|
### Other changes
|
|
123
123
|
|
|
124
124
|
* Updated translations. ([33c281c](https://github.com/ckeditor/ckeditor5-alignment/commit/33c281c))
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
## [10.0.1](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.0...v10.0.1) (2018
|
|
127
|
+
## [10.0.1](https://github.com/ckeditor/ckeditor5-alignment/compare/v10.0.0...v10.0.1) (June 21, 2018)
|
|
128
128
|
|
|
129
129
|
### Other changes
|
|
130
130
|
|
|
131
131
|
* Updated translations.
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
## [10.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v1.0.0-beta.4...v10.0.0) (2018
|
|
134
|
+
## [10.0.0](https://github.com/ckeditor/ckeditor5-alignment/compare/v1.0.0-beta.4...v10.0.0) (April 25, 2018)
|
|
135
135
|
|
|
136
136
|
### Other changes
|
|
137
137
|
|
|
@@ -143,19 +143,19 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
143
143
|
* 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.
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-alignment/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018
|
|
146
|
+
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-alignment/compare/v1.0.0-beta.2...v1.0.0-beta.4) (April 19, 2018)
|
|
147
147
|
|
|
148
148
|
### Other changes
|
|
149
149
|
|
|
150
150
|
* Updated translations. ([586ae62](https://github.com/ckeditor/ckeditor5-alignment/commit/586ae62))
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-alignment/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018
|
|
153
|
+
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-alignment/compare/v1.0.0-beta.1...v1.0.0-beta.2) (April 10, 2018)
|
|
154
154
|
|
|
155
155
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-alignment/compare/v0.0.1...v1.0.0-beta.1) (2018
|
|
158
|
+
## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-alignment/compare/v0.0.1...v1.0.0-beta.1) (March 15, 2018)
|
|
159
159
|
|
|
160
160
|
### Features
|
|
161
161
|
|
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 text alignment feature** – https://github.com/ckeditor/ckeditor5-alignment <br>
|
|
5
|
-
Copyright (c) 2003
|
|
5
|
+
Copyright (c) 2003–2023, [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-alignment",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.2.0",
|
|
4
4
|
"description": "Text alignment 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.
|
|
15
|
+
"ckeditor5": "40.2.0"
|
|
16
16
|
},
|
|
17
17
|
"author": "CKSource (http://cksource.com/)",
|
|
18
18
|
"license": "GPL-2.0-or-later",
|
package/src/alignment.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
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 alignment/alignment
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import AlignmentEditing from './alignmentediting';
|
|
10
|
-
import AlignmentUI from './alignmentui';
|
|
11
|
-
/**
|
|
12
|
-
* The text alignment plugin.
|
|
13
|
-
*
|
|
14
|
-
* For a detailed overview, check the {@glink features/text-alignment Text alignment} feature guide
|
|
15
|
-
* and the {@glink api/alignment package page}.
|
|
16
|
-
*
|
|
17
|
-
* This is a "glue" plugin which loads the {@link module:alignment/alignmentediting~AlignmentEditing} and
|
|
18
|
-
* {@link module:alignment/alignmentui~AlignmentUI} plugins.
|
|
19
|
-
*/
|
|
20
|
-
export default class Alignment extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires(): readonly [typeof AlignmentEditing, typeof AlignmentUI];
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
static get pluginName(): "Alignment";
|
|
29
|
-
}
|
|
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 alignment/alignment
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import AlignmentEditing from './alignmentediting';
|
|
10
|
+
import AlignmentUI from './alignmentui';
|
|
11
|
+
/**
|
|
12
|
+
* The text alignment plugin.
|
|
13
|
+
*
|
|
14
|
+
* For a detailed overview, check the {@glink features/text-alignment Text alignment} feature guide
|
|
15
|
+
* and the {@glink api/alignment package page}.
|
|
16
|
+
*
|
|
17
|
+
* This is a "glue" plugin which loads the {@link module:alignment/alignmentediting~AlignmentEditing} and
|
|
18
|
+
* {@link module:alignment/alignmentui~AlignmentUI} plugins.
|
|
19
|
+
*/
|
|
20
|
+
export default class Alignment extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get requires(): readonly [typeof AlignmentEditing, typeof AlignmentUI];
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get pluginName(): "Alignment";
|
|
29
|
+
}
|
package/src/alignment.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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 alignment/alignment
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import AlignmentEditing from './alignmentediting';
|
|
10
|
-
import AlignmentUI from './alignmentui';
|
|
11
|
-
/**
|
|
12
|
-
* The text alignment plugin.
|
|
13
|
-
*
|
|
14
|
-
* For a detailed overview, check the {@glink features/text-alignment Text alignment} feature guide
|
|
15
|
-
* and the {@glink api/alignment package page}.
|
|
16
|
-
*
|
|
17
|
-
* This is a "glue" plugin which loads the {@link module:alignment/alignmentediting~AlignmentEditing} and
|
|
18
|
-
* {@link module:alignment/alignmentui~AlignmentUI} plugins.
|
|
19
|
-
*/
|
|
20
|
-
export default class Alignment extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires() {
|
|
25
|
-
return [AlignmentEditing, AlignmentUI];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get pluginName() {
|
|
31
|
-
return 'Alignment';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
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 alignment/alignment
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import AlignmentEditing from './alignmentediting';
|
|
10
|
+
import AlignmentUI from './alignmentui';
|
|
11
|
+
/**
|
|
12
|
+
* The text alignment plugin.
|
|
13
|
+
*
|
|
14
|
+
* For a detailed overview, check the {@glink features/text-alignment Text alignment} feature guide
|
|
15
|
+
* and the {@glink api/alignment package page}.
|
|
16
|
+
*
|
|
17
|
+
* This is a "glue" plugin which loads the {@link module:alignment/alignmentediting~AlignmentEditing} and
|
|
18
|
+
* {@link module:alignment/alignmentui~AlignmentUI} plugins.
|
|
19
|
+
*/
|
|
20
|
+
export default class Alignment extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get requires() {
|
|
25
|
+
return [AlignmentEditing, AlignmentUI];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
static get pluginName() {
|
|
31
|
+
return 'Alignment';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
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 alignment/alignmentcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
import type { SupportedOption } from './alignmentconfig';
|
|
10
|
-
/**
|
|
11
|
-
* The alignment command plugin.
|
|
12
|
-
*/
|
|
13
|
-
export default class AlignmentCommand extends Command {
|
|
14
|
-
/**
|
|
15
|
-
* A value of the current block's alignment.
|
|
16
|
-
*
|
|
17
|
-
* @observable
|
|
18
|
-
* @readonly
|
|
19
|
-
*/
|
|
20
|
-
value: SupportedOption;
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
refresh(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Executes the command. Applies the alignment `value` to the selected blocks.
|
|
27
|
-
* If no `value` is passed, the `value` is the default one or it is equal to the currently selected block's alignment attribute,
|
|
28
|
-
* the command will remove the attribute from the selected blocks.
|
|
29
|
-
*
|
|
30
|
-
* @param options Options for the executed command.
|
|
31
|
-
* @param options.value The value to apply.
|
|
32
|
-
* @fires execute
|
|
33
|
-
*/
|
|
34
|
-
execute(options?: {
|
|
35
|
-
value?: SupportedOption;
|
|
36
|
-
}): void;
|
|
37
|
-
/**
|
|
38
|
-
* Checks whether a block can have alignment set.
|
|
39
|
-
*
|
|
40
|
-
* @param block The block to be checked.
|
|
41
|
-
*/
|
|
42
|
-
private _canBeAligned;
|
|
43
|
-
}
|
|
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 alignment/alignmentcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
import type { SupportedOption } from './alignmentconfig';
|
|
10
|
+
/**
|
|
11
|
+
* The alignment command plugin.
|
|
12
|
+
*/
|
|
13
|
+
export default class AlignmentCommand extends Command {
|
|
14
|
+
/**
|
|
15
|
+
* A value of the current block's alignment.
|
|
16
|
+
*
|
|
17
|
+
* @observable
|
|
18
|
+
* @readonly
|
|
19
|
+
*/
|
|
20
|
+
value: SupportedOption;
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
refresh(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Executes the command. Applies the alignment `value` to the selected blocks.
|
|
27
|
+
* If no `value` is passed, the `value` is the default one or it is equal to the currently selected block's alignment attribute,
|
|
28
|
+
* the command will remove the attribute from the selected blocks.
|
|
29
|
+
*
|
|
30
|
+
* @param options Options for the executed command.
|
|
31
|
+
* @param options.value The value to apply.
|
|
32
|
+
* @fires execute
|
|
33
|
+
*/
|
|
34
|
+
execute(options?: {
|
|
35
|
+
value?: SupportedOption;
|
|
36
|
+
}): void;
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether a block can have alignment set.
|
|
39
|
+
*
|
|
40
|
+
* @param block The block to be checked.
|
|
41
|
+
*/
|
|
42
|
+
private _canBeAligned;
|
|
43
|
+
}
|
package/src/alignmentcommand.js
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
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 alignment/alignmentcommand
|
|
7
|
-
*/
|
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
|
9
|
-
import { first } from 'ckeditor5/src/utils';
|
|
10
|
-
import { isDefault } from './utils';
|
|
11
|
-
const ALIGNMENT = 'alignment';
|
|
12
|
-
/**
|
|
13
|
-
* The alignment command plugin.
|
|
14
|
-
*/
|
|
15
|
-
export default class AlignmentCommand extends Command {
|
|
16
|
-
/**
|
|
17
|
-
* @inheritDoc
|
|
18
|
-
*/
|
|
19
|
-
refresh() {
|
|
20
|
-
const editor = this.editor;
|
|
21
|
-
const locale = editor.locale;
|
|
22
|
-
const firstBlock = first(this.editor.model.document.selection.getSelectedBlocks());
|
|
23
|
-
// As first check whether to enable or disable the command as the value will always be false if the command cannot be enabled.
|
|
24
|
-
this.isEnabled = Boolean(firstBlock) && this._canBeAligned(firstBlock);
|
|
25
|
-
if (this.isEnabled && firstBlock.hasAttribute('alignment')) {
|
|
26
|
-
this.value = firstBlock.getAttribute('alignment');
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.value = locale.contentLanguageDirection === 'rtl' ? 'right' : 'left';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Executes the command. Applies the alignment `value` to the selected blocks.
|
|
34
|
-
* If no `value` is passed, the `value` is the default one or it is equal to the currently selected block's alignment attribute,
|
|
35
|
-
* the command will remove the attribute from the selected blocks.
|
|
36
|
-
*
|
|
37
|
-
* @param options Options for the executed command.
|
|
38
|
-
* @param options.value The value to apply.
|
|
39
|
-
* @fires execute
|
|
40
|
-
*/
|
|
41
|
-
execute(options = {}) {
|
|
42
|
-
const editor = this.editor;
|
|
43
|
-
const locale = editor.locale;
|
|
44
|
-
const model = editor.model;
|
|
45
|
-
const doc = model.document;
|
|
46
|
-
const value = options.value;
|
|
47
|
-
model.change(writer => {
|
|
48
|
-
// Get only those blocks from selected that can have alignment set
|
|
49
|
-
const blocks = Array.from(doc.selection.getSelectedBlocks()).filter(block => this._canBeAligned(block));
|
|
50
|
-
const currentAlignment = blocks[0].getAttribute('alignment');
|
|
51
|
-
// Remove alignment attribute if current alignment is:
|
|
52
|
-
// - default (should not be stored in model as it will bloat model data)
|
|
53
|
-
// - equal to currently set
|
|
54
|
-
// - or no value is passed - denotes default alignment.
|
|
55
|
-
const removeAlignment = isDefault(value, locale) || currentAlignment === value || !value;
|
|
56
|
-
if (removeAlignment) {
|
|
57
|
-
removeAlignmentFromSelection(blocks, writer);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
setAlignmentOnSelection(blocks, writer, value);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Checks whether a block can have alignment set.
|
|
66
|
-
*
|
|
67
|
-
* @param block The block to be checked.
|
|
68
|
-
*/
|
|
69
|
-
_canBeAligned(block) {
|
|
70
|
-
return this.editor.model.schema.checkAttribute(block, ALIGNMENT);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Removes the alignment attribute from blocks.
|
|
75
|
-
*/
|
|
76
|
-
function removeAlignmentFromSelection(blocks, writer) {
|
|
77
|
-
for (const block of blocks) {
|
|
78
|
-
writer.removeAttribute(ALIGNMENT, block);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Sets the alignment attribute on blocks.
|
|
83
|
-
*/
|
|
84
|
-
function setAlignmentOnSelection(blocks, writer, alignment) {
|
|
85
|
-
for (const block of blocks) {
|
|
86
|
-
writer.setAttribute(ALIGNMENT, alignment, block);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
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 alignment/alignmentcommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
import { first } from 'ckeditor5/src/utils';
|
|
10
|
+
import { isDefault } from './utils';
|
|
11
|
+
const ALIGNMENT = 'alignment';
|
|
12
|
+
/**
|
|
13
|
+
* The alignment command plugin.
|
|
14
|
+
*/
|
|
15
|
+
export default class AlignmentCommand extends Command {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
refresh() {
|
|
20
|
+
const editor = this.editor;
|
|
21
|
+
const locale = editor.locale;
|
|
22
|
+
const firstBlock = first(this.editor.model.document.selection.getSelectedBlocks());
|
|
23
|
+
// As first check whether to enable or disable the command as the value will always be false if the command cannot be enabled.
|
|
24
|
+
this.isEnabled = Boolean(firstBlock) && this._canBeAligned(firstBlock);
|
|
25
|
+
if (this.isEnabled && firstBlock.hasAttribute('alignment')) {
|
|
26
|
+
this.value = firstBlock.getAttribute('alignment');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.value = locale.contentLanguageDirection === 'rtl' ? 'right' : 'left';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Executes the command. Applies the alignment `value` to the selected blocks.
|
|
34
|
+
* If no `value` is passed, the `value` is the default one or it is equal to the currently selected block's alignment attribute,
|
|
35
|
+
* the command will remove the attribute from the selected blocks.
|
|
36
|
+
*
|
|
37
|
+
* @param options Options for the executed command.
|
|
38
|
+
* @param options.value The value to apply.
|
|
39
|
+
* @fires execute
|
|
40
|
+
*/
|
|
41
|
+
execute(options = {}) {
|
|
42
|
+
const editor = this.editor;
|
|
43
|
+
const locale = editor.locale;
|
|
44
|
+
const model = editor.model;
|
|
45
|
+
const doc = model.document;
|
|
46
|
+
const value = options.value;
|
|
47
|
+
model.change(writer => {
|
|
48
|
+
// Get only those blocks from selected that can have alignment set
|
|
49
|
+
const blocks = Array.from(doc.selection.getSelectedBlocks()).filter(block => this._canBeAligned(block));
|
|
50
|
+
const currentAlignment = blocks[0].getAttribute('alignment');
|
|
51
|
+
// Remove alignment attribute if current alignment is:
|
|
52
|
+
// - default (should not be stored in model as it will bloat model data)
|
|
53
|
+
// - equal to currently set
|
|
54
|
+
// - or no value is passed - denotes default alignment.
|
|
55
|
+
const removeAlignment = isDefault(value, locale) || currentAlignment === value || !value;
|
|
56
|
+
if (removeAlignment) {
|
|
57
|
+
removeAlignmentFromSelection(blocks, writer);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
setAlignmentOnSelection(blocks, writer, value);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Checks whether a block can have alignment set.
|
|
66
|
+
*
|
|
67
|
+
* @param block The block to be checked.
|
|
68
|
+
*/
|
|
69
|
+
_canBeAligned(block) {
|
|
70
|
+
return this.editor.model.schema.checkAttribute(block, ALIGNMENT);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Removes the alignment attribute from blocks.
|
|
75
|
+
*/
|
|
76
|
+
function removeAlignmentFromSelection(blocks, writer) {
|
|
77
|
+
for (const block of blocks) {
|
|
78
|
+
writer.removeAttribute(ALIGNMENT, block);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sets the alignment attribute on blocks.
|
|
83
|
+
*/
|
|
84
|
+
function setAlignmentOnSelection(blocks, writer, alignment) {
|
|
85
|
+
for (const block of blocks) {
|
|
86
|
+
writer.setAttribute(ALIGNMENT, alignment, block);
|
|
87
|
+
}
|
|
88
|
+
}
|