Skip to content

Commit

Permalink
Fix CSS classes for the post editor iframe body.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Jan 8, 2025
1 parent 0f18e11 commit 61e2e15
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,30 @@ function Iframe( {
function preventFileDropDefault( event ) {
event.preventDefault();
}

const { ownerDocument } = node;

// Ideally ALL classes that are added through get_body_class should
// be added in the editor too, which we'll somehow have to get from
// the server in the future (which will run the PHP filters).
setBodyClasses(
Array.from( ownerDocument.body.classList ).filter(
( name ) =>
name.startsWith( 'admin-color-' ) ||
name.startsWith( 'post-type-' ) ||
name === 'wp-embed-responsive'
)
);

function onLoad() {
const { contentDocument, ownerDocument } = node;
const { contentDocument } = node;
const { documentElement } = contentDocument;
iFrameDocument = contentDocument;

documentElement.classList.add( 'block-editor-iframe__html' );

clearerRef( documentElement );

// Ideally ALL classes that are added through get_body_class should
// be added in the editor too, which we'll somehow have to get from
// the server in the future (which will run the PHP filters).
setBodyClasses(
Array.from( ownerDocument.body.classList ).filter(
( name ) =>
name.startsWith( 'admin-color-' ) ||
name.startsWith( 'post-type-' ) ||
name === 'wp-embed-responsive'
)
);

contentDocument.dir = ownerDocument.dir;

for ( const compatStyle of getCompatibilityStyles() ) {
Expand Down

0 comments on commit 61e2e15

Please sign in to comment.