Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { fontOfferingRenderStack, fontOfferingStack, getBuiltInToolbarFontOfferings } from '@superdoc/font-system';

/**
* Built-in toolbar font dropdown options, DERIVED from the shared font-offering registry
* (`@superdoc/font-system`) instead of a hand-maintained list. Bundled clean defaults and explicit
* qualified/category fallback choices are advertised; unbundled candidates are intentionally absent
* from the static defaults.
* Built-in toolbar font dropdown options, derived from the shared font-offering registry
* (`@superdoc/font-system`) instead of a hand-maintained list. The registry owns the conservative
* no-package toolbar baseline.
*
* Per `FontConfig`: `label` is the Word-facing logical name (stored on the selection + active-state
* match), `key` is the logical CSS stack, and the row preview renders in the physical clone that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,35 @@ import { describe, expect, it } from 'vitest';
import { composeToolbarFontOptions, TOOLBAR_FONTS } from './constants';

describe('TOOLBAR_FONTS (built-in font dropdown, derived from the font-offering registry)', () => {
it('advertises bundled defaults and selected bundled fallback choices, in alphabetical order', () => {
expect(TOOLBAR_FONTS.map((f) => f.label)).toEqual([
'Arial',
'Arial Black',
'Arial Narrow',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
]);
it('advertises the conservative no-package baseline, in alphabetical order', () => {
expect(TOOLBAR_FONTS.map((f) => f.label)).toEqual(['Arial', 'Courier New', 'Georgia', 'Times New Roman']);
});

it('does not leak non-advertised fonts into the default dropdown', () => {
const labels = new Set(TOOLBAR_FONTS.map((f) => f.label));
for (const name of ['Aptos', 'Cambria', 'Calibri Light', 'Century Schoolbook', 'Arial MT', 'Courier', 'Times']) {
for (const name of [
'Aptos',
'Calibri',
'Cambria',
'Calibri Light',
'Century Schoolbook',
'Helvetica',
'Arial MT',
'Courier',
'Times',
]) {
expect(labels.has(name)).toBe(false);
}
});

it('builds a FontConfig: logical label + logical key + physical-clone preview', () => {
const calibri = TOOLBAR_FONTS.find((f) => f.label === 'Calibri');
expect(calibri).toMatchObject({
label: 'Calibri', // applied to the selection + active-state match (Word-facing name)
key: 'Calibri, sans-serif', // logical CSS stack (option identity)
const arial = TOOLBAR_FONTS.find((f) => f.label === 'Arial');
expect(arial).toMatchObject({
label: 'Arial', // applied to the selection + active-state match (Word-facing name)
key: 'Arial, sans-serif', // logical CSS stack (option identity)
fontWeight: 400,
props: {
style: { fontFamily: 'Carlito, sans-serif' }, // preview renders in the bundled clone that paints
style: { fontFamily: 'Liberation Sans, sans-serif' }, // preview renders in the bundled clone that paints
'data-item': 'btn-fontFamily-option',
},
});
Expand Down Expand Up @@ -81,28 +68,11 @@ describe('composeToolbarFontOptions (document fonts unioned with the bundled def
'Apple Chancery',
'Aptos',
'Arial',
'Arial Black',
'Arial Narrow',
'Bangla MN',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
]);
expect(options.filter((o) => o.label === 'Calibri')).toHaveLength(1);
});
Expand Down
22 changes: 3 additions & 19 deletions packages/super-editor/src/headless-toolbar/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,22 @@ import { describe, expect, it } from 'vitest';
import { DEFAULT_FONT_FAMILY_OPTIONS } from './constants';

describe('DEFAULT_FONT_FAMILY_OPTIONS (headless default font options, derived from the font-offering registry)', () => {
it('advertises bundled defaults and selected bundled fallback choices (logical name + logical stack)', () => {
it('advertises the conservative no-package baseline (logical name + logical stack)', () => {
expect(DEFAULT_FONT_FAMILY_OPTIONS).toEqual([
{ label: 'Arial', value: 'Arial, sans-serif' },
{ label: 'Arial Black', value: 'Arial Black, sans-serif' },
{ label: 'Arial Narrow', value: 'Arial Narrow, sans-serif' },
{ label: 'Baskerville Old Face', value: 'Baskerville Old Face, serif' },
{ label: 'Bookman Old Style', value: 'Bookman Old Style, serif' },
{ label: 'Brush Script MT', value: 'Brush Script MT, serif' },
{ label: 'Calibri', value: 'Calibri, sans-serif' },
{ label: 'Century', value: 'Century, serif' },
{ label: 'Century Gothic', value: 'Century Gothic, sans-serif' },
{ label: 'Comic Sans MS', value: 'Comic Sans MS, sans-serif' },
{ label: 'Cooper Black', value: 'Cooper Black, serif' },
{ label: 'Courier New', value: 'Courier New, monospace' },
{ label: 'Garamond', value: 'Garamond, serif' },
{ label: 'Georgia', value: 'Georgia, serif' },
{ label: 'Gill Sans MT Condensed', value: 'Gill Sans MT Condensed, sans-serif' },
{ label: 'Helvetica', value: 'Helvetica, sans-serif' },
{ label: 'Lucida Console', value: 'Lucida Console, monospace' },
{ label: 'Segoe UI', value: 'Segoe UI, sans-serif' },
{ label: 'Tahoma', value: 'Tahoma, sans-serif' },
{ label: 'Times New Roman', value: 'Times New Roman, serif' },
{ label: 'Trebuchet MS', value: 'Trebuchet MS, sans-serif' },
{ label: 'Verdana', value: 'Verdana, sans-serif' },
]);
});

it('drops non-advertised fonts from defaults', () => {
const labels = new Set(DEFAULT_FONT_FAMILY_OPTIONS.map((o) => o.label));
expect(labels.has('Aptos')).toBe(false);
expect(labels.has('Calibri')).toBe(false);
expect(labels.has('Cambria')).toBe(false);
expect(labels.has('Calibri Light')).toBe(false);
expect(labels.has('Helvetica')).toBe(false);
expect(labels.has('Century Schoolbook')).toBe(false);
expect(labels.has('Arial MT')).toBe(false);
expect(labels.has('Courier')).toBe(false);
Expand Down
9 changes: 4 additions & 5 deletions packages/super-editor/src/headless-toolbar/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ export const DEFAULT_FONT_SIZE_OPTIONS = [
] as const;

/**
* Default headless-toolbar font options, DERIVED from the shared font-offering registry
* (`@superdoc/font-system`) instead of a hand-maintained list. Bundled clean defaults and explicit
* qualified choices are advertised; customer-supplied and category fallback rows stay absent.
* `label` is the Word-facing logical name (stored/exported); `value` is the logical CSS stack applied
* to the run.
* Default headless-toolbar font options, derived from the shared font-offering registry
* (`@superdoc/font-system`) instead of a hand-maintained list. The registry owns the conservative
* no-package toolbar baseline. `label` is the Word-facing logical name (stored/exported);
* `value` is the logical CSS stack applied to the run.
*/
export const DEFAULT_FONT_FAMILY_OPTIONS = getDefaultFontFamilyOptions();

