Page MenuHomePhabricator

Give skin developers decent default table of contents styles
Open, Needs TriagePublic

Description

The ResourceLoaderSkinModule has a feature called "toc" which provides some default styles for table of contents. These defaults are incomplete, do not look modern and are overriden in pretty much every skin.

Screen Shot 2021-05-27 at 9.00.00 AM.png (1×672 px, 190 KB)

Goals

  • We should review all skins, learn from them and simplify these styles
  • We should revisit the display: table format

Event Timeline

Might not be completely related but would it be possible to have an easy way for skin authors to get the content of the ToC and disable the default? In that way skin authors don't have to rely on CSS hacks or JS tricks to duplicate or move the ToC outside of the article.

@alistair3149: Feel free to file a separate Feature Request covering use cases, the situation, and explaining what "easy" means. Thanks!

@Aklapper it's okay I asked Alastair to take a look at some of the upcoming plans! This is a good place to discuss that. @alistair3149 yeh we have similiar requirements for the https://mediawiki.org/wiki/Desktop_improvements project. T270199 is probably the best place to discuss that and make your need known as there are some changes to the parser being planned, and one of the ones I'd like to see is exactly that.

The table of contents has never been a great fit for where it currently is. I think there's an argument to be made that it should be split out, but we need a solution for those who want to retain the existing solution..

As for disabling the default styles I think you do that already here:
https://github.com/StarCitizenTools/mediawiki-skins-Citizen/blob/main/skin.json#L100

All styles for table of contents should be there now. If they're some elsewhere you are having to override please open a new bug and I'll look into it.

@alistair3149: Feel free to file a separate Feature Request covering use cases, the situation, and explaining what "easy" means. Thanks!

@Aklapper it's okay I asked Alastair to take a look at some of the upcoming plans! This is a good place to discuss that. @alistair3149 yeh we have similiar requirements for the https://mediawiki.org/wiki/Desktop_improvements project. T270199 is probably the best place to discuss that and make your need known as there are some changes to the parser being planned, and one of the ones I'd like to see is exactly that.

Thanks for pointers, I thought that this ticket would be a better place since it is strictly about skins and the Parsoid refactor does not have to be a prerequisite for the ToC.

The table of contents has never been a great fit for where it currently is. I think there's an argument to be made that it should be split out...

As for disabling the default styles I think you do that already here:
https://github.com/StarCitizenTools/mediawiki-skins-Citizen/blob/main/skin.json#L100

All styles for table of contents should be there now. If they're some elsewhere you are having to override please open a new bug and I'll look into it.

Sorry for the confusion, I should have explained it more clearly. By disabling the default I meant as a skin author, I would like to be able to completely remove the ToC on a wiki page so that I can output the ToC in a different location in DOM. That also requires an easier method to retrieve the content of ToC through either PHP or Mustache (or maybe also JS). Being able to move the ToC is a highly requested feature by the whole community, and it can benefit many on-going endeavor such as:

  • Desktop Improvement Project : The ToC concept would require the ToC to be moved out of #mw-content-text
  • Minerva/MobileFrontEnd: ToC is only accessible at the top of the article, which makes navigating long articles a pain point as there are no 'to the top' button and collapsing each section takes multiple interactions.
  • Third-party skins: Skin authors want to be able to move the ToC but the current solution is very hacky. Citizen uses a lot of CSS hacks while Tweeki clone the whole DOM of #toc. Both solutions have a hefty penalty on the rendering path when it should be avoided.

Not to mention there are also gadgets, userscripts, and browser extensions (such as Wikiwand and TheNewWiki) that moves the ToC.

... but we need a solution for those who want to retain the existing solution.

Would it be possible to have the ToC assigned to a Mustache template (such as {{data-toc}})? Though I am unsure about how to retain the default since it is a part of the body content.

Would it be possible to have the ToC assigned to a Mustache template (such as {{data-toc}})? Though I am unsure about how to retain the default since it is a part of the body content.

Yep would love to see that. I think we first need the ParserOutput method being discussed in T270199
Moving conversation to > T287767