Skip to content

Commit

Permalink
try adding currentTheme to the editor settings
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Sep 20, 2024
1 parent c262896 commit 8ced871
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ function useEditorFontsResolver() {
const { currentTheme = {}, fontFamilies = [] } = useSelect( ( select ) => {
return {
currentTheme:
// Disable Reason: Using 'core' as string to avoid circular dependency importing from @wordpress/core-data.
// eslint-disable-next-line @wordpress/data-no-store-string-literals
select( 'core' )?.getCurrentTheme(),
select( editorStore ).getSettings()?.__experimentalFeatures
?.currentTheme,
fontFamilies:
select( editorStore ).getSettings()?.__experimentalFeatures
?.typography?.fontFamilies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { store as coreDataStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -15,12 +16,18 @@ import { TEMPLATE_POST_TYPE } from '../../utils/constants';
const { useGlobalStylesOutput } = unlock( blockEditorPrivateApis );

function useGlobalStylesRenderer() {
const postType = useSelect( ( select ) => {
return select( editSiteStore ).getEditedPostType();
const { postType, currentTheme } = useSelect( ( select ) => {
return {
postType: select( editSiteStore ).getEditedPostType(),
currentTheme: select( coreDataStore ).getCurrentTheme(),
};
} );
const [ styles, settings ] = useGlobalStylesOutput(
postType !== TEMPLATE_POST_TYPE
);

settings.currentTheme = currentTheme;

const { getSettings } = useSelect( editSiteStore );
const { updateSettings } = useDispatch( editSiteStore );

Expand Down

0 comments on commit 8ced871

Please sign in to comment.