Skip to content

Commit

Permalink
Merge pull request #11429 from ckeditor/ck/10703
Browse files Browse the repository at this point in the history
Fix (html-support): Skip inline image upcast conversion inside not supported element. Closes #10703.
  • Loading branch information
arkflpc authored Mar 8, 2022
2 parents b8da51d + ad5b159 commit 9f6e48a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/ckeditor5-html-support/src/integrations/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export default class ImageElementSupport extends Plugin {
function viewToModelImageAttributeConverter( dataFilter ) {
return dispatcher => {
dispatcher.on( 'element:img', ( evt, data, conversionApi ) => {
if ( !data.modelRange ) {
return;
}

const viewImageElement = data.viewItem;
const viewContainerElement = viewImageElement.parent;

Expand Down
19 changes: 19 additions & 0 deletions packages/ckeditor5-html-support/tests/integrations/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,25 @@ describe( 'ImageElementSupport', () => {
'<p><img src="/assets/sample.png"></p>'
);
} );

// See: https://github.com/ckeditor/ckeditor5/issues/10703.
it( 'should not break inside <dir> element if image contains an attribute', () => {
dataFilter.loadAllowedConfig( [ {
name: 'img',
attributes: true
}, {
name: 'dir'
} ] );

editor.setData( '<dir><img data-foo="bar">' );

expect( getModelDataWithAttributes( model, { withoutSelection: true } ) ).to.deep.equal( {
data: '<htmlDir></htmlDir>',
attributes: {}
} );

expect( editor.getData() ).to.equal( '' );
} );
} );

describe( 'Inline image with link', () => {
Expand Down

0 comments on commit 9f6e48a

Please sign in to comment.