fix: propagate frontmatter changes from raw editor to vault entries
When editing type/status/color/icon in the raw editor (Cmd+\), changes now immediately flow into the reactive VaultEntry state, updating the Properties panel, note list, and sidebar without save/reload. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
resolveTemplate,
|
||||
} from './useNoteCreation'
|
||||
import { needsRenameOnSave } from './useNoteRename'
|
||||
import { frontmatterToEntryPatch, applyRelationshipPatch } from './frontmatterOps'
|
||||
import { frontmatterToEntryPatch, applyRelationshipPatch, contentToEntryPatch } from './frontmatterOps'
|
||||
import { useNoteActions } from './useNoteActions'
|
||||
import type { NoteActionsConfig } from './useNoteActions'
|
||||
|
||||
@@ -440,6 +440,36 @@ describe('applyRelationshipPatch', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('contentToEntryPatch', () => {
|
||||
it('extracts type from frontmatter', () => {
|
||||
const content = '---\ntype: Project\nstatus: Active\n---\nBody text'
|
||||
expect(contentToEntryPatch(content)).toEqual({ isA: 'Project', status: 'Active' })
|
||||
})
|
||||
|
||||
it('returns empty patch when no frontmatter', () => {
|
||||
expect(contentToEntryPatch('Just a body')).toEqual({})
|
||||
})
|
||||
|
||||
it('returns empty patch for empty content', () => {
|
||||
expect(contentToEntryPatch('')).toEqual({})
|
||||
})
|
||||
|
||||
it('extracts color, icon, and aliases', () => {
|
||||
const content = '---\ncolor: red\nicon: star\naliases:\n - Foo\n - Bar\n---\n'
|
||||
expect(contentToEntryPatch(content)).toEqual({ color: 'red', icon: 'star', aliases: ['Foo', 'Bar'] })
|
||||
})
|
||||
|
||||
it('handles is_a as alias for type', () => {
|
||||
const content = '---\nis_a: Essay\n---\n'
|
||||
expect(contentToEntryPatch(content)).toEqual({ isA: 'Essay' })
|
||||
})
|
||||
|
||||
it('ignores unknown frontmatter keys', () => {
|
||||
const content = '---\ntype: Note\ncustom: value\n---\n'
|
||||
expect(contentToEntryPatch(content)).toEqual({ isA: 'Note' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('todayDateString', () => {
|
||||
it('returns date in YYYY-MM-DD format', () => {
|
||||
const result = todayDateString()
|
||||
|
||||
Reference in New Issue
Block a user