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

Ignore Collapsible Sections #11

Closed robstewart-nz closed 3 months ago

robstewart-nz commented 7 months ago

Would it be possible to have an option with each web part config as to whether to ignore collapsible sections on the page?

There are times we use collapsible sections as more of a callout for extra data not always needed but MS treats them as heading 2 so the TOC gives them lots of priority. It would be great to be able to flag that for that page to ignore them altogether for the TOC.

RedEchidnaUK commented 7 months ago

Well I was hoping to say yes it would be simple, but I've tried to do it and it turns out it is more complicated than I was expecting. In fact, I have found a bug with the current version. I've realised that as sections can contain other web parts when you search them for header tags you will automatically find all headers contained within that section even if you don't want them. A quick example being if you put a Markdown webpart in a collapsible section, it will always show up in the ToC even if you have Markdown disabled. If I can fix that bug, then yes, I should be able to make you a version that works. In the meantime I have made a version that may work for you, but it has this bug...

table-of-contents.sppkg.zip

Edit: I'm not sure when I will get a chance to try and fix the bug as I've got a lot going on at the moment. I'll try and not leave it 6 months, but no promises...

RedEchidnaUK commented 7 months ago

New test version that may have fixed the bug. table-of-contents.sppkg.zip

robstewart-nz commented 7 months ago

Just put it in and it works like a dream. The TOC looks super clean but I can make lots of information available on demand via the collapsible sections, you're a legend.

RedEchidnaUK commented 7 months ago

Glad it's working for you, but do let me know if you find anything odd going on as I haven't had time to do a full check. At some point I'll do an official release after I've cleaned up the code and done a few more checks etc.

RedEchidnaUK commented 7 months ago

Another day, another release :) I've released a new version which has the latest changes and also shows the collapsible headings in the ToC when in edit mode.