@ckeditor/ckeditor5-indent 48.2.0 → 48.3.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/dist/index.js CHANGED
@@ -2,958 +2,936 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import { Plugin, MultiCommand, Command } from '@ckeditor/ckeditor5-core/dist/index.js';
6
- import { ButtonView, MenuBarMenuListItemButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
7
- import { IconIndent, IconOutdent } from '@ckeditor/ckeditor5-icons/dist/index.js';
8
- import { addMarginStylesRules } from '@ckeditor/ckeditor5-engine/dist/index.js';
9
- import { first } from '@ckeditor/ckeditor5-utils/dist/index.js';
10
- import { _isListItemBlock } from '@ckeditor/ckeditor5-list/dist/index.js';
5
+ import { Command, MultiCommand, Plugin } from "@ckeditor/ckeditor5-core";
6
+ import { ButtonView, MenuBarMenuListItemButtonView } from "@ckeditor/ckeditor5-ui";
7
+ import { IconIndent, IconOutdent } from "@ckeditor/ckeditor5-icons";
8
+ import { addMarginStylesRules } from "@ckeditor/ckeditor5-engine";
9
+ import { first } from "@ckeditor/ckeditor5-utils";
10
+ import { _isListItemBlock } from "@ckeditor/ckeditor5-list";
11
11
 
12
12
  /**
13
- * The indent editing feature.
14
- *
15
- * This plugin registers the `'indent'` and `'outdent'` commands.
16
- *
17
- * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
18
- * {@link module:indent/indent~Indent indent feature} API documentation.
19
- */ class IndentEditing extends Plugin {
20
- /**
21
- * @inheritDoc
22
- */ static get pluginName() {
23
- return 'IndentEditing';
24
- }
25
- /**
26
- * @inheritDoc
27
- */ static get isOfficialPlugin() {
28
- return true;
29
- }
30
- /**
31
- * @inheritDoc
32
- */ init() {
33
- const editor = this.editor;
34
- editor.commands.add('indent', new MultiCommand(editor));
35
- editor.commands.add('outdent', new MultiCommand(editor));
36
- }
37
- }
13
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
14
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
15
+ */
16
+ /**
17
+ * @module indent/indentediting
18
+ */
19
+ /**
20
+ * The indent editing feature.
21
+ *
22
+ * This plugin registers the `'indent'` and `'outdent'` commands.
23
+ *
24
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the
25
+ * {@link module:indent/indent~Indent indent feature} API documentation.
26
+ */
27
+ var IndentEditing = class extends Plugin {
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get pluginName() {
32
+ return "IndentEditing";
33
+ }
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get isOfficialPlugin() {
38
+ return true;
39
+ }
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ init() {
44
+ const editor = this.editor;
45
+ editor.commands.add("indent", new MultiCommand(editor));
46
+ editor.commands.add("outdent", new MultiCommand(editor));
47
+ }
48
+ };
38
49
 
39
50
  /**
40
- * The indent UI feature.
41
- *
42
- * This plugin registers the `'indent'` and `'outdent'` buttons.
43
- *
44
- * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
45
- * the {@link module:indent/indent~Indent indent feature} API documentation.
46
- */ class IndentUI extends Plugin {
47
- /**
48
- * @inheritDoc
49
- */ static get pluginName() {
50
- return 'IndentUI';
51
- }
52
- /**
53
- * @inheritDoc
54
- */ static get isOfficialPlugin() {
55
- return true;
56
- }
57
- /**
58
- * @inheritDoc
59
- */ init() {
60
- const editor = this.editor;
61
- const locale = editor.locale;
62
- const t = editor.t;
63
- const localizedIndentIcon = locale.uiLanguageDirection == 'ltr' ? IconIndent : IconOutdent;
64
- const localizedOutdentIcon = locale.uiLanguageDirection == 'ltr' ? IconOutdent : IconIndent;
65
- this._defineButton('indent', t('Increase indent'), localizedIndentIcon);
66
- this._defineButton('outdent', t('Decrease indent'), localizedOutdentIcon);
67
- }
68
- /**
69
- * Defines UI buttons for both toolbar and menu bar.
70
- */ _defineButton(commandName, label, icon) {
71
- const editor = this.editor;
72
- editor.ui.componentFactory.add(commandName, ()=>{
73
- const buttonView = this._createButton(ButtonView, commandName, label, icon);
74
- buttonView.set({
75
- tooltip: true
76
- });
77
- return buttonView;
78
- });
79
- editor.ui.componentFactory.add('menuBar:' + commandName, ()=>{
80
- return this._createButton(MenuBarMenuListItemButtonView, commandName, label, icon);
81
- });
82
- }
83
- /**
84
- * Creates a button to use either in toolbar or in menu bar.
85
- */ _createButton(ButtonClass, commandName, label, icon) {
86
- const editor = this.editor;
87
- const command = editor.commands.get(commandName);
88
- const view = new ButtonClass(editor.locale);
89
- view.set({
90
- label,
91
- icon
92
- });
93
- view.bind('isEnabled').to(command, 'isEnabled');
94
- // Execute the command.
95
- this.listenTo(view, 'execute', ()=>{
96
- editor.execute(commandName);
97
- editor.editing.view.focus();
98
- });
99
- return view;
100
- }
101
- }
51
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
52
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
53
+ */
54
+ /**
55
+ * @module indent/indentui
56
+ */
57
+ /**
58
+ * The indent UI feature.
59
+ *
60
+ * This plugin registers the `'indent'` and `'outdent'` buttons.
61
+ *
62
+ * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in
63
+ * the {@link module:indent/indent~Indent indent feature} API documentation.
64
+ */
65
+ var IndentUI = class extends Plugin {
66
+ /**
67
+ * @inheritDoc
68
+ */
69
+ static get pluginName() {
70
+ return "IndentUI";
71
+ }
72
+ /**
73
+ * @inheritDoc
74
+ */
75
+ static get isOfficialPlugin() {
76
+ return true;
77
+ }
78
+ /**
79
+ * @inheritDoc
80
+ */
81
+ init() {
82
+ const editor = this.editor;
83
+ const locale = editor.locale;
84
+ const t = editor.t;
85
+ const localizedIndentIcon = locale.uiLanguageDirection == "ltr" ? IconIndent : IconOutdent;
86
+ const localizedOutdentIcon = locale.uiLanguageDirection == "ltr" ? IconOutdent : IconIndent;
87
+ this._defineButton("indent", t("Increase indent"), localizedIndentIcon);
88
+ this._defineButton("outdent", t("Decrease indent"), localizedOutdentIcon);
89
+ }
90
+ /**
91
+ * Defines UI buttons for both toolbar and menu bar.
92
+ */
93
+ _defineButton(commandName, label, icon) {
94
+ const editor = this.editor;
95
+ editor.ui.componentFactory.add(commandName, () => {
96
+ const buttonView = this._createButton(ButtonView, commandName, label, icon);
97
+ buttonView.set({ tooltip: true });
98
+ return buttonView;
99
+ });
100
+ editor.ui.componentFactory.add("menuBar:" + commandName, () => {
101
+ return this._createButton(MenuBarMenuListItemButtonView, commandName, label, icon);
102
+ });
103
+ }
104
+ /**
105
+ * Creates a button to use either in toolbar or in menu bar.
106
+ */
107
+ _createButton(ButtonClass, commandName, label, icon) {
108
+ const editor = this.editor;
109
+ const command = editor.commands.get(commandName);
110
+ const view = new ButtonClass(editor.locale);
111
+ view.set({
112
+ label,
113
+ icon
114
+ });
115
+ view.bind("isEnabled").to(command, "isEnabled");
116
+ this.listenTo(view, "execute", () => {
117
+ editor.execute(commandName);
118
+ editor.editing.view.focus();
119
+ });
120
+ return view;
121
+ }
122
+ };
102
123
 
103
124
  /**
104
- * The indent feature.
105
- *
106
- * This plugin acts as a single entry point plugin for other features that implement indentation of elements like lists or paragraphs.
107
- *
108
- * The compatible features are:
109
- *
110
- * * The {@link module:list/list~List} or {@link module:list/list/listediting~ListEditing} feature for list indentation.
111
- * * The {@link module:indent/indentblock~IndentBlock} feature for block indentation.
112
- *
113
- * This is a "glue" plugin that loads the following plugins:
114
- *
115
- * * The {@link module:indent/indentediting~IndentEditing indent editing feature}.
116
- * * The {@link module:indent/indentui~IndentUI indent UI feature}.
117
- *
118
- * The dependent plugins register the `'indent'` and `'outdent'` commands and introduce the `'indent'` and `'outdent'` buttons
119
- * that allow to increase or decrease text indentation of supported elements.
120
- *
121
- * **Note**: In order for the commands and buttons to work, at least one of compatible features is required.
122
- */ class Indent extends Plugin {
123
- /**
124
- * @inheritDoc
125
- */ static get pluginName() {
126
- return 'Indent';
127
- }
128
- /**
129
- * @inheritDoc
130
- */ static get isOfficialPlugin() {
131
- return true;
132
- }
133
- /**
134
- * @inheritDoc
135
- */ static get requires() {
136
- return [
137
- IndentEditing,
138
- IndentUI
139
- ];
140
- }
141
- }
125
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
126
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
127
+ */
128
+ /**
129
+ * @module indent/indent
130
+ */
131
+ /**
132
+ * The indent feature.
133
+ *
134
+ * This plugin acts as a single entry point plugin for other features that implement indentation of elements like lists or paragraphs.
135
+ *
136
+ * The compatible features are:
137
+ *
138
+ * * The {@link module:list/list~List} or {@link module:list/list/listediting~ListEditing} feature for list indentation.
139
+ * * The {@link module:indent/indentblock~IndentBlock} feature for block indentation.
140
+ *
141
+ * This is a "glue" plugin that loads the following plugins:
142
+ *
143
+ * * The {@link module:indent/indentediting~IndentEditing indent editing feature}.
144
+ * * The {@link module:indent/indentui~IndentUI indent UI feature}.
145
+ *
146
+ * The dependent plugins register the `'indent'` and `'outdent'` commands and introduce the `'indent'` and `'outdent'` buttons
147
+ * that allow to increase or decrease text indentation of supported elements.
148
+ *
149
+ * **Note**: In order for the commands and buttons to work, at least one of compatible features is required.
150
+ */
151
+ var Indent = class extends Plugin {
152
+ /**
153
+ * @inheritDoc
154
+ */
155
+ static get pluginName() {
156
+ return "Indent";
157
+ }
158
+ /**
159
+ * @inheritDoc
160
+ */
161
+ static get isOfficialPlugin() {
162
+ return true;
163
+ }
164
+ /**
165
+ * @inheritDoc
166
+ */
167
+ static get requires() {
168
+ return [IndentEditing, IndentUI];
169
+ }
170
+ };
142
171
 
143
172
  /**
144
- * The indent block command.
145
- *
146
- * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and
147
- * `'outdentBlock'` for outdenting blocks.
148
- *
149
- * To increase block indentation at the current selection, execute the command:
150
- *
151
- * ```ts
152
- * editor.execute( 'indentBlock' );
153
- * ```
154
- *
155
- * To decrease block indentation at the current selection, execute the command:
156
- *
157
- * ```ts
158
- * editor.execute( 'outdentBlock' );
159
- * ```
160
- */ class IndentBlockCommand extends Command {
161
- /**
162
- * The command's indentation behavior.
163
- */ _indentBehavior;
164
- /**
165
- * Creates an instance of the command.
166
- */ constructor(editor, indentBehavior){
167
- super(editor);
168
- this._indentBehavior = indentBehavior;
169
- }
170
- /**
171
- * @inheritDoc
172
- */ refresh() {
173
- const editor = this.editor;
174
- const model = editor.model;
175
- const block = first(model.document.selection.getSelectedBlocks());
176
- if (!block || !this._isIndentationChangeAllowed(block)) {
177
- this.isEnabled = false;
178
- return;
179
- }
180
- this.isEnabled = this._indentBehavior.checkEnabled(block.getAttribute('blockIndent'));
181
- }
182
- /**
183
- * @inheritDoc
184
- */ execute() {
185
- const model = this.editor.model;
186
- const blocksToChange = this._getBlocksToChange();
187
- model.change((writer)=>{
188
- for (const block of blocksToChange){
189
- const currentIndent = block.getAttribute('blockIndent');
190
- const nextIndent = this._indentBehavior.getNextIndent(currentIndent);
191
- if (nextIndent) {
192
- writer.setAttribute('blockIndent', nextIndent, block);
193
- } else {
194
- writer.removeAttribute('blockIndent', block);
195
- }
196
- }
197
- });
198
- }
199
- /**
200
- * Returns blocks from selection that should have blockIndent selection set.
201
- */ _getBlocksToChange() {
202
- const model = this.editor.model;
203
- const selection = model.document.selection;
204
- const blocksInSelection = Array.from(selection.getSelectedBlocks());
205
- return blocksInSelection.filter((block)=>this._isIndentationChangeAllowed(block));
206
- }
207
- /**
208
- * Returns false if indentation cannot be applied, i.e.:
209
- * - for blocks disallowed by schema declaration
210
- * - for blocks in Document Lists (disallowed forward indentation only). See https://github.com/ckeditor/ckeditor5/issues/14155.
211
- * Otherwise returns true.
212
- */ _isIndentationChangeAllowed(element) {
213
- const editor = this.editor;
214
- if (!editor.model.schema.checkAttribute(element, 'blockIndent')) {
215
- return false;
216
- }
217
- if (!editor.plugins.has('ListUtils')) {
218
- return true;
219
- }
220
- // Only forward indentation is disallowed in list items. This allows the user to outdent blocks that are already indented.
221
- if (!this._indentBehavior.isForward) {
222
- return true;
223
- }
224
- const listUtils = editor.plugins.get('ListUtils');
225
- return !listUtils.isListItemBlock(element);
226
- }
227
- }
173
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
174
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
175
+ */
176
+ /**
177
+ * @module indent/indentblockcommand
178
+ */
179
+ /**
180
+ * The indent block command.
181
+ *
182
+ * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and
183
+ * `'outdentBlock'` for outdenting blocks.
184
+ *
185
+ * To increase block indentation at the current selection, execute the command:
186
+ *
187
+ * ```ts
188
+ * editor.execute( 'indentBlock' );
189
+ * ```
190
+ *
191
+ * To decrease block indentation at the current selection, execute the command:
192
+ *
193
+ * ```ts
194
+ * editor.execute( 'outdentBlock' );
195
+ * ```
196
+ */
197
+ var IndentBlockCommand = class extends Command {
198
+ /**
199
+ * The command's indentation behavior.
200
+ */
201
+ _indentBehavior;
202
+ /**
203
+ * Creates an instance of the command.
204
+ */
205
+ constructor(editor, indentBehavior) {
206
+ super(editor);
207
+ this._indentBehavior = indentBehavior;
208
+ }
209
+ /**
210
+ * @inheritDoc
211
+ */
212
+ refresh() {
213
+ const model = this.editor.model;
214
+ const block = first(model.document.selection.getSelectedBlocks());
215
+ if (!block || !this._isIndentationChangeAllowed(block)) {
216
+ this.isEnabled = false;
217
+ return;
218
+ }
219
+ this.isEnabled = this._indentBehavior.checkEnabled(block.getAttribute("blockIndent"));
220
+ }
221
+ /**
222
+ * @inheritDoc
223
+ */
224
+ execute() {
225
+ const model = this.editor.model;
226
+ const blocksToChange = this._getBlocksToChange();
227
+ model.change((writer) => {
228
+ for (const block of blocksToChange) {
229
+ const currentIndent = block.getAttribute("blockIndent");
230
+ const nextIndent = this._indentBehavior.getNextIndent(currentIndent);
231
+ if (nextIndent) writer.setAttribute("blockIndent", nextIndent, block);
232
+ else writer.removeAttribute("blockIndent", block);
233
+ }
234
+ });
235
+ }
236
+ /**
237
+ * Returns blocks from selection that should have blockIndent selection set.
238
+ */
239
+ _getBlocksToChange() {
240
+ const selection = this.editor.model.document.selection;
241
+ return Array.from(selection.getSelectedBlocks()).filter((block) => this._isIndentationChangeAllowed(block));
242
+ }
243
+ /**
244
+ * Returns false if indentation cannot be applied, i.e.:
245
+ * - for blocks disallowed by schema declaration
246
+ * - for blocks in Document Lists (disallowed forward indentation only). See https://github.com/ckeditor/ckeditor5/issues/14155.
247
+ * Otherwise returns true.
248
+ */
249
+ _isIndentationChangeAllowed(element) {
250
+ const editor = this.editor;
251
+ if (!editor.model.schema.checkAttribute(element, "blockIndent")) return false;
252
+ if (!editor.plugins.has("ListUtils")) return true;
253
+ if (!this._indentBehavior.isForward) return true;
254
+ return !editor.plugins.get("ListUtils").isListItemBlock(element);
255
+ }
256
+ };
228
257
 
229
258
  /**
230
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
231
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
232
- */ /**
233
- * @module indent/indentcommandbehavior/indentusingoffset
234
- */ /**
235
- * The block indentation behavior that uses offsets to set indentation.
236
- *
237
- * @internal
238
- */ class IndentUsingOffset {
239
- /**
240
- * The direction of indentation.
241
- */ isForward;
242
- /**
243
- * The offset of the next indentation step.
244
- */ offset;
245
- /**
246
- * Indentation unit.
247
- */ unit;
248
- /**
249
- * Creates an instance of the indentation behavior.
250
- *
251
- * @param config.direction The direction of indentation.
252
- * @param config.offset The offset of the next indentation step.
253
- * @param config.unit Indentation unit.
254
- */ constructor(config){
255
- this.isForward = config.direction === 'forward';
256
- this.offset = config.offset;
257
- this.unit = config.unit;
258
- }
259
- /**
260
- * @inheritDoc
261
- */ checkEnabled(indentAttributeValue) {
262
- const currentOffset = parseFloat(indentAttributeValue || '0');
263
- // The command is always enabled for forward indentation.
264
- return this.isForward || currentOffset > 0;
265
- }
266
- /**
267
- * @inheritDoc
268
- */ getNextIndent(indentAttributeValue) {
269
- const currentOffset = parseFloat(indentAttributeValue || '0');
270
- const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith(this.unit);
271
- if (currentOffset < 0) {
272
- return;
273
- }
274
- if (!isSameUnit) {
275
- return this.isForward ? this.offset + this.unit : undefined;
276
- }
277
- const nextOffset = this.isForward ? this.offset : -this.offset;
278
- const offsetToSet = currentOffset + nextOffset;
279
- return offsetToSet > 0 ? offsetToSet + this.unit : undefined;
280
- }
281
- }
259
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
260
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
261
+ */
262
+ /**
263
+ * The block indentation behavior that uses offsets to set indentation.
264
+ *
265
+ * @internal
266
+ */
267
+ var IndentUsingOffset = class {
268
+ /**
269
+ * The direction of indentation.
270
+ */
271
+ isForward;
272
+ /**
273
+ * The offset of the next indentation step.
274
+ */
275
+ offset;
276
+ /**
277
+ * Indentation unit.
278
+ */
279
+ unit;
280
+ /**
281
+ * Creates an instance of the indentation behavior.
282
+ *
283
+ * @param config.direction The direction of indentation.
284
+ * @param config.offset The offset of the next indentation step.
285
+ * @param config.unit Indentation unit.
286
+ */
287
+ constructor(config) {
288
+ this.isForward = config.direction === "forward";
289
+ this.offset = config.offset;
290
+ this.unit = config.unit;
291
+ }
292
+ /**
293
+ * @inheritDoc
294
+ */
295
+ checkEnabled(indentAttributeValue) {
296
+ const currentOffset = parseFloat(indentAttributeValue || "0");
297
+ return this.isForward || currentOffset > 0;
298
+ }
299
+ /**
300
+ * @inheritDoc
301
+ */
302
+ getNextIndent(indentAttributeValue) {
303
+ const currentOffset = parseFloat(indentAttributeValue || "0");
304
+ const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith(this.unit);
305
+ if (currentOffset < 0) return;
306
+ if (!isSameUnit) return this.isForward ? this.offset + this.unit : void 0;
307
+ const offsetToSet = currentOffset + (this.isForward ? this.offset : -this.offset);
308
+ return offsetToSet > 0 ? offsetToSet + this.unit : void 0;
309
+ }
310
+ };
282
311
 
283
312
  /**
284
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
285
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
286
- */ /**
287
- * @module indent/indentcommandbehavior/indentusingclasses
288
- */ /**
289
- * The block indentation behavior that uses classes to set indentation.
290
- *
291
- * @internal
292
- */ class IndentUsingClasses {
293
- /**
294
- * The direction of indentation.
295
- */ isForward;
296
- /**
297
- * A list of classes used for indentation.
298
- */ classes;
299
- /**
300
- * Creates an instance of the indentation behavior.
301
- *
302
- * @param config.direction The direction of indentation.
303
- * @param config.classes A list of classes used for indentation.
304
- */ constructor(config){
305
- this.isForward = config.direction === 'forward';
306
- this.classes = config.classes;
307
- }
308
- /**
309
- * @inheritDoc
310
- */ checkEnabled(indentAttributeValue) {
311
- const currentIndex = this.classes.indexOf(indentAttributeValue);
312
- if (this.isForward) {
313
- return currentIndex < this.classes.length - 1;
314
- } else {
315
- return currentIndex >= 0;
316
- }
317
- }
318
- /**
319
- * @inheritDoc
320
- */ getNextIndent(indentAttributeValue) {
321
- const currentIndex = this.classes.indexOf(indentAttributeValue);
322
- const indexStep = this.isForward ? 1 : -1;
323
- const nextIndex = currentIndex + indexStep;
324
- const nextIndexClamped = Math.min(nextIndex, this.classes.length - 1);
325
- return this.classes[nextIndexClamped];
326
- }
327
- }
313
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
314
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
315
+ */
316
+ /**
317
+ * The block indentation behavior that uses classes to set indentation.
318
+ *
319
+ * @internal
320
+ */
321
+ var IndentUsingClasses = class {
322
+ /**
323
+ * The direction of indentation.
324
+ */
325
+ isForward;
326
+ /**
327
+ * A list of classes used for indentation.
328
+ */
329
+ classes;
330
+ /**
331
+ * Creates an instance of the indentation behavior.
332
+ *
333
+ * @param config.direction The direction of indentation.
334
+ * @param config.classes A list of classes used for indentation.
335
+ */
336
+ constructor(config) {
337
+ this.isForward = config.direction === "forward";
338
+ this.classes = config.classes;
339
+ }
340
+ /**
341
+ * @inheritDoc
342
+ */
343
+ checkEnabled(indentAttributeValue) {
344
+ const currentIndex = this.classes.indexOf(indentAttributeValue);
345
+ if (this.isForward) return currentIndex < this.classes.length - 1;
346
+ else return currentIndex >= 0;
347
+ }
348
+ /**
349
+ * @inheritDoc
350
+ */
351
+ getNextIndent(indentAttributeValue) {
352
+ const nextIndex = this.classes.indexOf(indentAttributeValue) + (this.isForward ? 1 : -1);
353
+ const nextIndexClamped = Math.min(nextIndex, this.classes.length - 1);
354
+ return this.classes[nextIndexClamped];
355
+ }
356
+ };
328
357
 
329
358
  /**
330
- * The indent block list command.
331
- *
332
- * The command is registered by the {@link module:indent/integrations/indentblocklistintegration~IndentBlockListIntegration} as
333
- * `'indentBlockList'` for indenting lists and `'outdentBlockList'` for outdenting lists.
334
- *
335
- * To increase/decrease block indentation of the list the selection must be at the start of the first top–level list item
336
- * in the list.
337
- *
338
- * To increase block indentation of the list, execute the command:
339
- *
340
- * ```ts
341
- * editor.execute( 'indentBlockList' );
342
- * ```
343
- *
344
- * To decrease block indentation of the list, execute the command:
345
- *
346
- * ```ts
347
- * editor.execute( 'outdentBlockList' );
348
- * ```
349
- */ class IndentBlockListCommand extends Command {
350
- /**
351
- * The command's indentation behavior.
352
- */ _indentBehavior;
353
- /**
354
- * Creates an instance of the command.
355
- */ constructor(editor, indentBehavior){
356
- super(editor);
357
- this._indentBehavior = indentBehavior;
358
- }
359
- /**
360
- * @inheritDoc
361
- */ refresh() {
362
- const listItem = this._getFirstListItemIfSelectionIsAtListStart(this.editor.model.document.selection);
363
- this.isEnabled = !!listItem && this._indentBehavior.checkEnabled(listItem.getAttribute('blockIndentList'));
364
- }
365
- /**
366
- * Executes the command.
367
- *
368
- * @fires execute
369
- * @param options Command options.
370
- * @param options.firstListOnly When `true`, indentation is applied only to the first list at the beginning of the selection.
371
- * When `false` or omitted, indentation is applied to all lists of the selection.
372
- */ execute(options = {}) {
373
- const editor = this.editor;
374
- const model = editor.model;
375
- const selection = model.document.selection;
376
- const listUtils = editor.plugins.get('ListUtils');
377
- model.change((writer)=>{
378
- const listItem = this._getFirstListItemIfSelectionIsAtListStart(selection);
379
- const listItems = [];
380
- if (!options.firstListOnly) {
381
- const blocks = Array.from(selection.getSelectedBlocks());
382
- for (const block of blocks){
383
- if (_isListItemBlock(block) && block.getAttribute('listIndent') === 0 && model.schema.checkAttribute(block, 'blockIndentList')) {
384
- listItems.push(block);
385
- }
386
- }
387
- } else {
388
- listItems.push(listItem);
389
- }
390
- // Expand to all list items in the selected lists to process them together and reduce postfixer usage.
391
- const expandedListItems = listUtils.expandListBlocksToCompleteList(listItems);
392
- for (const item of expandedListItems){
393
- const currentIndent = item.getAttribute('blockIndentList');
394
- const nextIndent = this._indentBehavior.getNextIndent(currentIndent);
395
- if (nextIndent) {
396
- writer.setAttribute('blockIndentList', nextIndent, item);
397
- } else {
398
- writer.removeAttribute('blockIndentList', item);
399
- }
400
- }
401
- });
402
- }
403
- /**
404
- * Returns the list item at the beginning of the current selection if it is the first top–level list item in the list.
405
- * Otherwise, returns `null`.
406
- */ _getFirstListItemIfSelectionIsAtListStart(selection) {
407
- const position = selection.getFirstPosition();
408
- const listUtils = this.editor.plugins.get('ListUtils');
409
- const parent = position.parent;
410
- const schema = this.editor.model.schema;
411
- if (position.isAtStart && _isListItemBlock(parent) && parent.getAttribute('listIndent') == 0 && schema.checkAttribute(parent, 'blockIndentList') && listUtils.isFirstListItemInList(parent)) {
412
- return parent;
413
- }
414
- return null;
415
- }
416
- }
359
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
360
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
361
+ */
362
+ /**
363
+ * @module indent/integrations/indentblocklistcommand
364
+ */
365
+ /**
366
+ * The indent block list command.
367
+ *
368
+ * The command is registered by the {@link module:indent/integrations/indentblocklistintegration~IndentBlockListIntegration} as
369
+ * `'indentBlockList'` for indenting lists and `'outdentBlockList'` for outdenting lists.
370
+ *
371
+ * To increase/decrease block indentation of the list the selection must be at the start of the first top–level list item
372
+ * in the list.
373
+ *
374
+ * To increase block indentation of the list, execute the command:
375
+ *
376
+ * ```ts
377
+ * editor.execute( 'indentBlockList' );
378
+ * ```
379
+ *
380
+ * To decrease block indentation of the list, execute the command:
381
+ *
382
+ * ```ts
383
+ * editor.execute( 'outdentBlockList' );
384
+ * ```
385
+ */
386
+ var IndentBlockListCommand = class extends Command {
387
+ /**
388
+ * The command's indentation behavior.
389
+ */
390
+ _indentBehavior;
391
+ /**
392
+ * Creates an instance of the command.
393
+ */
394
+ constructor(editor, indentBehavior) {
395
+ super(editor);
396
+ this._indentBehavior = indentBehavior;
397
+ }
398
+ /**
399
+ * @inheritDoc
400
+ */
401
+ refresh() {
402
+ const listItem = this._getFirstListItemIfSelectionIsAtListStart(this.editor.model.document.selection);
403
+ this.isEnabled = !!listItem && this._indentBehavior.checkEnabled(listItem.getAttribute("blockIndentList"));
404
+ }
405
+ /**
406
+ * Executes the command.
407
+ *
408
+ * @fires execute
409
+ * @param options Command options.
410
+ * @param options.firstListOnly When `true`, indentation is applied only to the first list at the beginning of the selection.
411
+ * When `false` or omitted, indentation is applied to all lists of the selection.
412
+ */
413
+ execute(options = {}) {
414
+ const editor = this.editor;
415
+ const model = editor.model;
416
+ const selection = model.document.selection;
417
+ const listUtils = editor.plugins.get("ListUtils");
418
+ model.change((writer) => {
419
+ const listItem = this._getFirstListItemIfSelectionIsAtListStart(selection);
420
+ const listItems = [];
421
+ if (!options.firstListOnly) {
422
+ const blocks = Array.from(selection.getSelectedBlocks());
423
+ for (const block of blocks) if (_isListItemBlock(block) && block.getAttribute("listIndent") === 0 && model.schema.checkAttribute(block, "blockIndentList")) listItems.push(block);
424
+ } else listItems.push(listItem);
425
+ const expandedListItems = listUtils.expandListBlocksToCompleteList(listItems);
426
+ for (const item of expandedListItems) {
427
+ const currentIndent = item.getAttribute("blockIndentList");
428
+ const nextIndent = this._indentBehavior.getNextIndent(currentIndent);
429
+ if (nextIndent) writer.setAttribute("blockIndentList", nextIndent, item);
430
+ else writer.removeAttribute("blockIndentList", item);
431
+ }
432
+ });
433
+ }
434
+ /**
435
+ * Returns the list item at the beginning of the current selection if it is the first top–level list item in the list.
436
+ * Otherwise, returns `null`.
437
+ */
438
+ _getFirstListItemIfSelectionIsAtListStart(selection) {
439
+ const position = selection.getFirstPosition();
440
+ const listUtils = this.editor.plugins.get("ListUtils");
441
+ const parent = position.parent;
442
+ const schema = this.editor.model.schema;
443
+ if (position.isAtStart && _isListItemBlock(parent) && parent.getAttribute("listIndent") == 0 && schema.checkAttribute(parent, "blockIndentList") && listUtils.isFirstListItemInList(parent)) return parent;
444
+ return null;
445
+ }
446
+ };
417
447
 
418
448
  /**
419
- * The indent block list item command.
420
- *
421
- * The command is registered by the {@link module:indent/integrations/indentblocklistintegration~IndentBlockListIntegration} as
422
- * `'indentBlockListItem'` for indenting list items and `'outdentBlockListItem'` for outdenting list items.
423
- *
424
- * It's only possible to reset the block indentation of a list item to `0`.
425
- * This means that if a list item has negative block indentation, the command will only allow forward indentation
426
- * to make it possible to reset it to `0` and if a list item has positive block indentation, the command
427
- * will only allow backward indentation to make it possible to reset it to `0`.
428
- *
429
- * To increase block indentation of the list item, execute the command:
430
- *
431
- * ```ts
432
- * editor.execute( 'indentBlockListItem' );
433
- * ```
434
- *
435
- * To decrease block indentation of the list item, execute the command:
436
- *
437
- * ```ts
438
- * editor.execute( 'outdentBlockListItem' );
439
- * ```
440
- */ class IndentBlockListItemCommand extends Command {
441
- /**
442
- * The command's indentation behavior.
443
- */ _indentBehavior;
444
- /**
445
- * Creates an instance of the command.
446
- */ constructor(editor, indentBehavior){
447
- super(editor);
448
- this._indentBehavior = indentBehavior;
449
- }
450
- /**
451
- * @inheritDoc
452
- */ refresh() {
453
- this.isEnabled = this._getAffectedListItems().length > 0;
454
- }
455
- /**
456
- * @inheritDoc
457
- */ execute() {
458
- const editor = this.editor;
459
- const model = editor.model;
460
- model.change((writer)=>{
461
- for (const block of this._getAffectedListItems()){
462
- writer.removeAttribute('blockIndentListItem', block);
463
- }
464
- });
465
- }
466
- /**
467
- * Returns an array of list items which block indentation should be changed.
468
- */ _getAffectedListItems() {
469
- const model = this.editor.model;
470
- const selection = model.document.selection;
471
- const listUtils = this.editor.plugins.get('ListUtils');
472
- const blocksInSelection = Array.from(selection.getSelectedBlocks());
473
- const expandedBlocks = listUtils.expandListBlocksToCompleteItems(blocksInSelection);
474
- return expandedBlocks.filter((block)=>this._isIndentationChangeAllowed(block));
475
- }
476
- /**
477
- * Returns `true` if changing the block indentation is allowed for the given list item.
478
- */ _isIndentationChangeAllowed(element) {
479
- if (!element.hasAttribute('blockIndentListItem')) {
480
- return false;
481
- }
482
- return this._indentBehavior.checkEnabled(element.getAttribute('blockIndentListItem'));
483
- }
484
- }
449
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
450
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
451
+ */
452
+ /**
453
+ * @module indent/integrations/indentblocklistitemcommand
454
+ */
455
+ /**
456
+ * The indent block list item command.
457
+ *
458
+ * The command is registered by the {@link module:indent/integrations/indentblocklistintegration~IndentBlockListIntegration} as
459
+ * `'indentBlockListItem'` for indenting list items and `'outdentBlockListItem'` for outdenting list items.
460
+ *
461
+ * It's only possible to reset the block indentation of a list item to `0`.
462
+ * This means that if a list item has negative block indentation, the command will only allow forward indentation
463
+ * to make it possible to reset it to `0` and if a list item has positive block indentation, the command
464
+ * will only allow backward indentation to make it possible to reset it to `0`.
465
+ *
466
+ * To increase block indentation of the list item, execute the command:
467
+ *
468
+ * ```ts
469
+ * editor.execute( 'indentBlockListItem' );
470
+ * ```
471
+ *
472
+ * To decrease block indentation of the list item, execute the command:
473
+ *
474
+ * ```ts
475
+ * editor.execute( 'outdentBlockListItem' );
476
+ * ```
477
+ */
478
+ var IndentBlockListItemCommand = class extends Command {
479
+ /**
480
+ * The command's indentation behavior.
481
+ */
482
+ _indentBehavior;
483
+ /**
484
+ * Creates an instance of the command.
485
+ */
486
+ constructor(editor, indentBehavior) {
487
+ super(editor);
488
+ this._indentBehavior = indentBehavior;
489
+ }
490
+ /**
491
+ * @inheritDoc
492
+ */
493
+ refresh() {
494
+ this.isEnabled = this._getAffectedListItems().length > 0;
495
+ }
496
+ /**
497
+ * @inheritDoc
498
+ */
499
+ execute() {
500
+ this.editor.model.change((writer) => {
501
+ for (const block of this._getAffectedListItems()) writer.removeAttribute("blockIndentListItem", block);
502
+ });
503
+ }
504
+ /**
505
+ * Returns an array of list items which block indentation should be changed.
506
+ */
507
+ _getAffectedListItems() {
508
+ const selection = this.editor.model.document.selection;
509
+ const listUtils = this.editor.plugins.get("ListUtils");
510
+ const blocksInSelection = Array.from(selection.getSelectedBlocks());
511
+ return listUtils.expandListBlocksToCompleteItems(blocksInSelection).filter((block) => this._isIndentationChangeAllowed(block));
512
+ }
513
+ /**
514
+ * Returns `true` if changing the block indentation is allowed for the given list item.
515
+ */
516
+ _isIndentationChangeAllowed(element) {
517
+ if (!element.hasAttribute("blockIndentListItem")) return false;
518
+ return this._indentBehavior.checkEnabled(element.getAttribute("blockIndentListItem"));
519
+ }
520
+ };
485
521
 
486
522
  /**
487
- * The list item block indentation behavior that resets offset-based indentation toward zero.
488
- *
489
- * Unlike {@link module:indent/indentcommandbehavior/indentusingoffset~IndentUsingOffset}, this behavior
490
- * is enabled only when the current indentation value can be moved toward zero:
491
- * - for forward direction only when the current offset is negative,
492
- * - for backward direction only when the current offset is positive.
493
- *
494
- * @internal
495
- */ class ResetIndentUsingOffset extends IndentUsingOffset {
496
- /**
497
- * @inheritDoc
498
- */ checkEnabled(indentAttributeValue) {
499
- const currentOffset = parseFloat(indentAttributeValue);
500
- return this.isForward && currentOffset < 0 || !this.isForward && currentOffset > 0;
501
- }
502
- }
523
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
524
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
525
+ */
526
+ /**
527
+ * @module indent/indentcommandbehavior/resetindentusingoffset
528
+ */
529
+ /**
530
+ * The list item block indentation behavior that resets offset-based indentation toward zero.
531
+ *
532
+ * Unlike {@link module:indent/indentcommandbehavior/indentusingoffset~IndentUsingOffset}, this behavior
533
+ * is enabled only when the current indentation value can be moved toward zero:
534
+ * - for forward direction only when the current offset is negative,
535
+ * - for backward direction only when the current offset is positive.
536
+ *
537
+ * @internal
538
+ */
539
+ var ResetIndentUsingOffset = class extends IndentUsingOffset {
540
+ /**
541
+ * @inheritDoc
542
+ */
543
+ checkEnabled(indentAttributeValue) {
544
+ const currentOffset = parseFloat(indentAttributeValue);
545
+ return this.isForward && currentOffset < 0 || !this.isForward && currentOffset > 0;
546
+ }
547
+ };
503
548
 
504
549
  /**
505
- * The list item block indentation behavior that resets class-based indentation toward zero.
506
- *
507
- * Unlike {@link module:indent/indentcommandbehavior/indentusingclasses~IndentUsingClasses}, this behavior
508
- * is enabled only in the backward (outdent) direction when a class-based indentation is set.
509
- * This is because class-based indentation values cannot be negative, so the only way to reset
510
- * them to zero is to remove the class by outdenting.
511
- *
512
- * @internal
513
- */ class ResetIndentUsingClasses extends IndentUsingClasses {
514
- /**
515
- * @inheritDoc
516
- */ checkEnabled(indentAttributeValue) {
517
- return !this.isForward && !!indentAttributeValue;
518
- }
519
- }
550
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
551
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
552
+ */
553
+ /**
554
+ * @module indent/indentcommandbehavior/resetindentusingclasses
555
+ */
556
+ /**
557
+ * The list item block indentation behavior that resets class-based indentation toward zero.
558
+ *
559
+ * Unlike {@link module:indent/indentcommandbehavior/indentusingclasses~IndentUsingClasses}, this behavior
560
+ * is enabled only in the backward (outdent) direction when a class-based indentation is set.
561
+ * This is because class-based indentation values cannot be negative, so the only way to reset
562
+ * them to zero is to remove the class by outdenting.
563
+ *
564
+ * @internal
565
+ */
566
+ var ResetIndentUsingClasses = class extends IndentUsingClasses {
567
+ /**
568
+ * @inheritDoc
569
+ */
570
+ checkEnabled(indentAttributeValue) {
571
+ return !this.isForward && !!indentAttributeValue;
572
+ }
573
+ };
520
574
 
521
575
  /**
522
- * This integration enables using block indentation feature with lists.
523
- */ class IndentBlockListIntegration extends Plugin {
524
- /**
525
- * @inheritDoc
526
- */ static get pluginName() {
527
- return 'IndentBlockListIntegration';
528
- }
529
- /**
530
- * @inheritDoc
531
- */ static get isOfficialPlugin() {
532
- return true;
533
- }
534
- /**
535
- * @inheritDoc
536
- */ init() {
537
- const editor = this.editor;
538
- if (!this.editor.plugins.has('ListEditing')) {
539
- return;
540
- }
541
- const config = editor.config.get('indentBlock');
542
- if (config.classes && config.classes.length) {
543
- this._setupConversionUsingClasses(config.classes, 'ol', 'blockIndentList', 'list');
544
- this._setupConversionUsingClasses(config.classes, 'ul', 'blockIndentList', 'list');
545
- this._setupConversionUsingClasses(config.classes, 'li', 'blockIndentListItem', 'item');
546
- editor.commands.add('indentBlockList', new IndentBlockListCommand(editor, new IndentUsingClasses({
547
- direction: 'forward',
548
- classes: config.classes
549
- })));
550
- editor.commands.add('outdentBlockList', new IndentBlockListCommand(editor, new IndentUsingClasses({
551
- direction: 'backward',
552
- classes: config.classes
553
- })));
554
- editor.commands.add('indentBlockListItem', new IndentBlockListItemCommand(editor, new ResetIndentUsingClasses({
555
- direction: 'forward',
556
- classes: config.classes
557
- })));
558
- editor.commands.add('outdentBlockListItem', new IndentBlockListItemCommand(editor, new ResetIndentUsingClasses({
559
- direction: 'backward',
560
- classes: config.classes
561
- })));
562
- } else {
563
- editor.data.addStyleProcessorRules(addMarginStylesRules);
564
- this._setupConversionUsingOffset('ol', 'blockIndentList', 'list');
565
- this._setupConversionUsingOffset('ul', 'blockIndentList', 'list');
566
- this._setupConversionUsingOffset('li', 'blockIndentListItem', 'item');
567
- editor.commands.add('indentBlockList', new IndentBlockListCommand(editor, new IndentUsingOffset({
568
- direction: 'forward',
569
- offset: config.offset,
570
- unit: config.unit
571
- })));
572
- editor.commands.add('outdentBlockList', new IndentBlockListCommand(editor, new IndentUsingOffset({
573
- direction: 'backward',
574
- offset: config.offset,
575
- unit: config.unit
576
- })));
577
- editor.commands.add('indentBlockListItem', new IndentBlockListItemCommand(editor, new ResetIndentUsingOffset({
578
- direction: 'forward',
579
- offset: config.offset,
580
- unit: config.unit
581
- })));
582
- editor.commands.add('outdentBlockListItem', new IndentBlockListItemCommand(editor, new ResetIndentUsingOffset({
583
- direction: 'backward',
584
- offset: config.offset,
585
- unit: config.unit
586
- })));
587
- }
588
- const listEditing = editor.plugins.get('ListEditing');
589
- // Make sure that all items in a single list (items at the same level & listType) have the same blockIndentList attribute value.
590
- // Also make sure that all block in a single list item (blocks with the same listItemId) have the same
591
- // blockIndentListItem attribute value.
592
- listEditing.on('postFixer', (evt, { listNodes, writer })=>{
593
- for (const { node, previousNodeInList } of listNodes){
594
- // This is a first item of a nested list.
595
- if (!previousNodeInList) {
596
- continue;
597
- }
598
- if (previousNodeInList.getAttribute('listType') != node.getAttribute('listType')) {
599
- continue;
600
- }
601
- if (ensureIndentValuesConsistency('blockIndentList', node, previousNodeInList, writer)) {
602
- evt.return = true;
603
- }
604
- if (previousNodeInList.getAttribute('listItemId') != node.getAttribute('listItemId')) {
605
- continue;
606
- }
607
- if (ensureIndentValuesConsistency('blockIndentListItem', node, previousNodeInList, writer)) {
608
- evt.return = true;
609
- }
610
- }
611
- });
612
- this.listenTo(editor.editing.view.document, 'tab', (evt, data)=>{
613
- const commandName = data.shiftKey ? 'outdentBlockList' : 'indentBlockList';
614
- const command = this.editor.commands.get(commandName);
615
- if (command.isEnabled) {
616
- editor.execute(commandName, {
617
- firstListOnly: true
618
- });
619
- data.stopPropagation();
620
- data.preventDefault();
621
- evt.stop();
622
- }
623
- }, {
624
- context: 'li',
625
- priority: 'high'
626
- });
627
- }
628
- /**
629
- * @inheritDoc
630
- */ afterInit() {
631
- const editor = this.editor;
632
- const model = editor.model;
633
- const schema = model.schema;
634
- if (!editor.plugins.has('ListEditing')) {
635
- return;
636
- }
637
- // Schema registration.
638
- schema.extend('$listItem', {
639
- allowAttributes: [
640
- 'blockIndentList',
641
- 'blockIndentListItem'
642
- ]
643
- });
644
- schema.setAttributeProperties('blockIndentList', {
645
- isFormatting: true
646
- });
647
- schema.setAttributeProperties('blockIndentListItem', {
648
- isFormatting: true
649
- });
650
- model.schema.addAttributeCheck((context)=>{
651
- const item = context.last;
652
- if (!item.getAttribute('listItemId')) {
653
- return false;
654
- }
655
- }, 'blockIndentList');
656
- model.schema.addAttributeCheck((context)=>{
657
- const item = context.last;
658
- if (!item.getAttribute('listItemId')) {
659
- return false;
660
- }
661
- }, 'blockIndentListItem');
662
- // Clear blockIndentList and blockIndentListItem when list indent changes.
663
- const clearBlockIndentAttributesOnListIndentChange = (_evt, changedBlocks)=>{
664
- editor.model.change((writer)=>{
665
- for (const node of changedBlocks){
666
- if (node.hasAttribute('listItemId')) {
667
- if (node.hasAttribute('blockIndentList')) {
668
- writer.removeAttribute('blockIndentList', node);
669
- }
670
- if (node.hasAttribute('blockIndentListItem')) {
671
- writer.removeAttribute('blockIndentListItem', node);
672
- }
673
- }
674
- }
675
- });
676
- };
677
- const indentListCommand = editor.commands.get('indentList');
678
- const outdentListCommand = editor.commands.get('outdentList');
679
- if (indentListCommand) {
680
- this.listenTo(indentListCommand, 'afterExecute', clearBlockIndentAttributesOnListIndentChange);
681
- }
682
- if (outdentListCommand) {
683
- this.listenTo(outdentListCommand, 'afterExecute', clearBlockIndentAttributesOnListIndentChange);
684
- }
685
- // Register list block indent commands in multi command.
686
- const indentCommand = editor.commands.get('indent');
687
- const outdentCommand = editor.commands.get('outdent');
688
- // Priority is highest so that block indent takes precedence over list indent (`indentList` is registered
689
- // at `high`). When the selection is at the start of the first list item at indent 0, the block indent
690
- // command adds margin instead of increasing the list indent level. For items at higher indent levels,
691
- // this command is disabled and falls through to `indentList`.
692
- indentCommand.registerChildCommand(editor.commands.get('indentBlockList'), {
693
- priority: 'highest'
694
- });
695
- outdentCommand.registerChildCommand(editor.commands.get('outdentBlockList'));
696
- indentCommand.registerChildCommand(editor.commands.get('indentBlockListItem'));
697
- outdentCommand.registerChildCommand(editor.commands.get('outdentBlockListItem'));
698
- }
699
- /**
700
- * Setups conversion for list block indent using offset.
701
- */ _setupConversionUsingOffset(element, attributeName, scope) {
702
- const editor = this.editor;
703
- const locale = editor.locale;
704
- const conversion = editor.conversion;
705
- const marginProperty = locale.contentLanguageDirection === 'rtl' ? 'margin-right' : 'margin-left';
706
- const listEditing = editor.plugins.get('ListEditing');
707
- conversion.for('upcast').add((dispatcher)=>{
708
- dispatcher.on(`element:${element}`, listBlockIndentUpcastConverter(attributeName, (item)=>item.getStyle(marginProperty), (consumable, item)=>consumable.consume(item, {
709
- styles: marginProperty
710
- })), {
711
- priority: 'low'
712
- });
713
- });
714
- listEditing.registerDowncastStrategy({
715
- scope,
716
- attributeName,
717
- setAttributeOnDowncast (writer, value, element) {
718
- if (value) {
719
- writer.setStyle(marginProperty, value, element);
720
- }
721
- }
722
- });
723
- }
724
- /**
725
- * Setups conversion for list block indent using classes.
726
- */ _setupConversionUsingClasses(classes, element, attributeName, scope) {
727
- const editor = this.editor;
728
- const conversion = editor.conversion;
729
- const listEditing = editor.plugins.get('ListEditing');
730
- conversion.for('upcast').add((dispatcher)=>{
731
- dispatcher.on(`element:${element}`, listBlockIndentUpcastConverter(attributeName, (item)=>classes.find((cls)=>item.hasClass(cls)), (consumable, item, value)=>consumable.consume(item, {
732
- classes: value
733
- })), {
734
- priority: 'low'
735
- });
736
- });
737
- listEditing.registerDowncastStrategy({
738
- scope,
739
- attributeName,
740
- setAttributeOnDowncast (writer, value, element) {
741
- if (value) {
742
- writer.addClass(value, element);
743
- }
744
- }
745
- });
746
- }
747
- }
576
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
577
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
578
+ */
748
579
  /**
749
- * Returns an upcast converter for block list indentation.
750
- *
751
- * @param attributeName The name of the model attribute.
752
- * @param getValue A function to get the value from the view element.
753
- * @param consume A function to consume the view element.
754
- * @returns A callback for the upcast conversion.
755
- */ function listBlockIndentUpcastConverter(attributeName, getValue, consume) {
756
- return (evt, data, conversionApi)=>{
757
- const { writer, consumable } = conversionApi;
758
- if (!data.modelRange) {
759
- Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));
760
- }
761
- const value = getValue(data.viewItem);
762
- if (value === undefined) {
763
- return;
764
- }
765
- let applied = false;
766
- let indentLevel;
767
- for (const item of data.modelRange.getItems({
768
- shallow: true
769
- })){
770
- if (indentLevel === undefined) {
771
- indentLevel = item.getAttribute('listIndent');
772
- }
773
- if (item.hasAttribute(attributeName)) {
774
- continue;
775
- }
776
- if (item.getAttribute('listIndent') !== indentLevel) {
777
- continue;
778
- }
779
- writer.setAttribute(attributeName, value, item);
780
- applied = true;
781
- }
782
- if (applied) {
783
- consume(consumable, data.viewItem, value);
784
- }
785
- };
580
+ * This integration enables using block indentation feature with lists.
581
+ */
582
+ var IndentBlockListIntegration = class extends Plugin {
583
+ /**
584
+ * @inheritDoc
585
+ */
586
+ static get pluginName() {
587
+ return "IndentBlockListIntegration";
588
+ }
589
+ /**
590
+ * @inheritDoc
591
+ */
592
+ static get isOfficialPlugin() {
593
+ return true;
594
+ }
595
+ /**
596
+ * @inheritDoc
597
+ */
598
+ init() {
599
+ const editor = this.editor;
600
+ if (!this.editor.plugins.has("ListEditing")) return;
601
+ const config = editor.config.get("indentBlock");
602
+ if (config.classes && config.classes.length) {
603
+ this._setupConversionUsingClasses(config.classes, "ol", "blockIndentList", "list");
604
+ this._setupConversionUsingClasses(config.classes, "ul", "blockIndentList", "list");
605
+ this._setupConversionUsingClasses(config.classes, "li", "blockIndentListItem", "item");
606
+ editor.commands.add("indentBlockList", new IndentBlockListCommand(editor, new IndentUsingClasses({
607
+ direction: "forward",
608
+ classes: config.classes
609
+ })));
610
+ editor.commands.add("outdentBlockList", new IndentBlockListCommand(editor, new IndentUsingClasses({
611
+ direction: "backward",
612
+ classes: config.classes
613
+ })));
614
+ editor.commands.add("indentBlockListItem", new IndentBlockListItemCommand(editor, new ResetIndentUsingClasses({
615
+ direction: "forward",
616
+ classes: config.classes
617
+ })));
618
+ editor.commands.add("outdentBlockListItem", new IndentBlockListItemCommand(editor, new ResetIndentUsingClasses({
619
+ direction: "backward",
620
+ classes: config.classes
621
+ })));
622
+ } else {
623
+ editor.data.addStyleProcessorRules(addMarginStylesRules);
624
+ this._setupConversionUsingOffset("ol", "blockIndentList", "list");
625
+ this._setupConversionUsingOffset("ul", "blockIndentList", "list");
626
+ this._setupConversionUsingOffset("li", "blockIndentListItem", "item");
627
+ editor.commands.add("indentBlockList", new IndentBlockListCommand(editor, new IndentUsingOffset({
628
+ direction: "forward",
629
+ offset: config.offset,
630
+ unit: config.unit
631
+ })));
632
+ editor.commands.add("outdentBlockList", new IndentBlockListCommand(editor, new IndentUsingOffset({
633
+ direction: "backward",
634
+ offset: config.offset,
635
+ unit: config.unit
636
+ })));
637
+ editor.commands.add("indentBlockListItem", new IndentBlockListItemCommand(editor, new ResetIndentUsingOffset({
638
+ direction: "forward",
639
+ offset: config.offset,
640
+ unit: config.unit
641
+ })));
642
+ editor.commands.add("outdentBlockListItem", new IndentBlockListItemCommand(editor, new ResetIndentUsingOffset({
643
+ direction: "backward",
644
+ offset: config.offset,
645
+ unit: config.unit
646
+ })));
647
+ }
648
+ editor.plugins.get("ListEditing").on("postFixer", (evt, { listNodes, writer }) => {
649
+ for (const { node, previousNodeInList } of listNodes) {
650
+ if (!previousNodeInList) continue;
651
+ if (previousNodeInList.getAttribute("listType") != node.getAttribute("listType")) continue;
652
+ if (ensureIndentValuesConsistency("blockIndentList", node, previousNodeInList, writer)) evt.return = true;
653
+ if (previousNodeInList.getAttribute("listItemId") != node.getAttribute("listItemId")) continue;
654
+ if (ensureIndentValuesConsistency("blockIndentListItem", node, previousNodeInList, writer)) evt.return = true;
655
+ }
656
+ });
657
+ this.listenTo(editor.editing.view.document, "tab", (evt, data) => {
658
+ const commandName = data.shiftKey ? "outdentBlockList" : "indentBlockList";
659
+ if (this.editor.commands.get(commandName).isEnabled) {
660
+ editor.execute(commandName, { firstListOnly: true });
661
+ data.stopPropagation();
662
+ data.preventDefault();
663
+ evt.stop();
664
+ }
665
+ }, {
666
+ context: "li",
667
+ priority: "high"
668
+ });
669
+ }
670
+ /**
671
+ * @inheritDoc
672
+ */
673
+ afterInit() {
674
+ const editor = this.editor;
675
+ const model = editor.model;
676
+ const schema = model.schema;
677
+ if (!editor.plugins.has("ListEditing")) return;
678
+ schema.extend("$listItem", { allowAttributes: ["blockIndentList", "blockIndentListItem"] });
679
+ schema.setAttributeProperties("blockIndentList", { isFormatting: true });
680
+ schema.setAttributeProperties("blockIndentListItem", { isFormatting: true });
681
+ model.schema.addAttributeCheck((context) => {
682
+ if (!context.last.getAttribute("listItemId")) return false;
683
+ }, "blockIndentList");
684
+ model.schema.addAttributeCheck((context) => {
685
+ if (!context.last.getAttribute("listItemId")) return false;
686
+ }, "blockIndentListItem");
687
+ const clearBlockIndentAttributesOnListIndentChange = (_evt, changedBlocks) => {
688
+ editor.model.change((writer) => {
689
+ for (const node of changedBlocks) if (node.hasAttribute("listItemId")) {
690
+ if (node.hasAttribute("blockIndentList")) writer.removeAttribute("blockIndentList", node);
691
+ if (node.hasAttribute("blockIndentListItem")) writer.removeAttribute("blockIndentListItem", node);
692
+ }
693
+ });
694
+ };
695
+ const indentListCommand = editor.commands.get("indentList");
696
+ const outdentListCommand = editor.commands.get("outdentList");
697
+ if (indentListCommand) this.listenTo(indentListCommand, "afterExecute", clearBlockIndentAttributesOnListIndentChange);
698
+ if (outdentListCommand) this.listenTo(outdentListCommand, "afterExecute", clearBlockIndentAttributesOnListIndentChange);
699
+ const indentCommand = editor.commands.get("indent");
700
+ const outdentCommand = editor.commands.get("outdent");
701
+ indentCommand.registerChildCommand(editor.commands.get("indentBlockList"), { priority: "highest" });
702
+ outdentCommand.registerChildCommand(editor.commands.get("outdentBlockList"));
703
+ indentCommand.registerChildCommand(editor.commands.get("indentBlockListItem"));
704
+ outdentCommand.registerChildCommand(editor.commands.get("outdentBlockListItem"));
705
+ }
706
+ /**
707
+ * Setups conversion for list block indent using offset.
708
+ */
709
+ _setupConversionUsingOffset(element, attributeName, scope) {
710
+ const editor = this.editor;
711
+ const locale = editor.locale;
712
+ const conversion = editor.conversion;
713
+ const marginProperty = locale.contentLanguageDirection === "rtl" ? "margin-right" : "margin-left";
714
+ const listEditing = editor.plugins.get("ListEditing");
715
+ conversion.for("upcast").add((dispatcher) => {
716
+ dispatcher.on(`element:${element}`, listBlockIndentUpcastConverter(attributeName, (item) => item.getStyle(marginProperty), (consumable, item) => consumable.consume(item, { styles: marginProperty })), { priority: "low" });
717
+ });
718
+ listEditing.registerDowncastStrategy({
719
+ scope,
720
+ attributeName,
721
+ setAttributeOnDowncast(writer, value, element) {
722
+ if (value) writer.setStyle(marginProperty, value, element);
723
+ }
724
+ });
725
+ }
726
+ /**
727
+ * Setups conversion for list block indent using classes.
728
+ */
729
+ _setupConversionUsingClasses(classes, element, attributeName, scope) {
730
+ const editor = this.editor;
731
+ const conversion = editor.conversion;
732
+ const listEditing = editor.plugins.get("ListEditing");
733
+ conversion.for("upcast").add((dispatcher) => {
734
+ dispatcher.on(`element:${element}`, listBlockIndentUpcastConverter(attributeName, (item) => classes.find((cls) => item.hasClass(cls)), (consumable, item, value) => consumable.consume(item, { classes: value })), { priority: "low" });
735
+ });
736
+ listEditing.registerDowncastStrategy({
737
+ scope,
738
+ attributeName,
739
+ setAttributeOnDowncast(writer, value, element) {
740
+ if (value) writer.addClass(value, element);
741
+ }
742
+ });
743
+ }
744
+ };
745
+ /**
746
+ * Returns an upcast converter for block list indentation.
747
+ *
748
+ * @param attributeName The name of the model attribute.
749
+ * @param getValue A function to get the value from the view element.
750
+ * @param consume A function to consume the view element.
751
+ * @returns A callback for the upcast conversion.
752
+ */
753
+ function listBlockIndentUpcastConverter(attributeName, getValue, consume) {
754
+ return (evt, data, conversionApi) => {
755
+ const { writer, consumable } = conversionApi;
756
+ if (!data.modelRange) Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));
757
+ const value = getValue(data.viewItem);
758
+ if (value === void 0) return;
759
+ let applied = false;
760
+ let indentLevel;
761
+ for (const item of data.modelRange.getItems({ shallow: true })) {
762
+ if (indentLevel === void 0) indentLevel = item.getAttribute("listIndent");
763
+ if (item.hasAttribute(attributeName)) continue;
764
+ if (item.getAttribute("listIndent") !== indentLevel) continue;
765
+ writer.setAttribute(attributeName, value, item);
766
+ applied = true;
767
+ }
768
+ if (applied) consume(consumable, data.viewItem, value);
769
+ };
786
770
  }
