Skip to content

Commit

Permalink
Enable Rename support for various blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 13, 2023
1 parent a6a2809 commit eabcc99
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/block-library/src/heading/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"textTransform": true
}
},
"__experimentalSlashInserter": true
"__experimentalSlashInserter": true,
"__experimentalMetadata": true
},
"editorStyle": "wp-block-heading-editor",
"style": "wp-block-heading"
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ export const settings = {
__experimentalLabel( attributes, { context } ) {
const { content, level } = attributes;

const customName = attributes?.metadata?.name;

// In the list view, use the block's content as the label.
// If the content is empty, fall back to the default label.
if ( context === 'list-view' && content ) {
return content;
if ( context === 'list-view' && ( customName || content ) ) {
return attributes?.metadata?.name || content;
}

if ( context === 'accessibility' ) {
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/paragraph/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
}
},
"__experimentalSelector": "p",
"__unstablePasteTextInline": true
"__unstablePasteTextInline": true,
"__experimentalMetadata": true
},
"editorStyle": "wp-block-paragraph-editor",
"style": "wp-block-paragraph"
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export const settings = {
},
},
__experimentalLabel( attributes, { context } ) {
const customName = attributes?.metadata?.name;

if ( context === 'list-view' && customName ) {
return attributes?.metadata?.name;
}

if ( context === 'accessibility' ) {
const { content } = attributes;
return ! content || content.length === 0 ? __( 'Empty' ) : content;
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/query/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"supports": {
"align": [ "wide", "full" ],
"html": false,
"layout": true
"layout": true,
"__experimentalMetadata": true
},
"editorStyle": "wp-block-query-editor",
"style": "wp-block-query",
Expand Down

0 comments on commit eabcc99

Please sign in to comment.