From 34aa26e672896cee64a90e0cb829a428db9cc2ac Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 13:56:37 +0530 Subject: [PATCH 01/16] Block Editor: Convert MediaUpload and MediaUploadCheck to TypeScript --- .../media-upload/{check.js => check.ts} | 6 +- .../media-upload/{index.js => index.ts} | 10 ++- .../src/components/media-upload/types.ts | 75 +++++++++++++++++++ 3 files changed, 87 insertions(+), 4 deletions(-) rename packages/block-editor/src/components/media-upload/{check.js => check.ts} (76%) rename packages/block-editor/src/components/media-upload/{index.js => index.ts} (56%) create mode 100644 packages/block-editor/src/components/media-upload/types.ts diff --git a/packages/block-editor/src/components/media-upload/check.js b/packages/block-editor/src/components/media-upload/check.ts similarity index 76% rename from packages/block-editor/src/components/media-upload/check.js rename to packages/block-editor/src/components/media-upload/check.ts index bce08a30e5b4c5..237b8c611a6221 100644 --- a/packages/block-editor/src/components/media-upload/check.js +++ b/packages/block-editor/src/components/media-upload/check.ts @@ -1,7 +1,11 @@ import { useSelect } from '@wordpress/data'; import { store as blockEditorStore } from '../../store'; +import type { MediaUploadCheckProps } from './types'; -export function MediaUploadCheck( { fallback = null, children } ) { +export function MediaUploadCheck( { + fallback = null, + children, +}: MediaUploadCheckProps ) { const hasUploadPermissions = useSelect( ( select ) => { const { getSettings } = select( blockEditorStore ); return !! getSettings().mediaUpload; diff --git a/packages/block-editor/src/components/media-upload/index.js b/packages/block-editor/src/components/media-upload/index.ts similarity index 56% rename from packages/block-editor/src/components/media-upload/index.js rename to packages/block-editor/src/components/media-upload/index.ts index cb49e4e129a320..bf626f69e22342 100644 --- a/packages/block-editor/src/components/media-upload/index.js +++ b/packages/block-editor/src/components/media-upload/index.ts @@ -1,15 +1,19 @@ +import type { ComponentType } from 'react'; import { withFilters } from '@wordpress/components'; +import type { MediaUploadProps } from './types'; /** * This is a placeholder for the media upload component necessary to make it possible to provide * an integration with the core blocks that handle media files. By default it renders nothing but * it provides a way to have it overridden with the `editor.MediaUpload` filter. * - * @return {Component} The component to be rendered. + * @return The component to be rendered. */ -const MediaUpload = () => null; +const MediaUpload = (): null => null; /** * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md */ -export default withFilters( 'editor.MediaUpload' )( MediaUpload ); +export default withFilters( 'editor.MediaUpload' )( + MediaUpload +) as unknown as ComponentType< MediaUploadProps >; // `withFilters` erases the props of the filter's implementation. diff --git a/packages/block-editor/src/components/media-upload/types.ts b/packages/block-editor/src/components/media-upload/types.ts new file mode 100644 index 00000000000000..8c9ae0d2f20e6f --- /dev/null +++ b/packages/block-editor/src/components/media-upload/types.ts @@ -0,0 +1,75 @@ +import type { ReactNode } from 'react'; + +/** + * Props of `MediaUploadCheck`. + */ +export interface MediaUploadCheckProps { + /** + * Rendered when the user cannot upload media. + */ + fallback?: ReactNode; + children?: ReactNode; +} + +/** + * Props of `MediaUpload`, implemented through the `editor.MediaUpload` filter. + */ +export interface MediaUploadProps { + /** + * The types of the media to upload or select from the media library, + * either a general mime type such as 'image' or a complete one such as + * 'image/gif'. All mime types are allowed when unset. + */ + allowedTypes?: string[]; + /** + * The frame content's default mode, such as 'browse' or 'upload'. + */ + mode?: string; + /** + * Whether to allow selecting multiple files. `add` allows it without + * holding `Shift` or `Ctrl`/`Cmd`. + */ + multiple?: boolean | string; + /** + * Media ID, or IDs if `multiple` is set, selected when the library opens. + */ + value?: number | number[]; + /** + * Called when the media modal closes, with or without a selection. + */ + onClose?: () => void; + /** + * Called after `onClose` with the selected media, which come from the + * filter's implementation and are untyped here. + */ + onSelect: ( media: unknown ) => void; + /** + * Title displayed in the media modal. + */ + title?: string; + /** + * CSS class added to the media modal frame. + */ + modalClass?: string; + /** + * Whether the gallery modal opens in the media library rather than in + * the edit frame. Only applies when `gallery` is set. + */ + addToGallery?: boolean; + /** + * Whether to initiate the states representing a gallery. + */ + gallery?: boolean; + /** + * Whether the modal opens as the featured image frame. + */ + featuredImageFlow?: boolean; + /** + * @deprecated Use `featuredImageFlow` instead. + */ + unstableFeaturedImageFlow?: boolean; + /** + * Renders the button opening the media library. + */ + render: ( props: { open: () => void } ) => ReactNode; +} From 71cf06f2dd31caa8b43a214f4311625ac13006db Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 13:57:07 +0530 Subject: [PATCH 02/16] Block Editor: Convert BlockTitle and useBlockDisplayTitle to TypeScript --- .../block-title/{index.js => index.ts} | 7 +++- .../src/components/block-title/types.ts | 17 +++++++++ ...ay-title.js => use-block-display-title.ts} | 35 +++++++++++-------- 3 files changed, 43 insertions(+), 16 deletions(-) rename packages/block-editor/src/components/block-title/{index.js => index.ts} (83%) create mode 100644 packages/block-editor/src/components/block-title/types.ts rename packages/block-editor/src/components/block-title/{use-block-display-title.js => use-block-display-title.ts} (65%) diff --git a/packages/block-editor/src/components/block-title/index.js b/packages/block-editor/src/components/block-title/index.ts similarity index 83% rename from packages/block-editor/src/components/block-title/index.js rename to packages/block-editor/src/components/block-title/index.ts index 42aeecb5851dc5..0daa48e04ea341 100644 --- a/packages/block-editor/src/components/block-title/index.js +++ b/packages/block-editor/src/components/block-title/index.ts @@ -1,4 +1,5 @@ import useBlockDisplayTitle from './use-block-display-title'; +import type { BlockTitleProps } from './types'; /** * Renders the block's configured title as a string, or empty if the title @@ -17,6 +18,10 @@ import useBlockDisplayTitle from './use-block-display-title'; * * @return {React.JSX.Element} Block title. */ -export default function BlockTitle( { clientId, maximumLength, context } ) { +export default function BlockTitle( { + clientId, + maximumLength, + context, +}: BlockTitleProps ) { return useBlockDisplayTitle( { clientId, maximumLength, context } ); } diff --git a/packages/block-editor/src/components/block-title/types.ts b/packages/block-editor/src/components/block-title/types.ts new file mode 100644 index 00000000000000..c805846a82fc43 --- /dev/null +++ b/packages/block-editor/src/components/block-title/types.ts @@ -0,0 +1,17 @@ +/** + * Props of `BlockTitle` and options of `useBlockDisplayTitle`. + */ +export interface BlockTitleProps { + /** + * Client ID of block. + */ + clientId: string; + /** + * The maximum length that the block title string may be before truncated. + */ + maximumLength?: number; + /** + * The context to pass to `getBlockLabel`. + */ + context?: string; +} diff --git a/packages/block-editor/src/components/block-title/use-block-display-title.js b/packages/block-editor/src/components/block-title/use-block-display-title.ts similarity index 65% rename from packages/block-editor/src/components/block-title/use-block-display-title.js rename to packages/block-editor/src/components/block-title/use-block-display-title.ts index cac4f36b9544ba..61970c2bbf6824 100644 --- a/packages/block-editor/src/components/block-title/use-block-display-title.js +++ b/packages/block-editor/src/components/block-title/use-block-display-title.ts @@ -1,33 +1,38 @@ import { useSelect } from '@wordpress/data'; +import type { DataRegistry } from '@wordpress/data'; import { __experimentalGetBlockLabel as getBlockLabel, store as blocksStore, } from '@wordpress/blocks'; import { store as blockEditorStore } from '../../store'; - -/** @typedef {import('@wordpress/data').WPDataRegistry['select']} RegistrySelect */ +import type { BlockTitleProps } from './types'; /** * Resolves a block's custom label, variation title, or registered title. * - * @param {RegistrySelect} select Registry selector accessor. - * @param {string} clientId Block client ID. - * @param {string} context Label context. - * @return {string|null} The block's display title. + * @param select Registry selector accessor. + * @param clientId Block client ID. + * @param context Label context. + * @return The block's display title. */ -export function getBlockDisplayTitle( select, clientId, context ) { +export function getBlockDisplayTitle( + select: DataRegistry[ 'select' ], + clientId: string, + context?: string +): string | null { if ( ! clientId ) { return null; } const { getBlockName, getBlockAttributes, getBlock } = select( blockEditorStore ); const { getBlockType, getActiveBlockVariation } = select( blocksStore ); - const blockName = getBlockName( clientId ); + // A missing block has no block type, which returns early below. + const blockName = getBlockName( clientId )!; const blockType = getBlockType( blockName ); if ( ! blockType ) { return null; } - const attributes = getBlockAttributes( clientId ); + const attributes = getBlockAttributes( clientId )!; const label = getBlockLabel( blockType, attributes, context ); if ( label !== blockType.title && @@ -54,17 +59,17 @@ export function getBlockDisplayTitle( select, clientId, context ) { * useBlockDisplayTitle( { clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', maximumLength: 17 } ); * ``` * - * @param {Object} props - * @param {string} props.clientId Client ID of block. - * @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated. - * @param {string|undefined} props.context The context to pass to `getBlockLabel`. - * @return {?string} Block title. + * @param props + * @param props.clientId Client ID of block. + * @param props.maximumLength The maximum length that the block title string may be before truncated. + * @param props.context The context to pass to `getBlockLabel`. + * @return Block title. */ export default function useBlockDisplayTitle( { clientId, maximumLength, context, -} ) { +}: BlockTitleProps ): string | null { const blockTitle = useSelect( ( select ) => getBlockDisplayTitle( select, clientId, context ), [ clientId, context ] From 66f4d8441332d4115d2119dd12b556bef0b9ea50 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 13:57:12 +0530 Subject: [PATCH 03/16] Block Editor: Convert the BlockTitle tests to TypeScript --- ...ex.jsdom.test.jsx => index.jsdom.test.tsx} | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) rename packages/block-editor/src/components/block-title/test/{index.jsdom.test.jsx => index.jsdom.test.tsx} (73%) diff --git a/packages/block-editor/src/components/block-title/test/index.jsdom.test.jsx b/packages/block-editor/src/components/block-title/test/index.jsdom.test.tsx similarity index 73% rename from packages/block-editor/src/components/block-title/test/index.jsdom.test.jsx rename to packages/block-editor/src/components/block-title/test/index.jsdom.test.tsx index 68176f09f0e5a7..09b8056e4bf50b 100644 --- a/packages/block-editor/src/components/block-title/test/index.jsdom.test.jsx +++ b/packages/block-editor/src/components/block-title/test/index.jsdom.test.tsx @@ -1,9 +1,10 @@ import { describe, expect, it, vi } from 'vitest'; +import type { Mock } from 'vitest'; import { render, screen } from '@testing-library/react'; import { useSelect } from '@wordpress/data'; import BlockTitle from '../'; -const blockTypeMap = { +const blockTypeMap: Record< string, { title: string } | null > = { 'name-not-exists': null, 'name-exists': { title: 'Block Title' }, 'name-with-label': { title: 'Block With Label' }, @@ -12,7 +13,7 @@ const blockTypeMap = { 'reusable-block': { title: 'Reusable Block' }, }; -const blockLabelMap = { +const blockLabelMap: Record< string, string > = { 'Block With Label': 'Test Label', 'Block With Long Label': 'This is a longer label than typical for blocks to have.', @@ -24,12 +25,13 @@ vi.mock( import( '@wordpress/blocks' ), async ( importOriginal ) => { const actualImplementation = await importOriginal(); return { ...actualImplementation, - isReusableBlock( { title } ) { + // The mocks only read the block type's title. + isReusableBlock: ( ( { title }: { title: string } ) => { return title === 'Reusable Block'; - }, - __experimentalGetBlockLabel( { title } ) { + } ) as typeof actualImplementation.isReusableBlock, + __experimentalGetBlockLabel: ( ( { title }: { title: string } ) => { return blockLabelMap[ title ] || title; - }, + } ) as typeof actualImplementation.__experimentalGetBlockLabel, }; } ); @@ -41,15 +43,18 @@ vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => ( { describe( 'BlockTitle', () => { it( 'renders nothing if name is falsey', () => { - useSelect.mockImplementation( () => null ); + ( useSelect as Mock ).mockImplementation( () => null ); - const { container } = render( ); + const { container } = render( + // @ts-expect-error The missing `clientId` is deliberate. + + ); expect( container ).toBeEmptyDOMElement(); } ); it( 'renders nothing if block type does not exist', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'name-not-exists', getBlockType: () => null, @@ -64,10 +69,10 @@ describe( 'BlockTitle', () => { } ); it( 'renders title if block type exists', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'name-exists', - getBlockType: ( name ) => blockTypeMap[ name ], + getBlockType: ( name: string ) => blockTypeMap[ name ], getBlockAttributes: () => null, getActiveBlockVariation: () => null, } ) ) @@ -79,10 +84,10 @@ describe( 'BlockTitle', () => { } ); it( 'renders label if it is set', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'name-with-label', - getBlockType: ( name ) => blockTypeMap[ name ], + getBlockType: ( name: string ) => blockTypeMap[ name ], getBlockAttributes: () => null, } ) ) ); @@ -93,10 +98,10 @@ describe( 'BlockTitle', () => { } ); it( 'should prioritize reusable block title over title', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'reusable-block', - getBlockType: ( name ) => blockTypeMap[ name ], + getBlockType: ( name: string ) => blockTypeMap[ name ], getBlockAttributes: () => ( { ref: 1 } ), } ) ) ); @@ -108,10 +113,10 @@ describe( 'BlockTitle', () => { } ); it( 'should prioritize block label over title', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'name-with-custom-label', - getBlockType: ( name ) => blockTypeMap[ name ], + getBlockType: ( name: string ) => blockTypeMap[ name ], getBlockAttributes: () => null, } ) ) ); @@ -125,10 +130,10 @@ describe( 'BlockTitle', () => { } ); it( 'should default to block variation title if no reusable title or block name is available', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'name-exists', - getBlockType: ( name ) => blockTypeMap[ name ], + getBlockType: ( name: string ) => blockTypeMap[ name ], getBlockAttributes: () => null, getActiveBlockVariation: () => ( { title: 'Block Variation Label', @@ -142,10 +147,10 @@ describe( 'BlockTitle', () => { } ); it( 'truncates the label with custom truncate length', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'name-with-long-label', - getBlockType: ( name ) => blockTypeMap[ name ], + getBlockType: ( name: string ) => blockTypeMap[ name ], getBlockAttributes: () => null, } ) ) ); @@ -161,10 +166,10 @@ describe( 'BlockTitle', () => { } ); it( 'should not truncate the label if maximum length is undefined', () => { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => 'name-with-long-label', - getBlockType: ( name ) => blockTypeMap[ name ], + getBlockType: ( name: string ) => blockTypeMap[ name ], getBlockAttributes: () => null, } ) ) ); From be82802d39fe7a4f3f1d45a1fdf2038a9118307a Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 13:58:21 +0530 Subject: [PATCH 04/16] Block Editor: Convert useBlockDisplayInformation to TypeScript --- packages/block-editor/README.md | 2 +- .../{index.js => index.ts} | 42 ++++++++-------- .../use-block-display-information/types.ts | 48 +++++++++++++++++++ packages/block-editor/src/store/types.ts | 1 + 4 files changed, 69 insertions(+), 24 deletions(-) rename packages/block-editor/src/components/use-block-display-information/{index.js => index.ts} (75%) create mode 100644 packages/block-editor/src/components/use-block-display-information/types.ts diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md index ea926783306c3f..fd285002a4dcc0 100644 --- a/packages/block-editor/README.md +++ b/packages/block-editor/README.md @@ -1126,7 +1126,7 @@ _Parameters_ _Returns_ -- `?WPBlockDisplayInformation`: Block's display information, or `null` when the block or its type not found. +- `?BlockDisplayInformation`: Block's display information, or `null` when the block or its type not found. ### useBlockEditContext diff --git a/packages/block-editor/src/components/use-block-display-information/index.js b/packages/block-editor/src/components/use-block-display-information/index.ts similarity index 75% rename from packages/block-editor/src/components/use-block-display-information/index.js rename to packages/block-editor/src/components/use-block-display-information/index.ts index 5fa7484754502b..bd6969a5305ed3 100644 --- a/packages/block-editor/src/components/use-block-display-information/index.js +++ b/packages/block-editor/src/components/use-block-display-information/index.ts @@ -9,29 +9,18 @@ import { __ } from '@wordpress/i18n'; import { symbol } from '@wordpress/icons'; import { store as blockEditorStore } from '../../store'; import { unlock } from '../../lock-unlock'; - -/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */ - -/** - * Contains basic block's information for display reasons. - * - * @typedef {Object} WPBlockDisplayInformation - * - * @property {boolean} isSynced True if is a reusable block or template part - * @property {string} title Human-readable block type label. - * @property {WPIcon} icon Block type icon. - * @property {string} description A detailed block type description. - * @property {string} anchor HTML anchor. - * @property {name} name A custom, human readable name for the block. - */ +import type { BlockEditorThunkArgs } from '../../store/types'; +import type { BlockDisplayAttributes, BlockDisplayInformation } from './types'; /** * Get the display label for a block's position type. * - * @param {Object} attributes Block attributes. - * @return {string} The position type label. + * @param attributes Block attributes. + * @return The position type label. */ -export function getPositionTypeLabel( attributes ) { +export function getPositionTypeLabel( + attributes: BlockDisplayAttributes | null +): string | null { const positionType = attributes?.style?.position?.type; if ( positionType === 'sticky' ) { @@ -57,10 +46,12 @@ export function getPositionTypeLabel( attributes ) { * If no blockType is found with the provided clientId, returns null. * * @param {string} clientId Block's client id. - * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found. + * @return {?BlockDisplayInformation} Block's display information, or `null` when the block or its type not found. */ -export default function useBlockDisplayInformation( clientId ) { +export default function useBlockDisplayInformation( + clientId: string +): BlockDisplayInformation | null { return useSelect( ( select ) => { if ( ! clientId ) { @@ -75,13 +66,18 @@ export default function useBlockDisplayInformation( clientId ) { } = blockEditorSelect; const { getBlockType, getActiveBlockVariation } = select( blocksStore ); - const blockName = getBlockName( clientId ); + // A missing block has no block type, which returns early below. + const blockName = getBlockName( clientId )!; const blockType = getBlockType( blockName ); if ( ! blockType ) { return null; } - const attributes = getBlockAttributes( clientId ); - const { isSectionBlock } = unlock( blockEditorSelect ); + // Attributes are not validated against the block type's schema. + const attributes = getBlockAttributes( + clientId + ) as BlockDisplayAttributes; + const { isSectionBlock } = + unlock< BlockEditorThunkArgs[ 'select' ] >( blockEditorSelect ); // Check if this block is a pattern const patternName = attributes?.metadata?.patternName; diff --git a/packages/block-editor/src/components/use-block-display-information/types.ts b/packages/block-editor/src/components/use-block-display-information/types.ts new file mode 100644 index 00000000000000..1f98a544387f60 --- /dev/null +++ b/packages/block-editor/src/components/use-block-display-information/types.ts @@ -0,0 +1,48 @@ +import type { BlockTypeIcon } from '@wordpress/blocks'; +import type { BlockAttributes } from '../../store/types'; + +/** + * The block attributes read for display. + */ +export interface BlockDisplayAttributes extends BlockAttributes { + anchor?: string; + style?: { position?: { type?: string } }; +} + +/** + * Contains basic block's information for display reasons. + */ +export interface BlockDisplayInformation { + /** + * True if is a reusable block or template part + */ + isSynced: boolean; + /** + * Human-readable block type label. + */ + title: string; + /** + * Block type icon. + */ + icon: BlockTypeIcon; + /** + * A detailed block type description. + */ + description?: string; + /** + * HTML anchor. + */ + anchor?: string; + /** + * The position type label. + */ + positionLabel: string | null; + /** + * The `style.position.type` attribute. + */ + positionType?: string; + /** + * A custom, human readable name for the block. + */ + name?: string; +} diff --git a/packages/block-editor/src/store/types.ts b/packages/block-editor/src/store/types.ts index d6b34d5a7b702a..b60f01abffae07 100644 --- a/packages/block-editor/src/store/types.ts +++ b/packages/block-editor/src/store/types.ts @@ -222,6 +222,7 @@ export interface BlockSelection { export interface BlockPattern { name: string; title?: string; + description?: string; content: string; categories?: Array< string | number >; blocks?: Block[]; From dcd1256ceac77d50164d6441dc18047c1bd6b6c3 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 13:58:27 +0530 Subject: [PATCH 05/16] Block Editor: Convert the useBlockDisplayInformation tests to TypeScript --- ...ex.jsdom.test.jsx => index.jsdom.test.tsx} | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) rename packages/block-editor/src/components/use-block-display-information/test/{index.jsdom.test.jsx => index.jsdom.test.tsx} (85%) diff --git a/packages/block-editor/src/components/use-block-display-information/test/index.jsdom.test.jsx b/packages/block-editor/src/components/use-block-display-information/test/index.jsdom.test.tsx similarity index 85% rename from packages/block-editor/src/components/use-block-display-information/test/index.jsdom.test.jsx rename to packages/block-editor/src/components/use-block-display-information/test/index.jsdom.test.tsx index 176d4aac8a1421..65c8cac35199a1 100644 --- a/packages/block-editor/src/components/use-block-display-information/test/index.jsdom.test.jsx +++ b/packages/block-editor/src/components/use-block-display-information/test/index.jsdom.test.tsx @@ -1,26 +1,34 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; +import type { Mock } from 'vitest'; import { render } from '@testing-library/react'; import { useSelect } from '@wordpress/data'; import { useEffect } from '@wordpress/element'; import { symbol } from '@wordpress/icons'; import useBlockDisplayInformation from '../'; +import type { unlock } from '../../../lock-unlock'; +import type { BlockDisplayAttributes, BlockDisplayInformation } from '../types'; vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => ( { ...( await importOriginal() ), useSelect: vi.fn(), } ) ); vi.mock( import( '../../../lock-unlock' ), () => ( { - unlock: ( value ) => ( { + // Returns the selectors themselves, with the private ones mixed in. + unlock: ( ( value: object ) => ( { registerPrivateActions: vi.fn(), registerPrivateSelectors: vi.fn(), ...value, - } ), + } ) ) as typeof unlock, } ) ); const groupIcon = 'group-icon'; const templatePartIcon = 'template-part-icon'; -function TestComponent( { onChange } ) { +function TestComponent( { + onChange, +}: { + onChange: ( information: BlockDisplayInformation | null ) => void; +} ) { const blockInformation = useBlockDisplayInformation( 'client-id' ); useEffect( () => { onChange( blockInformation ); @@ -50,8 +58,19 @@ function setupUseSelect( { }, getActiveBlockVariation = () => null, isSectionBlock = true, +}: { + attributes?: BlockDisplayAttributes; + blockName?: string; + blockType?: { + name: string; + title: string; + icon: string; + description: string; + }; + getActiveBlockVariation?: () => null; + isSectionBlock?: boolean; } = {} ) { - useSelect.mockImplementation( ( mapSelect ) => + ( useSelect as Mock ).mockImplementation( ( mapSelect ) => mapSelect( () => ( { getBlockName: () => blockName, getBlockAttributes: () => attributes, From 489d00c060d2dad28d1a678e6cbd534e35259b57 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 14:01:14 +0530 Subject: [PATCH 06/16] Block Editor: Convert BlockPopover to TypeScript --- .../block-popover/{cover.jsx => cover.tsx} | 15 +++- .../{drop-zone.jsx => drop-zone.tsx} | 11 ++- .../{inbetween.jsx => inbetween.tsx} | 25 +++--- .../block-popover/{index.jsx => index.tsx} | 14 ++-- .../src/components/block-popover/types.ts | 83 +++++++++++++++++++ ...opover-scroll.js => use-popover-scroll.ts} | 27 +++--- 6 files changed, 140 insertions(+), 35 deletions(-) rename packages/block-editor/src/components/block-popover/{cover.jsx => cover.tsx} (77%) rename packages/block-editor/src/components/block-popover/{drop-zone.jsx => drop-zone.tsx} (79%) rename packages/block-editor/src/components/block-popover/{inbetween.jsx => inbetween.tsx} (90%) rename packages/block-editor/src/components/block-popover/{index.jsx => index.tsx} (90%) create mode 100644 packages/block-editor/src/components/block-popover/types.ts rename packages/block-editor/src/components/block-popover/{use-popover-scroll.js => use-popover-scroll.ts} (64%) diff --git a/packages/block-editor/src/components/block-popover/cover.jsx b/packages/block-editor/src/components/block-popover/cover.tsx similarity index 77% rename from packages/block-editor/src/components/block-popover/cover.jsx rename to packages/block-editor/src/components/block-popover/cover.tsx index 97a97cb5e3f79e..9f49975bee31a3 100644 --- a/packages/block-editor/src/components/block-popover/cover.jsx +++ b/packages/block-editor/src/components/block-popover/cover.tsx @@ -1,6 +1,8 @@ +import type { CSSProperties, ForwardedRef, ReactNode } from 'react'; import { useEffect, useState, useMemo, forwardRef } from '@wordpress/element'; import { useBlockElement } from '../block-list/use-block-props/use-block-refs'; import { PrivateBlockPopover } from '.'; +import type { BlockPopoverCoverProps } from './types'; function BlockPopoverCover( { @@ -10,12 +12,13 @@ function BlockPopoverCover( shift = false, additionalStyles, ...props - }, - ref + }: BlockPopoverCoverProps, + ref: ForwardedRef< HTMLDivElement > ) { bottomClientId ??= clientId; - const selectedElement = useBlockElement( clientId ); + // Block wrappers are HTML elements. + const selectedElement = useBlockElement( clientId ) as HTMLElement | null; return ( observer.disconnect(); }, [ selectedElement ] ); - const style = useMemo( () => { + const style = useMemo< CSSProperties >( () => { return { position: 'absolute', width, diff --git a/packages/block-editor/src/components/block-popover/drop-zone.jsx b/packages/block-editor/src/components/block-popover/drop-zone.tsx similarity index 79% rename from packages/block-editor/src/components/block-popover/drop-zone.jsx rename to packages/block-editor/src/components/block-popover/drop-zone.tsx index 6445cb8b68eea4..35bd4354d2b763 100644 --- a/packages/block-editor/src/components/block-popover/drop-zone.jsx +++ b/packages/block-editor/src/components/block-popover/drop-zone.tsx @@ -3,6 +3,7 @@ import { useReducedMotion } from '@wordpress/compose'; import { __unstableMotion as motion } from '@wordpress/components'; import { store as blockEditorStore } from '../../store'; import BlockPopoverCover from './cover'; +import type { PrivateBlockPopoverSlotProps } from './types'; const animateVariants = { hide: { opacity: 0, scaleY: 0.75 }, @@ -13,8 +14,8 @@ const animateVariants = { function BlockDropZonePopover( { __unstablePopoverSlot, __unstableContentRef, -} ) { - const { clientId } = useSelect( ( select ) => { +}: PrivateBlockPopoverSlotProps ) { + const { clientId } = useSelect( ( select ): { clientId?: string } => { const { getBlockOrder, getBlockInsertionPoint } = select( blockEditorStore ); const insertionPoint = getBlockInsertionPoint(); @@ -25,14 +26,16 @@ function BlockDropZonePopover( { } return { - clientId: order[ insertionPoint.index ], + // A non-empty order always has an insertion index. + clientId: order[ insertionPoint.index! ], }; }, [] ); const reducedMotion = useReducedMotion(); return ( ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER, + ( s: number ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER, 0 ); @@ -80,13 +81,14 @@ function BlockPopoverInbetween( { ? nextElement.getBoundingClientRect() : null; + // At least one of the elements exists, see the check above. let left = 0; let top = 0; let width = 0; let height = 0; if ( operation === 'group' ) { - const targetRect = nextRect || previousRect; + const targetRect = ( nextRect || previousRect )!; top = targetRect.top; // No spacing is likely around blocks in this operation. // So width of the inserter containing rect is set to 0. @@ -100,11 +102,11 @@ function BlockPopoverInbetween( { : targetRect.right - 2; } else if ( isVertical ) { // vertical - top = previousRect ? previousRect.bottom : nextRect.top; + top = previousRect ? previousRect.bottom : nextRect!.top; width = nextRect && previousRect ? ( previousRect.width + nextRect.width ) / 2 - : ( previousRect || nextRect ).width; + : ( previousRect || nextRect )!.width; height = nextRect && previousRect ? nextRect.top - previousRect.bottom @@ -112,16 +114,16 @@ function BlockPopoverInbetween( { left = nextRect && previousRect ? ( previousRect.left + nextRect.left ) / 2 - : ( previousRect || nextRect ).left; + : ( previousRect || nextRect )!.left; } else { - top = previousRect ? previousRect.top : nextRect.top; + top = previousRect ? previousRect.top : nextRect!.top; height = previousRect ? previousRect.height - : nextRect.height; + : nextRect!.height; if ( isRTL() ) { // non vertical, rtl - left = nextRect ? nextRect.right : previousRect.left; + left = nextRect ? nextRect.right : previousRect!.left; width = previousRect && nextRect ? previousRect.left - nextRect.right @@ -130,7 +132,7 @@ function BlockPopoverInbetween( { // non vertical, ltr left = previousRect ? previousRect.right - : nextRect.left; + : nextRect!.left; width = previousRect && nextRect ? nextRect.left - previousRect.right @@ -193,7 +195,8 @@ function BlockPopoverInbetween( { if ( ! previousElement ) { return; } - previousElement.ownerDocument.defaultView.addEventListener( + // Block elements live in a document with a window. + previousElement.ownerDocument.defaultView!.addEventListener( 'resize', forcePopoverRecompute ); diff --git a/packages/block-editor/src/components/block-popover/index.jsx b/packages/block-editor/src/components/block-popover/index.tsx similarity index 90% rename from packages/block-editor/src/components/block-popover/index.jsx rename to packages/block-editor/src/components/block-popover/index.tsx index f9ee25840cfadd..361fd6eaf22fc0 100644 --- a/packages/block-editor/src/components/block-popover/index.jsx +++ b/packages/block-editor/src/components/block-popover/index.tsx @@ -1,4 +1,5 @@ import clsx from 'clsx'; +import type { ForwardedRef } from 'react'; import { useMergeRefs } from '@wordpress/compose'; import { Popover } from '@wordpress/components'; import { @@ -10,6 +11,7 @@ import { import { useBlockElement } from '../block-list/use-block-props/use-block-refs'; import usePopoverScroll from './use-popover-scroll'; import { rectUnion, getElementBounds } from '../../utils/dom'; +import type { BlockPopoverProps, PrivateBlockPopoverProps } from './types'; const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER; @@ -22,8 +24,8 @@ function BlockPopover( __unstableContentRef, shift = true, ...props - }, - ref + }: PrivateBlockPopoverProps, + ref: ForwardedRef< HTMLDivElement > ) { const selectedElement = useBlockElement( clientId ); const lastSelectedElement = useBlockElement( bottomClientId ?? clientId ); @@ -37,7 +39,7 @@ function BlockPopover( forceRecomputePopoverDimensions, ] = useReducer( // Module is there to make sure that the counter doesn't overflow. - ( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER, + ( s: number ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER, 0 ); @@ -53,7 +55,7 @@ function BlockPopover( return; } - let rafId; + let rafId: number | null | undefined; const observer = new window.MutationObserver( () => { if ( rafId ) { return; @@ -133,8 +135,8 @@ function BlockPopover( export const PrivateBlockPopover = forwardRef( BlockPopover ); const PublicBlockPopover = ( - { clientId, bottomClientId, children, ...props }, - ref + { clientId, bottomClientId, children, ...props }: BlockPopoverProps, + ref: ForwardedRef< HTMLDivElement > ) => ( , + 'children' +>; + +/** + * Props of `BlockPopover`. + */ +export interface BlockPopoverProps extends PopoverProps { + /** + * The client ID of the block representing the top position of the popover. + */ + clientId: string; + /** + * The client ID of the block representing the bottom position of the popover. + */ + bottomClientId?: string; + /** + * Whether the block popover always shifts into the viewport or remains at + * its original position. + */ + shift?: boolean; + /** + * The content rendered inside the popover. + */ + children?: ReactNode; +} + +/** + * Props shared by the private block popovers. + */ +export interface PrivateBlockPopoverSlotProps { + /** + * The legacy popover slot to render in, rendering in place when unset. + */ + __unstablePopoverSlot?: string; + /** + * The canvas content, scrolled when the pointer wheels over the popover. + */ + __unstableContentRef?: RefObject< HTMLElement | null >; +} + +/** + * Props of `PrivateBlockPopover`. + */ +export interface PrivateBlockPopoverProps + extends BlockPopoverProps, PrivateBlockPopoverSlotProps {} + +/** + * Props of `BlockPopoverCover`. + */ +export interface BlockPopoverCoverProps extends PrivateBlockPopoverProps { + /** + * Styles applied to the container covering the block. + */ + additionalStyles?: CSSProperties; +} + +/** + * Props of `BlockPopoverInbetween`. + */ +export interface BlockPopoverInbetweenProps + extends PopoverProps, PrivateBlockPopoverSlotProps { + /** + * The client ID of the block before the popover. + */ + previousClientId: string; + /** + * The client ID of the block after the popover. + */ + nextClientId: string; + children?: ReactNode; + operation?: string; + nearestSide?: string; +} diff --git a/packages/block-editor/src/components/block-popover/use-popover-scroll.js b/packages/block-editor/src/components/block-popover/use-popover-scroll.ts similarity index 64% rename from packages/block-editor/src/components/block-popover/use-popover-scroll.js rename to packages/block-editor/src/components/block-popover/use-popover-scroll.ts index 1e36a2992ecee7..f9f6bea3cc1150 100644 --- a/packages/block-editor/src/components/block-popover/use-popover-scroll.js +++ b/packages/block-editor/src/components/block-popover/use-popover-scroll.ts @@ -1,21 +1,23 @@ import { useRefEffect } from '@wordpress/compose'; import { getScrollContainer } from '@wordpress/dom'; +import type { RefObject } from 'react'; -const scrollContainerCache = new WeakMap(); +const scrollContainerCache = new WeakMap< Element, Element | undefined >(); /** * Allow scrolling "through" popovers over the canvas. This is only called for * as long as the pointer is over a popover. Do not use React events because it * will bubble through portals. * - * @param {Object} contentRef + * @param contentRef */ -function usePopoverScroll( contentRef ) { - const effect = useRefEffect( +function usePopoverScroll( contentRef?: RefObject< HTMLElement | null > ) { + const effect = useRefEffect< HTMLElement >( ( node ) => { - function onWheel( event ) { + function onWheel( event: WheelEvent ) { const { deltaX, deltaY, target } = event; - const contentEl = contentRef.current; + // The ref is only attached when `contentRef` is set, see below. + const contentEl = contentRef!.current!; let scrollContainer = scrollContainerCache.get( contentEl ); if ( ! scrollContainer ) { scrollContainer = getScrollContainer( contentEl ); @@ -24,16 +26,21 @@ function usePopoverScroll( contentRef ) { // Finds a scrollable ancestor of the event’s target. It's not cached because the // it may not remain scrollable due to popover position changes. The cache is also // less likely to be utilized because the target may be different every event. - const eventScrollContainer = getScrollContainer( target ); + // Wheel events target elements. + const eventScrollContainer = getScrollContainer( + target as Element + ); // Scrolls “through” the popover only if another contained scrollable area isn’t // in front of it. This is to avoid scrolling both containers simultaneously. - if ( ! node.contains( eventScrollContainer ) ) { - scrollContainer.scrollBy( deltaX, deltaY ); + // `contains` treats `undefined` as `null`. + if ( ! node.contains( eventScrollContainer as Node | null ) ) { + // The canvas content always sits in a scroll container. + scrollContainer!.scrollBy( deltaX, deltaY ); } } // Tell the browser that we do not call event.preventDefault // See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners - const options = { passive: true }; + const options: AddEventListenerOptions = { passive: true }; node.addEventListener( 'wheel', onWheel, options ); return () => { node.removeEventListener( 'wheel', onWheel, options ); From 8aa50d1ff796e7891d138b37b5d57b1da9a6ba2b Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 14:08:36 +0530 Subject: [PATCH 07/16] Block Editor: Convert the color and gradient controls to TypeScript --- .../{control.jsx => control.tsx} | 36 ++++--- .../{dropdown.jsx => dropdown.tsx} | 65 ++++++++++--- ....jsx => panel-color-gradient-settings.tsx} | 24 +++-- .../src/components/colors-gradients/types.ts | 94 +++++++++++++++++++ ...e-multiple-origin-colors-and-gradients.ts} | 31 ++++-- 5 files changed, 212 insertions(+), 38 deletions(-) rename packages/block-editor/src/components/colors-gradients/{control.jsx => control.tsx} (82%) rename packages/block-editor/src/components/colors-gradients/{dropdown.jsx => dropdown.tsx} (79%) rename packages/block-editor/src/components/colors-gradients/{panel-color-gradient-settings.jsx => panel-color-gradient-settings.tsx} (80%) create mode 100644 packages/block-editor/src/components/colors-gradients/types.ts rename packages/block-editor/src/components/colors-gradients/{use-multiple-origin-colors-and-gradients.js => use-multiple-origin-colors-and-gradients.ts} (78%) diff --git a/packages/block-editor/src/components/colors-gradients/control.jsx b/packages/block-editor/src/components/colors-gradients/control.tsx similarity index 82% rename from packages/block-editor/src/components/colors-gradients/control.jsx rename to packages/block-editor/src/components/colors-gradients/control.tsx index 725ea48cb5d813..e3e7e26797ad59 100644 --- a/packages/block-editor/src/components/colors-gradients/control.jsx +++ b/packages/block-editor/src/components/colors-gradients/control.tsx @@ -1,4 +1,5 @@ import clsx from 'clsx'; +import type { ComponentProps } from 'react'; import { __ } from '@wordpress/i18n'; import { BaseControl, @@ -10,6 +11,9 @@ import { } from '@wordpress/components'; import { useSettings } from '../use-settings'; import { unlock } from '../../lock-unlock'; +import type { ColorGradientControlProps, ColorGradientOptions } from './types'; + +export type NoticeProps = ComponentProps< typeof Notice >; const { Tabs } = unlock( componentsPrivateApis ); const colorsAndGradientKeys = [ @@ -40,7 +44,7 @@ function ColorGradientControlInner( { enableAlpha, headingLevel, noticeProps, -} ) { +}: ColorGradientControlProps ) { const canChooseAColor = onColorChange && ( ( colors && colors.length > 0 ) || ! disableCustomColors ); @@ -52,12 +56,14 @@ function ColorGradientControlInner( { return null; } + // `canChooseAColor` and `canChooseAGradient` imply their handlers are set. const colorPaletteOnChange = canChooseAGradient - ? ( newColor, _index, newSlug ) => { - onColorChange( newColor, newSlug ); - onGradientChange(); + ? ( newColor?: string, _index?: number, newSlug?: string ) => { + onColorChange!( newColor, newSlug ); + onGradientChange!(); } - : ( newColor, _index, newSlug ) => onColorChange( newColor, newSlug ); + : ( newColor?: string, _index?: number, newSlug?: string ) => + onColorChange!( newColor, newSlug ); const colorPalette = ( { - onGradientChange( newGradient, newSlug ); - onColorChange(); + onGradientChange!( newGradient, newSlug ); + onColorChange!(); } : ( newGradient, _index, newSlug ) => - onGradientChange( newGradient, newSlug ) + onGradientChange!( newGradient, newSlug ) } { ...{ gradients, disableCustomGradients } } __experimentalIsRenderedInSidebar={ @@ -112,7 +118,7 @@ function ColorGradientControlInner( { ), }; - const renderPanelType = ( type ) => ( + const renderPanelType = ( type: string ) => (
{ tabPanels[ type ] }
@@ -179,13 +185,19 @@ function ColorGradientControlInner( { ); } -function ColorGradientControlSelect( props ) { +function ColorGradientControlSelect( props: ColorGradientControlProps ) { + // Settings are untyped. const [ colors, gradients, customColors, customGradients ] = useSettings( 'color.palette', 'color.gradients', 'color.custom', 'color.customGradient' - ); + ) as [ + ColorGradientOptions[ 'colors' ], + ColorGradientOptions[ 'gradients' ], + boolean | undefined, + boolean | undefined, + ]; return ( props.hasOwnProperty( key ) ) ) { diff --git a/packages/block-editor/src/components/colors-gradients/dropdown.jsx b/packages/block-editor/src/components/colors-gradients/dropdown.tsx similarity index 79% rename from packages/block-editor/src/components/colors-gradients/dropdown.jsx rename to packages/block-editor/src/components/colors-gradients/dropdown.tsx index ffac60a242ceb8..d921d6e08c7676 100644 --- a/packages/block-editor/src/components/colors-gradients/dropdown.jsx +++ b/packages/block-editor/src/components/colors-gradients/dropdown.tsx @@ -1,4 +1,5 @@ import clsx from 'clsx'; +import type { ComponentProps, ReactNode } from 'react'; import { Button, ColorIndicator, @@ -12,15 +13,28 @@ import { useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { reset as resetIcon } from '@wordpress/icons'; import ColorGradientControl from './control'; +import type { + ColorGradientSetting, + ColorGradientSettingsDropdownProps, +} from './types'; // When the `ColorGradientSettingsDropdown` controls are being rendered to a // `ToolsPanel` they must be wrapped in a `ToolsPanelItem`. -const WithToolsPanelItem = ( { setting, children, panelId, ...props } ) => { +const WithToolsPanelItem = ( { + setting, + children, + panelId, + ...props +}: Partial< ComponentProps< typeof ToolsPanelItem > > & { + setting: ColorGradientSetting; + children: ReactNode; +} ) => { + // A set value implies its change handler. const clearValue = () => { if ( setting.colorValue ) { - setting.onColorChange(); + setting.onColorChange!(); } else if ( setting.gradientValue ) { - setting.onGradientChange(); + setting.onGradientChange!(); } }; return ( @@ -28,7 +42,8 @@ const WithToolsPanelItem = ( { setting, children, panelId, ...props } ) => { hasValue={ () => { return !! setting.colorValue || !! setting.gradientValue; } } - label={ setting.label } + // Every setting rendered in a `ToolsPanel` has a label. + label={ setting.label! } onDeselect={ clearValue } isShownByDefault={ setting.isShownByDefault !== undefined @@ -50,11 +65,18 @@ const WithToolsPanelItem = ( { setting, children, panelId, ...props } ) => { ); }; -const LabeledColorIndicator = ( { colorValue, label } ) => ( +const LabeledColorIndicator = ( { + colorValue, + label, +}: { + colorValue?: string | null; + label?: string; +} ) => ( ( // Renders a color dropdown's toggle as an `Item` if it is within an `ItemGroup` // or as a `Button` if it isn't e.g. the controls are being rendered in // a `ToolsPanel`. -const renderToggle = ( settings ) => - function Toggle( { onToggle, isOpen } ) { +const renderToggle = ( + settings: Pick< + ColorGradientSetting, + | 'clearable' + | 'colorValue' + | 'gradientValue' + | 'onColorChange' + | 'onGradientChange' + | 'label' + > +) => + function Toggle( { + onToggle, + isOpen, + }: { + onToggle: () => void; + isOpen: boolean; + } ) { const { clearable, colorValue, @@ -78,7 +116,7 @@ const renderToggle = ( settings ) => onGradientChange, label, } = settings; - const colorButtonRef = useRef( undefined ); + const colorButtonRef = useRef< HTMLButtonElement >( undefined ); const toggleProps = { onClick: onToggle, @@ -90,11 +128,12 @@ const renderToggle = ( settings ) => ref: colorButtonRef, }; + // A set value implies its change handler. const clearValue = () => { if ( colorValue ) { - onColorChange(); + onColorChange!(); } else if ( gradientValue ) { - onGradientChange(); + onGradientChange!(); } }; @@ -145,8 +184,8 @@ export default function ColorGradientSettingsDropdown( { settings, __experimentalIsRenderedInSidebar, ...props -} ) { - let popoverProps; +}: ColorGradientSettingsDropdownProps ) { + let popoverProps: ComponentProps< typeof Dropdown >[ 'popoverProps' ]; if ( __experimentalIsRenderedInSidebar ) { popoverProps = { placement: 'left-start', diff --git a/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.jsx b/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.tsx similarity index 80% rename from packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.jsx rename to packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.tsx index 582d4c5f926190..5a6868fba7ffe2 100644 --- a/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.jsx +++ b/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.tsx @@ -7,6 +7,7 @@ import { useRegistry } from '@wordpress/data'; import { useInstanceId } from '@wordpress/compose'; import ColorGradientSettingsDropdown from './dropdown'; import useColorsAndGradientsPalettes from './use-multiple-origin-colors-and-gradients'; +import type { PanelColorGradientSettingsProps } from './types'; const colorsAndGradientKeys = [ 'colors', @@ -27,8 +28,11 @@ export const PanelColorGradientSettingsInner = ( { showTitle = true, __experimentalIsRenderedInSidebar, enableAlpha, -} ) => { - const panelId = useInstanceId( PanelColorGradientSettingsInner ); +}: PanelColorGradientSettingsProps ) => { + // `ToolsPanel` only compares the id, so the numeric instance ID works. + const panelId = useInstanceId( + PanelColorGradientSettingsInner + ) as unknown as string; const { batch } = useRegistry(); if ( ( ! colors || colors.length === 0 ) && @@ -55,7 +59,8 @@ export const PanelColorGradientSettingsInner = ( { className ) } hasInnerWrapper - label={ showTitle ? title : undefined } + // `ToolsPanel` hides its header without a label. + label={ ( showTitle ? title : undefined ) as string } resetAll={ () => { batch( () => { settings.forEach( @@ -65,10 +70,11 @@ export const PanelColorGradientSettingsInner = ( { onColorChange, onGradientChange, } ) => { + // A set value implies its change handler. if ( colorValue ) { - onColorChange(); + onColorChange!(); } else if ( gradientValue ) { - onGradientChange(); + onGradientChange!(); } } ); @@ -102,7 +108,9 @@ export const PanelColorGradientSettingsInner = ( { ); }; -const PanelColorGradientSettingsSelect = ( props ) => { +const PanelColorGradientSettingsSelect = ( + props: PanelColorGradientSettingsProps +) => { const colorGradientSettings = useColorsAndGradientsPalettes(); return ( { ); }; -const PanelColorGradientSettings = ( props ) => { +const PanelColorGradientSettings = ( + props: PanelColorGradientSettingsProps +) => { if ( colorsAndGradientKeys.every( ( key ) => props.hasOwnProperty( key ) ) ) { diff --git a/packages/block-editor/src/components/colors-gradients/types.ts b/packages/block-editor/src/components/colors-gradients/types.ts new file mode 100644 index 00000000000000..ba955dfa554b05 --- /dev/null +++ b/packages/block-editor/src/components/colors-gradients/types.ts @@ -0,0 +1,94 @@ +import type { ComponentProps, ReactNode } from 'react'; +import type { + ColorPalette, + GradientPicker, + __experimentalToolsPanelItem as ToolsPanelItem, +} from '@wordpress/components'; +import type { Palette } from '@wordpress/global-styles-engine'; +import type { NoticeProps } from './control'; + +type ColorPaletteProps = ComponentProps< typeof ColorPalette >; +type ToolsPanelItemProps = ComponentProps< typeof ToolsPanelItem >; + +/** + * A color palette from one origin, i.e. "Core", "Theme" or "User". + */ +export type ColorOrigin = Required< + Pick< Palette, 'name' | 'slug' | 'colors' > +>; + +/** + * A gradient palette from one origin, i.e. "Core", "Theme" or "User". + */ +export type GradientOrigin = Required< + Pick< Palette, 'name' | 'slug' | 'gradients' > +>; + +/** + * Color and gradient related settings. + */ +export interface MultipleOriginColorsAndGradients { + colors: ColorOrigin[]; + gradients: GradientOrigin[]; + disableCustomColors: boolean; + disableCustomGradients: boolean; + hasColorsOrGradients: boolean; +} + +/** + * The color and gradient palettes available to pick from. + */ +export interface ColorGradientOptions { + colors?: ColorPaletteProps[ 'colors' ]; + gradients?: ComponentProps< typeof GradientPicker >[ 'gradients' ]; + disableCustomColors?: boolean; + disableCustomGradients?: boolean; + __experimentalIsRenderedInSidebar?: boolean; + enableAlpha?: boolean; +} + +/** + * Props of `ColorGradientControl`. + */ +export interface ColorGradientControlProps extends ColorGradientOptions { + className?: string; + label?: ReactNode; + onColorChange?: ( color?: string, slug?: string ) => void; + onGradientChange?: ( gradient?: string, slug?: string ) => void; + colorValue?: string; + colorSlug?: string; + gradientValue?: ComponentProps< typeof GradientPicker >[ 'value' ]; + gradientSlug?: string; + clearable?: boolean; + showTitle?: boolean; + headingLevel?: ColorPaletteProps[ 'headingLevel' ]; + noticeProps?: NoticeProps; +} + +/** + * A color or gradient control rendered by `ColorGradientSettingsDropdown`. + */ +export interface ColorGradientSetting extends ColorGradientControlProps { + label?: string; + isShownByDefault?: boolean; + resetAllFilter?: ToolsPanelItemProps[ 'resetAllFilter' ]; +} + +/** + * Props of `ColorGradientSettingsDropdown`. + */ +export interface ColorGradientSettingsDropdownProps + extends ColorGradientOptions, Partial< ToolsPanelItemProps > { + settings: ColorGradientSetting[]; +} + +/** + * Props of `PanelColorGradientSettings`. + */ +export interface PanelColorGradientSettingsProps extends ColorGradientOptions { + className?: string; + children?: ReactNode; + settings: ColorGradientSetting[]; + title?: string; + showTitle?: boolean; +} diff --git a/packages/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js b/packages/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.ts similarity index 78% rename from packages/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js rename to packages/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.ts index b4f18b96bbf4d6..c414bb077e5ae4 100644 --- a/packages/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +++ b/packages/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.ts @@ -1,6 +1,12 @@ import { useMemo } from '@wordpress/element'; import { _x } from '@wordpress/i18n'; +import type { Color, Gradient } from '@wordpress/global-styles-engine'; import { useSettings } from '../use-settings'; +import type { + ColorOrigin, + GradientOrigin, + MultipleOriginColorsAndGradients, +} from './types'; /** * Retrieves color and gradient related settings. @@ -8,9 +14,10 @@ import { useSettings } from '../use-settings'; * The arrays for colors and gradients are made up of color palettes from each * origin i.e. "Core", "Theme", and "User". * - * @return {Object} Color and gradient related settings. + * @return Color and gradient related settings. */ -export default function useMultipleOriginColorsAndGradients() { +export default function useMultipleOriginColorsAndGradients(): MultipleOriginColorsAndGradients { + // Settings are untyped. const [ enableCustomColors, customColors, @@ -33,15 +40,27 @@ export default function useMultipleOriginColorsAndGradients() { 'color.gradients.theme', 'color.gradients.default', 'color.defaultGradients' - ); + ) as [ + boolean | undefined, + Color[] | undefined, + Color[] | undefined, + Color[] | undefined, + boolean | undefined, + boolean | undefined, + Gradient[] | undefined, + Gradient[] | undefined, + Gradient[] | undefined, + boolean | undefined, + ]; + // The remaining settings are assigned below. const colorGradientSettings = { disableCustomColors: ! enableCustomColors, disableCustomGradients: ! enableCustomGradients, - }; + } as MultipleOriginColorsAndGradients; colorGradientSettings.colors = useMemo( () => { - const result = []; + const result: ColorOrigin[] = []; if ( themeColors && themeColors.length ) { result.push( { name: _x( @@ -85,7 +104,7 @@ export default function useMultipleOriginColorsAndGradients() { ] ); colorGradientSettings.gradients = useMemo( () => { - const result = []; + const result: GradientOrigin[] = []; if ( themeGradients && themeGradients.length ) { result.push( { name: _x( From 7ecb2c6b6a577c4e5b83f1efbe21924fdbe3e51e Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 14:08:41 +0530 Subject: [PATCH 08/16] Block Editor: Convert the color and gradient control tests to TypeScript --- .../test/{control.browser.test.jsx => control.browser.test.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/block-editor/src/components/colors-gradients/test/{control.browser.test.jsx => control.browser.test.tsx} (100%) diff --git a/packages/block-editor/src/components/colors-gradients/test/control.browser.test.jsx b/packages/block-editor/src/components/colors-gradients/test/control.browser.test.tsx similarity index 100% rename from packages/block-editor/src/components/colors-gradients/test/control.browser.test.jsx rename to packages/block-editor/src/components/colors-gradients/test/control.browser.test.tsx From 8aa48d3de5bad999d85aa12d68ccc3e13be2f3e9 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 14:08:45 +0530 Subject: [PATCH 09/16] Block Editor: Update the ESLint suppressions of the converted color and gradient controls --- tools/eslint/suppressions.json | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tools/eslint/suppressions.json b/tools/eslint/suppressions.json index f62b5026827117..fb42f19fdbfacf 100644 --- a/tools/eslint/suppressions.json +++ b/tools/eslint/suppressions.json @@ -846,33 +846,19 @@ "count": 1 } }, - "packages/block-editor/src/components/colors-gradients/control.jsx": { + "packages/block-editor/src/components/colors-gradients/control.tsx": { "@wordpress/use-recommended-components": { "count": 4 - }, - "react/jsx-filename-extension": { - "count": 1 } }, - "packages/block-editor/src/components/colors-gradients/dropdown.jsx": { + "packages/block-editor/src/components/colors-gradients/dropdown.tsx": { "@wordpress/use-recommended-components": { "count": 2 - }, - "react/jsx-filename-extension": { - "count": 1 } }, - "packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.jsx": { + "packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.tsx": { "@wordpress/use-recommended-components": { "count": 1 - }, - "react/jsx-filename-extension": { - "count": 1 - } - }, - "packages/block-editor/src/components/colors-gradients/test/control.browser.test.jsx": { - "react/jsx-filename-extension": { - "count": 1 } }, "packages/block-editor/src/components/colors/test/with-colors.jsdom.test.jsx": { From 62a0f721ec1fec58a615f43d1ec1c68730a61dcf Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 14:10:00 +0530 Subject: [PATCH 10/16] Block Editor: Prune the ESLint suppressions of the converted BlockPopover, BlockTitle and useBlockDisplayInformation --- tools/eslint/suppressions.json | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/tools/eslint/suppressions.json b/tools/eslint/suppressions.json index fb42f19fdbfacf..7f85309d52695c 100644 --- a/tools/eslint/suppressions.json +++ b/tools/eslint/suppressions.json @@ -468,26 +468,6 @@ "count": 1 } }, - "packages/block-editor/src/components/block-popover/cover.jsx": { - "react/jsx-filename-extension": { - "count": 1 - } - }, - "packages/block-editor/src/components/block-popover/drop-zone.jsx": { - "react/jsx-filename-extension": { - "count": 1 - } - }, - "packages/block-editor/src/components/block-popover/inbetween.jsx": { - "react/jsx-filename-extension": { - "count": 1 - } - }, - "packages/block-editor/src/components/block-popover/index.jsx": { - "react/jsx-filename-extension": { - "count": 1 - } - }, "packages/block-editor/src/components/block-popover/stories/index.story.jsx": { "react/jsx-filename-extension": { "count": 1 @@ -635,11 +615,6 @@ "count": 1 } }, - "packages/block-editor/src/components/block-title/test/index.jsdom.test.jsx": { - "react/jsx-filename-extension": { - "count": 1 - } - }, "packages/block-editor/src/components/block-toolbar/block-styles-dropdown.jsx": { "react/jsx-filename-extension": { "count": 1 @@ -2019,11 +1994,6 @@ "count": 1 } }, - "packages/block-editor/src/components/use-block-display-information/test/index.jsdom.test.jsx": { - "react/jsx-filename-extension": { - "count": 1 - } - }, "packages/block-editor/src/components/warning/index.jsx": { "react/jsx-filename-extension": { "count": 1 From 6cfe5b76d306aa295ccf56c999269819baf04b46 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 14:51:22 +0530 Subject: [PATCH 11/16] Block Editor: Add the CHANGELOG entry for #84813 --- packages/block-editor/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-editor/CHANGELOG.md b/packages/block-editor/CHANGELOG.md index 3e8e1a67739a56..e7cd10bbcacfec 100644 --- a/packages/block-editor/CHANGELOG.md +++ b/packages/block-editor/CHANGELOG.md @@ -54,6 +54,7 @@ - Convert the zoom out and content only section hooks to TypeScript ([#84731](https://github.com/WordPress/gutenberg/pull/84731)). - Convert `BlockControls` to TypeScript ([#84733](https://github.com/WordPress/gutenberg/pull/84733)). - Convert the flow layout to TypeScript ([#84734](https://github.com/WordPress/gutenberg/pull/84734)). +- Convert BlockPopover, the color and gradient controls, BlockTitle, useBlockDisplayInformation and MediaUpload to TypeScript ([#84813](https://github.com/WordPress/gutenberg/pull/84813)). ## 18.1.0 (2026-10-07) From d106de5edb881999fce7802b5e937f4fb652bdf1 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 20:21:42 +0530 Subject: [PATCH 12/16] Block Editor: Allow an absent neighboring block in BlockPopoverInbetween --- .../src/components/block-popover/README.md | 4 ++-- .../src/components/block-popover/inbetween.tsx | 13 ++++++++----- .../src/components/block-popover/types.ts | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/block-editor/src/components/block-popover/README.md b/packages/block-editor/src/components/block-popover/README.md index 1f6efa6fa9465e..d586ff3a41199f 100644 --- a/packages/block-editor/src/components/block-popover/README.md +++ b/packages/block-editor/src/components/block-popover/README.md @@ -45,12 +45,12 @@ The content rendered inside the popover. The client ID of the block before the popover. -- Type: `String` +- Type: `String|undefined` - Required: Yes #### nextClientId The client ID of the block after the popover. -- Type: `String` +- Type: `String|undefined` - Required: Yes diff --git a/packages/block-editor/src/components/block-popover/inbetween.tsx b/packages/block-editor/src/components/block-popover/inbetween.tsx index 16ecfa4afa3dcd..852316f015474a 100644 --- a/packages/block-editor/src/components/block-popover/inbetween.tsx +++ b/packages/block-editor/src/components/block-popover/inbetween.tsx @@ -35,23 +35,26 @@ function BlockPopoverInbetween( { isBlockVisible, } = select( blockEditorStore ); + // At least one neighboring block is set. const _rootClientId = getBlockRootClientId( - previousClientId ?? nextClientId + ( previousClientId ?? nextClientId )! ); return { orientation: getBlockListSettings( _rootClientId )?.orientation || 'vertical', rootClientId: _rootClientId, + // An absent neighboring block is looked up as a missing one. isVisible: - isBlockVisible( previousClientId ) && - isBlockVisible( nextClientId ), + isBlockVisible( previousClientId as string ) && + isBlockVisible( nextClientId as string ), }; }, [ previousClientId, nextClientId ] ); - const previousElement = useBlockElement( previousClientId ); - const nextElement = useBlockElement( nextClientId ); + // An absent neighboring block has no element. + const previousElement = useBlockElement( previousClientId as string ); + const nextElement = useBlockElement( nextClientId as string ); const isVertical = orientation === 'vertical'; const popoverAnchor = useMemo( () => { diff --git a/packages/block-editor/src/components/block-popover/types.ts b/packages/block-editor/src/components/block-popover/types.ts index 4d17aa73b9cf4f..8550da371fee01 100644 --- a/packages/block-editor/src/components/block-popover/types.ts +++ b/packages/block-editor/src/components/block-popover/types.ts @@ -72,11 +72,11 @@ export interface BlockPopoverInbetweenProps /** * The client ID of the block before the popover. */ - previousClientId: string; + previousClientId: string | undefined; /** * The client ID of the block after the popover. */ - nextClientId: string; + nextClientId: string | undefined; children?: ReactNode; operation?: string; nearestSide?: string; From ba2abaae11186b6a86aabd253a1adb9d3377a737 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 20:21:48 +0530 Subject: [PATCH 13/16] Block Editor: Let MediaUpload callers type the selected media --- .../block-editor/src/components/media-upload/index.ts | 6 ++++-- .../block-editor/src/components/media-upload/types.ts | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/media-upload/index.ts b/packages/block-editor/src/components/media-upload/index.ts index bf626f69e22342..6a1d50f3c175cf 100644 --- a/packages/block-editor/src/components/media-upload/index.ts +++ b/packages/block-editor/src/components/media-upload/index.ts @@ -1,4 +1,4 @@ -import type { ComponentType } from 'react'; +import type { ReactNode } from 'react'; import { withFilters } from '@wordpress/components'; import type { MediaUploadProps } from './types'; @@ -16,4 +16,6 @@ const MediaUpload = (): null => null; */ export default withFilters( 'editor.MediaUpload' )( MediaUpload -) as unknown as ComponentType< MediaUploadProps >; // `withFilters` erases the props of the filter's implementation. +) as unknown as < Media = unknown >( + props: MediaUploadProps< Media > +) => ReactNode; // `withFilters` erases the props of the filter's implementation. diff --git a/packages/block-editor/src/components/media-upload/types.ts b/packages/block-editor/src/components/media-upload/types.ts index 8c9ae0d2f20e6f..a2c6007c0910c3 100644 --- a/packages/block-editor/src/components/media-upload/types.ts +++ b/packages/block-editor/src/components/media-upload/types.ts @@ -14,7 +14,7 @@ export interface MediaUploadCheckProps { /** * Props of `MediaUpload`, implemented through the `editor.MediaUpload` filter. */ -export interface MediaUploadProps { +export interface MediaUploadProps< Media = unknown > { /** * The types of the media to upload or select from the media library, * either a general mime type such as 'image' or a complete one such as @@ -39,10 +39,10 @@ export interface MediaUploadProps { */ onClose?: () => void; /** - * Called after `onClose` with the selected media, which come from the - * filter's implementation and are untyped here. + * Called after `onClose` with the selected media, whose shape comes from + * the filter's implementation and is supplied by the caller. */ - onSelect: ( media: unknown ) => void; + onSelect: ( media: Media ) => void; /** * Title displayed in the media modal. */ From 02617eabd26ed38a77bf67a401002cbc2369fc27 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 20:50:52 +0530 Subject: [PATCH 14/16] Block Editor: Allow a null neighboring block in BlockPopoverInbetween --- packages/block-editor/src/components/block-popover/README.md | 4 ++-- packages/block-editor/src/components/block-popover/types.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/block-popover/README.md b/packages/block-editor/src/components/block-popover/README.md index d586ff3a41199f..ff082de086cef7 100644 --- a/packages/block-editor/src/components/block-popover/README.md +++ b/packages/block-editor/src/components/block-popover/README.md @@ -45,12 +45,12 @@ The content rendered inside the popover. The client ID of the block before the popover. -- Type: `String|undefined` +- Type: `String|null|undefined` - Required: Yes #### nextClientId The client ID of the block after the popover. -- Type: `String|undefined` +- Type: `String|null|undefined` - Required: Yes diff --git a/packages/block-editor/src/components/block-popover/types.ts b/packages/block-editor/src/components/block-popover/types.ts index 8550da371fee01..64addce6469d3e 100644 --- a/packages/block-editor/src/components/block-popover/types.ts +++ b/packages/block-editor/src/components/block-popover/types.ts @@ -72,11 +72,11 @@ export interface BlockPopoverInbetweenProps /** * The client ID of the block before the popover. */ - previousClientId: string | undefined; + previousClientId: string | null | undefined; /** * The client ID of the block after the popover. */ - nextClientId: string | undefined; + nextClientId: string | null | undefined; children?: ReactNode; operation?: string; nearestSide?: string; From 873ddcf5a990ae91b52ab156a0aeb5e419d173ef Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 21:09:42 +0530 Subject: [PATCH 15/16] Block Editor: Convert the BlockPopover story to TypeScript --- package-lock.json | 1 + packages/block-editor/package.json | 1 + .../stories/{index.story.jsx => index.story.tsx} | 9 ++++++--- 3 files changed, 8 insertions(+), 3 deletions(-) rename packages/block-editor/src/components/block-popover/stories/{index.story.jsx => index.story.tsx} (94%) diff --git a/package-lock.json b/package-lock.json index eec13cc3df7bab..93a26def378a13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44795,6 +44795,7 @@ "remove-accents": "^0.5.0" }, "devDependencies": { + "@storybook/react-vite": "^10.6.1", "@testing-library/dom": "^10.4.2", "@testing-library/react": "^16.3.3", "@testing-library/user-event": "^14.6.1", diff --git a/packages/block-editor/package.json b/packages/block-editor/package.json index 645f3b6d909912..fb942cb303ce21 100644 --- a/packages/block-editor/package.json +++ b/packages/block-editor/package.json @@ -108,6 +108,7 @@ "remove-accents": "^0.5.0" }, "devDependencies": { + "@storybook/react-vite": "^10.6.1", "@testing-library/dom": "^10.4.2", "@testing-library/react": "^16.3.3", "@testing-library/user-event": "^14.6.1", diff --git a/packages/block-editor/src/components/block-popover/stories/index.story.jsx b/packages/block-editor/src/components/block-popover/stories/index.story.tsx similarity index 94% rename from packages/block-editor/src/components/block-popover/stories/index.story.jsx rename to packages/block-editor/src/components/block-popover/stories/index.story.tsx index c6bbda0c0b730e..ce7063d77ca9f0 100644 --- a/packages/block-editor/src/components/block-popover/stories/index.story.jsx +++ b/packages/block-editor/src/components/block-popover/stories/index.story.tsx @@ -1,3 +1,4 @@ +import type { Meta, StoryObj } from '@storybook/react-vite'; import { createBlock, registerBlockType, @@ -19,7 +20,7 @@ const clientIds = BLOCK_LABELS.map( ( label, index ) => `example-block-${ index + 1 }` ); -function ExampleEdit( { attributes } ) { +function ExampleEdit( { attributes }: { attributes: { content?: string } } ) { return

{ attributes.content }

; } @@ -73,7 +74,7 @@ const clientIdLabels = Object.fromEntries( clientIds.map( ( clientId, index ) => [ clientId, `Block ${ index + 1 }` ] ) ); -const meta = { +const meta: Meta< typeof BlockPopover > = { id: 'blockeditor-blockpopover', title: 'Editor/Block Editor/BlockPopover', component: BlockPopover, @@ -142,7 +143,9 @@ const meta = { export default meta; -export const Default = { +type Story = StoryObj< typeof meta >; + +export const Default: Story = { args: { clientId: clientIds[ 1 ], children: 'This is a block popover example.', From 56009147e5b5cfe203521f98ff3ed7df4733cb50 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Thu, 15 Oct 2026 21:09:48 +0530 Subject: [PATCH 16/16] Block Editor: Update the ESLint suppressions of the converted BlockPopover story --- tools/eslint/suppressions.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/eslint/suppressions.json b/tools/eslint/suppressions.json index 7f85309d52695c..76906f476f0900 100644 --- a/tools/eslint/suppressions.json +++ b/tools/eslint/suppressions.json @@ -468,11 +468,6 @@ "count": 1 } }, - "packages/block-editor/src/components/block-popover/stories/index.story.jsx": { - "react/jsx-filename-extension": { - "count": 1 - } - }, "packages/block-editor/src/components/block-preview/auto.jsx": { "react/jsx-filename-extension": { "count": 1