Note Traits
Summary
Gotchas
- the
traits
property is represented astraitIds
on disk- ../code/dendron/packages/common-all/src/dnode.ts (Private)
serializeExplicitProps { if (cleanProps.traits) { propsWithTrait = { ...cleanProps, traitIds: cleanProps.traits.map((value) => value), }; } }
- ../code/dendron/packages/common-all/src/dnode.ts (Private)
Lifecycle
Activate
init {
traitRegistrar.initialize
}
initialize {
setupSavedTraitsFromFS
}
setupSavedTraitsFromFS {
asyncLoopOneAtATime {
setupTraitFromJSFile
}
}
setupTraitFromJSFile {
newNoteTrait = new UserDefinedTraitV1
newNoteTrait.initialize
registerTrait(newNoteTrait)
}
registerTrait {
// map of traits
registeredTraits.set(trait.id, trait)
cmdRegistar.registerCommandForTrait(trait)
}
registerCommandForTrait {
cmd = new CreateNoteWithTraitCommand(commandId, trait)
}
Lifecycle Old
Registering a trait
setupTraits {
files :=
files.forEach file => {
newNoteTrait = new UserDefinedTraitV1
_traitRegistrar.registerTrait(newNoteTrait)
}
}
UserDefinedTraitV1
Creating a note
-
command extends from
CreateNoteWithTraitCommand
> ../packages/plugin-core/src/commands/CreateNoteWithTraitCommand.ts (Private)
gatherInputs {
if trait.OnWillCreate?.setNameModifier
...
}
Reference
- Note Trait Interface: ../packages/common-all/src/types/noteTrait.ts (Private)
Past Tasks
Backlinks