Skip to content

Commit

Permalink
Paragraph: Use CSS to hide placeholders in Zoom out mode (#68690)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Jan 18, 2025
1 parent 5c2f7ed commit be5ce8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
21 changes: 3 additions & 18 deletions packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ import {
useBlockProps,
useSettings,
useBlockEditingMode,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { getBlockSupport } from '@wordpress/blocks';
import { formatLtr } from '@wordpress/icons';
/**
* Internal dependencies
*/
import { useOnEnter } from './use-enter';
import { unlock } from '../lock-unlock';

function ParagraphRTLControl( { direction, setDirection } ) {
return (
Expand Down Expand Up @@ -111,11 +108,7 @@ function ParagraphBlock( {
isSelected: isSingleSelected,
name,
} ) {
const isZoomOut = useSelect( ( select ) =>
unlock( select( blockEditorStore ) ).isZoomOut()
);

const { align, content, direction, dropCap } = attributes;
const { align, content, direction, dropCap, placeholder } = attributes;
const blockProps = useBlockProps( {
ref: useOnEnter( { clientId, content } ),
className: clsx( {
Expand All @@ -125,12 +118,6 @@ function ParagraphBlock( {
style: { direction },
} );
const blockEditingMode = useBlockEditingMode();
let { placeholder } = attributes;
if ( isZoomOut ) {
placeholder = '';
} else if ( ! placeholder ) {
placeholder = __( 'Type / to choose a block' );
}

return (
<>
Expand Down Expand Up @@ -182,10 +169,8 @@ function ParagraphBlock( {
: __( 'Block: Paragraph' )
}
data-empty={ RichText.isEmpty( content ) }
placeholder={ placeholder }
data-custom-placeholder={
placeholder && ! isZoomOut ? true : undefined
}
placeholder={ placeholder || __( 'Type / to choose a block' ) }
data-custom-placeholder={ placeholder ? true : undefined }
__unstableEmbedURLOnPaste
__unstableAllowPrefixTransformations
/>
Expand Down
7 changes: 7 additions & 0 deletions packages/block-library/src/paragraph/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@
.block-editor-block-list__block[data-type="core/paragraph"].has-text-align-left[style*="writing-mode: vertical-lr"] {
rotate: 180deg;
}

// Hide the placeholder when the editor is in zoomed out mode.
.is-zoomed-out .block-editor-block-list__block[data-empty="true"] {
[data-rich-text-placeholder] {
opacity: 0;
}
}

0 comments on commit be5ce8a

Please sign in to comment.