@ckeditor/ckeditor5-indent 39.0.1 → 40.0.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.
Files changed (80) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/indent.js +1 -1
  4. package/build/indent.js.map +1 -0
  5. package/lang/translations/ar.po +1 -0
  6. package/lang/translations/az.po +1 -0
  7. package/lang/translations/bg.po +1 -0
  8. package/lang/translations/bn.po +1 -0
  9. package/lang/translations/ca.po +1 -0
  10. package/lang/translations/cs.po +1 -0
  11. package/lang/translations/da.po +1 -0
  12. package/lang/translations/de-ch.po +1 -0
  13. package/lang/translations/de.po +1 -0
  14. package/lang/translations/el.po +1 -0
  15. package/lang/translations/en-au.po +1 -0
  16. package/lang/translations/en-gb.po +1 -0
  17. package/lang/translations/en.po +1 -0
  18. package/lang/translations/es.po +1 -0
  19. package/lang/translations/et.po +1 -0
  20. package/lang/translations/fa.po +1 -0
  21. package/lang/translations/fi.po +1 -0
  22. package/lang/translations/fr.po +1 -0
  23. package/lang/translations/gl.po +1 -0
  24. package/lang/translations/he.po +1 -0
  25. package/lang/translations/hi.po +1 -0
  26. package/lang/translations/hr.po +1 -0
  27. package/lang/translations/hu.po +1 -0
  28. package/lang/translations/id.po +1 -0
  29. package/lang/translations/it.po +1 -0
  30. package/lang/translations/ja.po +1 -0
  31. package/lang/translations/ko.po +1 -0
  32. package/lang/translations/ku.po +1 -0
  33. package/lang/translations/lt.po +1 -0
  34. package/lang/translations/lv.po +1 -0
  35. package/lang/translations/ms.po +1 -0
  36. package/lang/translations/ne.po +1 -0
  37. package/lang/translations/nl.po +1 -0
  38. package/lang/translations/no.po +1 -0
  39. package/lang/translations/pl.po +1 -0
  40. package/lang/translations/pt-br.po +1 -0
  41. package/lang/translations/pt.po +1 -0
  42. package/lang/translations/ro.po +1 -0
  43. package/lang/translations/ru.po +1 -0
  44. package/lang/translations/sk.po +1 -0
  45. package/lang/translations/sr-latn.po +1 -0
  46. package/lang/translations/sr.po +1 -0
  47. package/lang/translations/sv.po +1 -0
  48. package/lang/translations/th.po +1 -0
  49. package/lang/translations/tk.po +1 -0
  50. package/lang/translations/tr.po +1 -0
  51. package/lang/translations/ug.po +1 -0
  52. package/lang/translations/uk.po +1 -0
  53. package/lang/translations/ur.po +1 -0
  54. package/lang/translations/uz.po +1 -0
  55. package/lang/translations/vi.po +1 -0
  56. package/lang/translations/zh-cn.po +1 -0
  57. package/lang/translations/zh.po +1 -0
  58. package/package.json +2 -6
  59. package/src/augmentation.d.ts +24 -24
  60. package/src/augmentation.js +5 -5
  61. package/src/indent.d.ts +40 -40
  62. package/src/indent.js +44 -44
  63. package/src/indentblock.d.ts +42 -42
  64. package/src/indentblock.js +147 -142
  65. package/src/indentblockcommand.d.ts +56 -45
  66. package/src/indentblockcommand.js +98 -78
  67. package/src/indentcommandbehavior/indentbehavior.d.ts +25 -21
  68. package/src/indentcommandbehavior/indentbehavior.js +5 -5
  69. package/src/indentcommandbehavior/indentusingclasses.d.ts +39 -39
  70. package/src/indentcommandbehavior/indentusingclasses.js +39 -39
  71. package/src/indentcommandbehavior/indentusingoffset.d.ts +45 -45
  72. package/src/indentcommandbehavior/indentusingoffset.js +42 -42
  73. package/src/indentconfig.d.ts +72 -72
  74. package/src/indentconfig.js +5 -5
  75. package/src/indentediting.d.ts +26 -26
  76. package/src/indentediting.js +32 -32
  77. package/src/indentui.d.ts +27 -27
  78. package/src/indentui.js +60 -60
  79. package/src/index.d.ts +14 -14
  80. package/src/index.js +12 -12
@@ -1,142 +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) => 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';
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,45 +1,56 @@
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/indentblockcommand
7
- */
8
- import { Command, type Editor } from 'ckeditor5/src/core';
9
- import type { IndentBehavior } from './indentcommandbehavior/indentbehavior';
10
- /**
11
- * The indent block command.
12
- *
13
- * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and
14
- * `'outdentBlock'` for outdenting blocks.
15
- *
16
- * To increase block indentation at the current selection, execute the command:
17
- *
18
- * ```ts
19
- * editor.execute( 'indentBlock' );
20
- * ```
21
- *
22
- * To decrease block indentation at the current selection, execute the command:
23
- *
24
- * ```ts
25
- * editor.execute( 'outdentBlock' );
26
- * ```
27
- */
28
- export default class IndentBlockCommand extends Command {
29
- /**
30
- * The command's indentation behavior.
31
- */
32
- private readonly _indentBehavior;
33
- /**
34
- * Creates an instance of the command.
35
- */
36
- constructor(editor: Editor, indentBehavior: IndentBehavior);
37
- /**
38
- * @inheritDoc
39
- */
40
- refresh(): void;
41
- /**
42
- * @inheritDoc
43
- */
44
- execute(): void;
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/indentblockcommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core';
9
+ import type { IndentBehavior } from './indentcommandbehavior/indentbehavior';
10
+ /**
11
+ * The indent block command.
12
+ *
13
+ * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and
14
+ * `'outdentBlock'` for outdenting blocks.
15
+ *
16
+ * To increase block indentation at the current selection, execute the command:
17
+ *
18
+ * ```ts
19
+ * editor.execute( 'indentBlock' );
20
+ * ```
21
+ *
22
+ * To decrease block indentation at the current selection, execute the command:
23
+ *
24
+ * ```ts
25
+ * editor.execute( 'outdentBlock' );
26
+ * ```
27
+ */
28
+ export default class IndentBlockCommand extends Command {
29
+ /**
30
+ * The command's indentation behavior.
31
+ */
32
+ private readonly _indentBehavior;
33
+ /**
34
+ * Creates an instance of the command.
35
+ */
36
+ constructor(editor: Editor, indentBehavior: IndentBehavior);
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ refresh(): void;
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ execute(): void;
45
+ /**
46
+ * Returns blocks from selection that should have blockIndent selection set.
47
+ */
48
+ private _getBlocksToChange;
49
+ /**
50
+ * Returns false if indentation cannot be applied, i.e.:
51
+ * - for blocks disallowed by schema declaration
52
+ * - for blocks in Document Lists (disallowed forward indentation only). See https://github.com/ckeditor/ckeditor5/issues/14155.
53
+ * Otherwise returns true.
54
+ */
55
+ private _isIndentationChangeAllowed;
56
+ }
@@ -1,78 +1,98 @@
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/indentblockcommand
7
- */
8
- import { Command } from 'ckeditor5/src/core';
9
- import { first } from 'ckeditor5/src/utils';
10
- /**
11
- * The indent block command.
12
- *
13
- * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and
14
- * `'outdentBlock'` for outdenting blocks.
15
- *
16
- * To increase block indentation at the current selection, execute the command:
17
- *
18
- * ```ts
19
- * editor.execute( 'indentBlock' );
20
- * ```
21
- *
22
- * To decrease block indentation at the current selection, execute the command:
23
- *
24
- * ```ts
25
- * editor.execute( 'outdentBlock' );
26
- * ```
27
- */
28
- export default class IndentBlockCommand extends Command {
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
- }
69
- }
70
- /**
71
- * Returns blocks from selection that should have blockIndent selection set.
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
- }
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/indentblockcommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core';
9
+ import { first } from 'ckeditor5/src/utils';
10
+ /**
11
+ * The indent block command.
12
+ *
13
+ * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and
14
+ * `'outdentBlock'` for outdenting blocks.
15
+ *
16
+ * To increase block indentation at the current selection, execute the command:
17
+ *
18
+ * ```ts
19
+ * editor.execute( 'indentBlock' );
20
+ * ```
21
+ *
22
+ * To decrease block indentation at the current selection, execute the command:
23
+ *
24
+ * ```ts
25
+ * editor.execute( 'outdentBlock' );
26
+ * ```
27
+ */
28
+ export default class IndentBlockCommand extends Command {
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
+ const editor = this.editor;
41
+ const model = editor.model;
42
+ const block = first(model.document.selection.getSelectedBlocks());
43
+ if (!block || !this._isIndentationChangeAllowed(block)) {
44
+ this.isEnabled = false;
45
+ return;
46
+ }
47
+ this.isEnabled = this._indentBehavior.checkEnabled(block.getAttribute('blockIndent'));
48
+ }
49
+ /**
50
+ * @inheritDoc
51
+ */
52
+ execute() {
53
+ const model = this.editor.model;
54
+ const blocksToChange = this._getBlocksToChange();
55
+ model.change(writer => {
56
+ for (const block of blocksToChange) {
57
+ const currentIndent = block.getAttribute('blockIndent');
58
+ const nextIndent = this._indentBehavior.getNextIndent(currentIndent);
59
+ if (nextIndent) {
60
+ writer.setAttribute('blockIndent', nextIndent, block);
61
+ }
62
+ else {
63
+ writer.removeAttribute('blockIndent', block);
64
+ }
65
+ }
66
+ });
67
+ }
68
+ /**
69
+ * Returns blocks from selection that should have blockIndent selection set.
70
+ */
71
+ _getBlocksToChange() {
72
+ const model = this.editor.model;
73
+ const selection = model.document.selection;
74
+ const blocksInSelection = Array.from(selection.getSelectedBlocks());
75
+ return blocksInSelection.filter(block => this._isIndentationChangeAllowed(block));
76
+ }
77
+ /**
78
+ * Returns false if indentation cannot be applied, i.e.:
79
+ * - for blocks disallowed by schema declaration
80
+ * - for blocks in Document Lists (disallowed forward indentation only). See https://github.com/ckeditor/ckeditor5/issues/14155.
81
+ * Otherwise returns true.
82
+ */
83
+ _isIndentationChangeAllowed(element) {
84
+ const editor = this.editor;
85
+ if (!editor.model.schema.checkAttribute(element, 'blockIndent')) {
86
+ return false;
87
+ }
88
+ if (!editor.plugins.has('DocumentListUtils')) {
89
+ return true;
90
+ }
91
+ // Only forward indentation is disallowed in list items. This allows the user to outdent blocks that are already indented.
92
+ if (!this._indentBehavior.isForward) {
93
+ return true;
94
+ }
95
+ const documentListUtils = editor.plugins.get('DocumentListUtils');
96
+ return !documentListUtils.isListItemBlock(element);
97
+ }
98
+ }
@@ -1,21 +1,25 @@
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
- }
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
+ * The direction of indentation.
14
+ */
15
+ isForward: boolean;
16
+ /**
17
+ * Checks if the command should be enabled.
18
+ */
19
+ checkEnabled: (indentAttributeValue: string) => boolean;
20
+ /**
21
+ * Returns a new indent attribute value based on the current indent.
22
+ * This method returns `undefined` when the indentation should be removed.
23
+ */
24
+ getNextIndent: (indentAttributeValue: string) => string | undefined;
25
+ }
@@ -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 {};