CYS: fix: Assembler follows admin color schema (#49159)

* CYS: fix: Assembler follows admin color schema

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Luigi Teschio 2024-07-05 12:20:49 +02:00 committed by GitHub
parent 1675c63bba
commit 9fc207b1a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View File

@ -39,6 +39,8 @@ function Iframe( {
} ) {
const [ iframeDocument, setIframeDocument ] = useState();
const [ bodyClasses, setBodyClasses ] = useState( [] );
const { resolvedAssets } = useSelect( ( select ) => {
const settings = select( blockEditorStore ).getSettings();
@ -54,6 +56,28 @@ function Iframe( {
node._load = () => {
setIframeDocument( node.contentDocument );
};
function onLoad() {
const { contentDocument, ownerDocument } = node;
const { documentElement } = contentDocument;
documentElement.classList.add( 'block-editor-iframe__html' );
setBodyClasses(
Array.from( ownerDocument?.body.classList ).filter(
( name ) =>
name.startsWith( 'admin-color-' ) ||
name.startsWith( 'post-type-' ) ||
name === 'wp-embed-responsive'
)
);
}
node.addEventListener( 'load', onLoad );
return () => {
delete node._load;
node.removeEventListener( 'load', onLoad );
};
}, [] );
const disabledRef = useDisabled( { isDisabled: ! readonly } );
@ -125,7 +149,8 @@ function Iframe( {
ref={ bodyRef }
className={ clsx(
'block-editor-iframe__body',
'editor-styles-wrapper'
'editor-styles-wrapper',
...bodyClasses
) }
>
{ contentResizeListener }

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
CYS: fix: Assembler follows admin color schema.