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

Zoom out: Add an Editor setting to disable Zoom out mode #68878

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ _Properties_
- _\_\_experimentalBlockDirectory_ `boolean`: Whether the user has enabled the Block Directory
- _\_\_experimentalBlockPatterns_ `Array`: Array of objects representing the block patterns
- _\_\_experimentalBlockPatternCategories_ `Array`: Array of objects representing the block pattern categories
- _zoomOutEnabled_ `boolean`: Whether the zoom out feature is enabled or not.

### SkipToSelectedBlock

Expand Down
11 changes: 8 additions & 3 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ function InserterMenu(
},
ref
) {
const { isZoomOutMode, hasSectionRootClientId } = useSelect( ( select ) => {
const { isZoomOut, getSectionRootClientId } = unlock(
const {
isZoomOutMode,
zoomOutEditorSettingEnabled,
hasSectionRootClientId,
} = useSelect( ( select ) => {
const { isZoomOut, getSectionRootClientId, getSettings } = unlock(
select( blockEditorStore )
);

return {
isZoomOutMode: isZoomOut(),
hasSectionRootClientId: !! getSectionRootClientId(),
zoomOutEditorSettingEnabled: getSettings().zoomOutEnabled,
};
}, [] );

Expand Down Expand Up @@ -90,6 +94,7 @@ function InserterMenu(
const [ selectedTab, setSelectedTab ] = useState( getInitialTab() );

const shouldUseZoomOut =
zoomOutEditorSettingEnabled &&
hasSectionRootClientId &&
( selectedTab === 'patterns' || selectedTab === 'media' );

Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const PREFERENCES_DEFAULTS = {
* @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
* @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
* @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
* @property {boolean} zoomOutEnabled Whether the zoom out feature is enabled or not.
*/
export const SETTINGS_DEFAULTS = {
alignWide: false,
Expand Down
6 changes: 6 additions & 0 deletions packages/editor/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ function Header( {
};
}, [] );

const zoomOutEditorSettingEnabled = useSelect(
( select ) => select( editorStore ).getEditorSettings().zoomOutEnabled,
[]
);

const canBeZoomedOut =
zoomOutEditorSettingEnabled &&
[ 'post', 'page', 'wp_template' ].includes( postType ) &&
hasSectionRootClientId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const BLOCK_EDITOR_SETTINGS = [
'__unstableHasCustomAppender',
'__unstableResolvedAssets',
'__unstableIsBlockBasedTheme',
'zoomOutEnabled',
];

const {
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SETTINGS_DEFAULTS } from '@wordpress/block-editor';
* @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
* @property {number} maxUploadFileSize Maximum upload file size
* @property {boolean} supportsLayout Whether the editor supports layouts.
* @property {boolean} zoomOutEnabled Whether the zoom out feature is enabled or not.
*/
export const EDITOR_SETTINGS_DEFAULTS = {
...SETTINGS_DEFAULTS,
Expand All @@ -30,4 +31,5 @@ export const EDITOR_SETTINGS_DEFAULTS = {
fontLibraryEnabled: true,
enableCustomFields: undefined,
defaultRenderingMode: 'post-only',
zoomOutEnabled: true,
};
Loading