Skip to content

Commit

Permalink
Add RichText identifier to blocks (WordPress#59056)
Browse files Browse the repository at this point in the history
Co-authored-by: sunil25393 <sunil25393@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
  • Loading branch information
5 people authored and carstingaxion committed Mar 27, 2024
1 parent e0bd301 commit 99cd436
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/block-library/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
>
<summary onClick={ ( event ) => event.preventDefault() }>
<RichText
identifier="summary"
aria-label={ __( 'Write summary' ) }
placeholder={ __( 'Write summary…' ) }
allowedFormats={ [] }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/file/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
) }
<div className={ 'wp-block-file__content-wrapper' }>
<RichText
identifier="fileName"
tagName="a"
value={ fileName }
placeholder={ __( 'Write file name…' ) }
Expand All @@ -273,6 +274,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
>
{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }
<RichText
identifier="downloadButtonText"
tagName="div" // Must be block-level or else cursor disappears.
aria-label={ __( 'Download button text' ) }
className={ classnames(
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-author/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ function PostAuthorEdit( {
<div className="wp-block-post-author__content">
{ ( ! RichText.isEmpty( byline ) || isSelected ) && (
<RichText
identifier="byline"
className="wp-block-post-author__byline"
aria-label={ __( 'Post author byline text' ) }
placeholder={ __( 'Write byline…' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-excerpt/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default function PostExcerptEditor( {
}
const readMoreLink = (
<RichText
identifier="moreText"
className="wp-block-post-excerpt__more-link"
tagName="a"
aria-label={ __( '“Read more” link text' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export default function PostNavigationLinkEdit( {
) }
<RichText
tagName="a"
identifier="label"
aria-label={ ariaLabel }
placeholder={ placeholder }
value={ label }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-terms/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default function PostTermsEdit( {
{ isLoading && hasPost && <Spinner /> }
{ ! isLoading && ( isSelected || prefix ) && (
<RichText
identifier="prefix"
allowedFormats={ ALLOWED_FORMATS }
className="wp-block-post-terms__prefix"
aria-label={ __( 'Prefix' ) }
Expand Down Expand Up @@ -138,6 +139,7 @@ export default function PostTermsEdit( {
__( 'Term items not found.' ) ) }
{ ! isLoading && ( isSelected || suffix ) && (
<RichText
identifier="suffix"
allowedFormats={ ALLOWED_FORMATS }
className="wp-block-post-terms__suffix"
aria-label={ __( 'Suffix' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/read-more/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function ReadMore( {
</PanelBody>
</InspectorControls>
<RichText
identifier="content"
tagName="a"
aria-label={ __( '“Read more” link text' ) }
placeholder={ __( 'Read more' ) }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/search/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ export default function SearchEdit( {

{ ! buttonUseIcon && (
<RichText
identifier="buttonText"
className={ buttonClasses }
style={ buttonStyles }
aria-label={ __( 'Button text' ) }
Expand Down Expand Up @@ -546,6 +547,7 @@ export default function SearchEdit( {

{ showLabel && (
<RichText
identifier="label"
className={ labelClassnames }
aria-label={ __( 'Label text' ) }
placeholder={ __( 'Add label…' ) }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/search/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export default function SearchEdit( {
>
<RichText
className="wp-block-search__button"
identifier="text"
identifier="buttonText"
tagName="p"
style={ richTextButtonStyle }
placeholder={ buttonPlaceholderText }
Expand Down Expand Up @@ -449,7 +449,7 @@ export default function SearchEdit( {
>
<RichText
className="wp-block-search__label"
identifier="text"
identifier="label"
tagName="p"
style={ styles.richTextLabel }
placeholder={ __( 'Add label…' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/widgets/src/blocks/widget-group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function PreviewContent( { attributes, setAttributes } ) {
<>
<RichText
tagName="h2"
identifier="title"
className="widget-title"
allowedFormats={ [] }
placeholder={ __( 'Title' ) }
Expand Down

0 comments on commit 99cd436

Please sign in to comment.