-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Feature: Adding support for more granular controls over the ToC block #69063
base: trunk
Are you sure you want to change the base?
Conversation
…, such as heading level, and the option for excluding certain headings via a css class
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @jodamo5. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @gmovr! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
I tested it using Playgound, and it works as expected. Kapture.2025-02-06.at.15.50.21.mp4 |
The last design guidance on #51605 is from 2023, so I think we need a fresh perspective there. The toggle + dropdown seems a bit unnecessary to me. Either way, I don't think we need two attributes for this. |
] } | ||
onChange={ ( value ) => | ||
setAttributes( { | ||
maxLevel: parseInt( value, 10 ), |
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.
FYI passing radix 10 isn't needed and hasn't been for like 10 years. parseInt( value )
is enough
Where is this coming from? I don't see a feature request for it. IMHO this is better discussed in a new issue first before trying to add this in via this PR. There might be alternative approaches for this, e.g. with a new attribute on the heading block, or with a different class name or so. Hence best to split this up. |
Thanks for the feedback. This is coming from my own use wihin the team that update our blog. Often we do not want certain headings in the ToC, and to accomplish this now, we need to convert it to a static list. I was considering setting it on the heading block, but it felt a bit inverse in this case, as most pages will have headings while fewer will have the ToC block. So IMO the ToC block should contain ToC logic. I'm open to either approach, though, or moving it to an issue and a subsequent PR. :) |
That makes sense! I will change the filtering logic. |
To clarify, my suggestion was not necessarily to do the inverse, but for example to introduce a proper toggle on the heading block that the TOC block could then use. I would also take a look at how Google Docs does this for example. You can remove a heading from the TOC simply by clicking on an "X" next to it. That's why I think this needs its own issue & discussion first. |
What?
Closes #51605
toc-exclude
. This will exclude it from the ToC, even if the given settings for heading level would qualify it.Why?
On several sites, the ToC block is too rigid, and we're forced to convert it to a static list. This is subpar, as it loses the logic, and a changed heading will lead to a broken link reference.
How?
Testing Instructions
toc-exclude
class on a heading.Just like a TV cooking show, I've prepared some code you can paste into the editor to test this:
Testing Instructions for Keyboard
We use standard components only adding a standard select box.
Screenshots or screencast