fix(notes): number list items in order from the format toolbar

The numbered list button always inserted '1. ' and only on the caret's line, so writing a list item by item left 1. 1. 1. in the field. It now continues from the item above and formats every line of a multi-line selection (bullets and quotes too).
This commit is contained in:
Maurice
2026-11-23 12:05:03 +01:00
parent 493571c559
commit 3ec7cc73b2
4 changed files with 161 additions and 11 deletions
@@ -74,6 +74,32 @@ describe('NoteFormatToolbar', () => {
expect(field().value).toBe('already a list')
})
it('FE-NOTEBAR-010: pressing the numbered list button on each new line counts up instead of repeating 1.', async () => {
const user = userEvent.setup()
render(<Harness />)
const numbered = screen.getByRole('button', { name: /numbered list/i })
select(0, 0)
for (const [i, item] of ['Breakfast', 'Lunch', 'Dinner'].entries()) {
if (i > 0) await user.keyboard('{Enter}')
await user.click(numbered)
await waitFor(() => expect(field().selectionStart).toBe(field().value.length))
await user.keyboard(item)
}
expect(field().value).toBe('1. Breakfast\n2. Lunch\n3. Dinner')
})
it('FE-NOTEBAR-011: a multi-line selection gets a marker on every line', async () => {
const user = userEvent.setup()
render(<Harness initial={'Breakfast\nLunch\nDinner'} />)
select(0, 22)
await user.click(screen.getByRole('button', { name: /numbered list/i }))
expect(field().value).toBe('1. Breakfast\n2. Lunch\n3. Dinner')
})
it('FE-NOTEBAR-005: the link button leaves a placeholder URL to type over', async () => {
const user = userEvent.setup()
render(<Harness initial="opening hours" />)