Skip to content
Merged
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
16 changes: 16 additions & 0 deletions packages/block-editor/src/hooks/fit-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { store as blockEditorStore } from '../store';
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
import InspectorControls from '../components/inspector-controls';
import FitTextSizeWarning from '../components/fit-text-size-warning';
import { unlock } from '../lock-unlock';

export const FIT_TEXT_SUPPORT_KEY = 'typography.fitText';

Expand Down Expand Up @@ -248,9 +249,24 @@ export function FitTextControl( {
fontSize,
style,
} ) {
const hasSelectedStyleState = useSelect(
( select ) => {
const { hasSelectedStyleState: hasSelectedBlockStyleState } =
unlock( select( blockEditorStore ) );

return hasSelectedBlockStyleState( clientId );
},
[ clientId ]
);

if ( ! hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {
return null;
}

if ( hasSelectedStyleState ) {
return null;
}

return (
<ToolsPanelItem
hasValue={ () => fitText }
Expand Down
14 changes: 13 additions & 1 deletion packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ 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 useDeprecatedAlign from './deprecated-attributes';
import { unlock } from '../lock-unlock';

function ParagraphRTLControl( { direction, setDirection } ) {
return (
Expand All @@ -53,8 +56,17 @@ function DropCapControl( { clientId, attributes, setAttributes, name } ) {
// and type performance. By moving it within InspectorControls, the subscription is
// now only added for the selected block(s).
const [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );
const hasSelectedStyleState = useSelect(
( select ) => {
const { hasSelectedStyleState: hasSelectedBlockStyleState } =
unlock( select( blockEditorStore ) );

if ( ! isDropCapFeatureEnabled ) {
return hasSelectedBlockStyleState( clientId );
},
[ clientId ]
);

if ( ! isDropCapFeatureEnabled || hasSelectedStyleState ) {
return null;
}

Expand Down
Loading