-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
stylesheet-relative url(...)
s not rewritten in post-processed editor styles
#41035
Comments
Update: The underlying issue for the missing URL rewriting isn't located in the CSS transform but the editor style definition passed to the Gutenberg Block Editor, where for remotely fetched editor styles (by URL) no Related WordPress trac ticket: https://core.trac.wordpress.org/ticket/55728#ticket |
I am closing this issue in favor of the Trac issue, but can confirm the issue exists. |
@ndiego That trac ticket doesn't seem to be the same thing. That trac ticket is regarding using an absolute URL as an argument to |
This can be now closed with the introduction of PostCSS; I did attempt to reproduce this and I am unable to; the image loads as expected in the editor |
Hello ! |
@cb3rnard: Are those styles added at all, simply not prefixed? wp.domReady( function() {
wp.editSite.initializeEditor( "site-editor", |
@strarsis Sorry I didn't realise I was out of Sage's Github ! I am in deed using Sage 10, based on @dsturm setup (which is based on yours, which I also used recently) for FSE features. I had the same issue with a similar configuration. Maybe I should move this subject elsewhere... Styles are added, but not prefixed. url(...) is not correctly interpreted. |
@cb3rnard: Can you post the CSS that is not correctly processed (as with |
Off course. Here is below a small extract of the inline <style> tag in the iframe, computed from my compiled app.css. As you can see on 'container' class, it is not prefixed. The font-face url is a relative path, but the files are not downloaded. I don't have any backgrounds url(...) on that site but I had already had the same issue with it. *,
:after,
:before {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
/* ... */
}
.container {
width: 100%;
}
/* ... */
@font-face {
font-display: swap;
font-family: Futura;
font-style: normal;
font-weight: 700;
src: url(/app/themes/charivari/public/fonts/Futura_Std_Bold.73fa7e.woff2) format("woff2"),;
}
@font-face {
font-display: swap;
font-family: Bariol;
font-style: normal;
font-weight: 400;
src: url(/app/themes/charivari/public/fonts/Bariol_Regular.9459c8.woff2) format("woff2"),;
}
.siteFooter {
padding: 6rem 4rem 2rem;
} |
@cb3rnard: So with recent WordPress core the Gutenberg editor uses iframe-based style isolation and the CSS is not post-processed anymore (see #46212 (comment)). Can you request the |
It does work from the url, on the front, or in the post edit page when the visual editor is in desktop mode (= no iframe). |
That is actually an issue I encountered myself recently: host-relative URLs (as in your case) apparently do not work. |
I checked to be sure, absolute url load correctly in the editor iframe. Do you think this is a sage related issue ? Doesn't seem to be a lot of posts mentioning that, although that's both quite annoying. |
cb3rnard: Not necessarily a Sage-related issue. The workaround for this issue is using absolute URLs in the theme (as in block templates). Less than ideal, but it should work well on production. |
Yes, that's a s*** workaround... I can't really imagine using absolute urls, that would be a mess to synchronise between local, development and production environments. |
So, this issue has already been documented and shoud be fixed by #55152. I tried thinking about a fix using , but that's apparently not the best solution. Hope that will be validated and merged in the next release. |
Description
stylesheet-relative
url(...)
s are not rewritten in post-processed editor styles.As the post-processed CSS is added as inline-styles, these stylesheet-relative URLs don't resolve correctly anymore.
While in frontend the URLs are correctly loaded, in editor/backend they fail to load.
Edit: There is actually a test for rewriting those URLs:
gutenberg/packages/block-editor/src/utils/transform-styles/transforms/test/url-rewrite.js
Line 8 in 239a7ce
But it doesn't work for these styles...
Step-by-step reproduction instructions
url(...)
s (e.g..test { background: url('images/test.jpg'); }
) as editor style (add_editor_style(...)
) inside a theme.Note that the injected, post-processed CSS still uses the stylesheet-relative
url(...)
s.Screenshots, screen recording, code snippet
E.g.
app.css
:Environment info
5.9.3
13.2.0
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
The text was updated successfully, but these errors were encountered: