Skip to content

Planning for Table of Content Block Functionality and Heading IDs #22874

Open

Description

This issue sets up discussion started during a Core Editor chat for the functionality of a Table of Contents (TOC) Block. Currently, there are several PRs/Issues that provide possible solutions.

Add Table of Contents block (dynamic rendering + hooks version) PR #21234
"Table of Contents" Block PR #11047
#15426 (Closed) PR #15426

From a technical point, when working with a TOC block, how are items that aren't in blocks like headings and next page tags counted, and how is it determined if those items precede the current block? Counting Heading blocks is relatively easy, but counting all headings in the HTML is more difficult, and counting all headings in the HTML preceding the current block seems impossible in some situations. This challenge is compounded when considering if the headings are in a dynamic block.

Resolving these questions impacts:

  • Completion of the TOC block
  • Addressing edge-cases with the heading level checker in PR Heading block: add heading level checker #22650
  • Application for the existing content structure tool in the top toolbar.
  • Some Full Site Editing (FSE) blocks like site-title or post-title if the HTML is not set as an h1

Specific challenges that need feedback are:

  • Should the TOC block only support Heading Blocks?
  • How is support added for 3rd-party heading blocks?
  • Should there be some kind of generic "headings" API for blocks to hook into that is abstracted away from HTML?
  • What is involved in supporting third-party heading blocks?

Possible solutions include:

  • Something like allowing a block to declare one of its attributes as contributing to the outline of a document and abstracting away outline/table of contents in a getOutline rather than just getting core/heading. @mtias
  • Potentially adding a dedicated block API for third-party blocks. @youknowriad

@ZebulanStanphill @mtias @youknowriad @MichaelArestad contributed to the original conversation. Additional feedback here is welcome.

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

Metadata

Assignees

No one assigned

    Labels

    [Feature] Document OutlineAn option that outlines content based on a title and headings used in the post/page[Type] DiscussionFor issues that are high-level and not yet ready to implement.[Type] New APINew API to be used by plugin developers or package users.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions