Skip to content

Commit

Permalink
Merge pull request #17791 from ckeditor/ck/17789-code-conversion-fix
Browse files Browse the repository at this point in the history
Fix(basic-styles): Should not convert element with style `word-wrap: break-word` into `<code>` tag. Closes #17789.

MINOR BREAKING CHANGE (basic-styles): Elements which contains attribute `style` with `word-wrap: break-word` won't be converted to `<code>`. See #17789.
  • Loading branch information
pszczesniak authored Jan 21, 2025
2 parents daa1105 + f1dfe10 commit 0b637cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 1 addition & 6 deletions packages/ckeditor5-basic-styles/src/code/codeediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ export default class CodeEditing extends Plugin {

editor.conversion.attributeToElement( {
model: CODE,
view: 'code',
upcastAlso: {
styles: {
'word-wrap': 'break-word'
}
}
view: 'code'
} );

// Create code command.
Expand Down
7 changes: 4 additions & 3 deletions packages/ckeditor5-basic-styles/tests/code/codeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ describe( 'CodeEditing', () => {
expect( editor.getData() ).to.equal( '<p><code>foo</code>bar</p>' );
} );

it( 'should convert word-wrap:break-word to code attribute', () => {
// See: https://github.com/ckeditor/ckeditor5/issues/17789
it( 'should not convert word-wrap:break-word to code attribute', () => {
editor.setData( '<p><span style="word-wrap: break-word">foo</span>bar</p>' );

expect( getModelData( model, { withoutSelection: true } ) )
.to.equal( '<paragraph><$text code="true">foo</$text>bar</paragraph>' );
.to.equal( '<paragraph>foobar</paragraph>' );

expect( editor.getData() ).to.equal( '<p><code>foo</code>bar</p>' );
expect( editor.getData() ).to.equal( '<p>foobar</p>' );
} );

it( 'should be integrated with autoparagraphing', () => {
Expand Down

0 comments on commit 0b637cd

Please sign in to comment.