Skip to content

Commit

Permalink
Add support for WordPress 6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Nov 7, 2023
1 parent e8b26b2 commit 620a222
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/OnboardingSPA/components/LivePreview/BlockPreview/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
__unstableIframe as Iframe,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__unstableEditorStyles as EditorStyles,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__unstablePresetDuotoneFilter as PresetDuotoneFilter,
} from '@wordpress/block-editor';

// This is used to avoid rendering the block list if the sizes change.
Expand All @@ -29,10 +27,9 @@ function ScaledBlockPreview( {

const [ contentResizeListener, { height: contentHeight } ] =
useResizeObserver();
const { styles, assets, duotone } = {
const { styles, assets } = {
styles: settings.styles,
assets: settings.__unstableResolvedAssets,
duotone: settings.__experimentalFeatures?.color?.duotone,
};

// Avoid scrollbars for pattern previews.
Expand All @@ -51,20 +48,19 @@ function ScaledBlockPreview( {
return styles;
}, [ styles, additionalStyles ] );

const svgFilters = useMemo( () => {
return [ ...( duotone?.default ?? [] ), ...( duotone?.theme ?? [] ) ];
}, [ duotone ] );

// Initialize on render instead of module top level, to avoid circular dependency issues.
MemoizedBlockList = MemoizedBlockList || pure( BlockList );

const scale = containerWidth / viewportWidth;
const aspectRatio = contentHeight
? containerWidth / ( contentHeight * scale )
: 0;
return (
<Disabled
className="block-editor-block-preview__content"
style={ {
transform: `scale(${ scale })`,
height: contentHeight * scale,
aspectRatio,
maxHeight:
contentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined,
minHeight,
Expand Down Expand Up @@ -106,15 +102,6 @@ function ScaledBlockPreview( {
>
<EditorStyles styles={ editorStyles } />
{ contentResizeListener }
{
/* Filters need to be rendered before children to avoid Safari rendering issues. */
svgFilters.map( ( preset ) => (
<PresetDuotoneFilter
preset={ preset }
key={ preset.slug }
/>
) )
}
<MemoizedBlockList renderAppender={ false } />
</Iframe>
</Disabled>
Expand Down

0 comments on commit 620a222

Please sign in to comment.