refactor(editor): playground doc collection typing migration (#9593)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { AffineSchemas, SpecProvider, TestUtils } from '@blocksuite/blocks';
|
||||
import type { BlockSuiteFlags } from '@blocksuite/global/types';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { type BlockCollection, Job, nanoid, Schema } from '@blocksuite/store';
|
||||
import { Job, nanoid, Schema } from '@blocksuite/store';
|
||||
import {
|
||||
createAutoIncrementIdGenerator,
|
||||
type DocCollectionOptions,
|
||||
@@ -50,7 +49,7 @@ export function createStarterDocCollection() {
|
||||
}
|
||||
|
||||
const flags: Partial<BlockSuiteFlags> = Object.fromEntries(
|
||||
[...params.entries()]
|
||||
Array.from(params.entries())
|
||||
.filter(([key]) => key.startsWith('enable_'))
|
||||
.map(([k, v]) => [k, v === 'true'])
|
||||
);
|
||||
@@ -98,32 +97,6 @@ export function createStarterDocCollection() {
|
||||
}
|
||||
|
||||
export async function initStarterDocCollection(collection: TestWorkspace) {
|
||||
// init from other clients
|
||||
if (room && !params.has('init')) {
|
||||
const firstCollection = collection.docs.values().next().value as
|
||||
| BlockCollection
|
||||
| undefined;
|
||||
let firstDoc = firstCollection?.getDoc();
|
||||
if (!firstDoc) {
|
||||
await new Promise<string>(resolve =>
|
||||
collection.slots.docCreated.once(resolve)
|
||||
);
|
||||
const firstCollection = collection.docs.values().next().value as
|
||||
| BlockCollection
|
||||
| undefined;
|
||||
firstDoc = firstCollection?.getDoc();
|
||||
}
|
||||
assertExists(firstDoc);
|
||||
const doc = firstDoc;
|
||||
|
||||
doc.load();
|
||||
if (!doc.root) {
|
||||
await new Promise(resolve => doc.slots.rootAdded.once(resolve));
|
||||
}
|
||||
doc.resetHistory();
|
||||
return;
|
||||
}
|
||||
|
||||
// use built-in init function
|
||||
const functionMap = new Map<
|
||||
string,
|
||||
|
||||
Reference in New Issue
Block a user