Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat(server): add table support for doc parse (#11508)

darkskygite1bd2047c47e
diff --git a/packages/backend/server/src/core/utils/blocksuite.ts b/packages/backend/server/src/core/utils/blocksuite.ts
index 9e6bfcd223..0317bf9232 100644
--- a/packages/backend/server/src/core/utils/blocksuite.ts
+++ b/packages/backend/server/src/core/utils/blocksuite.ts
@@ -28,7 +28,8 @@ type KnownFlavour =
| 'affine:image'
| 'affine:attachment'
| 'affine:transcription'
- | 'affine:callout';
+ | 'affine:callout'
+ | 'affine:table';
export function parseWorkspaceDoc(doc: Doc): WorkspaceDocContent | null {
// not a workspace doc
@@ -118,6 +119,21 @@ export function parsePageDoc(
}
break;
}
+ case 'affine:table': {
+ // only extract text in full content mode
+ if (summaryLenNeeded === -1) {
+ const contents: string[] = [...block.keys()]
+ .map(key => {
+ if (key.startsWith('prop:cells.') && key.endsWith('.text')) {
+ return block.get(key)?.toString() ?? '';
+ }
+ return '';
+ })
+ .filter(Boolean);
+ content.summary += contents.join('|');
+ }
+ break;
+ }
case 'affine:paragraph':
case 'affine:list':
case 'affine:code': {