From 09f9a099c5d6ba176a22f4ecd6049be59e2efeb2 Mon Sep 17 00:00:00 2001 From: Toberumono Date: Fri, 26 Dec 2025 22:10:28 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74273=20[@wordpres?= =?UTF-8?q?s/block-editor]=20Add=20definitions=20for=20getBlocksByName=20a?= =?UTF-8?q?nd=20some=20missing=20props=20on=20RichText=20by=20@Toberumono?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joshua Lipstone --- types/wordpress__block-editor/components/rich-text.d.ts | 8 ++++++++ types/wordpress__block-editor/store/selectors.d.ts | 9 +++++++++ .../wordpress__block-editor-tests.tsx | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/types/wordpress__block-editor/components/rich-text.d.ts b/types/wordpress__block-editor/components/rich-text.d.ts index c7c2300e25a1f5..f4ca649da830c8 100644 --- a/types/wordpress__block-editor/components/rich-text.d.ts +++ b/types/wordpress__block-editor/components/rich-text.d.ts @@ -17,6 +17,10 @@ declare namespace RichText { autocompleters?: ComponentProps["completers"] | undefined; children?: never | undefined; className?: string | undefined; + /** + * Disables inserting line breaks on Enter when it is set to true + */ + disableLineBreaks?: boolean | undefined; identifier?: string | undefined; inlineToolbar?: boolean | undefined; /** @@ -66,6 +70,10 @@ declare namespace RichText { * if provided. */ value: string; + /** + * By default, all formatting controls are present. This setting can be used to remove formatting controls that would make content interactive. This is useful if you want to make content that is already interactive editable. + */ + withoutInteractiveFormatting?: boolean | undefined; wrapperClassName?: string | undefined; } interface ContentProps extends HTMLProps { diff --git a/types/wordpress__block-editor/store/selectors.d.ts b/types/wordpress__block-editor/store/selectors.d.ts index 95a978e7e28e1c..c2f464ed3584f6 100644 --- a/types/wordpress__block-editor/store/selectors.d.ts +++ b/types/wordpress__block-editor/store/selectors.d.ts @@ -191,6 +191,15 @@ export function getBlocks(rootClientId?: string): BlockInstance[]; */ export function getBlocksByClientId(clientIds: string | string[]): Array; +/** + * Returns all blocks that match a blockName. Results include nested blocks. + * + * @param blockName - Block name(s) for which clientIds are to be returned. + * + * @returns Array of clientIds of blocks with name equal to blockName. + */ +export function getBlocksByName(blockName: string | string[]): string[]; + /** * Returns an array containing the clientIds of all descendants of the blocks given. * diff --git a/types/wordpress__block-editor/wordpress__block-editor-tests.tsx b/types/wordpress__block-editor/wordpress__block-editor-tests.tsx index c0e806b27c7e29..f70620dd1baef1 100644 --- a/types/wordpress__block-editor/wordpress__block-editor-tests.tsx +++ b/types/wordpress__block-editor/wordpress__block-editor-tests.tsx @@ -370,6 +370,8 @@ be.withFontSizes("fontSize")(() =>

Hello World

); onReplace={blocks => blocks.forEach(b => console.log(b.clientId))} allowedFormats={["core/bold", "core/italic"]} onSplit={(value, isOriginal) => createBlock("core/paragraph", { content: value })} + disableLineBreaks + withoutInteractiveFormatting />; ; ; @@ -608,6 +610,10 @@ useSelect("core/block-editor").getBlockParentsByBlockName("foo", ["core/query"]) useSelect("core/block-editor").getBlockParents("foo", true); useSelect("core/block-editor").getBlockParentsByBlockName("foo", ["core/query"], true); +// $ExpectType string[] +useSelect("core/block-editor").getBlocksByName("core/group"); +useSelect("core/block-editor").getBlocksByName(["core/group", "core/paragraph"]); + { const blockProps: UseBlockProps.Merged & UseBlockProps.Reserved = be.useBlockProps(); blockProps;