mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
refactor(editor): rename presets to integration test (#10340)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { replaceIdMiddleware } from '@blocksuite/blocks';
|
||||
import {
|
||||
type DocSnapshot,
|
||||
Transformer,
|
||||
type Workspace,
|
||||
} from '@blocksuite/store';
|
||||
|
||||
export async function importFromSnapshot(
|
||||
collection: Workspace,
|
||||
snapshot: DocSnapshot
|
||||
) {
|
||||
const job = new Transformer({
|
||||
schema: collection.schema,
|
||||
blobCRUD: collection.blobSync,
|
||||
docCRUD: {
|
||||
create: (id: string) => collection.createDoc({ id }),
|
||||
get: (id: string) => collection.getDoc(id),
|
||||
delete: (id: string) => collection.removeDoc(id),
|
||||
},
|
||||
middlewares: [replaceIdMiddleware(collection.idGenerator)],
|
||||
});
|
||||
|
||||
return job.snapshotToDoc(snapshot);
|
||||
}
|
||||
Reference in New Issue
Block a user