diff --git a/src/view/placeholder.js b/src/view/placeholder.js index 9655e15d7..644ce4d54 100644 --- a/src/view/placeholder.js +++ b/src/view/placeholder.js @@ -153,6 +153,11 @@ export function needsPlaceholder( element ) { return false; } + // If the element is a Widget always consider it a non-empty and thus not needing a placeholder. + if ( element.getCustomProperty( 'widget' ) ) { + return false; + } + // The element is empty only as long as it contains nothing but uiElements. const isEmptyish = !Array.from( element.getChildren() ) .some( element => !element.is( 'uiElement' ) ); diff --git a/tests/view/placeholder.js b/tests/view/placeholder.js index 60a3d0730..43838765b 100644 --- a/tests/view/placeholder.js +++ b/tests/view/placeholder.js @@ -389,6 +389,20 @@ describe( 'placeholder', () => { expect( needsPlaceholder( element ) ).to.be.false; } ); + it( 'should return false if element is a widget', () => { + // Widget with ui-only elements inside (emptyish). + setData( view, '
' ); + viewDocument.isFocused = false; + + const element = viewRoot.getChild( 0 ); + + view.change( writer => { + writer.setCustomProperty( 'widget', true, element ); + } ); + + expect( needsPlaceholder( element ) ).to.be.false; + } ); + it( 'should return true if element is empty and document is blurred', () => { setData( view, '

' ); viewDocument.isFocused = false;