chore: merge blocksuite source code (#9213)

This commit is contained in:
Mirone
2024-12-20 15:38:06 +08:00
committed by GitHub
parent 2c9ef916f4
commit 30200ff86d
2031 changed files with 238888 additions and 229 deletions
@@ -0,0 +1,30 @@
import type { Text } from '@blocksuite/store';
import { BlockModel, defineBlockSchema } from '@blocksuite/store';
import type { Column, SerializedCells, ViewBasicDataType } from './types.js';
export type DatabaseBlockProps = {
views: ViewBasicDataType[];
title: Text;
cells: SerializedCells;
columns: Array<Column>;
};
export class DatabaseBlockModel extends BlockModel<DatabaseBlockProps> {}
export const DatabaseBlockSchema = defineBlockSchema({
flavour: 'affine:database',
props: (internal): DatabaseBlockProps => ({
views: [],
title: internal.Text(),
cells: Object.create(null),
columns: [],
}),
metadata: {
role: 'hub',
version: 3,
parent: ['affine:note'],
children: ['affine:paragraph', 'affine:list'],
},
toModel: () => new DatabaseBlockModel(),
});
@@ -0,0 +1,2 @@
export * from './database-model.js';
export * from './types.js';
@@ -0,0 +1,21 @@
export interface Column<
Data extends Record<string, unknown> = Record<string, unknown>,
> {
id: string;
type: string;
name: string;
data: Data;
}
export type ColumnUpdater<T extends Column = Column> = (data: T) => Partial<T>;
export type Cell<ValueType = unknown> = {
columnId: Column['id'];
value: ValueType;
};
export type SerializedCells = Record<string, Record<string, Cell>>;
export type ViewBasicDataType = {
id: string;
name: string;
mode: string;
};