Front end XWiki APIs

Last modified by Lucas Charpentier on 2025/06/02 12:02

 XWiki
 Design
 Idea
 
No

Description

This page is a brainstorming document to define criteria of what should be an API or not. What is written should be understood as proposal only, and not something voted or even discussed.

Goal

Define for all non java resources:

  • How do we mark an element public or internal?
  • How do we deprecate them?
  • How we do introduce a new element?
  • How do we keep backward compatibility?
  • What elements are public or internal

All non java resources:

  • vms
  • javascript API
  • velocity macros
  • CSS / LESS elements

Front end components

On Front End resources, we already have a list of components. The featuresaddaddadd, style add and architecture addadd of these components would be part of the API as they are meant to be exposed publicly, reused and augmented.

There's velocity macros bundled in the default flavor, some of them match the resources above.

DOM API

Any style attribute should never be considered as API: it's been a long time that we indicate in our documentation to not use inline style, so scripts should never rely on it, and it should always be ok to remove them in old code. Example of such change: https://github.com/xwiki/xwiki-platform/pull/2812/files/95f349912c19b66f00b684153dcf8be6ec526db1#r1504545037

The changes on this basic layout should be documented and backward compatible (CSS or DOM or both ?): https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/Skins/CSSLayout/

Warning

The DOM of the different Admin sections are not considered part of the API : admins shouldn't have to extend them. Extensions should only provide their admin UI through dedicated extension points and templates.

Discussed on https://forum.xwiki.org/t/front-end-api-html-ids/16947/4 :

Seems like using the `xwiki-` prefix on class and id names would make it clear classes and ids we consider as APIs (and also mean that all the others are not API and subject to changes emoticon_smile)) )

Here is the search I went with to find all of those classes and ids. It should be a bit too wide, finding a few things that are not of interest to us, but not miss any of the items we're looking for:
https://github.com/search?q=repo%3Axwiki%2Fxwiki-platform+%28language%3ACSS+OR+language%3ALess+OR+language%3Avelocity%29+%2F%5B%5C.%23%22%27%5Dxwiki-%2F&type=code 

Good news, in XS, there's almost only classes starting with `xwiki-` and no useful IDs starting with `xwiki-`.

