feat: add note width modes

This commit is contained in:
lucaronin
2026-04-27 05:34:11 +02:00
parent fb39c6679a
commit f8721f2a1b
34 changed files with 353 additions and 233 deletions

View File

@@ -10,6 +10,7 @@ describe('frontmatterOps system metadata', () => {
['order', 4, { order: 4 }],
['_sort', 'title:asc', { sort: 'title:asc' }],
['sort', 'title:asc', { sort: 'title:asc' }],
['_width', 'wide', { noteWidth: 'wide' }],
['_sidebar_label', 'Projects', { sidebarLabel: 'Projects' }],
['sidebar label', 'Projects', { sidebarLabel: 'Projects' }],
] as [string, unknown, Partial<VaultEntry>][])('maps %s to the expected entry field', (key, value, expected) => {
@@ -21,11 +22,12 @@ describe('frontmatterOps system metadata', () => {
expect(frontmatterToEntryPatch('delete', '_sidebar_label').patch).toEqual({ sidebarLabel: null })
expect(frontmatterToEntryPatch('delete', '_order').patch).toEqual({ order: null })
expect(frontmatterToEntryPatch('delete', '_sort').patch).toEqual({ sort: null })
expect(frontmatterToEntryPatch('delete', '_width').patch).toEqual({ noteWidth: null })
})
it('keeps canonical system metadata out of custom properties', () => {
const patch = contentToEntryPatch(
'---\ntype: Type\n_icon: rocket\n_order: 4\n_sidebar_label: Projects\n_sort: title:asc\n_internal: secret\nOwner: Luca\n---\n# Project\n',
'---\ntype: Type\n_icon: rocket\n_order: 4\n_sidebar_label: Projects\n_sort: title:asc\n_width: wide\n_internal: secret\nOwner: Luca\n---\n# Project\n',
)
expect(patch).toEqual({
@@ -34,7 +36,16 @@ describe('frontmatterOps system metadata', () => {
order: 4,
sidebarLabel: 'Projects',
sort: 'title:asc',
noteWidth: 'wide',
properties: { Owner: 'Luca' },
})
})
it('keeps bare width as a custom property', () => {
const patch = contentToEntryPatch('---\nwidth: 320\n---\n# Project\n')
expect(patch).toEqual({
properties: { width: 320 },
})
})
})