mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-23 01:07:12 +08:00
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,
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
BlockServiceWatcher,
|
||||
type EditorHost,
|
||||
type ExtensionType,
|
||||
} from '@blocksuite/block-std';
|
||||
import { BlockServiceWatcher, type EditorHost } from '@blocksuite/block-std';
|
||||
import {
|
||||
AffineFormatBarWidget,
|
||||
CommunityCanvasTextFonts,
|
||||
@@ -19,7 +15,7 @@ import {
|
||||
toolbarDefaultConfig,
|
||||
} from '@blocksuite/blocks';
|
||||
import { AffineEditorContainer, CommentPanel } from '@blocksuite/presets';
|
||||
import type { DocCollection } from '@blocksuite/store';
|
||||
import type { ExtensionType, Workspace } from '@blocksuite/store';
|
||||
|
||||
import { AttachmentViewerPanel } from '../../_common/components/attachment-viewer-panel.js';
|
||||
import { CustomFramePanel } from '../../_common/components/custom-frame-panel.js';
|
||||
@@ -47,7 +43,7 @@ function configureFormatBar(formatBar: AffineFormatBarWidget) {
|
||||
toolbarDefaultConfig(formatBar);
|
||||
}
|
||||
|
||||
export async function mountDefaultDocEditor(collection: DocCollection) {
|
||||
export async function mountDefaultDocEditor(collection: Workspace) {
|
||||
const app = document.getElementById('app');
|
||||
if (!app) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user