@ckeditor/ckeditor5-indent 36.0.1 → 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/build/indent.js +1 -1
- package/package.json +18 -13
- package/src/indent.d.ts +43 -0
- package/src/indent.js +12 -19
- package/src/indentblock.d.ts +48 -0
- package/src/indentblock.js +121 -212
- package/src/indentblockcommand.d.ts +51 -0
- package/src/indentblockcommand.js +53 -97
- package/src/indentcommandbehavior/indentbehavior.d.ts +21 -0
- package/src/indentcommandbehavior/indentbehavior.js +5 -0
- package/src/indentcommandbehavior/indentusingclasses.d.ts +39 -0
- package/src/indentcommandbehavior/indentusingclasses.js +30 -52
- package/src/indentcommandbehavior/indentusingoffset.d.ts +45 -0
- package/src/indentcommandbehavior/indentusingoffset.js +33 -65
- package/src/indentconfig.d.ts +82 -0
- package/src/indentconfig.js +5 -0
- package/src/indentediting.d.ts +26 -0
- package/src/indentediting.js +14 -21
- package/src/indentui.d.ts +32 -0
- package/src/indentui.js +39 -58
- package/src/index.d.ts +11 -0
- package/src/index.js +0 -2
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module indent/indentblockcommand
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Command } from 'ckeditor5/src/core';
|
|
11
9
|
import { first } from 'ckeditor5/src/utils';
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* The indent block command.
|
|
15
12
|
*
|
|
@@ -18,105 +15,64 @@ import { first } from 'ckeditor5/src/utils';
|
|
|
18
15
|
*
|
|
19
16
|
* To increase block indentation at the current selection, execute the command:
|
|
20
17
|
*
|
|
21
|
-
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* editor.execute( 'indentBlock' );
|
|
20
|
+
* ```
|
|
22
21
|
*
|
|
23
22
|
* To decrease block indentation at the current selection, execute the command:
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* editor.execute( 'outdentBlock' );
|
|
26
|
+
* ```
|
|
28
27
|
*/
|
|
29
28
|
export default class IndentBlockCommand extends Command {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
execute() {
|
|
71
|
-
const model = this.editor.model;
|
|
72
|
-
|
|
73
|
-
const blocksToChange = getBlocksToChange( model );
|
|
74
|
-
|
|
75
|
-
model.change( writer => {
|
|
76
|
-
for ( const block of blocksToChange ) {
|
|
77
|
-
const currentIndent = block.getAttribute( 'blockIndent' );
|
|
78
|
-
|
|
79
|
-
const nextIndent = this._indentBehavior.getNextIndent( currentIndent );
|
|
80
|
-
|
|
81
|
-
if ( nextIndent ) {
|
|
82
|
-
writer.setAttribute( 'blockIndent', nextIndent, block );
|
|
83
|
-
} else {
|
|
84
|
-
writer.removeAttribute( 'blockIndent', block );
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
} );
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Returns blocks from selection that should have blockIndent selection set.
|
|
92
|
-
//
|
|
93
|
-
// @param {module:engine/model/model~model} model A model.
|
|
94
|
-
function getBlocksToChange( model ) {
|
|
95
|
-
const selection = model.document.selection;
|
|
96
|
-
const schema = model.schema;
|
|
97
|
-
const blocksInSelection = Array.from( selection.getSelectedBlocks() );
|
|
98
|
-
|
|
99
|
-
return blocksInSelection.filter( block => schema.checkAttribute( block, 'blockIndent' ) );
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of the command.
|
|
31
|
+
*/
|
|
32
|
+
constructor(editor, indentBehavior) {
|
|
33
|
+
super(editor);
|
|
34
|
+
this._indentBehavior = indentBehavior;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
refresh() {
|
|
40
|
+
// Check whether any of the position's ancestors is a list item.
|
|
41
|
+
const editor = this.editor;
|
|
42
|
+
const model = editor.model;
|
|
43
|
+
const block = first(model.document.selection.getSelectedBlocks());
|
|
44
|
+
if (!block || !model.schema.checkAttribute(block, 'blockIndent')) {
|
|
45
|
+
this.isEnabled = false;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.isEnabled = this._indentBehavior.checkEnabled(block.getAttribute('blockIndent'));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
*/
|
|
53
|
+
execute() {
|
|
54
|
+
const model = this.editor.model;
|
|
55
|
+
const blocksToChange = getBlocksToChange(model);
|
|
56
|
+
model.change(writer => {
|
|
57
|
+
for (const block of blocksToChange) {
|
|
58
|
+
const currentIndent = block.getAttribute('blockIndent');
|
|
59
|
+
const nextIndent = this._indentBehavior.getNextIndent(currentIndent);
|
|
60
|
+
if (nextIndent) {
|
|
61
|
+
writer.setAttribute('blockIndent', nextIndent, block);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
writer.removeAttribute('blockIndent', block);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
100
69
|
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Provides indentation behavior to {@link module:indent/indentblockcommand~IndentBlockCommand}.
|
|
104
|
-
*
|
|
105
|
-
* @interface module:indent/indentblockcommand~IndentBehavior
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
70
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* @method #checkEnabled
|
|
112
|
-
* @param {String} indentAttributeValue The current indent attribute value.
|
|
113
|
-
* @returns {Boolean}
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Returns a new indent attribute value based on the current indent. This method returns `undefined` when the indentation should be removed.
|
|
118
|
-
*
|
|
119
|
-
* @method #getNextIndent
|
|
120
|
-
* @param {String} indentAttributeValue The current indent attribute value.
|
|
121
|
-
* @returns {String|undefined}
|
|
71
|
+
* Returns blocks from selection that should have blockIndent selection set.
|
|
122
72
|
*/
|
|
73
|
+
function getBlocksToChange(model) {
|
|
74
|
+
const selection = model.document.selection;
|
|
75
|
+
const schema = model.schema;
|
|
76
|
+
const blocksInSelection = Array.from(selection.getSelectedBlocks());
|
|
77
|
+
return blocksInSelection.filter(block => schema.checkAttribute(block, 'blockIndent'));
|
|
78
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 indent/indentcommandbehavior/indentbehavior
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Provides indentation behavior to {@link module:indent/indentblockcommand~IndentBlockCommand}.
|
|
10
|
+
*/
|
|
11
|
+
export interface IndentBehavior {
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the command should be enabled.
|
|
14
|
+
*/
|
|
15
|
+
checkEnabled: (indentAttributeValue: string) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a new indent attribute value based on the current indent.
|
|
18
|
+
* This method returns `undefined` when the indentation should be removed.
|
|
19
|
+
*/
|
|
20
|
+
getNextIndent: (indentAttributeValue: string) => string | undefined;
|
|
21
|
+
}
|
|
@@ -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
|
+
/**
|
|
6
|
+
* @module indent/indentcommandbehavior/indentusingclasses
|
|
7
|
+
*/
|
|
8
|
+
import type { IndentBehavior } from './indentbehavior';
|
|
9
|
+
/**
|
|
10
|
+
* The block indentation behavior that uses classes to set indentation.
|
|
11
|
+
*/
|
|
12
|
+
export default class IndentUsingClasses implements IndentBehavior {
|
|
13
|
+
/**
|
|
14
|
+
* The direction of indentation.
|
|
15
|
+
*/
|
|
16
|
+
isForward: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* A list of classes used for indentation.
|
|
19
|
+
*/
|
|
20
|
+
classes: Array<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of the indentation behavior.
|
|
23
|
+
*
|
|
24
|
+
* @param config.direction The direction of indentation.
|
|
25
|
+
* @param config.classes A list of classes used for indentation.
|
|
26
|
+
*/
|
|
27
|
+
constructor(config: {
|
|
28
|
+
direction: 'forward' | 'backward';
|
|
29
|
+
classes: Array<string>;
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
checkEnabled(indentAttributeValue: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
getNextIndent(indentAttributeValue: string): string | undefined;
|
|
39
|
+
}
|
|
@@ -2,60 +2,38 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @module indent/indentcommandbehavior/indentusingclasses
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
/**
|
|
11
6
|
* The block indentation behavior that uses classes to set indentation.
|
|
12
|
-
*
|
|
13
|
-
* @implements module:indent/indentblockcommand~IndentBehavior
|
|
14
7
|
*/
|
|
15
8
|
export default class IndentUsingClasses {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return currentIndex < this.classes.length - 1;
|
|
47
|
-
} else {
|
|
48
|
-
return currentIndex >= 0;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @inheritDoc
|
|
54
|
-
*/
|
|
55
|
-
getNextIndent( indentAttributeValue ) {
|
|
56
|
-
const currentIndex = this.classes.indexOf( indentAttributeValue );
|
|
57
|
-
const indexStep = this.isForward ? 1 : -1;
|
|
58
|
-
|
|
59
|
-
return this.classes[ currentIndex + indexStep ];
|
|
60
|
-
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of the indentation behavior.
|
|
11
|
+
*
|
|
12
|
+
* @param config.direction The direction of indentation.
|
|
13
|
+
* @param config.classes A list of classes used for indentation.
|
|
14
|
+
*/
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.isForward = config.direction === 'forward';
|
|
17
|
+
this.classes = config.classes;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
checkEnabled(indentAttributeValue) {
|
|
23
|
+
const currentIndex = this.classes.indexOf(indentAttributeValue);
|
|
24
|
+
if (this.isForward) {
|
|
25
|
+
return currentIndex < this.classes.length - 1;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return currentIndex >= 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
getNextIndent(indentAttributeValue) {
|
|
35
|
+
const currentIndex = this.classes.indexOf(indentAttributeValue);
|
|
36
|
+
const indexStep = this.isForward ? 1 : -1;
|
|
37
|
+
return this.classes[currentIndex + indexStep];
|
|
38
|
+
}
|
|
61
39
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 indent/indentcommandbehavior/indentusingoffset
|
|
7
|
+
*/
|
|
8
|
+
import type { IndentBehavior } from './indentbehavior';
|
|
9
|
+
/**
|
|
10
|
+
* The block indentation behavior that uses offsets to set indentation.
|
|
11
|
+
*/
|
|
12
|
+
export default class IndentUsingOffset implements IndentBehavior {
|
|
13
|
+
/**
|
|
14
|
+
* The direction of indentation.
|
|
15
|
+
*/
|
|
16
|
+
isForward: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The offset of the next indentation step.
|
|
19
|
+
*/
|
|
20
|
+
offset: number;
|
|
21
|
+
/**
|
|
22
|
+
* Indentation unit.
|
|
23
|
+
*/
|
|
24
|
+
unit: string;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of the indentation behavior.
|
|
27
|
+
*
|
|
28
|
+
* @param config.direction The direction of indentation.
|
|
29
|
+
* @param config.offset The offset of the next indentation step.
|
|
30
|
+
* @param config.unit Indentation unit.
|
|
31
|
+
*/
|
|
32
|
+
constructor(config: {
|
|
33
|
+
direction: 'forward' | 'backward';
|
|
34
|
+
offset: number;
|
|
35
|
+
unit: string;
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
checkEnabled(indentAttributeValue: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @inheritDoc
|
|
43
|
+
*/
|
|
44
|
+
getNextIndent(indentAttributeValue: string): string | undefined;
|
|
45
|
+
}
|
|
@@ -2,73 +2,41 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @module indent/indentcommandbehavior/indentusingoffset
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
/**
|
|
11
6
|
* The block indentation behavior that uses offsets to set indentation.
|
|
12
|
-
*
|
|
13
|
-
* @implements module:indent/indentblockcommand~IndentBehavior
|
|
14
7
|
*/
|
|
15
8
|
export default class IndentUsingOffset {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
checkEnabled( indentAttributeValue ) {
|
|
51
|
-
const currentOffset = parseFloat( indentAttributeValue || 0 );
|
|
52
|
-
|
|
53
|
-
// The command is always enabled for forward indentation.
|
|
54
|
-
return this.isForward || currentOffset > 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @inheritDoc
|
|
59
|
-
*/
|
|
60
|
-
getNextIndent( indentAttributeValue ) {
|
|
61
|
-
const currentOffset = parseFloat( indentAttributeValue || 0 );
|
|
62
|
-
const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith( this.unit );
|
|
63
|
-
|
|
64
|
-
if ( !isSameUnit ) {
|
|
65
|
-
return this.isForward ? this.offset + this.unit : undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const nextOffset = this.isForward ? this.offset : -this.offset;
|
|
69
|
-
|
|
70
|
-
const offsetToSet = currentOffset + nextOffset;
|
|
71
|
-
|
|
72
|
-
return offsetToSet > 0 ? offsetToSet + this.unit : undefined;
|
|
73
|
-
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of the indentation behavior.
|
|
11
|
+
*
|
|
12
|
+
* @param config.direction The direction of indentation.
|
|
13
|
+
* @param config.offset The offset of the next indentation step.
|
|
14
|
+
* @param config.unit Indentation unit.
|
|
15
|
+
*/
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.isForward = config.direction === 'forward';
|
|
18
|
+
this.offset = config.offset;
|
|
19
|
+
this.unit = config.unit;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
checkEnabled(indentAttributeValue) {
|
|
25
|
+
const currentOffset = parseFloat(indentAttributeValue || '0');
|
|
26
|
+
// The command is always enabled for forward indentation.
|
|
27
|
+
return this.isForward || currentOffset > 0;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
getNextIndent(indentAttributeValue) {
|
|
33
|
+
const currentOffset = parseFloat(indentAttributeValue || '0');
|
|
34
|
+
const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith(this.unit);
|
|
35
|
+
if (!isSameUnit) {
|
|
36
|
+
return this.isForward ? this.offset + this.unit : undefined;
|
|
37
|
+
}
|
|
38
|
+
const nextOffset = this.isForward ? this.offset : -this.offset;
|
|
39
|
+
const offsetToSet = currentOffset + nextOffset;
|
|
40
|
+
return offsetToSet > 0 ? offsetToSet + this.unit : undefined;
|
|
41
|
+
}
|
|
74
42
|
}
|
|
@@ -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 indent/indentconfig
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the block indentation feature.
|
|
10
|
+
*
|
|
11
|
+
* If no {@link module:indent/indentconfig~IndentBlockConfig#classes} are set, the block indentation feature will use
|
|
12
|
+
* {@link module:indent/indentconfig~IndentBlockConfig#offset} and {@link module:indent/indentconfig~IndentBlockConfig#unit} to
|
|
13
|
+
* create indentation steps.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* ClassicEditor
|
|
17
|
+
* .create( editorElement, {
|
|
18
|
+
* indentBlock: {
|
|
19
|
+
* offset: 2,
|
|
20
|
+
* unit: 'em'
|
|
21
|
+
* }
|
|
22
|
+
* } )
|
|
23
|
+
* .then( ... )
|
|
24
|
+
* .catch( ... );
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Alternatively, the block indentation feature may set one of defined {@link module:indent/indentconfig~IndentBlockConfig#classes} as
|
|
28
|
+
* indentation steps:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* ClassicEditor
|
|
32
|
+
* .create( editorElement, {
|
|
33
|
+
* indentBlock: {
|
|
34
|
+
* classes: [
|
|
35
|
+
* 'indent-a', // The first step - smallest indentation.
|
|
36
|
+
* 'indent-b',
|
|
37
|
+
* 'indent-c',
|
|
38
|
+
* 'indent-d',
|
|
39
|
+
* 'indent-e' // The last step - biggest indentation.
|
|
40
|
+
* ]
|
|
41
|
+
* }
|
|
42
|
+
* } )
|
|
43
|
+
* .then( ... )
|
|
44
|
+
* .catch( ... );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* In the example above only 5 indentation steps will be available.
|
|
48
|
+
*
|
|
49
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
50
|
+
*/
|
|
51
|
+
export interface IndentBlockConfig {
|
|
52
|
+
/**
|
|
53
|
+
* The size of indentation {@link module:indent/indentconfig~IndentBlockConfig#unit units} for each indentation step.
|
|
54
|
+
*
|
|
55
|
+
* @default 40
|
|
56
|
+
*/
|
|
57
|
+
offset?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The unit used for indentation {@link module:indent/indentconfig~IndentBlockConfig#offset}.
|
|
60
|
+
*
|
|
61
|
+
* @default 'px'
|
|
62
|
+
*/
|
|
63
|
+
unit?: string;
|
|
64
|
+
/**
|
|
65
|
+
* An optional list of classes to use for indenting the editor content. If not set or set to an empty array, no classes will be used.
|
|
66
|
+
* The {@link module:indent/indentconfig~IndentBlockConfig#unit `indentBlock.unit`} and
|
|
67
|
+
* {@link module:indent/indentconfig~IndentBlockConfig#offset `indentBlock.offset`} properties will be used instead.
|
|
68
|
+
*
|
|
69
|
+
* @default undefined
|
|
70
|
+
*/
|
|
71
|
+
classes?: Array<string>;
|
|
72
|
+
}
|
|
73
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
74
|
+
interface EditorConfig {
|
|
75
|
+
/**
|
|
76
|
+
* The configuration of the {@link module:indent/indentblock~IndentBlock block indentation feature}.
|
|
77
|
+
*
|
|
78
|
+
* Read more in {@link module:indent/indentconfig~IndentBlockConfig}.
|
|
79
|
+
*/
|
|
80
|
+
indentBlock?: IndentBlockConfig;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 indent/indentediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The indent editing feature.
|
|
11
|
+
*
|
|
12
|
+
* This plugin registers the `'indent'` and `'outdent'` commands.
|
|
13
|
+
*
|
|
14
|
+
* **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
|
|
15
|
+
* {@link module:indent/indent~Indent indent feature} API documentation.
|
|
16
|
+
*/
|
|
17
|
+
export default class IndentEditing extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): 'IndentEditing';
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
init(): void;
|
|
26
|
+
}
|
package/src/indentediting.js
CHANGED
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module indent/indentediting
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin, MultiCommand } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* The indent editing feature.
|
|
14
11
|
*
|
|
@@ -16,24 +13,20 @@ import { Plugin, MultiCommand } from 'ckeditor5/src/core';
|
|
|
16
13
|
*
|
|
17
14
|
* **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
|
|
18
15
|
* {@link module:indent/indent~Indent indent feature} API documentation.
|
|
19
|
-
*
|
|
20
|
-
* @extends module:core/plugin~Plugin
|
|
21
16
|
*/
|
|
22
17
|
export default class IndentEditing extends Plugin {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
editor.commands.add( 'outdent', new MultiCommand( editor ) );
|
|
38
|
-
}
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName() {
|
|
22
|
+
return 'IndentEditing';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
init() {
|
|
28
|
+
const editor = this.editor;
|
|
29
|
+
editor.commands.add('indent', new MultiCommand(editor));
|
|
30
|
+
editor.commands.add('outdent', new MultiCommand(editor));
|
|
31
|
+
}
|
|
39
32
|
}
|