diff --git a/packages/ckeditor5-html-support/src/integrations/image.js b/packages/ckeditor5-html-support/src/integrations/image.js index 45f38bfdd6d..7dde1986772 100644 --- a/packages/ckeditor5-html-support/src/integrations/image.js +++ b/packages/ckeditor5-html-support/src/integrations/image.js @@ -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; diff --git a/packages/ckeditor5-html-support/tests/integrations/image.js b/packages/ckeditor5-html-support/tests/integrations/image.js index 9b8727653ed..931f7355cce 100644 --- a/packages/ckeditor5-html-support/tests/integrations/image.js +++ b/packages/ckeditor5-html-support/tests/integrations/image.js @@ -1221,6 +1221,25 @@ describe( 'ImageElementSupport', () => { '

' ); } ); + + // See: https://github.com/ckeditor/ckeditor5/issues/10703. + it( 'should not break inside element if image contains an attribute', () => { + dataFilter.loadAllowedConfig( [ { + name: 'img', + attributes: true + }, { + name: 'dir' + } ] ); + + editor.setData( '' ); + + expect( getModelDataWithAttributes( model, { withoutSelection: true } ) ).to.deep.equal( { + data: '', + attributes: {} + } ); + + expect( editor.getData() ).to.equal( '' ); + } ); } ); describe( 'Inline image with link', () => {