Highlight a single table cell?

What is the recommended way to handle highlighting of single cells within a table?

Under the Styles menu, I see the option to highlight a table row as Danger, Warning, etc., but I don’t see a way to use the Styles menu to highlight a single cell. I also see the Background Color option under the Cell Properties, but that’s a little tedious since you have to type in a RGB color code and which makes it hard to enforce a consistent color across all tables in the wiki. There didn’t appear to be a good extension that added a cell color picker or similar to the UI either.

In order to have consistent styling we have recently developed Image Style Application (XWiki.org) but that’s for image and not for tables unfortunately :wink:

For tables, if you’re using the WYSIWYG editor I don’t think there’s more than what you’ve found.

If you’re willing to use the wiki editor, then you could pass some class attribute.

For example:

|a|a1 
|b|(% class="cell-highlight" %)b1
|c|c1 

See XWiki Syntaxes (XWiki.org)

Then you’ll need to define the CSS for cell-highlight, either in the Skin or (better IMO), in a SSX.

Another idea would to be write a wiki macro (e.g. cellHighlight) and ask users to use it to wrap the content of a cell when using the WYSIWYG editor. That macro would just wrap the content with:

(% class="cell-highlight" %)(((
...content here...
)))
1 Like

Thank you for these suggestions, @vmassol. The recommendation to use a SSX to define color classes seems like it will be particularly useful.

However, using the wiki editor is not the most convenient solution to this issue. My wiki contains many comparison tables highlighted similarly to ones that you’ll often find on Wikipedia. (For example, see the style of the tables in: Comparison of wiki software - Wikipedia) In my old Confluence instance, it was possible to highlight a group of cells using ctrl-click and click a Confluence toolbar button to quickly highlight the selected cells in the desired color. However, using the wiki editor in XWiki would require copy/pasting the style info which would be a little tedious and probably not go over too well with my users.

I can look into writing a macro though since macros appear to be compatible with the multi-selection feature for table cells. I assume that macros can then be used to create new entries in the Styles menu in the WYSIWYG editor? (e.g., Could the macros be used to create new entries in the Styles menu such as: Info Cell, Danger Cell, etc?)