fix highlight color

This commit is contained in:
Philipinho
2026-08-03 02:13:45 +01:00
parent b9d8612ecd
commit 231f0deeb0
3 changed files with 66 additions and 1 deletions
@@ -0,0 +1,41 @@
import { mapConfluenceHighlightColor } from './confluence-highlight-color';
describe('mapConfluenceHighlightColor', () => {
it('maps named DC colours to the Docmost table palette', () => {
expect(mapConfluenceHighlightColor('grey')).toEqual({
color: '#eaecef',
name: 'gray',
});
expect(mapConfluenceHighlightColor('red')).toEqual({
color: '#ffbead',
name: 'red',
});
expect(mapConfluenceHighlightColor('yellow')).toEqual({
color: '#fef1b4',
name: 'yellow',
});
});
it('is case- and whitespace-insensitive', () => {
expect(mapConfluenceHighlightColor(' Grey ')).toEqual({
color: '#eaecef',
name: 'gray',
});
});
it('maps teal to the closest Docmost colour', () => {
expect(mapConfluenceHighlightColor('teal')).toEqual({
color: '#b4d5ff',
name: 'blue',
});
});
it('passes hex values through untouched', () => {
expect(mapConfluenceHighlightColor('#f4f5f7')).toEqual({
color: '#f4f5f7',
});
expect(mapConfluenceHighlightColor('#4c9aff')).toEqual({
color: '#4c9aff',
});
});
});
@@ -0,0 +1,24 @@
const CONFLUENCE_HIGHLIGHT_TO_DOCMOST: Record<
string,
{ color: string; name: string }
> = {
grey: { color: '#eaecef', name: 'gray' },
gray: { color: '#eaecef', name: 'gray' },
blue: { color: '#b4d5ff', name: 'blue' },
teal: { color: '#b4d5ff', name: 'blue' },
green: { color: '#acf5d2', name: 'green' },
yellow: { color: '#fef1b4', name: 'yellow' },
red: { color: '#ffbead', name: 'red' },
purple: { color: '#c1b7f2', name: 'purple' },
};
export function mapConfluenceHighlightColor(colour: string): {
color: string;
name?: string;
} {
return (
CONFLUENCE_HIGHLIGHT_TO_DOCMOST[colour.trim().toLowerCase()] ?? {
color: colour,
}
);
}