@ckeditor/ckeditor5-alignment 36.0.0 → 37.0.0-alpha.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/package.json +16 -15
- package/src/alignment.d.ts +32 -0
- package/src/alignment.js +1 -1
- package/src/alignmentcommand.d.ts +48 -0
- package/src/alignmentconfig.d.ts +82 -0
- package/src/alignmentconfig.js +5 -0
- package/src/alignmentediting.d.ts +31 -0
- package/src/alignmentui.d.ts +50 -0
- package/src/alignmentui.js +1 -1
- package/src/index.d.ts +10 -0
- package/src/utils.d.ts +39 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-alignment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0-alpha.0",
|
|
4
4
|
"description": "Text alignment feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "^
|
|
15
|
+
"ckeditor5": "^37.0.0-alpha.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@ckeditor/ckeditor5-block-quote": "^
|
|
19
|
-
"@ckeditor/ckeditor5-core": "^
|
|
20
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
21
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
22
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
23
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
24
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
25
|
-
"@ckeditor/ckeditor5-image": "^
|
|
26
|
-
"@ckeditor/ckeditor5-list": "^
|
|
27
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
28
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
29
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
18
|
+
"@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-dev-utils": "^34.0.0",
|
|
21
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
|
|
25
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
|
|
26
|
+
"@ckeditor/ckeditor5-list": "^37.0.0-alpha.0",
|
|
27
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
|
28
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
|
|
29
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
|
30
30
|
"typescript": "^4.8.4",
|
|
31
31
|
"webpack": "^5.58.1",
|
|
32
32
|
"webpack-cli": "^4.9.0"
|
|
@@ -57,5 +57,6 @@
|
|
|
57
57
|
"dll:build": "webpack",
|
|
58
58
|
"build": "tsc -p ./tsconfig.release.json",
|
|
59
59
|
"postversion": "npm run build"
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"types": "src/index.d.ts"
|
|
61
62
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The text alignment plugin.
|
|
11
|
+
*
|
|
12
|
+
* For a detailed overview, check the {@glink features/text-alignment Text alignment} feature guide
|
|
13
|
+
* and the {@glink api/alignment package page}.
|
|
14
|
+
*
|
|
15
|
+
* This is a "glue" plugin which loads the {@link module:alignment/alignmentediting~AlignmentEditing} and
|
|
16
|
+
* {@link module:alignment/alignmentui~AlignmentUI} plugins.
|
|
17
|
+
*/
|
|
18
|
+
export default class Alignment extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get requires(): PluginDependencies;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName(): 'Alignment';
|
|
27
|
+
}
|
|
28
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
29
|
+
interface PluginsMap {
|
|
30
|
+
[Alignment.pluginName]: Alignment;
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/alignment.js
CHANGED
|
@@ -11,7 +11,7 @@ import AlignmentUI from './alignmentui';
|
|
|
11
11
|
/**
|
|
12
12
|
* The text alignment plugin.
|
|
13
13
|
*
|
|
14
|
-
* For a detailed overview, check the {@glink features/text-alignment Text alignment feature
|
|
14
|
+
* For a detailed overview, check the {@glink features/text-alignment Text alignment} feature guide
|
|
15
15
|
* and the {@glink api/alignment package page}.
|
|
16
16
|
*
|
|
17
17
|
* This is a "glue" plugin which loads the {@link module:alignment/alignmentediting~AlignmentEditing} and
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|
|
44
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
45
|
+
interface CommandsMap {
|
|
46
|
+
alignment: AlignmentCommand;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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/alignmentconfig
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the {@link module:alignment/alignment~Alignment alignment feature}.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* ClassicEditor
|
|
13
|
+
* .create( editorElement, {
|
|
14
|
+
* alignment: {
|
|
15
|
+
* options: [ 'left', 'right' ]
|
|
16
|
+
* }
|
|
17
|
+
* } )
|
|
18
|
+
* .then( ... )
|
|
19
|
+
* .catch( ... );
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
|
|
23
|
+
*/
|
|
24
|
+
export type AlignmentConfig = {
|
|
25
|
+
options?: Array<SupportedOption | AlignmentFormat>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Available alignment options.
|
|
29
|
+
*
|
|
30
|
+
* The available options are: `'left'`, `'right'`, `'center'` and `'justify'`. Other values are ignored.
|
|
31
|
+
*
|
|
32
|
+
* **Note:** It is recommended to always use `'left'` or `'right'` as these are default values which the user should
|
|
33
|
+
* normally be able to choose depending on the
|
|
34
|
+
* {@glink features/ui-language#setting-the-language-of-the-content language of the editor content}.
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* ClassicEditor
|
|
38
|
+
* .create( editorElement, {
|
|
39
|
+
* alignment: {
|
|
40
|
+
* options: [ 'left', 'right' ]
|
|
41
|
+
* }
|
|
42
|
+
* } )
|
|
43
|
+
* .then( ... )
|
|
44
|
+
* .catch( ... );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* By default the alignment is set inline using the `text-align` CSS property. To further customize the alignment,
|
|
48
|
+
* you can provide names of classes for each alignment option using the `className` property.
|
|
49
|
+
*
|
|
50
|
+
* **Note:** Once you define the `className` property for one option, you need to specify it for all other options.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* ClassicEditor
|
|
54
|
+
* .create( editorElement, {
|
|
55
|
+
* alignment: {
|
|
56
|
+
* options: [
|
|
57
|
+
* { name: 'left', className: 'my-align-left' },
|
|
58
|
+
* { name: 'right', className: 'my-align-right' }
|
|
59
|
+
* ]
|
|
60
|
+
* }
|
|
61
|
+
* } )
|
|
62
|
+
* .then( ... )
|
|
63
|
+
* .catch( ... );
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* See the demo of {@glink features/text-alignment#configuring-alignment-options custom alignment options}.
|
|
67
|
+
*/
|
|
68
|
+
export type AlignmentFormat = {
|
|
69
|
+
name: SupportedOption;
|
|
70
|
+
className?: string;
|
|
71
|
+
};
|
|
72
|
+
export type SupportedOption = 'left' | 'right' | 'center' | 'justify';
|
|
73
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
74
|
+
interface EditorConfig {
|
|
75
|
+
/**
|
|
76
|
+
* The configuration of the {@link module:alignment/alignment~Alignment alignment feature}.
|
|
77
|
+
*
|
|
78
|
+
* Read more in {@link module:alignment/alignmentconfig~AlignmentConfig}.
|
|
79
|
+
*/
|
|
80
|
+
alignment?: AlignmentConfig;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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/alignmentediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The alignment editing feature. It introduces the {@link module:alignment/alignmentcommand~AlignmentCommand command} and adds
|
|
11
|
+
* the `alignment` attribute for block elements in the {@link module:engine/model/model~Model model}.
|
|
12
|
+
*/
|
|
13
|
+
export default class AlignmentEditing extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): 'AlignmentEditing';
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
constructor(editor: Editor);
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
init(): void;
|
|
26
|
+
}
|
|
27
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
28
|
+
interface PluginsMap {
|
|
29
|
+
[AlignmentEditing.pluginName]: AlignmentEditing;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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/alignmentui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import type { SupportedOption } from './alignmentconfig';
|
|
10
|
+
/**
|
|
11
|
+
* The default alignment UI plugin.
|
|
12
|
+
*
|
|
13
|
+
* It introduces the `'alignment:left'`, `'alignment:right'`, `'alignment:center'` and `'alignment:justify'` buttons
|
|
14
|
+
* and the `'alignment'` dropdown.
|
|
15
|
+
*/
|
|
16
|
+
export default class AlignmentUI extends Plugin {
|
|
17
|
+
/**
|
|
18
|
+
* Returns the localized option titles provided by the plugin.
|
|
19
|
+
*
|
|
20
|
+
* The following localized titles corresponding with
|
|
21
|
+
* {@link module:alignment/alignmentconfig~AlignmentConfig#options} are available:
|
|
22
|
+
*
|
|
23
|
+
* * `'left'`,
|
|
24
|
+
* * `'right'`,
|
|
25
|
+
* * `'center'`,
|
|
26
|
+
* * `'justify'`.
|
|
27
|
+
*
|
|
28
|
+
* @readonly
|
|
29
|
+
*/
|
|
30
|
+
get localizedOptionTitles(): Record<SupportedOption, string>;
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
static get pluginName(): 'AlignmentUI';
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
init(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Helper method for initializing the button and linking it with an appropriate command.
|
|
41
|
+
*
|
|
42
|
+
* @param option The name of the alignment option for which the button is added.
|
|
43
|
+
*/
|
|
44
|
+
private _addButton;
|
|
45
|
+
}
|
|
46
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
47
|
+
interface PluginsMap {
|
|
48
|
+
[AlignmentUI.pluginName]: AlignmentUI;
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/alignmentui.js
CHANGED
|
@@ -25,7 +25,7 @@ export default class AlignmentUI extends Plugin {
|
|
|
25
25
|
* Returns the localized option titles provided by the plugin.
|
|
26
26
|
*
|
|
27
27
|
* The following localized titles corresponding with
|
|
28
|
-
* {@link module:alignment/
|
|
28
|
+
* {@link module:alignment/alignmentconfig~AlignmentConfig#options} are available:
|
|
29
29
|
*
|
|
30
30
|
* * `'left'`,
|
|
31
31
|
* * `'right'`,
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
7
|
+
*/
|
|
8
|
+
export { default as Alignment } from './alignment';
|
|
9
|
+
export { default as AlignmentEditing } from './alignmentediting';
|
|
10
|
+
export { default as AlignmentUI } from './alignmentui';
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import { type Locale } from 'ckeditor5/src/utils';
|
|
6
|
+
import type { AlignmentFormat, SupportedOption } from './alignmentconfig';
|
|
7
|
+
/**
|
|
8
|
+
* @module alignment/utils
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The list of supported alignment options:
|
|
12
|
+
*
|
|
13
|
+
* * `'left'`,
|
|
14
|
+
* * `'right'`,
|
|
15
|
+
* * `'center'`,
|
|
16
|
+
* * `'justify'`
|
|
17
|
+
*/
|
|
18
|
+
export declare const supportedOptions: ReadonlyArray<SupportedOption>;
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether the passed option is supported by {@link module:alignment/alignmentediting~AlignmentEditing}.
|
|
21
|
+
*
|
|
22
|
+
* @param option The option value to check.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isSupported(option: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether alignment is the default one considering the direction
|
|
27
|
+
* of the editor content.
|
|
28
|
+
*
|
|
29
|
+
* @param alignment The name of the alignment to check.
|
|
30
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isDefault(alignment: string, locale: Locale): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Brings the configuration to the common form, an array of objects.
|
|
35
|
+
*
|
|
36
|
+
* @param configuredOptions Alignment plugin configuration.
|
|
37
|
+
* @returns Normalized object holding the configuration.
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeAlignmentOptions(configuredOptions: Array<string | AlignmentFormat>): Array<AlignmentFormat>;
|