diff --git a/apps/server/src/ee b/apps/server/src/ee index ffe5c9fd0..1ecd90b9e 160000 --- a/apps/server/src/ee +++ b/apps/server/src/ee @@ -1 +1 @@ -Subproject commit ffe5c9fd0759719055033d56d847b5d6f45267e1 +Subproject commit 1ecd90b9e9b75e1a3dadf2d2e441889ece59ff23 diff --git a/apps/server/src/integrations/import/utils/confluence-highlight-color.spec.ts b/apps/server/src/integrations/import/utils/confluence-highlight-color.spec.ts new file mode 100644 index 000000000..75d840fd1 --- /dev/null +++ b/apps/server/src/integrations/import/utils/confluence-highlight-color.spec.ts @@ -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', + }); + }); +}); diff --git a/apps/server/src/integrations/import/utils/confluence-highlight-color.ts b/apps/server/src/integrations/import/utils/confluence-highlight-color.ts new file mode 100644 index 000000000..8b2807c96 --- /dev/null +++ b/apps/server/src/integrations/import/utils/confluence-highlight-color.ts @@ -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, + } + ); +}