Skip to content

Commit 5a95ae3

Browse files
🤖 Merge PR DefinitelyTyped#74509 [@wordpress/block-editor] Add missing properties to InnerBlocks Props by @hspiess-correctiv
1 parent 111a435 commit 5a95ae3

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

‎types/wordpress__block-editor/components/inner-blocks.d.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TemplateArray } from "@wordpress/blocks";
1+
import { BlockAttributes, TemplateArray } from "@wordpress/blocks";
22
import { ComponentType, JSX, ReactElement, Ref } from "react";
33

44
import { EditorTemplateLock } from "../";
@@ -7,7 +7,7 @@ import { Merged, Reserved } from "./use-block-props";
77

88
declare namespace InnerBlocks {
99
interface Props {
10-
allowedBlocks?: string[] | undefined;
10+
allowedBlocks?: string[] | boolean | undefined;
1111
/**
1212
* A 'render prop' function that can be used to customize the block's appender.
1313
*/
@@ -56,6 +56,20 @@ declare namespace InnerBlocks {
5656
* `prioritizedInserterBlocks` takes an array of the form {blockName}/{variationName}, where {variationName} is optional.
5757
*/
5858
prioritizedInserterBlocks?: string[] | undefined;
59+
60+
/**
61+
* Determines which block type should be inserted by default and any attributes that should be set by default when the block is inserted.
62+
* Takes an object in the form of `{ name: blockname, attributes: {blockAttributes} }`.
63+
*/
64+
defaultBlock?: {
65+
name: string;
66+
attributes?: BlockAttributes;
67+
} | undefined;
68+
69+
/**
70+
* Determines whether the default block should be inserted directly into the InnerBlocks area by the block appender.
71+
*/
72+
directInsert?: boolean | undefined;
5973
}
6074
}
6175
declare const InnerBlocks: {

‎types/wordpress__block-editor/wordpress__block-editor-tests.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,15 @@ be.withFontSizes("fontSize")(() => <h1>Hello World</h1>);
246246
// inner-blocks
247247
//
248248
<be.InnerBlocks />;
249+
<be.InnerBlocks allowedBlocks={false} />;
249250
<be.InnerBlocks renderAppender={be.InnerBlocks.ButtonBlockAppender} />;
250251
<be.InnerBlocks.Content />;
251252
<be.InnerBlocks.DefaultBlockAppender />;
252253
<be.InnerBlocks orientation="vertical" />;
253254
<be.InnerBlocks prioritizedInserterBlocks={["core/navigation-link/page"]} />;
254255
<be.InnerBlocks templateLock="all" />;
256+
<be.InnerBlocks defaultBlock={{ name: "core/paragraph", attributes: { content: "Default content" } }} />;
257+
<be.InnerBlocks directInsert={true} />;
255258

256259
//
257260
// inserter

0 commit comments

Comments
 (0)