Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichText: document the identifier prop #60036

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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