From 40f70d0238c76487f3ce9bf8847d907e22e9d162 Mon Sep 17 00:00:00 2001 From: Niels Lange Date: Thu, 17 Nov 2022 10:54:07 +0700 Subject: [PATCH 1/2] Add ancestor property to block-registration.md doc --- .../reference-guides/block-api/block-registration.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/reference-guides/block-api/block-registration.md b/docs/reference-guides/block-api/block-registration.md index 5c38bf7f79c361..6f8cdcfb71f927 100644 --- a/docs/reference-guides/block-api/block-registration.md +++ b/docs/reference-guides/block-api/block-registration.md @@ -253,6 +253,18 @@ Blocks are able to be inserted into blocks that use [`InnerBlocks`](https://gith Setting `parent` lets a block require that it is only available when nested within the specified blocks. +```js +// Only allow this block when it is nested in a Columns block +parent: [ 'core/columns' ], +``` + +#### ancestor (optional) + +- **Type:** `Array` + +The `ancestor` property makes a block available inside the specified block types at any position of the ancestor block subtree. That allows, for example, to place a ‘Comment Content’ block inside a ‘Column’ block, as long as ‘Column’ is somewhere within a ‘Comment Template’ block. In comparrison to the `parent` property blocks that specify their `ancestor` can be placed anywhere in the subtree whilst blocks with a specified `parent` need to be direct children. + + ```js // Only allow this block when it is nested in a Columns block parent: [ 'core/columns' ], From 63cf6f2b9e9a4ed0755e0141c471c5da92a56cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=B3=C5=82kowski?= Date: Thu, 2 Feb 2023 10:35:23 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- docs/reference-guides/block-api/block-registration.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference-guides/block-api/block-registration.md b/docs/reference-guides/block-api/block-registration.md index 6f8cdcfb71f927..d67c3232ede7c6 100644 --- a/docs/reference-guides/block-api/block-registration.md +++ b/docs/reference-guides/block-api/block-registration.md @@ -262,12 +262,12 @@ parent: [ 'core/columns' ], - **Type:** `Array` -The `ancestor` property makes a block available inside the specified block types at any position of the ancestor block subtree. That allows, for example, to place a ‘Comment Content’ block inside a ‘Column’ block, as long as ‘Column’ is somewhere within a ‘Comment Template’ block. In comparrison to the `parent` property blocks that specify their `ancestor` can be placed anywhere in the subtree whilst blocks with a specified `parent` need to be direct children. +The `ancestor` property makes a block available inside the specified block types at any position of the ancestor block subtree. That allows, for example, to place a 'Comment Content' block inside a 'Column' block, as long as 'Column' is somewhere within a 'Comment Template' block. In comparison to the `parent` property blocks that specify their `ancestor` can be placed anywhere in the subtree whilst blocks with a specified `parent` need to be direct children. ```js -// Only allow this block when it is nested in a Columns block -parent: [ 'core/columns' ], +// Only allow this block when it is nested at any level in a Columns block. +ancestor: [ 'core/columns' ], ``` ## Block Collections