mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 23:26:30 +08:00
ce87dcf58e
1. **Major Architectural Change: Schema Management**
- Moved from `workspace.schema` to `store.schema` throughout the codebase
- Removed schema property from Workspace and Doc interfaces
- Added `BlockSchemaExtension` pattern across multiple block types
2. **Block Schema Extensions Added**
- Added new `BlockSchemaExtension` to numerous block types including:
- DataView, Surface, Attachment, Bookmark, Code
- Database, Divider, EdgelessText, Embed blocks (Figma, Github, HTML, etc.)
- Frame, Image, Latex, List, Note, Paragraph
- Root, Surface Reference, Table blocks
3. **Import/Export System Updates**
- Updated import functions to accept `schema` parameter:
- `importHTMLToDoc`
- `importHTMLZip`
- `importMarkdownToDoc`
- `importMarkdownZip`
- `importNotionZip`
- Modified export functions to use new schema pattern
4. **Test Infrastructure Updates**
- Updated test files to use new schema extensions
- Modified test document creation to include schema extensions
- Removed direct schema registration in favor of extensions
5. **Service Layer Changes**
- Updated various services to use `getAFFiNEWorkspaceSchema()`
- Modified transformer initialization to use document schema
- Updated collection initialization patterns
6. **Version Management**
- Removed version-related properties and methods from:
- `WorkspaceMetaImpl`
- `TestMeta`
- `DocImpl`
- Removed `blockVersions` and `workspaceVersion/pageVersion`
7. **Store and Extension Updates**
- Added new store extensions and adapters
- Updated store initialization patterns
- Added new schema-related functionality in store extension
This PR represents a significant architectural shift in how schemas are managed, moving from a workspace-centric to a store-centric approach, while introducing a more extensible block schema system through `BlockSchemaExtension`. The changes touch multiple layers of the application including core functionality, services, testing infrastructure, and import/export capabilities.
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import type { Slot } from '@blocksuite/global/utils';
|
|
import type * as Y from 'yjs';
|
|
|
|
import type { AwarenessStore } from '../yjs/awareness.js';
|
|
import type { YBlock } from './block/types.js';
|
|
import type { Query } from './store/query.js';
|
|
import type { Store, StoreOptions } from './store/store.js';
|
|
import type { Workspace } from './workspace.js';
|
|
import type { DocMeta } from './workspace-meta.js';
|
|
|
|
export type GetBlocksOptions = Omit<StoreOptions, 'schema' | 'doc'>;
|
|
export type CreateBlocksOptions = GetBlocksOptions & {
|
|
id?: string;
|
|
};
|
|
export type YBlocks = Y.Map<YBlock>;
|
|
|
|
export interface Doc {
|
|
readonly id: string;
|
|
get meta(): DocMeta | undefined;
|
|
|
|
remove(): void;
|
|
load(initFn?: () => void): void;
|
|
get ready(): boolean;
|
|
dispose(): void;
|
|
|
|
slots: {
|
|
historyUpdated: Slot;
|
|
yBlockUpdated: Slot<
|
|
| {
|
|
type: 'add';
|
|
id: string;
|
|
}
|
|
| {
|
|
type: 'delete';
|
|
id: string;
|
|
}
|
|
>;
|
|
};
|
|
|
|
get history(): Y.UndoManager;
|
|
get canRedo(): boolean;
|
|
get canUndo(): boolean;
|
|
undo(): void;
|
|
redo(): void;
|
|
resetHistory(): void;
|
|
transact(fn: () => void, shouldTransact?: boolean): void;
|
|
withoutTransact(fn: () => void): void;
|
|
|
|
captureSync(): void;
|
|
clear(): void;
|
|
getStore(options?: GetBlocksOptions): Store;
|
|
clearQuery(query: Query, readonly?: boolean): void;
|
|
|
|
get loaded(): boolean;
|
|
get awarenessStore(): AwarenessStore;
|
|
|
|
get workspace(): Workspace;
|
|
|
|
get rootDoc(): Y.Doc;
|
|
get spaceDoc(): Y.Doc;
|
|
get yBlocks(): Y.Map<YBlock>;
|
|
}
|