@@ -7,6 +7,7 @@ import { VirtualTestEditor } from '@ckeditor/ckeditor5-core/tests/_utils/virtual
77import { Paragraph } from '@ckeditor/ckeditor5-paragraph/src/paragraph.js' ;
88import { Plugin } from '@ckeditor/ckeditor5-core/src/plugin.js' ;
99import { BlockQuoteEditing } from '@ckeditor/ckeditor5-block-quote' ;
10+ import { RemoveFormatEditing } from '@ckeditor/ckeditor5-remove-format' ;
1011import { _setModelData , _getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js' ;
1112import { testUtils } from '@ckeditor/ckeditor5-core/tests/_utils/utils.js' ;
1213
@@ -25,13 +26,15 @@ describe( 'ListFormatting', () => {
2526
2627 beforeEach ( async ( ) => {
2728 editor = await VirtualTestEditor . create ( {
28- plugins : [ ListFormatting , Paragraph , BlockQuoteEditing , MyPlugin , MyPlugin2 ]
29+ plugins : [ ListFormatting , Paragraph , BlockQuoteEditing , RemoveFormatEditing , MyPlugin , MyPlugin2 ]
2930 } ) ;
3031
3132 model = editor . model ;
3233 docSelection = model . document . selection ;
3334
3435 model . schema . extend ( '$text' , { allowAttributes : [ 'inlineFormat' , 'inlineFormat2' ] } ) ;
36+ model . schema . setAttributeProperties ( 'inlineFormat' , { isFormatting : true } ) ;
37+ model . schema . setAttributeProperties ( 'inlineFormat2' , { isFormatting : true } ) ;
3538
3639 model . schema . register ( 'blockObject' , {
3740 inheritAllFrom : '$blockObject' ,
@@ -260,6 +263,76 @@ describe( 'ListFormatting', () => {
260263 '</paragraph>'
261264 ) ;
262265 } ) ;
266+
267+ describe ( 'with remove-format feature' , ( ) => {
268+ it ( 'should remove marker format when whole text format is removed' , ( ) => {
269+ _setModelData ( model ,
270+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
271+ '<$text inlineFormat="foo">[foo]</$text>' +
272+ '</paragraph>' +
273+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
274+ '<$text inlineFormat="foo">bar</$text>' +
275+ '</paragraph>'
276+ ) ;
277+
278+ editor . execute ( 'removeFormat' ) ;
279+
280+ expect ( _getModelData ( model ) ) . to . equalMarkup (
281+ '<paragraph listIndent="0" listItemId="a" listType="numbered">' +
282+ '[foo]' +
283+ '</paragraph>' +
284+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
285+ '<$text inlineFormat="foo">bar</$text>' +
286+ '</paragraph>'
287+ ) ;
288+ } ) ;
289+
290+ it ( 'should remove marker format when part of text format is removed' , ( ) => {
291+ _setModelData ( model ,
292+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
293+ '<$text inlineFormat="foo">f[o]o</$text>' +
294+ '</paragraph>' +
295+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
296+ '<$text inlineFormat="foo">bar</$text>' +
297+ '</paragraph>'
298+ ) ;
299+
300+ editor . execute ( 'removeFormat' ) ;
301+
302+ expect ( _getModelData ( model ) ) . to . equalMarkup (
303+ '<paragraph listIndent="0" listItemId="a" listType="numbered">' +
304+ '<$text inlineFormat="foo">f</$text>' +
305+ '[o]' +
306+ '<$text inlineFormat="foo">o</$text>' +
307+ '</paragraph>' +
308+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
309+ '<$text inlineFormat="foo">bar</$text>' +
310+ '</paragraph>'
311+ ) ;
312+ } ) ;
313+
314+ it ( 'should not remove marker format for a collapsed selection' , ( ) => {
315+ _setModelData ( model ,
316+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
317+ '<$text inlineFormat="foo">foo[]</$text>' +
318+ '</paragraph>' +
319+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
320+ '<$text inlineFormat="foo">bar</$text>' +
321+ '</paragraph>'
322+ ) ;
323+
324+ editor . execute ( 'removeFormat' ) ;
325+
326+ expect ( _getModelData ( model ) ) . to . equalMarkup (
327+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="a" listType="numbered">' +
328+ '<$text inlineFormat="foo">foo</$text>[]' +
329+ '</paragraph>' +
330+ '<paragraph listIndent="0" listItemFormat="foo" listItemId="b" listType="numbered">' +
331+ '<$text inlineFormat="foo">bar</$text>' +
332+ '</paragraph>'
333+ ) ;
334+ } ) ;
335+ } ) ;
263336 } ) ;
264337
265338 describe ( 'inserting a text node into a list item' , ( ) => {
@@ -833,6 +906,7 @@ describe( 'ListFormatting', () => {
833906 const model = this . editor . model ;
834907
835908 model . schema . extend ( '$listItem' , { allowAttributes : 'listItemFormat' } ) ;
909+ model . schema . setAttributeProperties ( 'listItemFormat' , { isFormatting : true } ) ;
836910 model . schema . addAttributeCheck ( context => {
837911 const item = context . last ;
838912 if ( ! item . getAttribute ( 'listItemId' ) ) {
@@ -853,6 +927,7 @@ describe( 'ListFormatting', () => {
853927 const model = this . editor . model ;
854928
855929 model . schema . extend ( '$listItem' , { allowAttributes : 'listItemFormat2' } ) ;
930+ model . schema . setAttributeProperties ( 'listItemFormat2' , { isFormatting : true } ) ;
856931 model . schema . addAttributeCheck ( context => {
857932 const item = context . last ;
858933 if ( ! item . getAttribute ( 'listItemId' ) ) {
0 commit comments