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

Block editor: Iframe: Remove reset styles #33204

Merged
merged 1 commit into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ function gutenberg_extend_block_editor_styles_html() {

ob_start();

wp_styles()->done = array();
// We do not need reset styles for the iframed editor.
wp_styles()->done = array( 'wp-reset-editor-styles' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the easiest way to get the job done. We trick do_items in thinking that the handle has already been added, so it will be skipped.

wp_styles()->do_items( $style_handles );
wp_styles()->done = $done;

Expand Down
7 changes: 7 additions & 0 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ function styleSheetsCompat( doc ) {
return;
}

// Don't try to add the reset styles, which were removed as a dependency
// from `edit-blocks` for the iframe since we don't need to reset admin
// styles.
if ( ownerNode.id === 'wp-reset-editor-styles-css' ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ignore this in the compatibility layer because it will search stylesheet for relevant selectors, which also matches wp-reset-editor-styles.

return;
}

const isMatch = Array.from( cssRules ).find(
( { selectorText } ) =>
selectorText &&
Expand Down