-
Notifications
You must be signed in to change notification settings - Fork 328
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
Gutenberg Compatibility? #2009
Comments
I'm looking for a way to add the Google Fonts generated by kirki to the block editor assets as well. |
I like the idea and I'd love to do it... I'm just a bit pressed on time this period so I can't make this a priority. |
Thank you for the response, and good to hear that you will eventually do this. :) I tried a little and was able to enqueue customizer generated css file to the editor simply by hooking it to the action "enqueue_block_editor_assets". Now that loads the kirki generated CSS in the editor, however having two issues. 1) The Google Fonts do not load/work in the editor. 2) The enqueued CSS interfere/applies to WP admin and Gutenberg interface elements. To resolve styling conflict we simply need to target editor specific selectors for the elements, now if that could be handled automatically by kirki that will make it awesome. Here is the only theme support instructions available for Gutenberg officially. Hope this helps? Could you please provide a solution for loading google fonts meanwhile you work on this full compatibility? TIA, |
I added PR #2017 which does provide an example of how you can use the module async loader to ensure the webfonts are added. You can reference that code here:
Yes, that's correct, as you're adding a styles directly into the editor without using
Yeah, I wish this was all explained in documentation somewhere, because I also took the same path as you. Seems a bit ridiculous that setting the "standard way of creating content moving forward" means that developers are left with having to dive in deep to the code to get any useful things done. The documentation barely scratches the surface of what can be done/extended. There's also a lot of things that you can't do (well at least not very easily without reinventing the wheel) that are needed for more complex themes and plugins. Hopefully this will change soon. For reference - WordPress/gutenberg#9008 was useful to get familiar with how |
I found a couple of free hours so I was able to take a look at this. This is what we used to write: 'output' => array(
array(
'element' => 'body',
'property' => 'font-size',
),
), In Gutenberg the font-size for the main body would be in the 'output' => array(
array(
'element' => 'body',
'property' => 'font-size',
),
array(
'element' => '.edit-post-visual-editor.editor-styles-wrapper',
'property' => 'font-size',
'context' => array( 'editor' ),
),
), As you can see, there's a new This is now in the I know that ideally we'd want to avoid writing the same output arguments again for the dashboard and in a perfect world we wouldn't have conflicts with the default dashboard styles. |
@aristath can you check out #2017? It leverages the automatic transformation/namespacing of CSS being imported to use in gutenberg so it won't impact the interface elements of the editor. This removes the need to specify editor specific styles for each control to just allowing themes to optin on a per config basis. This is the documentation for adding editor styles for themes in order to support gutenberg: https://wordpress.org/gutenberg/handbook/extensibility/theme-support/#editor-styles I think it's better to rely on the namespacing provided for styles in core as the wrapper or classes are prone to be changed as gutenberg grows. I could also see use cases where a custom editor may have a different wrap scheme, in which case the styles are no longer accurate. I do like the context output option for allowing themes to conditionally add styles per control basis for the editor as needed, maybe a combination of these two things could be worked in? I know in a lot of theme testing I've done, it's been easier to use the solution in #2017 as everything is automatically handled for me for all styles I output without conflict. To do it via the context argument would introduce hours of extra work in fixing them all. |
@timelsass That is exactly how I imagined it to work. Your solution seems great to me. And yes @aristath having a context output will be a nice option as well. FYI, Gutenberg / WordPress release is now rescheduled to 27th Nov. So I am hoping this kirki Gutenberg compatibility if possible to be released earlier so the Themes using Kirki can be updated timely with the Gutenberg support. This will definitely be a great update for Kirki framework. Thank you for all your hard work on this opensource project @aristath |
@timelsass that looks great to me... I just made a couple of minor changes to the PR (nothing major, just minor details) and merged it. So now we have 2 ways to add Gutenberg support: automatic using |
@aristath That is amazing. I will give it a try with my theme and report any issues or suggestions. Thank you @timelsass for this. |
Just started testing the develop branch. I am getting this error.
TIA |
@munirkamal can you check now? I just pushed something that should fix this. |
@timelsass does the theme need to opt-in with |
@braginteractive Only if output is disabled, otherwise Kirki adds it - https://github.com/aristath/kirki/blob/ec63944decfbf128ead44e7f8653779bbfcbf718/modules/gutenberg/class-kirki-modules-gutenberg.php#L146 |
Can't seem to get this working. Keep getting this error:
Update: Adding the following fixes the above issue: add_filter( 'kirki_output_inline_styles', '__return_false' ); However this loads all of the styles in the admin, and they are also being applied to elements outside of the editor. Update: Adding the following workaround seems to work: add_filter( 'kirki_gutenberg_' . $config_id . '_dynamic_css', function () {
return file_get_contents( WP_CONTENT_DIR . '/uploads/kirki-css/styles.css' );
} ); |
Issue description:
I have got a theme built heavily with the kirki, I am looking to make it compatible with Gutenberg now. The first thing obviously is to render/enqueue all the styles generated via the customizer to the editor view. I was looking for the documentation and found this latest pull request got merged to be available with the next version 4.2 of Gutenberg.
WordPress/gutenberg#10956
Wondering if you @aristath is already working on something for Kirki to auto opt-in for this functionality? To make the life easier for the themes using kirki for the customizer? Any news?
Looking forward to your response.
TIA,
Munir
The text was updated successfully, but these errors were encountered: