From 528c752b1a9dc572dfb2c8880f2fc1d129ffec4e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 15 Mar 2025 13:05:02 -0400 Subject: [PATCH] Add column, column_list support (flatted into document until we have support) --- server/utils/NotionConverter.ts | 18 +++--- .../NotionConverter.test.ts.snap | 60 +++++++++++++++++++ 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/server/utils/NotionConverter.ts b/server/utils/NotionConverter.ts index f7b32f7b14..fa232e295d 100644 --- a/server/utils/NotionConverter.ts +++ b/server/utils/NotionConverter.ts @@ -23,6 +23,8 @@ import type { PageObjectResponse, VideoBlockObjectResponse, CalloutBlockObjectResponse, + ColumnListBlockObjectResponse, + ColumnBlockObjectResponse, } from "@notionhq/client/build/src/api-endpoints"; import isArray from "lodash/isArray"; import { NoticeTypes } from "@shared/editor/nodes/Notice"; @@ -42,8 +44,6 @@ export class NotionConverter { // TODO: Implement the following blocks: // - "child_database" // - "child_page" - // - "column" - // - "column_list" // - "link_preview" // - "link_to_page" // - "synced_block" @@ -52,11 +52,7 @@ export class NotionConverter { * Nodes which cannot contain block children in Outline, their children * will be flattened into the parent. */ - private static nodesWithoutBlockChildren = [ - // TODO. - "paragraph", - "toggle", - ]; + private static nodesWithoutBlockChildren = ["paragraph", "toggle"]; public static page(item: NotionPage) { return { @@ -178,6 +174,14 @@ export class NotionConverter { }; } + private static column_list(item: NotionBlock) { + return this.mapChildren(item); + } + + private static column(item: NotionBlock) { + return this.mapChildren(item); + } + private static bookmark(item: BookmarkBlockObjectResponse) { return { type: "paragraph", diff --git a/server/utils/__snapshots__/NotionConverter.test.ts.snap b/server/utils/__snapshots__/NotionConverter.test.ts.snap index eb6561e6ea..bfb539028d 100644 --- a/server/utils/__snapshots__/NotionConverter.test.ts.snap +++ b/server/utils/__snapshots__/NotionConverter.test.ts.snap @@ -336,6 +336,66 @@ exports[`NotionConverter converts a page 1`] = ` ], "type": "paragraph", }, + { + "content": [ + { + "marks": [ + { + "type": "strong", + }, + ], + "text": "Column one content", + "type": "text", + }, + ], + "type": "paragraph", + }, + { + "content": [ + { + "marks": [], + "text": "It can have any node permissible in the page", + "type": "text", + }, + ], + "type": "paragraph", + }, + { + "content": [], + "type": "paragraph", + }, + { + "content": [ + { + "marks": [ + { + "type": "strong", + }, + ], + "text": "Column two content", + "type": "text", + }, + ], + "type": "paragraph", + }, + { + "attrs": { + "style": "info", + }, + "content": [ + { + "content": [ + { + "marks": [], + "text": "Callout inside column", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "container_notice", + }, { "attrs": { "level": 2,