-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Table of Contents: Try maintaining block example attributes #65549
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,28 @@ export const settings = { | |
icon, | ||
edit, | ||
save, | ||
example: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be moved to block.json? I think the example check above might be unnecessary if we use "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
}
]
}
}, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that works, thanks 🙇 I take it that the definition of the If I remove the I've pushed a commit using the suggested approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That sounds legit. My brain stops functioning when I see something working. 😄 |
||
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 } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggled to find a better option to avoid the
useObserveHeadings
hook overriding arbitrary block example attributes. More than happy to hear better approaches if you have them 🙏