@ckeditor/ckeditor5-indent 40.0.0 → 40.1.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/LICENSE.md +2 -2
- package/package.json +2 -2
- package/src/augmentation.d.ts +24 -24
- package/src/augmentation.js +5 -5
- package/src/indent.d.ts +40 -40
- package/src/indent.js +44 -44
- package/src/indentblock.d.ts +42 -42
- package/src/indentblock.js +147 -147
- package/src/indentblockcommand.d.ts +56 -56
- package/src/indentblockcommand.js +98 -98
- package/src/indentcommandbehavior/indentbehavior.d.ts +25 -25
- package/src/indentcommandbehavior/indentbehavior.js +5 -5
- package/src/indentcommandbehavior/indentusingclasses.d.ts +39 -39
- package/src/indentcommandbehavior/indentusingclasses.js +39 -39
- package/src/indentcommandbehavior/indentusingoffset.d.ts +45 -45
- package/src/indentcommandbehavior/indentusingoffset.js +42 -42
- package/src/indentconfig.d.ts +72 -72
- package/src/indentconfig.js +5 -5
- package/src/indentediting.d.ts +26 -26
- package/src/indentediting.js +32 -32
- package/src/indentui.d.ts +27 -27
- package/src/indentui.js +60 -60
- package/src/index.d.ts +14 -14
- package/src/index.js +12 -12
- package/build/indent.js.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**CKEditor 5 block indentation feature** – https://github.com/ckeditor/ckeditor5-indent <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-indent",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.1.0",
|
|
4
4
|
"description": "Block indentation 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.1.0"
|
|
16
16
|
},
|
|
17
17
|
"author": "CKSource (http://cksource.com/)",
|
|
18
18
|
"license": "GPL-2.0-or-later",
|
package/src/augmentation.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
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 { IndentBlockConfig, Indent, IndentBlock, IndentUI, IndentBlockCommand } from './index';
|
|
6
|
-
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
-
interface EditorConfig {
|
|
8
|
-
/**
|
|
9
|
-
* The configuration of the {@link module:indent/indentblock~IndentBlock block indentation feature}.
|
|
10
|
-
*
|
|
11
|
-
* Read more in {@link module:indent/indentconfig~IndentBlockConfig}.
|
|
12
|
-
*/
|
|
13
|
-
indentBlock?: IndentBlockConfig;
|
|
14
|
-
}
|
|
15
|
-
interface PluginsMap {
|
|
16
|
-
[Indent.pluginName]: Indent;
|
|
17
|
-
[IndentBlock.pluginName]: IndentBlock;
|
|
18
|
-
[IndentUI.pluginName]: IndentUI;
|
|
19
|
-
}
|
|
20
|
-
interface CommandsMap {
|
|
21
|
-
indentBlock: IndentBlockCommand;
|
|
22
|
-
outdentBlock: IndentBlockCommand;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
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 { IndentBlockConfig, Indent, IndentBlock, IndentUI, IndentBlockCommand } from './index';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface EditorConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the {@link module:indent/indentblock~IndentBlock block indentation feature}.
|
|
10
|
+
*
|
|
11
|
+
* Read more in {@link module:indent/indentconfig~IndentBlockConfig}.
|
|
12
|
+
*/
|
|
13
|
+
indentBlock?: IndentBlockConfig;
|
|
14
|
+
}
|
|
15
|
+
interface PluginsMap {
|
|
16
|
+
[Indent.pluginName]: Indent;
|
|
17
|
+
[IndentBlock.pluginName]: IndentBlock;
|
|
18
|
+
[IndentUI.pluginName]: IndentUI;
|
|
19
|
+
}
|
|
20
|
+
interface CommandsMap {
|
|
21
|
+
indentBlock: IndentBlockCommand;
|
|
22
|
+
outdentBlock: IndentBlockCommand;
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/augmentation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
export {};
|
|
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
|
+
export {};
|
package/src/indent.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
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/indent
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import IndentEditing from './indentediting';
|
|
10
|
-
import IndentUI from './indentui';
|
|
11
|
-
/**
|
|
12
|
-
* The indent feature.
|
|
13
|
-
*
|
|
14
|
-
* This plugin acts as a single entry point plugin for other features that implement indentation of elements like lists or paragraphs.
|
|
15
|
-
*
|
|
16
|
-
* The compatible features are:
|
|
17
|
-
*
|
|
18
|
-
* * The {@link module:list/list~List} or {@link module:list/list/listediting~ListEditing} feature for list indentation.
|
|
19
|
-
* * The {@link module:indent/indentblock~IndentBlock} feature for block indentation.
|
|
20
|
-
*
|
|
21
|
-
* This is a "glue" plugin that loads the following plugins:
|
|
22
|
-
*
|
|
23
|
-
* * The {@link module:indent/indentediting~IndentEditing indent editing feature}.
|
|
24
|
-
* * The {@link module:indent/indentui~IndentUI indent UI feature}.
|
|
25
|
-
*
|
|
26
|
-
* The dependent plugins register the `'indent'` and `'outdent'` commands and introduce the `'indent'` and `'outdent'` buttons
|
|
27
|
-
* that allow to increase or decrease text indentation of supported elements.
|
|
28
|
-
*
|
|
29
|
-
* **Note**: In order for the commands and buttons to work, at least one of compatible features is required.
|
|
30
|
-
*/
|
|
31
|
-
export default class Indent extends Plugin {
|
|
32
|
-
/**
|
|
33
|
-
* @inheritDoc
|
|
34
|
-
*/
|
|
35
|
-
static get pluginName(): "Indent";
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
static get requires(): readonly [typeof IndentEditing, typeof IndentUI];
|
|
40
|
-
}
|
|
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/indent
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import IndentEditing from './indentediting';
|
|
10
|
+
import IndentUI from './indentui';
|
|
11
|
+
/**
|
|
12
|
+
* The indent feature.
|
|
13
|
+
*
|
|
14
|
+
* This plugin acts as a single entry point plugin for other features that implement indentation of elements like lists or paragraphs.
|
|
15
|
+
*
|
|
16
|
+
* The compatible features are:
|
|
17
|
+
*
|
|
18
|
+
* * The {@link module:list/list~List} or {@link module:list/list/listediting~ListEditing} feature for list indentation.
|
|
19
|
+
* * The {@link module:indent/indentblock~IndentBlock} feature for block indentation.
|
|
20
|
+
*
|
|
21
|
+
* This is a "glue" plugin that loads the following plugins:
|
|
22
|
+
*
|
|
23
|
+
* * The {@link module:indent/indentediting~IndentEditing indent editing feature}.
|
|
24
|
+
* * The {@link module:indent/indentui~IndentUI indent UI feature}.
|
|
25
|
+
*
|
|
26
|
+
* The dependent plugins register the `'indent'` and `'outdent'` commands and introduce the `'indent'` and `'outdent'` buttons
|
|
27
|
+
* that allow to increase or decrease text indentation of supported elements.
|
|
28
|
+
*
|
|
29
|
+
* **Note**: In order for the commands and buttons to work, at least one of compatible features is required.
|
|
30
|
+
*/
|
|
31
|
+
export default class Indent extends Plugin {
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
static get pluginName(): "Indent";
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
static get requires(): readonly [typeof IndentEditing, typeof IndentUI];
|
|
40
|
+
}
|
package/src/indent.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
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/indent
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import IndentEditing from './indentediting';
|
|
10
|
-
import IndentUI from './indentui';
|
|
11
|
-
/**
|
|
12
|
-
* The indent feature.
|
|
13
|
-
*
|
|
14
|
-
* This plugin acts as a single entry point plugin for other features that implement indentation of elements like lists or paragraphs.
|
|
15
|
-
*
|
|
16
|
-
* The compatible features are:
|
|
17
|
-
*
|
|
18
|
-
* * The {@link module:list/list~List} or {@link module:list/list/listediting~ListEditing} feature for list indentation.
|
|
19
|
-
* * The {@link module:indent/indentblock~IndentBlock} feature for block indentation.
|
|
20
|
-
*
|
|
21
|
-
* This is a "glue" plugin that loads the following plugins:
|
|
22
|
-
*
|
|
23
|
-
* * The {@link module:indent/indentediting~IndentEditing indent editing feature}.
|
|
24
|
-
* * The {@link module:indent/indentui~IndentUI indent UI feature}.
|
|
25
|
-
*
|
|
26
|
-
* The dependent plugins register the `'indent'` and `'outdent'` commands and introduce the `'indent'` and `'outdent'` buttons
|
|
27
|
-
* that allow to increase or decrease text indentation of supported elements.
|
|
28
|
-
*
|
|
29
|
-
* **Note**: In order for the commands and buttons to work, at least one of compatible features is required.
|
|
30
|
-
*/
|
|
31
|
-
export default class Indent extends Plugin {
|
|
32
|
-
/**
|
|
33
|
-
* @inheritDoc
|
|
34
|
-
*/
|
|
35
|
-
static get pluginName() {
|
|
36
|
-
return 'Indent';
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @inheritDoc
|
|
40
|
-
*/
|
|
41
|
-
static get requires() {
|
|
42
|
-
return [IndentEditing, IndentUI];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
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/indent
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import IndentEditing from './indentediting';
|
|
10
|
+
import IndentUI from './indentui';
|
|
11
|
+
/**
|
|
12
|
+
* The indent feature.
|
|
13
|
+
*
|
|
14
|
+
* This plugin acts as a single entry point plugin for other features that implement indentation of elements like lists or paragraphs.
|
|
15
|
+
*
|
|
16
|
+
* The compatible features are:
|
|
17
|
+
*
|
|
18
|
+
* * The {@link module:list/list~List} or {@link module:list/list/listediting~ListEditing} feature for list indentation.
|
|
19
|
+
* * The {@link module:indent/indentblock~IndentBlock} feature for block indentation.
|
|
20
|
+
*
|
|
21
|
+
* This is a "glue" plugin that loads the following plugins:
|
|
22
|
+
*
|
|
23
|
+
* * The {@link module:indent/indentediting~IndentEditing indent editing feature}.
|
|
24
|
+
* * The {@link module:indent/indentui~IndentUI indent UI feature}.
|
|
25
|
+
*
|
|
26
|
+
* The dependent plugins register the `'indent'` and `'outdent'` commands and introduce the `'indent'` and `'outdent'` buttons
|
|
27
|
+
* that allow to increase or decrease text indentation of supported elements.
|
|
28
|
+
*
|
|
29
|
+
* **Note**: In order for the commands and buttons to work, at least one of compatible features is required.
|
|
30
|
+
*/
|
|
31
|
+
export default class Indent extends Plugin {
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
static get pluginName() {
|
|
36
|
+
return 'Indent';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
static get requires() {
|
|
42
|
+
return [IndentEditing, IndentUI];
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/indentblock.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
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/indentblock
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
9
|
-
/**
|
|
10
|
-
* The block indentation feature.
|
|
11
|
-
*
|
|
12
|
-
* It registers the `'indentBlock'` and `'outdentBlock'` commands.
|
|
13
|
-
*
|
|
14
|
-
* If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to
|
|
15
|
-
* the `'indent'` and `'outdent'` commands.
|
|
16
|
-
*/
|
|
17
|
-
export default class IndentBlock extends Plugin {
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
constructor(editor: Editor);
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
static get pluginName(): "IndentBlock";
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
init(): void;
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
afterInit(): void;
|
|
34
|
-
/**
|
|
35
|
-
* Setups conversion for using offset indents.
|
|
36
|
-
*/
|
|
37
|
-
private _setupConversionUsingOffset;
|
|
38
|
-
/**
|
|
39
|
-
* Setups conversion for using classes.
|
|
40
|
-
*/
|
|
41
|
-
private _setupConversionUsingClasses;
|
|
42
|
-
}
|
|
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/indentblock
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The block indentation feature.
|
|
11
|
+
*
|
|
12
|
+
* It registers the `'indentBlock'` and `'outdentBlock'` commands.
|
|
13
|
+
*
|
|
14
|
+
* If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to
|
|
15
|
+
* the `'indent'` and `'outdent'` commands.
|
|
16
|
+
*/
|
|
17
|
+
export default class IndentBlock extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
constructor(editor: Editor);
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): "IndentBlock";
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
afterInit(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Setups conversion for using offset indents.
|
|
36
|
+
*/
|
|
37
|
+
private _setupConversionUsingOffset;
|
|
38
|
+
/**
|
|
39
|
+
* Setups conversion for using classes.
|
|
40
|
+
*/
|
|
41
|
+
private _setupConversionUsingClasses;
|
|
42
|
+
}
|
package/src/indentblock.js
CHANGED
|
@@ -1,147 +1,147 @@
|
|
|
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/indentblock
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import { addMarginRules } from 'ckeditor5/src/engine';
|
|
10
|
-
import IndentBlockCommand from './indentblockcommand';
|
|
11
|
-
import IndentUsingOffset from './indentcommandbehavior/indentusingoffset';
|
|
12
|
-
import IndentUsingClasses from './indentcommandbehavior/indentusingclasses';
|
|
13
|
-
const DEFAULT_ELEMENTS = ['paragraph', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6'];
|
|
14
|
-
/**
|
|
15
|
-
* The block indentation feature.
|
|
16
|
-
*
|
|
17
|
-
* It registers the `'indentBlock'` and `'outdentBlock'` commands.
|
|
18
|
-
*
|
|
19
|
-
* If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to
|
|
20
|
-
* the `'indent'` and `'outdent'` commands.
|
|
21
|
-
*/
|
|
22
|
-
export default class IndentBlock extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
constructor(editor) {
|
|
27
|
-
super(editor);
|
|
28
|
-
editor.config.define('indentBlock', {
|
|
29
|
-
offset: 40,
|
|
30
|
-
unit: 'px'
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
static get pluginName() {
|
|
37
|
-
return 'IndentBlock';
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
init() {
|
|
43
|
-
const editor = this.editor;
|
|
44
|
-
const configuration = editor.config.get('indentBlock');
|
|
45
|
-
if (configuration.classes && configuration.classes.length) {
|
|
46
|
-
this._setupConversionUsingClasses(configuration.classes);
|
|
47
|
-
editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
|
|
48
|
-
direction: 'forward',
|
|
49
|
-
classes: configuration.classes
|
|
50
|
-
})));
|
|
51
|
-
editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
|
|
52
|
-
direction: 'backward',
|
|
53
|
-
classes: configuration.classes
|
|
54
|
-
})));
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
editor.data.addStyleProcessorRules(addMarginRules);
|
|
58
|
-
this._setupConversionUsingOffset();
|
|
59
|
-
editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
|
|
60
|
-
direction: 'forward',
|
|
61
|
-
offset: configuration.offset,
|
|
62
|
-
unit: configuration.unit
|
|
63
|
-
})));
|
|
64
|
-
editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
|
|
65
|
-
direction: 'backward',
|
|
66
|
-
offset: configuration.offset,
|
|
67
|
-
unit: configuration.unit
|
|
68
|
-
})));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @inheritDoc
|
|
73
|
-
*/
|
|
74
|
-
afterInit() {
|
|
75
|
-
const editor = this.editor;
|
|
76
|
-
const schema = editor.model.schema;
|
|
77
|
-
const indentCommand = editor.commands.get('indent');
|
|
78
|
-
const outdentCommand = editor.commands.get('outdent');
|
|
79
|
-
// Enable block indentation to heading configuration options. If it is not defined enable in paragraph and default headings.
|
|
80
|
-
const options = editor.config.get('heading.options');
|
|
81
|
-
const configuredElements = options && options.map(option => option.model);
|
|
82
|
-
const knownElements = configuredElements || DEFAULT_ELEMENTS;
|
|
83
|
-
knownElements.forEach(elementName => {
|
|
84
|
-
if (schema.isRegistered(elementName)) {
|
|
85
|
-
schema.extend(elementName, { allowAttributes: 'blockIndent' });
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
schema.setAttributeProperties('blockIndent', { isFormatting: true });
|
|
89
|
-
indentCommand.registerChildCommand(editor.commands.get('indentBlock'));
|
|
90
|
-
outdentCommand.registerChildCommand(editor.commands.get('outdentBlock'));
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Setups conversion for using offset indents.
|
|
94
|
-
*/
|
|
95
|
-
_setupConversionUsingOffset() {
|
|
96
|
-
const conversion = this.editor.conversion;
|
|
97
|
-
const locale = this.editor.locale;
|
|
98
|
-
const marginProperty = locale.contentLanguageDirection === 'rtl' ? 'margin-right' : 'margin-left';
|
|
99
|
-
conversion.for('upcast').attributeToAttribute({
|
|
100
|
-
view: {
|
|
101
|
-
styles: {
|
|
102
|
-
[marginProperty]: /[\s\S]+/
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
model: {
|
|
106
|
-
key: 'blockIndent',
|
|
107
|
-
value: (viewElement) => {
|
|
108
|
-
// Do not indent block elements in Document Lists. See https://github.com/ckeditor/ckeditor5/issues/12466.
|
|
109
|
-
if (!viewElement.is('element', 'li')) {
|
|
110
|
-
return viewElement.getStyle(marginProperty);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
conversion.for('downcast').attributeToAttribute({
|
|
116
|
-
model: 'blockIndent',
|
|
117
|
-
view: modelAttributeValue => {
|
|
118
|
-
return {
|
|
119
|
-
key: 'style',
|
|
120
|
-
value: {
|
|
121
|
-
[marginProperty]: modelAttributeValue
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Setups conversion for using classes.
|
|
129
|
-
*/
|
|
130
|
-
_setupConversionUsingClasses(classes) {
|
|
131
|
-
const definition = {
|
|
132
|
-
model: {
|
|
133
|
-
key: 'blockIndent',
|
|
134
|
-
values: []
|
|
135
|
-
},
|
|
136
|
-
view: {}
|
|
137
|
-
};
|
|
138
|
-
for (const className of classes) {
|
|
139
|
-
definition.model.values.push(className);
|
|
140
|
-
definition.view[className] = {
|
|
141
|
-
key: 'class',
|
|
142
|
-
value: [className]
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
this.editor.conversion.attributeToAttribute(definition);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
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/indentblock
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import { addMarginRules } from 'ckeditor5/src/engine';
|
|
10
|
+
import IndentBlockCommand from './indentblockcommand';
|
|
11
|
+
import IndentUsingOffset from './indentcommandbehavior/indentusingoffset';
|
|
12
|
+
import IndentUsingClasses from './indentcommandbehavior/indentusingclasses';
|
|
13
|
+
const DEFAULT_ELEMENTS = ['paragraph', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6'];
|
|
14
|
+
/**
|
|
15
|
+
* The block indentation feature.
|
|
16
|
+
*
|
|
17
|
+
* It registers the `'indentBlock'` and `'outdentBlock'` commands.
|
|
18
|
+
*
|
|
19
|
+
* If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to
|
|
20
|
+
* the `'indent'` and `'outdent'` commands.
|
|
21
|
+
*/
|
|
22
|
+
export default class IndentBlock extends Plugin {
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
constructor(editor) {
|
|
27
|
+
super(editor);
|
|
28
|
+
editor.config.define('indentBlock', {
|
|
29
|
+
offset: 40,
|
|
30
|
+
unit: 'px'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
static get pluginName() {
|
|
37
|
+
return 'IndentBlock';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
init() {
|
|
43
|
+
const editor = this.editor;
|
|
44
|
+
const configuration = editor.config.get('indentBlock');
|
|
45
|
+
if (configuration.classes && configuration.classes.length) {
|
|
46
|
+
this._setupConversionUsingClasses(configuration.classes);
|
|
47
|
+
editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
|
|
48
|
+
direction: 'forward',
|
|
49
|
+
classes: configuration.classes
|
|
50
|
+
})));
|
|
51
|
+
editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
|
|
52
|
+
direction: 'backward',
|
|
53
|
+
classes: configuration.classes
|
|
54
|
+
})));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
editor.data.addStyleProcessorRules(addMarginRules);
|
|
58
|
+
this._setupConversionUsingOffset();
|
|
59
|
+
editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
|
|
60
|
+
direction: 'forward',
|
|
61
|
+
offset: configuration.offset,
|
|
62
|
+
unit: configuration.unit
|
|
63
|
+
})));
|
|
64
|
+
editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
|
|
65
|
+
direction: 'backward',
|
|
66
|
+
offset: configuration.offset,
|
|
67
|
+
unit: configuration.unit
|
|
68
|
+
})));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @inheritDoc
|
|
73
|
+
*/
|
|
74
|
+
afterInit() {
|
|
75
|
+
const editor = this.editor;
|
|
76
|
+
const schema = editor.model.schema;
|
|
77
|
+
const indentCommand = editor.commands.get('indent');
|
|
78
|
+
const outdentCommand = editor.commands.get('outdent');
|
|
79
|
+
// Enable block indentation to heading configuration options. If it is not defined enable in paragraph and default headings.
|
|
80
|
+
const options = editor.config.get('heading.options');
|
|
81
|
+
const configuredElements = options && options.map(option => option.model);
|
|
82
|
+
const knownElements = configuredElements || DEFAULT_ELEMENTS;
|
|
83
|
+
knownElements.forEach(elementName => {
|
|
84
|
+
if (schema.isRegistered(elementName)) {
|
|
85
|
+
schema.extend(elementName, { allowAttributes: 'blockIndent' });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
schema.setAttributeProperties('blockIndent', { isFormatting: true });
|
|
89
|
+
indentCommand.registerChildCommand(editor.commands.get('indentBlock'));
|
|
90
|
+
outdentCommand.registerChildCommand(editor.commands.get('outdentBlock'));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Setups conversion for using offset indents.
|
|
94
|
+
*/
|
|
95
|
+
_setupConversionUsingOffset() {
|
|
96
|
+
const conversion = this.editor.conversion;
|
|
97
|
+
const locale = this.editor.locale;
|
|
98
|
+
const marginProperty = locale.contentLanguageDirection === 'rtl' ? 'margin-right' : 'margin-left';
|
|
99
|
+
conversion.for('upcast').attributeToAttribute({
|
|
100
|
+
view: {
|
|
101
|
+
styles: {
|
|
102
|
+
[marginProperty]: /[\s\S]+/
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
model: {
|
|
106
|
+
key: 'blockIndent',
|
|
107
|
+
value: (viewElement) => {
|
|
108
|
+
// Do not indent block elements in Document Lists. See https://github.com/ckeditor/ckeditor5/issues/12466.
|
|
109
|
+
if (!viewElement.is('element', 'li')) {
|
|
110
|
+
return viewElement.getStyle(marginProperty);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
conversion.for('downcast').attributeToAttribute({
|
|
116
|
+
model: 'blockIndent',
|
|
117
|
+
view: modelAttributeValue => {
|
|
118
|
+
return {
|
|
119
|
+
key: 'style',
|
|
120
|
+
value: {
|
|
121
|
+
[marginProperty]: modelAttributeValue
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Setups conversion for using classes.
|
|
129
|
+
*/
|
|
130
|
+
_setupConversionUsingClasses(classes) {
|
|
131
|
+
const definition = {
|
|
132
|
+
model: {
|
|
133
|
+
key: 'blockIndent',
|
|
134
|
+
values: []
|
|
135
|
+
},
|
|
136
|
+
view: {}
|
|
137
|
+
};
|
|
138
|
+
for (const className of classes) {
|
|
139
|
+
definition.model.values.push(className);
|
|
140
|
+
definition.view[className] = {
|
|
141
|
+
key: 'class',
|
|
142
|
+
value: [className]
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
this.editor.conversion.attributeToAttribute(definition);
|
|
146
|
+
}
|
|
147
|
+
}
|