Skip to content

Editor styles are broken when a Google Font @import is included #53509

@andreiglingeanu

Description

@andreiglingeanu

Description

When the editor style contains this line, it breaks the page entirely:

@import url('https://fonts.googleapis.com/css2?family=Lobster:wght@400;500;600;700&display=swap');

Step-by-step reproduction instructions

  1. Start with any classic theme
  2. Put the code from down below in the functions.php
  3. Observe the problem
add_editor_style('some-style.css');
@import url('https://fonts.googleapis.com/css2?family=Lobster:wght@400;500;600;700&display=swap');

:root {
	--test: red;
}

Result:

CleanShot 2023-08-10 at 10 57 06@2x

Expected result:

@import url('https://fonts.googleapis.com/css2?family=Lobster:wght@400;500;600;700&display=swap');

.editor-styles-wrapper {
	--test: red;
}

Screenshots, screen recording, code snippet

This seems like a problem within the block-editor/src/utils/transform-styles/transforms/wrap.js file.

Environment info

WordPress 6.3, a classic theme.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Labels

[Feature] TypographyFont and typography-related issues and PRs[Package] Style Engine/packages/style-engine[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions