mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 05:07:06 +08:00
feat(editor): replace spec provider with extension manager (#11861)
Closes: BS-3273
This commit is contained in:
@@ -2,7 +2,6 @@ import '../../style.css';
|
||||
|
||||
import * as databaseBlocks from '@blocksuite/affine/blocks/database';
|
||||
import * as noteBlocks from '@blocksuite/affine/blocks/note';
|
||||
import { effects as blocksEffects } from '@blocksuite/affine/effects';
|
||||
import { registerStoreSpecs } from '@blocksuite/affine/extensions';
|
||||
import * as globalUtils from '@blocksuite/affine/global/utils';
|
||||
import * as services from '@blocksuite/affine/shared/services';
|
||||
@@ -10,7 +9,8 @@ import * as blockStd from '@blocksuite/affine/std';
|
||||
import * as store from '@blocksuite/affine/store';
|
||||
import * as affineModel from '@blocksuite/affine-model';
|
||||
import * as editor from '@blocksuite/integration-test';
|
||||
import { effects as presetsEffects } from '@blocksuite/integration-test/effects';
|
||||
import { effects as itEffects } from '@blocksuite/integration-test/effects';
|
||||
import { getTestStoreManager } from '@blocksuite/integration-test/store';
|
||||
|
||||
import { setupEdgelessTemplate } from '../_common/setup.js';
|
||||
import { effects as commentEffects } from '../comment/effects.js';
|
||||
@@ -22,8 +22,8 @@ import { mountDefaultDocEditor } from './utils/setup-playground';
|
||||
import { prepareTestApp } from './utils/test';
|
||||
|
||||
registerStoreSpecs();
|
||||
blocksEffects();
|
||||
presetsEffects();
|
||||
itEffects();
|
||||
const storeManager = getTestStoreManager();
|
||||
commentEffects();
|
||||
|
||||
async function main() {
|
||||
@@ -34,7 +34,7 @@ async function main() {
|
||||
const params = new URLSearchParams(location.search);
|
||||
const room = params.get('room') ?? Math.random().toString(16).slice(2, 8);
|
||||
const isE2E = room.startsWith('playwright');
|
||||
const collection = createStarterDocCollection();
|
||||
const collection = createStarterDocCollection(storeManager);
|
||||
|
||||
if (isE2E) {
|
||||
Object.defineProperty(window, '$blocksuite', {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { StoreExtensionManager } from '@blocksuite/affine/ext-loader';
|
||||
import { AffineSchemas } from '@blocksuite/affine/schemas';
|
||||
import { SpecProvider } from '@blocksuite/affine/shared/utils';
|
||||
import { nanoid, Schema, Transformer } from '@blocksuite/affine/store';
|
||||
import {
|
||||
createAutoIncrementIdGenerator,
|
||||
@@ -23,7 +23,9 @@ const room = params.get('room');
|
||||
const isE2E = room?.startsWith('playwright');
|
||||
const blobSourceArgs = (params.get('blobSource') ?? '').split(',');
|
||||
|
||||
export function createStarterDocCollection() {
|
||||
export function createStarterDocCollection(
|
||||
storeExtensionManager: StoreExtensionManager
|
||||
) {
|
||||
const collectionId = room ?? 'starter';
|
||||
const schema = new Schema();
|
||||
schema.register(AffineSchemas);
|
||||
@@ -56,7 +58,7 @@ export function createStarterDocCollection() {
|
||||
blobSources,
|
||||
};
|
||||
const collection = new TestWorkspace(options);
|
||||
collection.storeExtensions = SpecProvider._.getSpec('store').value;
|
||||
collection.storeExtensions = storeExtensionManager.get('store');
|
||||
collection.start();
|
||||
|
||||
// debug info
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import {
|
||||
EdgelessEditorBlockSpecs,
|
||||
PageEditorBlockSpecs,
|
||||
} from '@blocksuite/affine/extensions';
|
||||
import { RefNodeSlotsProvider } from '@blocksuite/affine/inlines/reference';
|
||||
import {
|
||||
CommunityCanvasTextFonts,
|
||||
@@ -13,6 +9,7 @@ import {
|
||||
} from '@blocksuite/affine/shared/services';
|
||||
import type { ExtensionType, Store, Workspace } from '@blocksuite/affine/store';
|
||||
import { type TestAffineEditorContainer } from '@blocksuite/integration-test';
|
||||
import { getTestViewManager } from '@blocksuite/integration-test/view';
|
||||
|
||||
import {
|
||||
mockDocModeService,
|
||||
@@ -20,6 +17,8 @@ import {
|
||||
mockParseDocUrlService,
|
||||
} from '../../_common/mock-services';
|
||||
|
||||
const viewManager = getTestViewManager();
|
||||
|
||||
export function getTestCommonExtensions(
|
||||
editor: TestAffineEditorContainer
|
||||
): ExtensionType[] {
|
||||
@@ -48,8 +47,8 @@ export function createTestEditor(store: Store, workspace: Workspace) {
|
||||
editor.doc = store;
|
||||
|
||||
const defaultExtensions = getTestCommonExtensions(editor);
|
||||
editor.pageSpecs = [...PageEditorBlockSpecs, ...defaultExtensions];
|
||||
editor.edgelessSpecs = [...EdgelessEditorBlockSpecs, ...defaultExtensions];
|
||||
editor.pageSpecs = [...viewManager.get('page'), ...defaultExtensions];
|
||||
editor.edgelessSpecs = [...viewManager.get('edgeless'), ...defaultExtensions];
|
||||
|
||||
editor.std
|
||||
.get(RefNodeSlotsProvider)
|
||||
|
||||
Reference in New Issue
Block a user