close
Skip to content

Feature: Allow user to exclude headings from the ToC block in the editor.#70235

Closed
Vrishabhsk wants to merge 1 commit intoWordPress:trunkfrom
Vrishabhsk:add/toc-heading-control
Closed

Feature: Allow user to exclude headings from the ToC block in the editor.#70235
Vrishabhsk wants to merge 1 commit intoWordPress:trunkfrom
Vrishabhsk:add/toc-heading-control

Conversation

@Vrishabhsk
Copy link
Contributor

What?

Why?

  • As per #69200 "In the ToC block, there is currently no way to exclude a specific heading from the list."
  • Give user more flexibility to exclude specific headings from the ToC block.

How?

  1. In the TOC block's Inspector Controls, you'll find a "Heading Visibility" panel
  2. This panel lists all headings in your post with individual toggles
  3. You can quickly show/hide multiple headings from this central location
  4. The "Reset All" option makes all headings visible again
  5. Any existing or new heading blocks will automatically show a "Table of Contents" panel in their Inspector Controls
  6. When the TOC block is removed, these controls automatically disappear

Technical implications

  1. No modifications to heading block core files: All functionality is managed through the TOC block
  2. Dynamic controls: Heading controls only appear when a TOC block exists
  3. Clean removal: When TOC blocks are removed, all related controls disappear
  4. Multiple TOC support: Works correctly with multiple TOC blocks in the same post

Testing Instructions

  1. Create a post with several heading blocks
  2. Add a Table of Contents block
  3. Notice that each heading now has TOC visibility controls
  4. Hide some headings using either the individual controls or the centralized panel
  5. Observe that the TOC updates to reflect your choices
  6. Remove the TOC block and notice the heading controls disappear

Testing Instructions for Keyboard

  • NA

Screenshots or screencast

Feature Screencast

@github-actions
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Vrishabhsk <vrishabhsk@git.wordpress.org>
Co-authored-by: mrfoxtalbot <mrfoxtalbot@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: gmovr <etobiesen@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Vrishabhsk Vrishabhsk changed the title Improvement: A user should be able to exclude headings from the ToC block in the editor. Feature: Allow user to exclude headings from the ToC block in the editor. May 28, 2025
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Table of contents (experimental) Affects the Table of contents Block labels May 28, 2025
@mrfoxtalbot
Copy link

mrfoxtalbot commented May 30, 2025

Thank you for taking the time to submit this P.R However, this gap has already been addressed, and the PR below has been merged:

#69063

I am going to close this PR. Thanks again @Vrishabhsk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Table of contents (experimental) Affects the Table of contents Block [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvement: A user should be able to exclude headings from the ToC block in the editor.

3 participants