RedEchidnaUK / Table-of-Contents

Creates a Table of Contents on SharePoint Online Modern pages based on the heading tags in the standard Text web part. This has not been tested with standalone SharePoint, but it may work.
MIT License
10 stars 4 forks source link
sharepoint sharepoint-online webpart

Table of Contents Web Part

Summary

This SharePoint Framework web part displays a Table of Contents for the current page and is based on Dzmitry Rogozhny's excellent Table of Contents. I haven't forked the code as it was originally for an internal project and I didn't want to fork the entire repositry, just this sub folder. There's probably some way in GIT to fork just a sub folder, but I don't know how.

web part preview

The web part provides the following properties:

*This mode will not work correctly on the local workbench, only the live site. It should also be used with caution as it works by manipulating Microsoft's styles on the containing element, so it may stop working if Microsoft change their code, you have been warned! When used with this mode, it is best to place the Table of Contents in a 'vertical section' as this covers the full length of a page.

Known Issues

When using the Markdown webpart within a Collapsible section, the headings do not show in the Table of Contents until the page is scrolled to show those items. This is due to Microsoft not rendering the items in the DOM until they are visible on the page. Consequently, the Table of Contents is also unable to 'see' them.

Minimal Path to Awesome

Pre-built package

You can grab the pre-built package ready for deployment from ./package/table-of-contents.sppkg.

Here's how to deploy the web part to the site collection's app catalog: deploying to site app catalog

Local testing

Deploy