787
771
  /**
788
- * Ensures that two nodes have the same value of the given attribute.
789
- * If the values are different, the attribute value from the previous node is applied to the given node.
790
- * Returns true if the attribute value was changed, false otherwise.
791
- */ function ensureIndentValuesConsistency(attributeName, node, previousNodeInList, writer) {
792
- const prevNodeIndentListValue = previousNodeInList.getAttribute(attributeName);
793
- if (node.getAttribute(attributeName) === prevNodeIndentListValue) {
794
- return false;
795
- }
796
- if (prevNodeIndentListValue) {
797
- writer.setAttribute(attributeName, prevNodeIndentListValue, node);
798
- } else {
799
- writer.removeAttribute(attributeName, node);
800
- }
801
- return true;
772
+ * Ensures that two nodes have the same value of the given attribute.
773
+ * If the values are different, the attribute value from the previous node is applied to the given node.
774
+ * Returns true if the attribute value was changed, false otherwise.
775
+ */
776
+ function ensureIndentValuesConsistency(attributeName, node, previousNodeInList, writer) {
777
+ const prevNodeIndentListValue = previousNodeInList.getAttribute(attributeName);
778
+ if (node.getAttribute(attributeName) === prevNodeIndentListValue) return false;
779
+ if (prevNodeIndentListValue) writer.setAttribute(attributeName, prevNodeIndentListValue, node);
780
+ else writer.removeAttribute(attributeName, node);
781
+ return true;
802
782
  }
803
783
 
784
+ /**
785
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
786
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
787
+ */
788
+ /**
789
+ * @module indent/indentblock
790
+ */
804
791
  const DEFAULT_ELEMENTS = [
805
- 'paragraph',
806
- 'heading1',
807
- 'heading2',
808
- 'heading3',
809
- 'heading4',
810
- 'heading5',
811
- 'heading6'
792
+ "paragraph",
793
+ "heading1",
794
+ "heading2",
795
+ "heading3",
796
+ "heading4",
797
+ "heading5",
798
+ "heading6"
812
799
  ];
813
800
  /**
814
- * The block indentation feature.
815
- *
816
- * It registers the `'indentBlock'` and `'outdentBlock'` commands.
817
- *
818
- * If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to
819
- * the `'indent'` and `'outdent'` commands.
820
- */ class IndentBlock extends Plugin {
821
- /**
822
- * @inheritDoc
823
- */ constructor(editor){
824
- super(editor);
825
- editor.config.define('indentBlock', {
826
- offset: 40,
827
- unit: 'px'
828
- });
829
- }
830
- /**
831
- * @inheritDoc
832
- */ static get pluginName() {
833
- return 'IndentBlock';
834
- }
835
- /**
836
- * @inheritDoc
837
- */ static get isOfficialPlugin() {
838
- return true;
839
- }
840
- /**
841
- * @inheritDoc
842
- */ static get requires() {
843
- return [
844
- IndentBlockListIntegration
845
- ];
846
- }
847
- /**
848
- * @inheritDoc
849
- */ init() {
850
- const editor = this.editor;
851
- const configuration = editor.config.get('indentBlock');
852
- if (configuration.classes && configuration.classes.length) {
853
- this._setupConversionUsingClasses(configuration.classes);
854
- editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
855
- direction: 'forward',
856
- classes: configuration.classes
857
- })));
858
- editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({
859
- direction: 'backward',
860
- classes: configuration.classes
861
- })));
862
- } else {
863
- editor.data.addStyleProcessorRules(addMarginStylesRules);
864
- this._setupConversionUsingOffset();
865
- editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
866
- direction: 'forward',
867
- offset: configuration.offset,
868
- unit: configuration.unit
869
- })));
870
- editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({
871
- direction: 'backward',
872
- offset: configuration.offset,
873
- unit: configuration.unit
874
- })));
875
- }
876
- }
877
- /**
878
- * @inheritDoc
879
- */ afterInit() {
880
- const editor = this.editor;
881
- const schema = editor.model.schema;
882
- const indentCommand = editor.commands.get('indent');
883
- const outdentCommand = editor.commands.get('outdent');
884
- // Enable block indentation to heading configuration options. If it is not defined enable in paragraph and default headings.
885
- const options = editor.config.get('heading.options');
886
- const configuredElements = options && options.map((option)=>option.model);
887
- const knownElements = configuredElements || DEFAULT_ELEMENTS;
888
- knownElements.forEach((elementName)=>{
889
- if (schema.isRegistered(elementName)) {
890
- schema.extend(elementName, {
891
- allowAttributes: 'blockIndent'
892
- });
893
- }
894
- });
895
- schema.setAttributeProperties('blockIndent', {
896
- isFormatting: true
897
- });
898
- indentCommand.registerChildCommand(editor.commands.get('indentBlock'));
899
- outdentCommand.registerChildCommand(editor.commands.get('outdentBlock'));
900
- }
901
- /**
902
- * Setups conversion for using offset indents.
903
- */ _setupConversionUsingOffset() {
904
- const conversion = this.editor.conversion;
905
- const locale = this.editor.locale;
906
- const marginProperty = locale.contentLanguageDirection === 'rtl' ? 'margin-right' : 'margin-left';
907
- conversion.for('upcast').attributeToAttribute({
908
- view: {
909
- styles: {
910
- [marginProperty]: /[\s\S]+/
911
- }
912
- },
913
- model: {
914
- key: 'blockIndent',
915
- value: (viewElement)=>{
916
- // Do not indent block elements in Document Lists. See https://github.com/ckeditor/ckeditor5/issues/12466.
917
- if (!viewElement.is('element', 'li')) {
918
- return viewElement.getStyle(marginProperty);
919
- }
920
- }
921
- }
922
- });
923
- conversion.for('downcast').attributeToAttribute({
924
- model: 'blockIndent',
925
- view: (modelAttributeValue)=>{
926
- return {
927
- key: 'style',
928
- value: {
929
- [marginProperty]: modelAttributeValue
930
- }
931
- };
932
- }
933
- });
934
- }
935
- /**
936
- * Setups conversion for using classes.
937
- */ _setupConversionUsingClasses(classes) {
938
- const definition = {
939
- model: {
940
- key: 'blockIndent',
941
- values: []
942
- },
943
- view: {}
944
- };
945
- for (const className of classes){
946
- definition.model.values.push(className);
947
- definition.view[className] = {
948
- key: 'class',
949
- value: [
950
- className
951
- ]
952
- };
953
- }
954
- this.editor.conversion.attributeToAttribute(definition);
955
- }
956
- }
801
+ * The block indentation feature.
802
+ *
803
+ * It registers the `'indentBlock'` and `'outdentBlock'` commands.
804
+ *
805
+ * If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to
806
+ * the `'indent'` and `'outdent'` commands.
807
+ */
808
+ var IndentBlock = class extends Plugin {
809
+ /**
810
+ * @inheritDoc
811
+ */
812
+ constructor(editor) {
813
+ super(editor);
814
+ editor.config.define("indentBlock", {
815
+ offset: 40,
816
+ unit: "px"
817
+ });
818
+ }
819
+ /**
820
+ * @inheritDoc
821
+ */
822
+ static get pluginName() {
823
+ return "IndentBlock";
824
+ }
825
+ /**
826
+ * @inheritDoc
827
+ */
828
+ static get isOfficialPlugin() {
829
+ return true;
830
+ }
831
+ /**
832
+ * @inheritDoc
833
+ */
834
+ static get requires() {
835
+ return [IndentBlockListIntegration];
836
+ }
837
+ /**
838
+ * @inheritDoc
839
+ */
840
+ init() {
841
+ const editor = this.editor;
842
+ const configuration = editor.config.get("indentBlock");
843
+ if (configuration.classes && configuration.classes.length) {
844
+ this._setupConversionUsingClasses(configuration.classes);
845
+ editor.commands.add("indentBlock", new IndentBlockCommand(editor, new IndentUsingClasses({
846
+ direction: "forward",
847
+ classes: configuration.classes
848
+ })));
849
+ editor.commands.add("outdentBlock", new IndentBlockCommand(editor, new IndentUsingClasses({
850
+ direction: "backward",
851
+ classes: configuration.classes
852
+ })));
853
+ } else {
854
+ editor.data.addStyleProcessorRules(addMarginStylesRules);
855
+ this._setupConversionUsingOffset();
856
+ editor.commands.add("indentBlock", new IndentBlockCommand(editor, new IndentUsingOffset({
857
+ direction: "forward",
858
+ offset: configuration.offset,
859
+ unit: configuration.unit
860
+ })));
861
+ editor.commands.add("outdentBlock", new IndentBlockCommand(editor, new IndentUsingOffset({
862
+ direction: "backward",
863
+ offset: configuration.offset,
864
+ unit: configuration.unit
865
+ })));
866
+ }
867
+ }
868
+ /**
869
+ * @inheritDoc
870
+ */
871
+ afterInit() {
872
+ const editor = this.editor;
873
+ const schema = editor.model.schema;
874
+ const indentCommand = editor.commands.get("indent");
875
+ const outdentCommand = editor.commands.get("outdent");
876
+ const options = editor.config.get("heading.options");
877
+ (options && options.map((option) => option.model) || DEFAULT_ELEMENTS).forEach((elementName) => {
878
+ if (schema.isRegistered(elementName)) schema.extend(elementName, { allowAttributes: "blockIndent" });
879
+ });
880
+ schema.setAttributeProperties("blockIndent", { isFormatting: true });
881
+ indentCommand.registerChildCommand(editor.commands.get("indentBlock"));
882
+ outdentCommand.registerChildCommand(editor.commands.get("outdentBlock"));
883
+ }
884
+ /**
885
+ * Setups conversion for using offset indents.
886
+ */
887
+ _setupConversionUsingOffset() {
888
+ const conversion = this.editor.conversion;
889
+ const marginProperty = this.editor.locale.contentLanguageDirection === "rtl" ? "margin-right" : "margin-left";
890
+ conversion.for("upcast").attributeToAttribute({
891
+ view: { styles: { [marginProperty]: /[\s\S]+/ } },
892
+ model: {
893
+ key: "blockIndent",
894
+ value: (viewElement) => {
895
+ if (!viewElement.is("element", "li")) return viewElement.getStyle(marginProperty);
896
+ }
897
+ }
898
+ });
899
+ conversion.for("downcast").attributeToAttribute({
900
+ model: "blockIndent",
901
+ view: (modelAttributeValue) => {
902
+ return {
903
+ key: "style",
904
+ value: { [marginProperty]: modelAttributeValue }
905
+ };
906
+ }
907
+ });
908
+ }
909
+ /**
910
+ * Setups conversion for using classes.
911
+ */
912
+ _setupConversionUsingClasses(classes) {
913
+ const definition = {
914
+ model: {
915
+ key: "blockIndent",
916
+ values: []
917
+ },
918
+ view: {}
919
+ };
920
+ for (const className of classes) {
921
+ definition.model.values.push(className);
922
+ definition.view[className] = {
923
+ key: "class",
924
+ value: [className]
925
+ };
926
+ }
927
+ this.editor.conversion.attributeToAttribute(definition);
928
+ }
929
+ };
930
+
931
+ /**
932
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
933
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
934
+ */
957
935
 
958
936
  export { Indent, IndentBlock, IndentBlockCommand, IndentBlockListCommand, IndentBlockListIntegration, IndentBlockListItemCommand, IndentEditing, IndentUI, IndentUsingClasses as _IndentUsingClasses, IndentUsingOffset as _IndentUsingOffset };
959
- //# sourceMappingURL=index.js.map
937
+ //# sourceMappingURL=index.js.map