Skip to content

Commit

Permalink
i18n: make example translatable in table-of-contents (#68377)
Browse files Browse the repository at this point in the history
Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Jan 2, 2025
1 parent 1673ed8 commit 42658e2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 52 deletions.
52 changes: 0 additions & 52 deletions packages/block-library/src/table-of-contents/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,57 +62,5 @@
}
}
},
"example": {
"innerBlocks": [
{
"name": "core/heading",
"attributes": {
"level": 2,
"content": "Heading"
}
},
{
"name": "core/heading",
"attributes": {
"level": 3,
"content": "Subheading"
}
},
{
"name": "core/heading",
"attributes": {
"level": 2,
"content": "Heading"
}
},
{
"name": "core/heading",
"attributes": {
"level": 3,
"content": "Subheading"
}
}
],
"attributes": {
"headings": [
{
"content": "Heading",
"level": 2
},
{
"content": "Subheading",
"level": 3
},
{
"content": "Heading",
"level": 2
},
{
"content": "Subheading",
"level": 3
}
]
}
},
"style": "wp-block-table-of-contents"
}
53 changes: 53 additions & 0 deletions packages/block-library/src/table-of-contents/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { tableOfContents as icon } from '@wordpress/icons';

/**
Expand All @@ -19,6 +20,58 @@ export const settings = {
icon,
edit,
save,
example: {
innerBlocks: [
{
name: 'core/heading',
attributes: {
level: 2,
content: __( 'Heading' ),
},
},
{
name: 'core/heading',
attributes: {
level: 3,
content: __( 'Subheading' ),
},
},
{
name: 'core/heading',
attributes: {
level: 2,
content: __( 'Heading' ),
},
},
{
name: 'core/heading',
attributes: {
level: 3,
content: __( 'Subheading' ),
},
},
],
attributes: {
headings: [
{
content: __( 'Heading' ),
level: 2,
},
{
content: __( 'Subheading' ),
level: 3,
},
{
content: __( 'Heading' ),
level: 2,
},
{
content: __( 'Subheading' ),
level: 3,
},
],
},
},
};

export const init = () => initBlock( { name, metadata, settings } );

1 comment on commit 42658e2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 42658e2.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12579244258
📝 Reported issues:

Please sign in to comment.