NameSemanticsSource filenameKeep in API?
.xwiki-whatsnew-containerMain node of the whatsnew template.whatsnew.vmYes
.xwiki-whatsnew-itemContainer for one piece of news displayed in the whatsnew template.whatsnew.vmNo?
.xwiki-whatsnew-item-titleTitle of one piece of news displayed in the whatsnew template.whatsnew.vmNo
.xwiki-whatsnew-item-datePublish date of one piece of news displayed in the whatsnew template.whatsnew.vmNo
.xwiki-whatsnew-item-descriptionContent of one piece of news displayed in the whatsnew template.whatsnew.vmNo
.xwiki-livedataContainer for a livedatalivedata webjar variables.less, general.lessYes
.xwiki-flavor-select-smallStyle only class for the flavorPickerweb template flavor macros.vm, picker.cssNo?
.xwiki-flavor-select-mediumStyle only class for the flavorPickerweb template flavor macros.vm, picker.cssNo?
.xwiki-flavor-select-tallStyle only class for the flavorPickerweb template flavor macros.vm, picker.cssNo?
.xwiki-flavor-pickerMain container of the flavorPicker velocimacroweb template flavor macros.vm, picker.cssYes
.xwiki-flavor-picker-filterText input to filter entries displayed in the rich input of the flavorPicker velocimacroweb template flavor macros.vm, picker.cssNo?
#xwiki-flavor-picker-progress-backgroundTODO, part of the flavorPicker velocimacroweb template flavor macros.vmNo?
#xwiki-flavor-picker-progress-barTODO, part of the flavorPicker velocimacroweb template flavor macros.vmNo?
.xwiki-flavor-picker-results-containerContainer of the richselect used in the flavorPicker velocimacro. Style only class because repeated semantics with child?web template flavor macros.vm, picker.cssNo?
.xwiki-flavor-picker-noflavorButton to not pick any flavor in the flavorPicker velocimacroweb template flavor macros.vmNo?
.xwiki-flavor-picker-resultsContainer of the richselect used in the flavorPicker velocimacro.web template flavor macros.vmNo?
.xwiki-flavor-picker-optionDisplay of one flavor in the flavorPicker velocimacro.web template flavor macros.vm, picker.cssNo?
.xwiki-flavor-picker-option-selectedDisplay of one flavor in a specific state in the flavorPicker velocimacro.web template flavor macros.vm, picker.cssNo?
.xwiki-flavor-picker-option-iconIcon of one flavor in the flavorPicker velocimacro.web template flavor macros.vm, picker.cssNo
.xwiki-livetableContainer of the table for the livetable. Does not include tagclouds and topfilters but does include pagination elements.livetable.css, rightsUI.vm, flamingo misc.less, flamingo skin macros.vm, web templates macros.vmNo?
.xwiki-livetable-loaderElement displayed while waiting for a livetable content to be retrieved.livetable.css, rightsUI.vm, flamingo skin macros.vm, web templates macros.vmNo
.xwiki-livetable-paginationContainer for the livetable pagination controls.livetable.css, rightsUI.vm, flamingo skin macros.vm, web templates macros.vmNo?
.xwiki-livetable-pagination-contentChild of livedata-pagination. Probably layout only class.livetable.css, rightsUI.vm, flamingo skin macros.vm, web templates macros.vmNo
.xwiki-livetable-pagination-textChild of livedata-pagination. Probably layout only class. Quite an unspecific name...livetable.css, rightsUI.vm, flamingo skin macros.vmNo
.xwiki-livetable-limitsStatus of elements displayed currently in the livetable, next to pagination.livetable.css, rightsUI.vm, flamingo skin macros.vmNo?
.xwiki-livetable-pagesizeLabel and input to select the page size for a livetable, next to pagination.livetable.css, flamingo skin macros.vmNo?
.xwiki-livetable-pagesize-contentInput to select the page size for a livetable, next to pagination.flamingo skin macros.vmNo?
.xwiki-livetable-display-containerMain container for the livetable actual content.livetable.css, rightsUI.vm, flamingo skin macros.vmYes?
.xwiki-livetable-displayNot sure? Could not find it quick. Might be layout only class and probably duplicated semantics with container...livetable.css, rightsUI.vm, livetable.less, flamingo skin macros.vmNo?
.xwiki-livetable-display-headerthead of the live table.livetable.css, rightsUI.vm, livetable.less, flamingo skin macros.vmYes?
.xwiki-livetable-display-header-textLayout only class... elements in the first row of the theadlivetable.css, livetable.less, flamingo skin macros.vmYes?
.xwiki-livetable-display-header-filterOne filter in the second row of the thead.livetable.css, xwiki.selectize.css, livetable.lessNo?
.xwiki-livetable-display-filterssecond row of the thead, containing filters.livetable.css, livetable.lessYes?
.xwiki-livetable-filter-activeSpecific state on a livetable filter.livetable.cssNo
.xwiki-livetable-display-bodytbody of the livetable.livetable.css, rightsUI.vm, livetable.less, flamingo skin macros.vmNo?
.xwiki-livetable-topfilters-containerContainer for the optional HTML provided in the topFilters optionlivetable.css, flamingo skin macros.vmNo?
.xwiki-livetable-tagcloud-containerContainer for the optional tagcloud. Note that this contains a legacy icon still hardcoded...livetable.css, flamingo skin macros.vmNo
.xwiki-livetable-tagcloudMostly used for layout/JS, no specific meaning added upon what's already meant by the containerlivetable.css, flamingo skin macros.vmNo
.xwiki-livetable-topfilters-tipTechnical class added above the container, not sure what tip it's needed for though...  Definitely internallivetable.css, flamingo skin macros.vmNo
.xwiki-livetable-tagcloud-tipTechnical class added above the container, not sure what tip it's needed for though... Definitely internallivetable.css, flamingo skin macros.vmNo
.xwiki-livetable-containerContainer for live tables,livetable.css, admin.less, general.less, flamingo skin macros.vm, web templates macros.vmNo?
.xwiki-livetable-initial-messageContainer for a live table warning in the table head.flamingo skin macros.vm, web templates macros.vmNo?
.xwiki-livetable-multilistContainer a specific kind of filter select node.flamingo skin macros.vm, web templates macros.vmNo?
.xwiki-selectize-optionOne entry int he selectize dropdown.xwiki.selectize.cssNo?
.xwiki-selectize-option-icon-wrapperLayout only, duplicated semantics with selectize-option-iconxwiki.selectize.cssNo
.xwiki-selectize-option-iconIcon used to represent one optionxwiki.selectize.cssNo?
.xwiki-selectize-option-labelAnchor used for the name of the optionxwiki.selectize.cssNo?
.xwiki-selectize-option-hintHint of the option? When selecting a page, this is the path to navigate to this pagexwiki.selectize.cssNo?
.xwiki-selectMain node of the xwikiSelect componentweb templates macros.vm, select.cssYes
.xwiki-select-optionsContainer for all options in the rich select input component xwikiSelectweb templates macros.vm, select.cssYes?
.xwiki-select-smallStyling only class, no semanticsselect.cssNo
.xwiki-select-mediumStyling only class, no semanticsselect.cssNo
.xwiki-select-tallStyling only class, no semanticsselect.cssNo (would need a rename to use `large` instead of `tall`)
.xwiki-select-adaptable-mediumStyling only class, no semanticsselect.css, createinline.vmNo
.xwiki-select-optionOption in the rich select input component xwikiSelectweb templates macros.vm, select.cssYes?
.xwiki-export-3-columnsStyling only class, no semanticsexport_modal.vm, select.cssNo
.xwiki-select-option-iconIcon of the option in the rich select input component xwikiSelectweb templates macros.vm, select.cssNo?
.xwiki-metadata-containerTechnical class for inline editable properties in inline edit mode.messages.lessNo
.xwiki-select-option-highlightedStatus for option in xwikiSelectflamingo misc.lessNo
.xwiki-select-option-selectedStatus for option in xwikiSelectflamingo misc.lessNo
.xwiki-form-listclassClass used on the label of a form listclass field? Could not find doc, name is not clear to me (because too generic)forms.less,delete.vmNo
.xwiki-export-formatsThis is a class but could is only used to identify one element in the content of the export modal. export_modal.vmNo?
.xwiki-select-3-columnsStyle only class. Could probably be factorized with xwiki-export-3-columns...  export_modal.vmNo
.xwiki-select-filterText input to filter entries displayed in the rich input of xwikiSelectweb templates macros.vmYes?
.xwiki-select-categoryGroup of options in the rich select input component xwikiSelectweb templates macros.vmYes?
.xwiki-select-category-countCount display for the group of options in the rich select input component xwikiSelectweb templates macros.vmNo

