-
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
Migrate post editor editorMode
to use preferences store and remove localAutosaveInterval
preference
#39180
Migrate post editor editorMode
to use preferences store and remove localAutosaveInterval
preference
#39180
Changes from all commits
4f03223
d1d3278
6955965
5214466
5367371
5c94254
18ec159
b892747
6096ad6
9ce49a3
0c643cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* Adds settings to the block editor. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Extends the block editor with settings that are only in the plugin. | ||
* | ||
* This is a temporary solution until the Gutenberg plugin sets | ||
* the required WordPress version to 5.9. | ||
* | ||
* @see https://core.trac.wordpress.org/ticket/52920 | ||
* | ||
* @param array $settings Existing editor settings. | ||
* | ||
* @return array Filtered settings. | ||
*/ | ||
function gutenberg_get_block_editor_settings_5_9( $settings ) { | ||
$settings['__unstableEnableFullSiteEditingBlocks'] = current_theme_supports( 'block-templates' ); | ||
|
||
if ( wp_is_block_theme() ) { | ||
$settings['defaultTemplatePartAreas'] = get_allowed_block_template_part_areas(); | ||
} | ||
|
||
return $settings; | ||
} | ||
add_filter( 'block_editor_settings_all', 'gutenberg_get_block_editor_settings_5_9' ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
export const PREFERENCES_DEFAULTS = { | ||
editorMode: 'visual', | ||
panels: { | ||
'post-status': { | ||
opened: true, | ||
}, | ||
}, | ||
hiddenBlockTypes: [], | ||
preferredStyleVariations: {}, | ||
localAutosaveInterval: 15, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,9 @@ const EMPTY_ARRAY = []; | |
* | ||
* @return {string} Editing mode. | ||
*/ | ||
export function getEditorMode( state ) { | ||
return getPreference( state, 'editorMode', 'visual' ); | ||
} | ||
export const getEditorMode = createRegistrySelector( ( select ) => () => | ||
select( preferencesStore ).get( 'core/edit-post', 'editorMode' ) ?? 'visual' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it is. I added it back so that the unit tests are more logical. I suppose the unit tests could call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nah all good that makes sense 👍 |
||
); | ||
|
||
/** | ||
* Returns true if the editor sidebar is opened. | ||
|
@@ -91,7 +91,7 @@ export const getActiveGeneralSidebarName = createRegistrySelector( | |
|
||
// The current list of preference keys that have been migrated to the | ||
// preferences package. | ||
const MIGRATED_KEYS = [ 'hiddenBlockTypes' ]; | ||
const MIGRATED_KEYS = [ 'hiddenBlockTypes', 'editorMode' ]; | ||
|
||
/** | ||
* Returns the preferences (these preferences are persisted locally). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there's some defaults here - https://github.com/WordPress/gutenberg/blob/trunk/packages/react-native-bridge/common/gutenberg-web-single-block/local-storage-overrides.json.
There are some preferences that don't have matching settings in the web codebase ('pinnedPluginItems', 'isGeneralSidebarDismissed' and 'showInserterHelpPanel'), so I'm not sure if those are mobile only features, or things that were removed in the web codebase.
The web codebase also stopped using 'nux' a long time ago. Is it still in use on mobile?