feat(workspace): numbered lists and reliable markdown paste
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m5s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m5s
- block type 'numbered' (/number): 1., a., i. by nesting, continues on Enter, an empty item ends the list; markdown export/import as 1. - pasting: parser moved to lib/pasteOutline with tests; blank lines split paragraphs, numbered lists keep their type, indentation levels follow the widths in use (2, 3 or 4 spaces, tabs) - text that stays in the focused block after pasting (a paragraph with line breaks) was dropped; the block now takes it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9008d7c915
commit
2bfe74e66b
13 files changed
+286
-176
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { listLabel, numberedLabels } from '../outlineList';
|
||||
import type { DocumentBlock } from '../types';
|
||||
|
||||
const blk = (id: string, level: number, type: DocumentBlock['type'] = 'numbered'): DocumentBlock => ({
|
||||
id, documentId: 'd', type, content: id, level, position: 0,
|
||||
});
|
||||
|
||||
describe('numbered lists', () => {
|
||||
it('formats numbers, letters and roman numerals by depth', () => {
|
||||
expect(listLabel(3, 0)).toBe('3.');
|
||||
expect(listLabel(2, 1)).toBe('b.');
|
||||
expect(listLabel(27, 1)).toBe('aa.');
|
||||
expect(listLabel(4, 2)).toBe('iv.');
|
||||
expect(listLabel(1, 3)).toBe('1.');
|
||||
});
|
||||
|
||||
it('counts siblings, nests and restarts after other blocks', () => {
|
||||
const labels = numberedLabels([
|
||||
blk('a', 0), blk('a1', 1), blk('a2', 1), blk('a2i', 2), blk('b', 0),
|
||||
blk('note', 0, 'text'), blk('c', 0), blk('plain', 1, 'text'), blk('c1', 2),
|
||||
]);
|
||||
expect(Object.fromEntries(labels)).toEqual({
|
||||
a: '1.', a1: 'a.', a2: 'b.', a2i: 'i.', b: '2.', c: '1.', c1: 'a.',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user