I (CharpentierLucas) used four types of annotations when commenting my idea of whether we should keep those in the API:

  • Yes: Keep it in the API, the class is common and nicely named, I expect it to be used in a lot of customizations. The class has a clear meaning for an existing concept.
  • Yes? : Can keep it in the API, not strongly against removing it. The class is clear, but usually it's not really useful for much, selectors can already rely on another class.
  • No? Should probably remove from the API (renaming the class), but not strongly opposed to keeping it. The class is never useful for customization IMO, poorly worded or very specific with easy selectors on the parent. Often those classes are used in XS only for a couple styles.
  • No: Should remove from the API, keeping good support and backward compatibility for those will have a relatively high timecost for relatively low usefulness. The class is either very poorly worded, its scope is very very specific and it's purely cosmetic. In order to apply styles, XS developers should instead use 1. a standard styling class. 2. a non API custom class.

IMO it'd make sense we only support classes as API for now, most of XS interface element IDs do not have any naming rules.

Error

TODO

* For all of those, decide whether we rename them to make sure they are not interpreted as API OR we keep them and we'll support them as API
  • Find a solution for those that are generated depending on context or use (with a large or infinite number of possible values). As I see things now, we should probably never support them as API, but support a common ID/class instead if needed.

What should we support?

For every single class starting with xwiki- in XS, we ensure that we keep backward compatibility on:

  • the node architecture under it (node nature + how they are nested/ordered)
  • the styles associated to this class
  • the styles associated to the expected children of this class

I don't think it's a good idea to engage ourselves to respect backward compatibility on:

  • the content of this element and its children
  • the attributes of this element and its children

The first one is very often contained in a translation, which AFAIK are not API (i.e. we can edit them without making an announcement and waiting for feedback). The second one should be something only XS relies on IMO. Customizations don't need it much, and it's very difficult to make any change to the UI if we block ourselves on this. Customizations shouldn't need to rely on those, either they have enough with the class and node structure, or they use their own component. E.g. if I want to style livetable, I can make CSS selectors with the API classes and the way their children are arranged. If I want to have a custom script run when a livetable filter is selected, what I'm doing is an extension of the livetable behaviour, and the XS devs can't assure full backward compatibility for this one (if for one reason or another, we need to remove the `selected` attribute, it won't go through the API breakage process).

CSS API

Elements to include in the API:

1. Bootstrap 3 classes: used everywhere, for a long time. When moving to a new design system, we want to consider how to keep support for those classes. E.g. `.btn`, `.btn-default`, ...

2. Special CSS classes defined in https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/SpecialCSSClasses/

Information

Get a list of all classes used in the XWiki interface with their meaning, possibly the docs it's used in and a screenshot?

Javascript API

Already pretty well defined in https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/JavaScriptAPI/

Resources

Previous research about defining a CSS API: https://design.xwiki.org/xwiki/bin/view/Standards/CSSAPI


 

Get Connected