Presets
Presets are reusable dynamic or static content snippets that can be used in templates and notes. Reference them using the {{identifier}} format.
Use Cases
- Automatically insert current date/time
- Define frequently used text snippets
- Create dynamic content with parameters
- Set cursor focus position in templates
Open Presets Management
Click the Presets icon in the sidebar to enter the presets management page.
Preset Types
Static Presets
Fixed text content that directly replaces with the set value when inserted.
Example:
- Identifier:
signature - Value:
—— John Doe
Using {{signature}} will be replaced with —— John Doe
Dynamic Presets
Use JavaScript code to dynamically generate content, with parameter support.
Example:
- Identifier:
date - Code:
function(context, params = { format: 'YYYY/MM/DD' }) {
return context.dayjs().format(params.format);
}Built-in Presets
The system provides the following built-in presets:
| Identifier | Description | Default Output |
|---|---|---|
time | Current time | 14:30:00 |
date | Current date | 2025/01/20 |
datetime | Full date and time | 2025/01/20 14:30:00 |
focus | Cursor focus position | No output, cursor positions here |
Using Presets
In the Editor
- Type
{{to trigger the preset selector - Type the identifier to search
- Select a preset and press
Enterto insert
In Templates
Use {{ in the template editor to trigger the selector. Inserted presets will be automatically replaced when the template is applied.
Parameter Usage
Dynamic presets support parameters to customize output format.
Parameter Format
Parameters use JSON object format, passed via | separator: {{identifier|{"key": "value"}}}
Usage Examples
Custom Date Format
Default {{date}} output: 2025/01/20
With params {{date|{"format": "YYYY-MM-DD"}}}, output: 2025-01-20
With params {{date|{"format": "MMM DD, YYYY"}}}, output: Jan 20, 2025
Custom Time Format
Default {{time}} output: 14:30:00
With params {{time|{"format": "HH:mm"}}}, output: 14:30
With params {{time|{"format": "h:mm A"}}}, output: 2:30 PM
Custom DateTime Format
Default {{datetime}} output: 2025/01/20 14:30:00
With params {{datetime|{"format": "MMMM DD, YYYY at HH:mm"}}}, output: January 20, 2025 at 14:30
Date Format Reference
| Token | Description | Example |
|---|---|---|
YYYY | 4-digit year | 2025 |
YY | 2-digit year | 25 |
MMMM | Full month name | January |
MMM | Abbreviated month | Jan |
MM | 2-digit month | 01 |
M | Month | 1 |
DD | 2-digit day | 20 |
D | Day | 20 |
HH | 24-hour hour | 14 |
hh | 12-hour hour (padded) | 02 |
h | 12-hour hour | 2 |
mm | Minutes | 30 |
ss | Seconds | 00 |
A | AM/PM | PM |
a | am/pm | pm |
dddd | Full weekday | Monday |
ddd | Abbreviated weekday | Mon |
Creating Custom Presets
- Click the New button in the top toolbar
- Fill in:
- Identifier: Supports Chinese, English, numbers, underscores, e.g.,
my_preset(identifiers can be duplicated, but using unique identifiers is recommended for clarity) - Description: Optional, explains the preset's purpose
- Type: Static or Dynamic
- Value: For static type, enter fixed text; for dynamic type, enter JavaScript function
- Identifier: Supports Chinese, English, numbers, underscores, e.g.,
- Click Save
Dynamic Preset Code Specification
function(context, params = { /* default params */ }) {
// context provides:
// - context.dayjs: dayjs library for date/time handling
// - context.focus(): call to position cursor here
// params is the user-provided parameter object
return 'returned text content';
}Available Globals and Methods:
- Basic types:
Array,Boolean,Date,JSON,Math,Number,Object,String,RegExp - Utility methods:
parseInt,parseFloat,isNaN,isFinite,encodeURI,encodeURIComponent,decodeURI,decodeURIComponent - Date handling:
dayjs(full dayjs library with the following plugins loaded)utc- UTC time supporttimezone- Timezone supportweekOfYear- Week of yeardayOfYear- Day of yearisoWeek- ISO week standardisSameOrBefore- Date comparisonisSameOrAfter- Date comparisonisBetween- Date range checkduration- Duration calculationrelativeTime- Relative time (e.g., "3 days ago")customParseFormat- Custom parse formatadvancedFormat- Advanced formatting options
- Network requests:
fetch(supports async network requests)
Security Restrictions:
- Code executes in a sandboxed environment with no access to file system, Electron APIs, or other system features
- Execution timeout limit: 5 seconds
- Prohibited:
require,import,eval,window,document,localStorage, etc.
Example: Date Range
Generate a date range string, useful for meeting notes or project planning.
function(context, params = { startDate: '', days: 7, format: 'YYYY-MM-DD' }) {
const { dayjs } = context;
const start = params.startDate ? dayjs(params.startDate) : dayjs();
const end = start.add(params.days, 'day');
return `${start.format(params.format)} ~ ${end.format(params.format)}`;
}Usage:
{{dateRange}}→2025-01-20 ~ 2025-01-27(from today, 7 days by default){{dateRange|{"days": 30}}}→2025-01-20 ~ 2025-02-19(30 days){{dateRange|{"startDate": "2025-02-01", "days": 14}}}→2025-02-01 ~ 2025-02-15(custom start date){{dateRange|{"days": 7, "format": "MMM DD"}}}→Jan 20 ~ Jan 27
Example: Day of Week
Get the day of week for a specified date, with long/short format support.
function(context, params = { date: '', format: 'long' }) {
const { dayjs } = context;
const targetDate = params.date ? dayjs(params.date) : dayjs();
const weekdays = {
long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
short: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
};
return weekdays[params.format][targetDate.day()];
}Usage:
{{weekday}}→Monday(current date){{weekday|{"date": "2025-01-01"}}}→Wednesday(specified date){{weekday|{"date": "2025-01-20", "format": "short"}}}→Mon(short format)
