Configuring Property Hooks¶
Property hooks can be configured through the ZettelFlow settings panel. You can add, edit, and remove hooks for different frontmatter properties.
Accessing Property Hooks Settings¶
- Open Obsidian Settings
- Navigate to the ZettelFlow plugin settings
- Scroll down to the "Hooks" section
- Find the "Property Hooks" subsection
Adding a New Property Hook¶
- Click the Add hook button
- Select a property from the search (this shows all available frontmatter property types in your vault)
- Click Add to confirm — the new hook appears in the list, already expanded, ready to edit
Editing a Property Hook¶
Once you've added a hook, expand it to edit:
- Click the expand button (down arrow) on the hook
- (Optional) Give it a Description — a human label shown in the list instead of the raw property name
- (Optional) Set a Run condition — see below
- Write your JavaScript code in the editor
- Click Save hook when done
Enable / disable, describe, and condition¶
Each hook now carries a few extra controls (all optional and persisted):
- Enabled toggle (in the hook's header) — pause a hook without deleting it. A disabled hook is dimmed, marked Paused, and is skipped by the runtime.
- Description — a friendly label so a list of hooks reads clearly.
-
Run condition — a small
zfexpression evaluated before the script runs; the hook only runs when it holds. Leave it blank to always run. The condition references the change event:event.property,event.oldValue,event.newValue,event.notePath. Example insert-buttons and a live sanity check are provided. For the full vocabulary see Trigger conditions.
Test on the active note (dry run)¶
Inside a hook's editor, Test on active note runs the hook (condition + script) against the note you have open and shows exactly what it would set, remove, or trigger — without writing anything. Use it to author a hook safely before you rely on it.
Script Environment¶
When writing your hook script, you have access to these variables:
event: An object containing:request: Information about the property changeoldValue: The previous value of the propertynewValue: The new value of the propertyproperty: The name of the property that changedfrontmatter: The note's full current frontmatter, so a hook can read properties other than the one that changed
file: The TFile object representing the current file-
response: Object where you can set new frontmatter valuesfrontmatter: Record of property/value pairs to update/add to the frontmatterremoveProperties: Array of properties to delete from the frontmatterflowToTrigger: Canvas name to trigger (if applicable). It must be avaliable in the vault inside the path defined in the ZettelFlow settings panel - hooks section. It can only be initialized once and will be triggered when the all hooks are finished.
-
zf: Access to ZettelFlow functions and utilities. For detailed documentation on all ZettelFlow API functionality, please refer to the ZettelFlow API Reference. -
app: Obsidian's own API. See the official documentation.
The run condition receives the same zf and app, alongside its own flat event shape (event.property, event.oldValue, event.newValue, event.notePath).
The script editor completes event., zf. and app. from the live objects, shows a member's signature on hover, and flags syntax errors in the gutter as you type.
Saving Updated Frontmatter¶
To update frontmatter properties as a result of your hook, add them to the event.response.frontmatter object:
// Example: Update a 'status' property when 'progress' reaches 100
if (event.request.property === 'progress' && event.request.newValue === 100) {
event.response.frontmatter.status = 'Complete';
}
// Always return the event object
return event;
Managing Hooks¶
- Reordering: Drag and drop hooks to change their execution order
- Deleting: Click the X button on a hook to remove it
- Editing: Expand a hook to edit its script