feat: add auto-date titles for new documents (#14716)
## Summary Adds an Editor setting to automatically title blank new documents with the current date. fixes https://github.com/toeverything/AFFiNE/issues/14709 https://www.loom.com/share/953b4eafcfb247839e977dca6f457229 ## What Changed - Added `Auto-title new docs with current date` under Editor settings - Added `New doc date format`, shown only when auto-title is enabled - Supported formats: - `DD-MM-YYYY` - `MM-DD-YYYY` - `YYYY-MM-DD` - `Journal style (localized)` - Kept titles unique by appending duplicate-style suffixes: - `2026-03-24` - `2026-03-24(2)` - `2026-03-24(3)` ## Behavior - Only applies to blank new docs - Does not override explicitly provided titles - Uses the existing journal-style localized formatter for the localized option ## Implementation Notes - Extended editor setting schema with: - `autoTitleNewDocWithCurrentDate` - `newDocDateTitleFormat` - Added a helper for generating unique date-based titles - Wired title generation into doc creation middleware - Synced created titles into doc metadata so uniqueness works consistently ## Tests - Added unit coverage for: - date title formatting - duplicate suffix generation - doc creation middleware behavior - settings UI behavior <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * General settings: toggle to auto-insert current date into new document titles; selectable formats: DD-MM-YYYY, MM-DD-YYYY, YYYY-MM-DD, and localized "journal". Date-format chooser appears only when enabled. * **Behavior** * Blank new-docs are auto-populated per chosen format; user-provided titles are preserved. Auto-generated titles avoid collisions by appending incrementing suffixes. * **Localization** * Added translations for the setting, description, format chooser, and all format labels. * **Tests** * Added UI and unit tests covering formatting, uniqueness, middleware behavior, and interaction. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
"ja": 96,
|
||||
"ko": 97,
|
||||
"nb-NO": 47,
|
||||
"pl": 98,
|
||||
"pl": 97,
|
||||
"pt-BR": 96,
|
||||
"ru": 98,
|
||||
"sv-SE": 96,
|
||||
|
||||
@@ -5490,6 +5490,38 @@ export function useAFFiNEI18N(): {
|
||||
* `New doc default mode`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.default-new-doc.title"](): string;
|
||||
/**
|
||||
* `Auto-title new docs with current date`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.title"](): string;
|
||||
/**
|
||||
* `Automatically title blank new docs with today's date.`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.description"](): string;
|
||||
/**
|
||||
* `New doc date format`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.format.title"](): string;
|
||||
/**
|
||||
* `Choose the date format used for automatic new doc titles.`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.format.description"](): string;
|
||||
/**
|
||||
* `DD-MM-YYYY`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.format.dd-mm-yyyy"](): string;
|
||||
/**
|
||||
* `MM-DD-YYYY`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.format.mm-dd-yyyy"](): string;
|
||||
/**
|
||||
* `YYYY-MM-DD`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.format.yyyy-mm-dd"](): string;
|
||||
/**
|
||||
* `Journal style (localized)`
|
||||
*/
|
||||
["com.affine.settings.editorSettings.general.auto-date-title.format.journal"](): string;
|
||||
/**
|
||||
* `Customize your text experience.`
|
||||
*/
|
||||
|
||||
@@ -1366,6 +1366,14 @@
|
||||
"com.affine.settings.editorSettings.general.default-code-block.wrap.title": "Wrap code in code blocks",
|
||||
"com.affine.settings.editorSettings.general.default-new-doc.description": "Default mode for new doc.",
|
||||
"com.affine.settings.editorSettings.general.default-new-doc.title": "New doc default mode",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.title": "Auto-title new docs with current date",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.description": "Automatically title blank new docs with today's date.",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.format.title": "New doc date format",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.format.description": "Choose the date format used for automatic new doc titles.",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.format.dd-mm-yyyy": "DD-MM-YYYY",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.format.mm-dd-yyyy": "MM-DD-YYYY",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.format.yyyy-mm-dd": "YYYY-MM-DD",
|
||||
"com.affine.settings.editorSettings.general.auto-date-title.format.journal": "Journal style (localized)",
|
||||
"com.affine.settings.editorSettings.general.font-family.custom.description": "Customize your text experience.",
|
||||
"com.affine.settings.editorSettings.general.font-family.custom.title": "Custom font family",
|
||||
"com.affine.settings.editorSettings.general.font-family.description": "Choose your editor's font family.",
|
||||
|
||||
Reference in New Issue
Block a user