Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ _Returns_

- `Element`: Block Breadcrumb.

### BlockCanvasCover

Undocumented declaration.

### BlockColorsStyleSelector

Undocumented declaration.
Expand Down
44 changes: 44 additions & 0 deletions packages/block-editor/src/components/block-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { useMergeRefs, useViewportMatch } from '@wordpress/compose';
import { useRef } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { createSlotFill } from '@wordpress/components';

/**
* Internal dependencies
Expand All @@ -19,6 +20,8 @@ import { useBlockCommands } from '../use-block-commands';
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';

export const BlockCanvasCover = createSlotFill( 'BlockCanvasCover' );

// EditorStyles is a memoized component, so avoid passing a new
// object reference on each render.
const EDITOR_STYLE_TRANSFORM_OPTIONS = {
Expand Down Expand Up @@ -74,6 +77,27 @@ export function ExperimentalBlockCanvas( {
>
{ children }
</WritingFlow>

<BlockCanvasCover.Slot fillProps={ { containerRef: localRef } }>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a feeling the test failures might be due to the lack of a lock/unlock being used? I could be wrong here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't a private API and the other usages of createSlotFill don't need it.

{ ( covers ) =>
covers.map( ( cover, index ) => (
<div
key={ index }
className="block-canvas-cover"
style={ {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
pointerEvents: 'none',
} }
>
{ cover }
</div>
) )
}
</BlockCanvasCover.Slot>
</BlockTools>
);
}
Expand All @@ -95,6 +119,26 @@ export function ExperimentalBlockCanvas( {
>
<EditorStyles styles={ styles } />
{ children }
<BlockCanvasCover.Slot fillProps={ { containerRef: localRef } }>
{ ( covers ) =>
covers.map( ( cover, index ) => (
<div
key={ index }
className="block-canvas-cover"
style={ {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
pointerEvents: 'none',
} }
>
{ cover }
</div>
) )
}
</BlockCanvasCover.Slot>
</Iframe>
</BlockTools>
);
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * from './utils';
export { storeConfig, store } from './store';
export { SETTINGS_DEFAULTS } from './store/defaults';
export { privateApis } from './private-apis';
export { BlockCanvasCover } from './components/block-canvas';
Loading