Skip to content

Commit

Permalink
RichText: document the identifier prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Mar 21, 2024
1 parent 2f93eb3 commit 49cbb83
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/block-editor/src/components/rich-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ _Required._ HTML string to make editable. The HTML should be valid, and valid in

_Required._ Called when the value changes.

### `identifier: String`

_Optional._ If the editable field is bound to a block attribute (through the `value` and `onChange` props) then this prop should specify the attribute name. The field will use this value to set the block editor selection correctly, specifying in which attribute and at what offset does the selection start or end.

### `tagName: String`

_Default: `div`._ The [tag name](https://www.w3.org/TR/html51/syntax.html#tag-name) of the editable element.
Expand Down Expand Up @@ -50,6 +54,7 @@ _Optional._ By default, all registered formats are allowed. This setting can be
```js
<RichText
tagName="h2"
identifier="content"
value={ attributes.content }
allowedFormats={ [ 'core/bold', 'core/italic' ] } // Allow the content to be made bold or italic, but do not allow othe formatting options
onChange={ ( content ) => setAttributes( { content } ) }
Expand Down Expand Up @@ -99,6 +104,7 @@ registerBlockType( /* ... */, {
<RichText
tagName="h2"
className={ className }
identifier="content"
value={ attributes.content }
onChange={ ( content ) => setAttributes( { content } ) }
/>
Expand Down

0 comments on commit 49cbb83

Please sign in to comment.