Skip to content

Commit

Permalink
Send updates to editor settings and let them sync to block editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Jan 25, 2023
1 parent 0451839 commit 0dd56db
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions packages/editor/src/components/provider/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ class NativeEditorProvider extends Component {
}

componentDidMount() {
const { capabilities, locale, hostAppNamespace, updateSettings } =
this.props;
const {
capabilities,
locale,
hostAppNamespace,
updateEditorSettings,
updateBlockEditorSettings,
} = this.props;

updateSettings( {
updateEditorSettings( {
...capabilities,
...this.getThemeColors( this.props ),
locale,
Expand Down Expand Up @@ -152,7 +157,9 @@ class NativeEditorProvider extends Component {
window.wp.galleryBlockV2Enabled =
galleryWithImageBlocks;
}
updateSettings( this.getThemeColors( editorSettings ) );
updateEditorSettings(
this.getThemeColors( editorSettings )
);
}
);

Expand All @@ -177,7 +184,7 @@ class NativeEditorProvider extends Component {
const impressions = { ...NEW_BLOCK_TYPES, ...storedImpressions };

// Persist impressions to JavaScript store.
updateSettings( { impressions } );
updateBlockEditorSettings( { impressions } );

// Persist impressions to native store if they do not include latest
// `NEW_BLOCK_TYPES` configuration.
Expand Down Expand Up @@ -318,7 +325,7 @@ class NativeEditorProvider extends Component {
}

updateCapabilitiesAction( capabilities ) {
this.props.updateSettings( capabilities );
this.props.updateEditorSettings( capabilities );
}

render() {
Expand Down Expand Up @@ -352,17 +359,14 @@ export default compose( [
getEditorBlocks,
getEditedPostAttribute,
getEditedPostContent,
getEditorSettings,
} = select( editorStore );
const { getEditorMode } = select( editPostStore );

const {
getBlockIndex,
getSelectedBlockClientId,
getGlobalBlockCount,
getSettings: getBlockEditorSettings,
} = select( blockEditorStore );
const { getBlockIndex, getSelectedBlockClientId, getGlobalBlockCount } =
select( blockEditorStore );

const settings = getBlockEditorSettings();
const settings = getEditorSettings();
const defaultEditorColors = settings?.colors ?? [];
const defaultEditorGradients = settings?.gradients ?? [];

Expand All @@ -381,7 +385,8 @@ export default compose( [
};
} ),
withDispatch( ( dispatch ) => {
const { editPost, resetEditorBlocks } = dispatch( editorStore );
const { editPost, resetEditorBlocks, updateEditorSettings } =
dispatch( editorStore );
const {
updateSettings,
clearSelectedBlock,
Expand All @@ -393,7 +398,8 @@ export default compose( [
const { createSuccessNotice } = dispatch( noticesStore );

return {
updateSettings,
updateBlockEditorSettings: updateSettings,
updateEditorSettings,
addEntities,
clearSelectedBlock,
insertBlock,
Expand Down

0 comments on commit 0dd56db

Please sign in to comment.