Expand Down
68 changes: 2 additions & 66 deletions packages/super-editor/src/ui/create-super-doc-ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,11 @@ describe('createSuperDocUI', () => {
expect(options.map((option) => option.label)).toEqual([
'Aptos',
'Arial',
'Arial Black',
'Arial Narrow',
'Bangla MN',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
]);
expect(options.find((option) => option.label === 'Aptos')).toEqual({
label: 'Aptos',
Expand Down Expand Up @@ -214,55 +197,8 @@ describe('createSuperDocUI', () => {
superdoc.fireSuperdoc('fonts-changed');
await flushMicrotasks();

expect(observed.at(0)).toEqual([
'Arial',
'Arial Black',
'Arial Narrow',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
]);
expect(observed.at(-1)).toEqual([
'Aptos',
'Arial',
'Arial Black',
'Arial Narrow',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
]);
expect(observed.at(0)).toEqual(['Arial', 'Courier New', 'Georgia', 'Times New Roman']);
expect(observed.at(-1)).toEqual(['Aptos', 'Arial', 'Courier New', 'Georgia', 'Times New Roman']);
});

it('refreshes ui.fonts for delimiter-colliding font names', async () => {
Expand Down
18 changes: 0 additions & 18 deletions packages/super-editor/src/ui/react/hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,27 +186,9 @@ describe('domain hooks', () => {
expect(options?.map((option) => option.label)).toEqual([
'Aptos',
'Arial',
'Arial Black',
'Arial Narrow',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
]);
expect(options?.find((option) => option.label === 'Aptos')).toEqual({
label: 'Aptos',
Expand Down
17 changes: 0 additions & 17 deletions shared/font-system/src/document-font-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,11 @@ describe('buildFontFamilyOptions (custom UI font picker rows)', () => {
'Apple Chancery',
'Aptos',
'Arial',
'Arial Black',
'Arial Narrow',
'Bangla MN',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
]);
expect(options.filter((option) => option.label === 'Calibri')).toHaveLength(1);
expect(options.every((option) => !('status' in option))).toBe(true);
Expand Down
51 changes: 6 additions & 45 deletions shared/font-system/src/font-offerings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,7 @@ import {
import { SUBSTITUTION_EVIDENCE } from './substitution-evidence';

const EXPECTED_DEFAULTS = ['Arial', 'Calibri', 'Courier New', 'Helvetica', 'Times New Roman'];
const EXPECTED_BUILT_IN_TOOLBAR = [
'Arial',
'Arial Black',
'Arial Narrow',
'Baskerville Old Face',
'Bookman Old Style',
'Brush Script MT',
'Calibri',
'Century',
'Century Gothic',
'Comic Sans MS',
'Cooper Black',
'Courier New',
'Garamond',
'Georgia',
'Gill Sans MT Condensed',
'Helvetica',
'Lucida Console',
'Segoe UI',
'Tahoma',
'Times New Roman',
'Trebuchet MS',
'Verdana',
];
const EXPECTED_BUILT_IN_TOOLBAR = ['Arial', 'Courier New', 'Georgia', 'Times New Roman'];

/**
* Must NOT appear as DEFAULT options yet. Aptos has no clone, Cambria/Georgia/Cooper Black/
Expand Down Expand Up @@ -85,13 +62,15 @@ describe('font offerings', () => {
}
});

it('built-in toolbar offerings include advertised bundled rows without reclassifying them as defaults', () => {
it('built-in toolbar offerings use the conservative no-package baseline', () => {
expect(getBuiltInToolbarFontOfferings().map((o) => o.logicalFamily)).toEqual(EXPECTED_BUILT_IN_TOOLBAR);
expect(getBuiltInToolbarFontOfferings().find((o) => o.logicalFamily === 'Cooper Black')).toMatchObject({
expect(getBuiltInToolbarFontOfferings().find((o) => o.logicalFamily === 'Georgia')).toMatchObject({
offering: 'qualified',
verdict: 'visual_only',
verdict: 'near_metric',
bundled: true,
});
expect(getBuiltInToolbarFontOfferings().some((o) => o.logicalFamily === 'Calibri')).toBe(false);
expect(getBuiltInToolbarFontOfferings().some((o) => o.logicalFamily === 'Helvetica')).toBe(false);
});

it('classifies the qualified and category rows distinctly (carried for the later fidelity layer)', () => {
Expand Down Expand Up @@ -214,27 +193,9 @@ describe('font offerings', () => {
it('getDefaultFontFamilyOptions returns logical label + logical stack', () => {
expect(getDefaultFontFamilyOptions()).toEqual([
{ label: 'Arial', value: 'Arial, sans-serif' },
{ label: 'Arial Black', value: 'Arial Black, sans-serif' },
{ label: 'Arial Narrow', value: 'Arial Narrow, sans-serif' },
{ label: 'Baskerville Old Face', value: 'Baskerville Old Face, serif' },
{ label: 'Bookman Old Style', value: 'Bookman Old Style, serif' },
{ label: 'Brush Script MT', value: 'Brush Script MT, serif' },
{ label: 'Calibri', value: 'Calibri, sans-serif' },
{ label: 'Century', value: 'Century, serif' },
{ label: 'Century Gothic', value: 'Century Gothic, sans-serif' },
{ label: 'Comic Sans MS', value: 'Comic Sans MS, sans-serif' },
{ label: 'Cooper Black', value: 'Cooper Black, serif' },
{ label: 'Courier New', value: 'Courier New, monospace' },
{ label: 'Garamond', value: 'Garamond, serif' },
{ label: 'Georgia', value: 'Georgia, serif' },
{ label: 'Gill Sans MT Condensed', value: 'Gill Sans MT Condensed, sans-serif' },
{ label: 'Helvetica', value: 'Helvetica, sans-serif' },
{ label: 'Lucida Console', value: 'Lucida Console, monospace' },
{ label: 'Segoe UI', value: 'Segoe UI, sans-serif' },
{ label: 'Tahoma', value: 'Tahoma, sans-serif' },
{ label: 'Times New Roman', value: 'Times New Roman, serif' },
{ label: 'Trebuchet MS', value: 'Trebuchet MS, sans-serif' },
{ label: 'Verdana', value: 'Verdana, sans-serif' },
]);
});

Expand Down
Loading
Loading