mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-20 19:42:04 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user