Skip to content

Commit

Permalink
i18n: make example translatable in table-of-contents
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshbhutkar committed Dec 30, 2024
1 parent b4304f8 commit f77225e
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 } );

0 comments on commit f77225e

Please sign in to comment.