Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
The placeholder will not be shown over widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Jun 25, 2019
1 parent da5670a commit 6fb56bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/view/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down
14 changes: 14 additions & 0 deletions tests/view/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<div><ui:span></ui:span></div>' );
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, '<p></p>' );
viewDocument.isFocused = false;
Expand Down

0 comments on commit 6fb56bd

Please sign in to comment.