fix: remove built-in note body templates

This commit is contained in:
lucaronin
2026-05-16 17:23:56 +02:00
parent 0983e4e288
commit 4061d5e88e
4 changed files with 9 additions and 29 deletions

View File

@@ -327,7 +327,7 @@ describe('useNoteActions hook', () => {
expect(createdEntry.isA).toBe('Project')
})
it('handleCreateNote uses default template for Project type', () => {
it('handleCreateNote leaves Project body empty without an explicit type template', () => {
const { result } = renderHook(() => useNoteActions(makeConfig()))
act(() => {
@@ -335,8 +335,7 @@ describe('useNoteActions hook', () => {
})
const tabContent = result.current.tabs[0].content
expect(tabContent).toContain('## Objective')
expect(tabContent).toContain('## Key Results')
expect(tabContent).toBe('---\ntitle: My Project\ntype: Project\n---\n')
})
it('handleCreateNote uses custom template from type entry', () => {

View File

@@ -9,7 +9,6 @@ import {
resolveNewNote,
resolveNewType,
planNewTypeCreation,
DEFAULT_TEMPLATES,
resolveTemplate,
} from './useNoteCreation'
@@ -232,8 +231,8 @@ describe('resolveTemplate', () => {
expect(resolveTemplate({ entries: [typeEntry], typeName: 'Recipe' })).toBe('## Ingredients\n\n## Steps\n\n')
})
it('falls back to DEFAULT_TEMPLATES for built-in types', () => {
expect(resolveTemplate({ entries: [], typeName: 'Project' })).toBe(DEFAULT_TEMPLATES.Project)
it('returns null for built-in types without an explicit type template', () => {
expect(resolveTemplate({ entries: [], typeName: 'Project' })).toBeNull()
})
it('returns null when no template and no default', () => {
@@ -246,15 +245,6 @@ describe('resolveTemplate', () => {
})
})
describe('DEFAULT_TEMPLATES', () => {
it('has templates for Project, Person, Responsibility, Experiment', () => {
expect(DEFAULT_TEMPLATES.Project).toBeDefined()
expect(DEFAULT_TEMPLATES.Person).toBeDefined()
expect(DEFAULT_TEMPLATES.Responsibility).toBeDefined()
expect(DEFAULT_TEMPLATES.Experiment).toBeDefined()
})
})
describe('resolveNewNote', () => {
it('creates note at vault root', () => {
const { entry, content } = resolveNewNote({ title: 'My Project', type: 'Project', vaultPath: '/my/vault' })

View File

@@ -13,7 +13,6 @@ import {
resolveNewType,
resolveTemplate,
resolveTypeInstanceDefaults,
DEFAULT_TEMPLATES,
RAPID_CREATE_NOTE_SETTLE_MS,
planNewNoteCreation,
useNoteCreation,
@@ -284,8 +283,8 @@ describe('resolveTemplate', () => {
expect(resolveTemplate({ entries: [typeEntry], typeName: 'Recipe' })).toBe('## Ingredients\n\n')
})
it('falls back to DEFAULT_TEMPLATES', () => {
expect(resolveTemplate({ entries: [], typeName: 'Project' })).toBe(DEFAULT_TEMPLATES.Project)
it('returns null for built-in types without an explicit type template', () => {
expect(resolveTemplate({ entries: [], typeName: 'Project' })).toBeNull()
})
it('returns null when no template and no default', () => {
@@ -473,7 +472,7 @@ describe('useNoteCreation hook', () => {
})
expect(addEntry.mock.calls[0][0].isA).toBe('Project')
expect(addEntry.mock.calls[0][0].status).toBeNull()
expect(openTabWithContent.mock.calls[0][1]).toBe('---\ntype: Project\n---\n\n# \n\n## Objective\n\n\n\n## Key Results\n\n\n\n## Notes\n\n')
expect(openTabWithContent.mock.calls[0][1]).toBe('---\ntype: Project\n---\n\n# \n\n')
})
it('handleCreateNoteImmediate persists typed notes under Windows verbatim vault roots', async () => {

View File

@@ -88,15 +88,7 @@ export function entryMatchesTarget({ entry, target }: EntryMatchParams): boolean
return resolveEntry([entry], target) === entry
}
/** Default templates for built-in types. Used when the type entry has no custom template. */
export const DEFAULT_TEMPLATES: Record<string, string> = {
Project: '## Objective\n\n\n\n## Key Results\n\n\n\n## Notes\n\n',
Person: '## Role\n\n\n\n## Contact\n\n\n\n## Notes\n\n',
Responsibility: '## Description\n\n\n\n## Key Activities\n\n\n\n## Notes\n\n',
Experiment: '## Hypothesis\n\n\n\n## Method\n\n\n\n## Results\n\n\n\n## Conclusion\n\n',
}
/** Look up the template for a given type from the type entry or defaults. */
/** Look up the template for a given type from the type entry. */
export interface TemplateLookupParams {
entries: VaultEntry[]
typeName: string
@@ -104,7 +96,7 @@ export interface TemplateLookupParams {
export function resolveTemplate({ entries, typeName }: TemplateLookupParams): string | null {
const typeEntry = entries.find((entry) => entry.isA === 'Type' && entry.title === typeName)
return typeEntry?.template ?? (Reflect.get(DEFAULT_TEMPLATES, typeName) as string | undefined) ?? null
return typeEntry?.template ?? null
}
export interface NoteContentParams {