From 525c95f3a800f854b37d7d1ff5a0d9447916c8c1 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Wed, 26 Aug 2026 14:03:55 +0000 Subject: [PATCH] feat: add Numbering 1.a.i, the default cycle as a preset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gallery avoids presets the dropdown plus default nesting already covers, but the default cycle itself earns its slot: once a list wears another style, switching back needs a style to switch to. No sheet version bump — an added built-in survives the merge on its own. --- src/lib/styles/CLAUDE.md | 7 ++++--- src/lib/styles/listStyles.ts | 8 +++++--- tests/unit/list-style.test.ts | 8 ++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib/styles/CLAUDE.md b/src/lib/styles/CLAUDE.md index 99313a6..1954c5d 100644 --- a/src/lib/styles/CLAUDE.md +++ b/src/lib/styles/CLAUDE.md @@ -17,11 +17,12 @@ plain lists) and both exporters share. **The style level decides the depth's kin ODF the list style alone says what a depth renders, the editor's node species doesn't travel. `setListStyle` retypes the subtree to the levels' kinds; a Tab-nested list of the other species still renders (and exports) what the level says, and both importers -build the species from the level, so a round trip normalizes it. The five built-ins are a **preset gallery of +build the species from the level, so a round trip normalizes it. The six built-ins are a **preset gallery of patterns the depth cycle can't produce** — the outline chains Outline I.A.1 / A.I.1, the kind-mixing Numbering with Bullets and Checklist, and the Diamond Bullets ladder — all on -the plain 1.27cm step (no indentCm), so a preset that only restates a dropdown format plus -the default nesting has no place in it. +the plain 1.27cm step (no indentCm). The one deliberate exception is Numbering 1.a.i, the +default cycle captured as a style so a style switch can lead back to it; any further +preset that only restates a dropdown format plus the default nesting has no place here. Export writes the full named `` into styles.xml and points the list at it **only when nothing overrides** — ODF list styles have no parent chain, so an overridden list keeps the fully resolved automatic clone and drops the name (marker formats count as diff --git a/src/lib/styles/listStyles.ts b/src/lib/styles/listStyles.ts index 639e747..c34fa89 100644 --- a/src/lib/styles/listStyles.ts +++ b/src/lib/styles/listStyles.ts @@ -124,9 +124,9 @@ const ladder = (head: ListLevelStyle[], tail: ListLevelStyle[]): ListLevelStyle[ Array.from({ length: MAX_LIST_LEVELS }, (_, i) => structuredClone(i < head.length ? head[i] : tail[(i - head.length) % tail.length])); -// The gallery: presets the depth cycle can't produce on its own — uppercase outline -// chains, levels mixing numbers with bullets, a decorative bullet ladder. All keep the -// plain 1.27cm step per level (no indentCm), the geometry an unstyled list gets. +// The gallery: outline chains, kind mixes and a bullet ladder the depth cycle can't +// produce — plus that cycle itself as Numbering 1.a.i, the way back after a switch. +// All keep the plain 1.27cm step per level (no indentCm), like an unstyled list. const LIST_BUILTINS: ListStyle[] = [ { name: 'Outline I.A.1', builtin: true, levels: ladder([num('upper-roman', 'right'), num('upper-alpha')], @@ -134,6 +134,8 @@ const LIST_BUILTINS: ListStyle[] = [ { name: 'Outline A.I.1', builtin: true, levels: ladder([num('upper-alpha'), num('upper-roman', 'right')], [num('decimal'), num('lower-alpha-paren'), num('lower-roman-paren')]) }, + { name: 'Numbering 1.a.i', builtin: true, + levels: ladder([], [num('decimal'), num('lower-alpha'), num('lower-roman')]) }, { name: 'Numbering with Bullets', builtin: true, levels: ladder([num('decimal')], [bul('–'), bul('◦'), bul('▪')]) }, { name: 'Diamond Bullets', builtin: true, diff --git a/tests/unit/list-style.test.ts b/tests/unit/list-style.test.ts index 75175d4..9634604 100644 --- a/tests/unit/list-style.test.ts +++ b/tests/unit/list-style.test.ts @@ -87,9 +87,9 @@ describe('listStyleOverridden', () => { describe('the built-ins (the preset gallery)', () => { const builtins = builtinListStyles(); - it('ship five presets, ten levels each, none uniform across its levels', () => { + it('ship six presets, ten levels each, none uniform across its levels', () => { expect(Object.keys(builtins).sort()).toEqual( - ['Checklist', 'Diamond Bullets', 'Numbering with Bullets', 'Outline A.I.1', 'Outline I.A.1']); + ['Checklist', 'Diamond Bullets', 'Numbering 1.a.i', 'Numbering with Bullets', 'Outline A.I.1', 'Outline I.A.1']); for (const s of Object.values(builtins)) { expect(s.levels).toHaveLength(MAX_LIST_LEVELS); const markers = new Set(s.levels.map((l) => `${l.kind}:${l.bulletChar ?? l.numType}`)); @@ -105,6 +105,10 @@ describe('the built-ins (the preset gallery)', () => { ['upper-roman', 'upper-alpha', 'decimal', 'lower-alpha-paren', 'lower-roman-paren']); expect(builtins['Outline I.A.1'].levels[0].markerAlign).toBe('right'); }); + it('Numbering 1.a.i captures the default cycle, so a style switch can lead back', () => { + expect(builtins['Numbering 1.a.i'].levels.slice(0, 4).map((l) => l.numType)).toEqual( + ['decimal', 'lower-alpha', 'lower-roman', 'decimal']); + }); it('Numbering with Bullets numbers level 1 and dashes the levels below', () => { expect(builtins['Numbering with Bullets'].levels[0]).toMatchObject({ kind: 'number', numType: 'decimal' }); expect(builtins['Numbering with Bullets'].levels[1]).toMatchObject({ kind: 'bullet', bulletChar: '–' });