From af42c32969e053b11e09998e58699308454c3329 Mon Sep 17 00:00:00 2001 From: Vasiliy Artamonov Date: Tue, 31 May 2022 20:27:13 +0300 Subject: [PATCH 1/5] Block attributes docs: consistency across attribute definitions --- docs/reference-guides/block-api/block-attributes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference-guides/block-api/block-attributes.md b/docs/reference-guides/block-api/block-attributes.md index e3eb3c9903bc44..6c5adf1abcb274 100644 --- a/docs/reference-guides/block-api/block-attributes.md +++ b/docs/reference-guides/block-api/block-attributes.md @@ -230,7 +230,7 @@ Saved content: Attribute definition: ```js -attributes: { +{ content: { type: 'string', source: 'text', @@ -259,7 +259,7 @@ Saved content: Attribute definition: ```js -attributes { +{ content: { type: 'string', source: 'html', From d483c081210b38437becb02dc5952c47ae393b8e Mon Sep 17 00:00:00 2001 From: Vasiliy Artamonov Date: Tue, 31 May 2022 20:30:04 +0300 Subject: [PATCH 2/5] Block attributes docs: use tabs --- docs/reference-guides/block-api/block-attributes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/reference-guides/block-api/block-attributes.md b/docs/reference-guides/block-api/block-attributes.md index 6c5adf1abcb274..cdd3c3f9802f65 100644 --- a/docs/reference-guides/block-api/block-attributes.md +++ b/docs/reference-guides/block-api/block-attributes.md @@ -333,10 +333,10 @@ Attribute definition: Attribute available in the block: ```js { - "images": [ - { "url": "https://lorempixel.com/1200/800/", "alt": "large image" }, - { "url": "https://lorempixel.com/50/50/", "alt": "small image" } - ] + "images": [ + { "url": "https://lorempixel.com/1200/800/", "alt": "large image" }, + { "url": "https://lorempixel.com/50/50/", "alt": "small image" } + ] } ``` From 594fab7f7c45127a099fde9300fa3b29e58bb067 Mon Sep 17 00:00:00 2001 From: Vasiliy Artamonov Date: Tue, 31 May 2022 20:47:45 +0300 Subject: [PATCH 3/5] Block attributes docs: unify code blocks descriptions --- docs/reference-guides/block-api/block-attributes.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/reference-guides/block-api/block-attributes.md b/docs/reference-guides/block-api/block-attributes.md index cdd3c3f9802f65..b367674b7b3f37 100644 --- a/docs/reference-guides/block-api/block-attributes.md +++ b/docs/reference-guides/block-api/block-attributes.md @@ -156,6 +156,7 @@ Attribute available in the block: Most attributes from markup will be of type `string`. Numeric attributes in HTML are still stored as strings, and are not converted automatically. +Attribute definition: ```js { width: { @@ -167,12 +168,14 @@ Most attributes from markup will be of type `string`. Numeric attributes in HTML } ``` +Attribute available in the block: ```js { "width": "50" } ``` The only exception is when checking for the existence of an attribute (for example, the `disabled` attribute on a `button`). In that case type `boolean` can be used and the stored value will be a boolean. +Attribute definition: ```js { disabled: { @@ -184,6 +187,7 @@ The only exception is when checking for the existence of an attribute (for examp } ``` +Attribute available in the block: ```js { "disabled": true } ``` @@ -275,6 +279,7 @@ Attribute available in the block: Use the `multiline` property to extract the inner HTML of matching tag names for the use in `RichText` with the `multiline` prop. +Attribute definition: ```js { content: { @@ -346,8 +351,9 @@ Attribute available in the block: Although attributes may be obtained from a post's meta, meta attribute sources are considered deprecated; EntityProvider and related hook APIs should be used instead, as shown in the Create Meta Block how-to. -Attributes may be obtained from a post's meta rather than from the block's representation in saved post content. For this, an attribute is required to specify its corresponding meta key under the `meta` key: +Attributes may be obtained from a post's meta rather than from the block's representation in saved post content. For this, an attribute is required to specify its corresponding meta key under the `meta` key. +Attribute definition: ```js { author: { From 45b1cb4ddd929c8ff3197034f05bdfd9ace68cc6 Mon Sep 17 00:00:00 2001 From: Vasiliy Artamonov Date: Tue, 31 May 2022 21:24:31 +0300 Subject: [PATCH 4/5] Block attributes docs: add 'source' --- docs/reference-guides/block-api/block-attributes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference-guides/block-api/block-attributes.md b/docs/reference-guides/block-api/block-attributes.md index b367674b7b3f37..d4c24ab1dd9f5e 100644 --- a/docs/reference-guides/block-api/block-attributes.md +++ b/docs/reference-guides/block-api/block-attributes.md @@ -248,7 +248,7 @@ Attribute available in the block: { "content": "The inner text of .my-content class" } ``` -### `html` +### `html` source Use `html` to extract the inner HTML from markup. Note that text is returned according to the rules of [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerHTML). @@ -296,7 +296,7 @@ Attribute available in the block: { "content": "

First line

Second line

" } ``` -### `query` +### `query` source Use `query` to extract an array of values from markup. Entries of the array are determined by the `selector` argument, where each matched element within the block will have an entry structured corresponding to the second argument, an object of attribute sources. @@ -345,7 +345,7 @@ Attribute available in the block: } ``` -## Meta (deprecated) +## Meta source (deprecated)
Although attributes may be obtained from a post's meta, meta attribute sources are considered deprecated; EntityProvider and related hook APIs should be used instead, as shown in the Create Meta Block how-to. From 5371d9cbed0de559d300b7cfdb97ec674e041374 Mon Sep 17 00:00:00 2001 From: Vasiliy Artamonov Date: Tue, 31 May 2022 21:26:54 +0300 Subject: [PATCH 5/5] Block attributes docs: nest 'Meta source' heading one level deeper It's the source too, and other sources are placed on the `h3` level. The nested heading is also updated. --- docs/reference-guides/block-api/block-attributes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference-guides/block-api/block-attributes.md b/docs/reference-guides/block-api/block-attributes.md index d4c24ab1dd9f5e..ea57074d11f576 100644 --- a/docs/reference-guides/block-api/block-attributes.md +++ b/docs/reference-guides/block-api/block-attributes.md @@ -345,7 +345,7 @@ Attribute available in the block: } ``` -## Meta source (deprecated) +### Meta source (deprecated)
Although attributes may be obtained from a post's meta, meta attribute sources are considered deprecated; EntityProvider and related hook APIs should be used instead, as shown in the Create Meta Block how-to. @@ -396,7 +396,7 @@ edit: function( props ) { {% end %} -### Considerations +#### Considerations By default, a meta field will be excluded from a post object's meta. This can be circumvented by explicitly making the field visible: