Skip to content
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

Select Mode: Hide tool selector in the post editor and force design mode #66784

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2764,8 +2764,11 @@ export function isNavigationMode( state ) {
* @return {string} the editor mode.
*/
export const __unstableGetEditorMode = createRegistrySelector(
( select ) => () => {
return select( preferencesStore ).get( 'core', 'editorTool' );
( select ) => ( state ) => {
return (
state.settings.editorTool ??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that approach where we don't mess with the preference.

select( preferencesStore ).get( 'core', 'editorTool' )
);
}
);

Expand Down
8 changes: 7 additions & 1 deletion packages/editor/src/components/document-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ function DocumentTools( { className, disableBlockTools = false } ) {
inserterSidebarToggleRef,
listViewToggleRef,
showIconLabels,
showTools,
} = useSelect( ( select ) => {
const { get } = select( preferencesStore );
const {
isListViewOpened,
getEditorMode,
getInserterSidebarToggleRef,
getListViewToggleRef,
getRenderingMode,
getCurrentPostType,
} = unlock( select( editorStore ) );
const { getShortcutRepresentation } = select( keyboardShortcutsStore );

Expand All @@ -56,6 +59,9 @@ function DocumentTools( { className, disableBlockTools = false } ) {
showIconLabels: get( 'core', 'showIconLabels' ),
isDistractionFree: get( 'core', 'distractionFree' ),
isVisualMode: getEditorMode() === 'visual',
showTools:
getRenderingMode() !== 'post-only' ||
getCurrentPostType() === 'wp_template',
};
}, [] );

Expand Down Expand Up @@ -128,7 +134,7 @@ function DocumentTools( { className, disableBlockTools = false } ) {
) }
{ ( isWideViewport || ! showIconLabels ) && (
<>
{ isLargeViewport && (
{ showTools && isLargeViewport && (
<ToolbarItem
as={ ToolSelector }
showTooltip={ ! showIconLabels }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
: settings.template,
__experimentalSetIsInserterOpened: setIsInserterOpened,
[ sectionRootClientIdKey ]: sectionRootClientId,
editorTool:
renderingMode === 'post-only' && postType !== 'wp_template'
? 'edit'
: undefined,
};

return blockEditorSettings;
Expand Down Expand Up @@ -355,6 +359,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
sectionRootClientId,
globalStylesData,
globalStylesLinksData,
renderingMode,
] );
}

Expand Down
Loading