@ckeditor/ckeditor5-indent 38.1.1 → 38.2.0-alpha.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-indent",
3
- "version": "38.1.1",
3
+ "version": "38.2.0-alpha.1",
4
4
  "description": "Block indentation feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -11,8 +11,9 @@
11
11
  "ckeditor5-dll"
12
12
  ],
13
13
  "main": "src/index.js",
14
+ "type": "module",
14
15
  "dependencies": {
15
- "ckeditor5": "38.1.1"
16
+ "ckeditor5": "38.2.0-alpha.1"
16
17
  },
17
18
  "engines": {
18
19
  "node": ">=16.0.0",
@@ -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.js';
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,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.js';
9
+ import IndentEditing from './indentediting.js';
10
+ import IndentUI from './indentui.js';
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.js';
9
+ import IndentEditing from './indentediting.js';
10
+ import IndentUI from './indentui.js';
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,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.js';
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,142 +1,142 @@
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) => viewElement.getStyle(marginProperty)
108
- }
109
- });
110
- conversion.for('downcast').attributeToAttribute({
111
- model: 'blockIndent',
112
- view: modelAttributeValue => {
113
- return {
114
- key: 'style',
115
- value: {
116
- [marginProperty]: modelAttributeValue
117
- }
118
- };
119
- }
120
- });
121
- }
122
- /**
123
- * Setups conversion for using classes.
124
- */
125
- _setupConversionUsingClasses(classes) {
126
- const definition = {
127
- model: {
128
- key: 'blockIndent',
129
- values: []
130
- },
131
- view: {}
132
- };
133
- for (const className of classes) {
134
- definition.model.values.push(className);
135
- definition.view[className] = {
136
- key: 'class',
137
- value: [className]
138
- };
139
- }
140
- this.editor.conversion.attributeToAttribute(definition);
141
- }
142
- }
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.js';
9
+ import { addMarginRules } from 'ckeditor5/src/engine.js';
10
+ import IndentBlockCommand from './indentblockcommand.js';
11
+ import IndentUsingOffset from './indentcommandbehavior/indentusingoffset.js';
12
+ import IndentUsingClasses from './indentcommandbehavior/indentusingclasses.js';
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) => viewElement.getStyle(marginProperty)
108
+ }
109
+ });
110
+ conversion.for('downcast').attributeToAttribute({
111
+ model: 'blockIndent',
112
+ view: modelAttributeValue => {
113
+ return {
114
+ key: 'style',
115
+ value: {
116
+ [marginProperty]: modelAttributeValue
117
+ }
118
+ };
119
+ }
120
+ });
121
+ }
122
+ /**
123
+ * Setups conversion for using classes.
124
+ */
125
+ _setupConversionUsingClasses(classes) {
126
+ const definition = {
127
+ model: {
128
+ key: 'blockIndent',
129
+ values: []
130
+ },
131
+ view: {}
132
+ };
133
+ for (const className of classes) {
134
+ definition.model.values.push(className);
135
+ definition.view[className] = {
136
+ key: 'class',
137
+ value: [className]
138
+ };
139
+ }
140
+ this.editor.conversion.attributeToAttribute(definition);
141
+ }
142
+ }