Skip to content

Commit

Permalink
Merge pull request #16294 from ckeditor/ck/16227
Browse files Browse the repository at this point in the history
Other (html-support): GHS list integration will create proper model structure on upcast and not fire a redundant post-fixer during editor initialization. Closes #16227.
  • Loading branch information
scofalik committed Apr 29, 2024
2 parents 97e41cd + a933122 commit 12d0e5d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ckeditor5-html-support/src/integrations/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function viewToModelListAttributeConverter( attributeName: string, dataFilter: D

// Set list attributes only on same level items, those nested deeper are already handled
// by the recursive conversion.
if ( item.hasAttribute( attributeName ) ) {
if ( item.hasAttribute( 'htmlUlAttributes' ) || item.hasAttribute( 'htmlOlAttributes' ) ) {
continue;
}

Expand Down
38 changes: 38 additions & 0 deletions packages/ckeditor5-html-support/tests/integrations/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,44 @@ describe( 'ListElementSupport', () => {
}
} );
} );

it( 'should not apply the attributes from ancestor list', () => {
dataFilter.allowElement( /^(ul|ol)$/ );
dataFilter.allowAttributes( { name: /^(ul|ol)$/, attributes: { 'data-foo': true } } );
dataFilter.allowAttributes( { name: /^(ul|ol)$/, attributes: { 'data-bar': true } } );

editor.setData( '<ul data-foo="myUl"><li>Foo<ol data-bar="myOl"><li>Bar</li></ol></li></ul>' );

// The attributes from the `ul` list should not be applied to the `ol` list.
// In that case, the postfixer should not create an additional operation to clean those attributes.
for ( const operation of editor.model.document.history.getOperations() ) {
expect( operation.type ).to.be.not.equal( 'removeAttribute' );
}

expect( getModelDataWithAttributes( model, { withoutSelection: true } ) ).to.deep.equal( {
data:
'<paragraph htmlLiAttributes="(1)" htmlUlAttributes="(2)" listIndent="0" listItemId="a01" listType="bulleted">' +
'Foo' +
'</paragraph>' +
'<paragraph htmlLiAttributes="(3)" htmlOlAttributes="(4)" listIndent="1" listItemId="a00" listType="numbered">' +
'Bar' +
'</paragraph>',
attributes: {
1: {},
2: {
attributes: {
'data-foo': 'myUl'
}
},
3: {},
4: {
attributes: {
'data-bar': 'myOl'
}
}
}
} );
} );
} );

describe( 'post-fixer', () => {
Expand Down

0 comments on commit 12d0e5d

Please sign in to comment.