diff --git a/packages/ckeditor5-list/src/listformatting.ts b/packages/ckeditor5-list/src/listformatting.ts
index f72dd31597e..624088590b8 100644
--- a/packages/ckeditor5-list/src/listformatting.ts
+++ b/packages/ckeditor5-list/src/listformatting.ts
@@ -242,6 +242,9 @@ function getSingleListItemConsistentFormat( model: Model, listItem: ModelElement
attributesToCheck.delete( attributeKey );
valuesMap[ attributeKey ] = undefined;
}
+ } else if ( !( attributeKey in valuesMap ) ) {
+ // Store it so a format would be removed when all items in the given list item does not allow that formatting.
+ valuesMap[ attributeKey ] = undefined;
}
}
diff --git a/packages/ckeditor5-list/tests/listformatting.js b/packages/ckeditor5-list/tests/listformatting.js
index 229bc05ab9d..75b73fcb450 100644
--- a/packages/ckeditor5-list/tests/listformatting.js
+++ b/packages/ckeditor5-list/tests/listformatting.js
@@ -8,6 +8,7 @@ import { Paragraph } from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
import { Plugin } from '@ckeditor/ckeditor5-core/src/plugin.js';
import { BlockQuoteEditing } from '@ckeditor/ckeditor5-block-quote';
import { RemoveFormatEditing } from '@ckeditor/ckeditor5-remove-format';
+import { CodeBlockEditing } from '@ckeditor/ckeditor5-code-block';
import { _setModelData, _getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
import { testUtils } from '@ckeditor/ckeditor5-core/tests/_utils/utils.js';
@@ -26,7 +27,7 @@ describe( 'ListFormatting', () => {
beforeEach( async () => {
editor = await VirtualTestEditor.create( {
- plugins: [ ListFormatting, Paragraph, BlockQuoteEditing, RemoveFormatEditing, MyPlugin, MyPlugin2 ]
+ plugins: [ ListFormatting, Paragraph, BlockQuoteEditing, CodeBlockEditing, RemoveFormatEditing, MyPlugin, MyPlugin2 ]
} );
model = editor.model;
@@ -393,6 +394,29 @@ describe( 'ListFormatting', () => {
);
} );
+ it( 'should not change attribute on formatted li if inserted inline object does not accept formatting', () => {
+ _setModelData( model,
+ '' +
+ '<$text inlineFormat="foo">foo[]$text>' +
+ ''
+ );
+
+ model.schema.extend( 'inlineObject', {
+ disallowAttributes: 'inlineFormat'
+ } );
+
+ model.change( writer => {
+ writer.insert( writer.createElement( 'inlineObject' ), docSelection.getFirstPosition() );
+ } );
+
+ expect( _getModelData( model, { withoutSelection: true } ) ).to.equalMarkup(
+ '' +
+ '<$text inlineFormat="foo">foo$text>' +
+ '' +
+ ''
+ );
+ } );
+
it( 'should remove attribute from formatted li if inserted text has different format', () => {
_setModelData( model,
'' +
@@ -486,6 +510,37 @@ describe( 'ListFormatting', () => {
''
);
} );
+
+ it( 'should reset marker formatting when list item block changed to code block', () => {
+ _setModelData( model,
+ '' +
+ '<$text inlineFormat="foo">fo[]o$text>' +
+ '' +
+ '' +
+ '<$text inlineFormat="foo">bar$text>' +
+ ''
+ );
+
+ expect( _getModelData( model, { withoutSelection: true } ) ).to.equalMarkup(
+ '' +
+ '<$text inlineFormat="foo">foo$text>' +
+ '' +
+ '' +
+ '<$text inlineFormat="foo">bar$text>' +
+ ''
+ );
+
+ editor.execute( 'codeBlock' );
+
+ expect( _getModelData( model, { withoutSelection: true } ) ).to.equalMarkup(
+ '' +
+ 'foo' +
+ '' +
+ '' +
+ '<$text inlineFormat="foo">bar$text>' +
+ ''
+ );
+ } );
} );
describe( 'other elements handling (block objects, inline objects)', () => {