@@ -5,11 +5,6 @@ import { addFilter } from '@wordpress/hooks';
55import { hasBlockSupport } from '@wordpress/blocks' ;
66import { useEffect , useCallback } from '@wordpress/element' ;
77import { useSelect } from '@wordpress/data' ;
8- import { __ } from '@wordpress/i18n' ;
9- import {
10- ToggleControl ,
11- __experimentalToolsPanelItem as ToolsPanelItem ,
12- } from '@wordpress/components' ;
138
149const EMPTY_OBJECT = { } ;
1510
@@ -19,7 +14,6 @@ const EMPTY_OBJECT = {};
1914import { optimizeFitText } from '../utils/fit-text-utils' ;
2015import { store as blockEditorStore } from '../store' ;
2116import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs' ;
22- import InspectorControls from '../components/inspector-controls' ;
2317
2418export const FIT_TEXT_SUPPORT_KEY = 'typography.fitText' ;
2519
@@ -207,76 +201,6 @@ function useFitText( { fitText, name, clientId } ) {
207201 ] ) ;
208202}
209203
210- /**
211- * Fit text control component for the typography panel.
212- *
213- * @param {Object } props Component props.
214- * @param {string } props.clientId Block client ID.
215- * @param {Function } props.setAttributes Function to set block attributes.
216- * @param {string } props.name Block name.
217- * @param {boolean } props.fitText Whether fit text is enabled.
218- * @param {string } props.fontSize Font size slug.
219- * @param {Object } props.style Block style object.
220- */
221- export function FitTextControl ( {
222- clientId,
223- fitText = false ,
224- setAttributes,
225- name,
226- fontSize,
227- style,
228- } ) {
229- if ( ! hasBlockSupport ( name , FIT_TEXT_SUPPORT_KEY ) ) {
230- return null ;
231- }
232- return (
233- < InspectorControls group = "typography" >
234- < ToolsPanelItem
235- hasValue = { ( ) => fitText }
236- label = { __ ( 'Fit text' ) }
237- onDeselect = { ( ) => setAttributes ( { fitText : undefined } ) }
238- resetAllFilter = { ( ) => ( { fitText : undefined } ) }
239- panelId = { clientId }
240- >
241- < ToggleControl
242- __nextHasNoMarginBottom
243- label = { __ ( 'Fit text' ) }
244- checked = { fitText }
245- onChange = { ( ) => {
246- const newFitText = ! fitText || undefined ;
247- const updates = { fitText : newFitText } ;
248-
249- // When enabling fit text, clear font size if it has a value
250- if ( newFitText ) {
251- if ( fontSize ) {
252- updates . fontSize = undefined ;
253- }
254- if ( style ?. typography ?. fontSize ) {
255- updates . style = {
256- ...style ,
257- typography : {
258- ...style ?. typography ,
259- fontSize : undefined ,
260- } ,
261- } ;
262- }
263- }
264-
265- setAttributes ( updates ) ;
266- } }
267- help = {
268- fitText
269- ? __ ( 'Text will resize to fit its container.' )
270- : __ (
271- 'The text will resize to fit its container, resetting other font size settings.'
272- )
273- }
274- />
275- </ ToolsPanelItem >
276- </ InspectorControls >
277- ) ;
278- }
279-
280204/**
281205 * Override props applied to the block element on save.
282206 *
@@ -338,7 +262,7 @@ const hasFitTextSupport = ( blockNameOrType ) => {
338262export default {
339263 useBlockProps,
340264 addSaveProps,
341- attributeKeys : [ 'fitText' , 'fontSize' , 'style' ] ,
265+ attributeKeys : [ 'fitText' ] ,
342266 hasSupport : hasFitTextSupport ,
343- edit : FitTextControl ,
267+ edit : ( ) => null ,
344268} ;
0 commit comments