Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WordPress 6.4 #355

Merged
merged 1 commit into from
Nov 7, 2023
Merged
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
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