Skip to content

Commit 773834a

Browse files
committed
Merge branch 'release' into ck/18807
# Conflicts: # packages/ckeditor5-list/tests/listformatting.js
2 parents 198cae5 + cf0793d commit 773834a

File tree

3 files changed

+177
-2
lines changed

3 files changed

+177
-2
lines changed

packages/ckeditor5-list/ckeditor5-metadata.json

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,109 @@
123123
}
124124
]
125125
},
126+
{
127+
"name": "List formatting",
128+
"className": "ListFormatting",
129+
"description": "Enables integration with formatting plugins to style the list marker. Supports font color, font size, font family, bold, and italic formatting.",
130+
"docs": "features/lists/lists.html#list-item-marker-formatting",
131+
"path": "src/listformatting.js",
132+
"requires": [
133+
"ListItemBoldIntegration",
134+
"ListItemItalicIntegration",
135+
"ListItemFontSizeIntegration",
136+
"ListItemFontColorIntegration",
137+
"ListItemFontFamilyIntegration"
138+
]
139+
},
140+
{
141+
"name": "List item bold integration",
142+
"className": "ListItemBoldIntegration",
143+
"description": "Integrates bold formatting with list items to style list markers with bold formatting when the content is consistently bold.",
144+
"docs": "features/lists/lists.html#list-item-marker-formatting",
145+
"path": "src/listformatting/listitemboldintegration.js",
146+
"requires": [
147+
"ListEditing"
148+
],
149+
"htmlOutput": [
150+
{
151+
"elements": "li",
152+
"classes": "ck-list-marker-bold"
153+
}
154+
]
155+
},
156+
{
157+
"name": "List item italic integration",
158+
"className": "ListItemItalicIntegration",
159+
"description": "Integrates italic formatting with list items to style list markers with italic formatting when the content is consistently italic.",
160+
"docs": "features/lists/lists.html#list-item-marker-formatting",
161+
"path": "src/listformatting/listitemitalicintegration.js",
162+
"requires": [
163+
"ListEditing"
164+
],
165+
"htmlOutput": [
166+
{
167+
"elements": "li",
168+
"classes": "ck-list-marker-italic"
169+
}
170+
]
171+
},
172+
{
173+
"name": "List item font size integration",
174+
"className": "ListItemFontSizeIntegration",
175+
"description": "Integrates font size formatting with list items to style list markers with specific font sizes when the content has consistent font sizing.",
176+
"docs": "features/lists/lists.html#list-item-marker-formatting",
177+
"path": "src/listformatting/listitemfontsizeintegration.js",
178+
"requires": [
179+
"ListEditing"
180+
],
181+
"htmlOutput": [
182+
{
183+
"elements": "li",
184+
"classes": [
185+
"ck-list-marker-font-size",
186+
"ck-list-marker-font-size-tiny",
187+
"ck-list-marker-font-size-small",
188+
"ck-list-marker-font-size-big",
189+
"ck-list-marker-font-size-huge"
190+
],
191+
"styles": "--ck-content-list-marker-font-size"
192+
}
193+
]
194+
},
195+
{
196+
"name": "List item font color integration",
197+
"className": "ListItemFontColorIntegration",
198+
"description": "Integrates font color formatting with list items to style list markers with specific colors when the content has consistent font coloring.",
199+
"docs": "features/lists/lists.html#list-item-marker-formatting",
200+
"path": "src/listformatting/listitemfontcolorintegration.js",
201+
"requires": [
202+
"ListEditing"
203+
],
204+
"htmlOutput": [
205+
{
206+
"elements": "li",
207+
"classes": "ck-list-marker-color",
208+
"styles": "--ck-content-list-marker-color"
209+
}
210+
]
211+
},
212+
{
213+
"name": "List item font family integration",
214+
"className": "ListItemFontFamilyIntegration",
215+
"description": "Integrates font family formatting with list items to style list markers with specific font families when the content has consistent font family formatting.",
216+
"docs": "features/lists/lists.html#list-item-marker-formatting",
217+
"path": "src/listformatting/listitemfontfamilyintegration.js",
218+
"requires": [
219+
"ListEditing"
220+
],
221+
"htmlOutput": [
222+
{
223+
"elements": "li",
224+
"classes": "ck-list-marker-font-family",
225+
"styles": "--ck-content-list-marker-font-family"
226+
}
227+
]
228+
},
126229
{
127230
"name": "To-do list",
128231
"className": "TodoList",

packages/ckeditor5-list/src/listformatting.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export class ListFormatting extends Plugin {
112112
if (
113113
entry.attributeKey == 'listItemId' ||
114114
entry.attributeKey == 'listType' ||
115-
this._isInlineOrSelectionFormatting( entry.attributeKey )
115+
this._isInlineOrSelectionFormatting( entry.attributeKey ) ||
116+
Object.values( this._loadedFormatting ).includes( entry.attributeKey )
116117
) {
117118
if ( isListItemBlock( entry.range.start.nodeAfter ) ) {
118119
modifiedListItems.add( entry.range.start.nodeAfter );

packages/ckeditor5-list/tests/listformatting.js

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { VirtualTestEditor } from '@ckeditor/ckeditor5-core/tests/_utils/virtual
77
import { Paragraph } from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
88
import { Plugin } from '@ckeditor/ckeditor5-core/src/plugin.js';
99
import { BlockQuoteEditing } from '@ckeditor/ckeditor5-block-quote';
10+
import { RemoveFormatEditing } from '@ckeditor/ckeditor5-remove-format';
1011
import { CodeBlockEditing } from '@ckeditor/ckeditor5-code-block';
1112
import { _setModelData, _getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
1213
import { testUtils } from '@ckeditor/ckeditor5-core/tests/_utils/utils.js';
@@ -26,7 +27,7 @@ describe( 'ListFormatting', () => {
2627

2728
beforeEach( async () => {
2829
editor = await VirtualTestEditor.create( {
29-
plugins: [ ListFormatting, Paragraph, BlockQuoteEditing, CodeBlockEditing, MyPlugin, MyPlugin2 ]
30+
plugins: [ ListFormatting, Paragraph, BlockQuoteEditing, CodeBlockEditing, RemoveFormatEditing, MyPlugin, MyPlugin2 ]
3031
} );
3132

3233
model = editor.model;
@@ -263,6 +264,76 @@ describe( 'ListFormatting', () => {
263264
'</paragraph>'
264265
);
265266
} );
267+
268+
describe( 'with remove-format feature', () => {
269+
it( 'should remove marker format when whole text format is removed', () => {
270+
_setModelData( model,
271+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
272+
'<$text inlineFormat="foo">[foo]</$text>' +
273+
'</paragraph>' +
274+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
275+
'<$text inlineFormat="foo">bar</$text>' +
276+
'</paragraph>'
277+
);
278+
279+
editor.execute( 'removeFormat' );
280+
281+
expect( _getModelData( model ) ).to.equalMarkup(
282+
'<paragraph listIndent="0" listItemId="a" listType="numbered">' +
283+
'[foo]' +
284+
'</paragraph>' +
285+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
286+
'<$text inlineFormat="foo">bar</$text>' +
287+
'</paragraph>'
288+
);
289+
} );
290+
291+
it( 'should remove marker format when part of text format is removed', () => {
292+
_setModelData( model,
293+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
294+
'<$text inlineFormat="foo">f[o]o</$text>' +
295+
'</paragraph>' +
296+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
297+
'<$text inlineFormat="foo">bar</$text>' +
298+
'</paragraph>'
299+
);
300+
301+
editor.execute( 'removeFormat' );
302+
303+
expect( _getModelData( model ) ).to.equalMarkup(
304+
'<paragraph listIndent="0" listItemId="a" listType="numbered">' +
305+
'<$text inlineFormat="foo">f</$text>' +
306+
'[o]' +
307+
'<$text inlineFormat="foo">o</$text>' +
308+
'</paragraph>' +
309+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
310+
'<$text inlineFormat="foo">bar</$text>' +
311+
'</paragraph>'
312+
);
313+
} );
314+
315+
it( 'should not remove marker format for a collapsed selection', () => {
316+
_setModelData( model,
317+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
318+
'<$text inlineFormat="foo">foo[]</$text>' +
319+
'</paragraph>' +
320+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
321+
'<$text inlineFormat="foo">bar</$text>' +
322+
'</paragraph>'
323+
);
324+
325+
editor.execute( 'removeFormat' );
326+
327+
expect( _getModelData( model ) ).to.equalMarkup(
328+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
329+
'<$text inlineFormat="foo">foo</$text>[]' +
330+
'</paragraph>' +
331+
'<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
332+
'<$text inlineFormat="foo">bar</$text>' +
333+
'</paragraph>'
334+
);
335+
} );
336+
} );
266337
} );
267338

268339
describe( 'inserting a text node into a list item', () => {

0 commit comments

Comments
 (0)