-
-
Notifications
You must be signed in to change notification settings - Fork 73
feat(buttons): Add date format placeholders for templaterCreateNote and createNote actions #643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for dynamic date format placeholders in the fileName and folderPath properties of button actions, enabling users to create date-based file names and organize notes by date automatically using moment.js format tokens wrapped in curly braces (e.g., {YYYY-MM-DD}).
Key Changes:
- Implements date placeholder processing using regex pattern
/\{([^}]+)\}/gto detect and replace format tokens - Processes both
fileNameandfolderPathbefore file operations - Applies the same functionality to both
createNoteandtemplaterCreateNotebutton actions
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| packages/core/src/fields/button/actions/TemplaterCreateNoteButtonActionConfig.ts | Adds processDateFormatPlaceholders method and applies date processing to fileName and folderPath before creating notes with Templater |
| packages/core/src/fields/button/actions/CreateNoteButtonActionConfig.ts | Adds processDateFormatPlaceholders method and applies date processing to fileName and folderPath before creating notes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/core/src/fields/button/actions/TemplaterCreateNoteButtonActionConfig.ts
Outdated
Show resolved
Hide resolved
packages/core/src/fields/button/actions/CreateNoteButtonActionConfig.ts
Outdated
Show resolved
Hide resolved
packages/core/src/fields/button/actions/CreateNoteButtonActionConfig.ts
Outdated
Show resolved
Hide resolved
packages/core/src/fields/button/actions/CreateNoteButtonActionConfig.ts
Outdated
Show resolved
Hide resolved
packages/core/src/fields/button/actions/TemplaterCreateNoteButtonActionConfig.ts
Outdated
Show resolved
Hide resolved
packages/core/src/fields/button/actions/TemplaterCreateNoteButtonActionConfig.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/core/src/fields/button/actions/CreateNoteButtonActionConfig.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
packages/core/src/utils/Utils.ts:391
- Character 's' is repeated in the same character class.
const validMomentFormat = /^[YMDdHhmsaAQWwXxZzGgEeSsokl:/\-\s.,[\]]+$/.test(format);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const processedFileName = processDateFormatPlaceholders(action.fileName); | ||
| const processedFolderPath = processDateFormatPlaceholders(action.folderPath); | ||
|
|
||
| if (action.openIfAlreadyExists && action.fileName) { |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks action.fileName instead of processedFileName. If date placeholder processing results in an empty string or the original action.fileName is just a placeholder that becomes empty, the openIfAlreadyExists logic may not work as intended. Consider checking processedFileName instead, or ensure the processed value is truthy before attempting to open the existing file.
| const processedFileName = processDateFormatPlaceholders(action.fileName); | ||
| const processedFolderPath = processDateFormatPlaceholders(action.folderPath); | ||
|
|
||
| if (action.openIfAlreadyExists && action.fileName) { |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks action.fileName instead of processedFileName. If date placeholder processing results in an empty string or the original action.fileName is just a placeholder that becomes empty, the openIfAlreadyExists logic may not work as intended. Consider checking processedFileName instead, or ensure the processed value is truthy before attempting to open the existing file.
| // Validate that the format string only contains valid moment.js tokens and delimiters | ||
| // Moment.js tokens: Y M D d H h m s S a A Q W w X x Z z G g E e o k l | ||
| // Common delimiters: : / - space . , [ ] | ||
| const validMomentFormat = /^[YMDdHhmsaAQWwXxZzGgEeSsokl:/\-\s.,[\]]+$/.test(format); |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex character class contains 'S' twice: once standalone and once in 'Ss'. While this doesn't break functionality (duplicate characters in character classes are simply ignored), it's redundant and could indicate a typo or oversight. Consider simplifying the pattern to remove the duplication.
| action.folderPath ?? '', | ||
| action.fileName, | ||
| processedFolderPath ?? '', | ||
| processedFileName ?? 'Untitled', |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If processedFileName is an empty string (which can happen if action.fileName is an empty string), the nullish coalescing operator won't trigger and an empty string will be passed to mb.file.create(). Consider using a falsy check instead: processedFileName || 'Untitled' to handle empty strings properly.
Summary
This PR adds support for dynamic date format placeholders in
fileNameandfolderPathproperties for bothtemplaterCreateNoteandcreateNotebutton actions. Users can now use moment.js format tokens wrapped in curly braces{format}to automatically generate date-based file names and folder paths.Motivation
Users often need to create daily notes or organize notes by date with automated buttons. Previously, they had to use static file names or complex workarounds. This feature enables seamless date-based note organization directly from Meta Bind buttons.
Real-world Use Case
Creating daily journal entries with automatic date-based naming and folder organization:
This creates notes at paths like:
001 Journal/2025/12/2025-12-18.md