From 66407f2b2fe08f7b1da761f8cba716fdce3fe582 Mon Sep 17 00:00:00 2001 From: Daniel Dybing Date: Tue, 16 Dec 2025 03:55:34 +0100 Subject: [PATCH] feat(core): adapt date fields in database for notion import (#14111) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is related to issue/feature request https://github.com/toeverything/AFFiNE/issues/13962. This PR extends the Notion import functionality to properly handle date fields from databases. Previously, these were imported as text (see photo below), which served little purpose. These Notion date fields are now parsed as actual dates, and imported to AFFiNE as epoch time (which is what the date field in AFFiNe expects). Because of this, even date fields with time (e.g. 09:00 AM) are also handled correctly - although they are only shown as dates, since AFFiNE's `Date` field does not support time. Tested with several Notion imports both with and without time, and they all seem to work correctly. Affected files: - blocksuite/affine/blocks/database/src/adapters/notion-html.ts Old: image New: image ## Summary by CodeRabbit * **New Features** * Enhanced Notion imports with automatic date column detection. When importing Notion databases, date fields are now automatically recognized, properly configured as date columns, and formatted correctly. This improvement ensures accurate data preservation, eliminates manual type corrections, and provides a streamlined import experience for all users working with date-rich Notion databases. ✏️ Tip: You can customize this high-level summary in your review settings. --- .../database/src/adapters/notion-html.ts | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/blocksuite/affine/blocks/database/src/adapters/notion-html.ts b/blocksuite/affine/blocks/database/src/adapters/notion-html.ts index a8b7fcb41..12a39f139 100644 --- a/blocksuite/affine/blocks/database/src/adapters/notion-html.ts +++ b/blocksuite/affine/blocks/database/src/adapters/notion-html.ts @@ -15,6 +15,7 @@ const ColumnClassMap: Record = { typesCheckbox: 'checkbox', typesText: 'rich-text', typesTitle: 'title', + typesDate: 'date', }; const NotionDatabaseToken = '.collection-content'; @@ -165,7 +166,36 @@ export const databaseBlockNotionHtmlAdapterMatcher: BlockNotionHtmlAdapterMatche if (!column) { return; } - if (HastUtils.querySelector(child, '.selected-value')) { + + // Check for