Skip to content

Commit

Permalink
Editor: Refactor preview styles to use a constant for hiding block ed…
Browse files Browse the repository at this point in the history
…itor warnings
  • Loading branch information
yogeshbhutkar committed Jan 16, 2025
1 parent cc27cf0 commit b88e4ba
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/block-editor/src/components/block-preview/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const MemoizedBlockList = memo( BlockList );

const MAX_HEIGHT = 2000;
const EMPTY_ADDITIONAL_STYLES = [];
const PREVIEW_STYLES = {
css: 'body{height:auto;overflow:hidden;border:none;padding:0;} .block-editor-warning{display:none;} .is-root-container .block-editor-block-list__block.has-warning:after{background:none;}',
__unstableType: 'presets',
};

function ScaledBlockPreview( {
viewportWidth,
Expand All @@ -42,14 +46,7 @@ function ScaledBlockPreview( {
// Avoid scrollbars and hide block editor warnings for pattern previews.
const editorStyles = useMemo( () => {
if ( styles ) {
return [
...styles,
{
css: 'body{height:auto;overflow:hidden;border:none;padding:0;} .block-editor-warning{display:none;} .is-root-container .block-editor-block-list__block.has-warning:after{background:none;}',
__unstableType: 'presets',
},
...additionalStyles,
];
return [ ...styles, PREVIEW_STYLES, ...additionalStyles ];
}

return styles;
Expand Down

0 comments on commit b88e4ba

Please sign in to comment.