mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
refactor(editor): remove AbstractEditor type and feature flags in test (#10308)
This commit is contained in:
42
blocksuite/playground/apps/starter/utils/setup-playground.ts
Normal file
42
blocksuite/playground/apps/starter/utils/setup-playground.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { DocModeProvider } from '@blocksuite/blocks';
|
||||
import { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
getDocFromUrlParams,
|
||||
listenHashChange,
|
||||
setDocModeFromUrlParams,
|
||||
} from '../../_common/history.js';
|
||||
import { createTestApp } from './app.js';
|
||||
|
||||
export async function mountDefaultDocEditor(collection: Workspace) {
|
||||
const app = document.getElementById('app');
|
||||
if (!app) return;
|
||||
|
||||
const url = new URL(location.toString());
|
||||
const doc = getDocFromUrlParams(collection, url);
|
||||
|
||||
const editor = await createTestApp(doc, collection);
|
||||
|
||||
const modeService = editor.std.provider.get(DocModeProvider);
|
||||
editor.mode = modeService.getPrimaryMode(doc.id);
|
||||
setDocModeFromUrlParams(modeService, url.searchParams, doc.id);
|
||||
|
||||
// for multiple editor
|
||||
const params = new URLSearchParams(location.search);
|
||||
const init = params.get('init');
|
||||
if (init && init.startsWith('multiple-editor')) {
|
||||
app.childNodes.forEach(node => {
|
||||
if (node instanceof AffineEditorContainer) {
|
||||
node.style.flex = '1';
|
||||
if (init === 'multiple-editor-vertical') {
|
||||
node.style.overflow = 'auto';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
listenHashChange(collection, editor);
|
||||
|
||||
return editor;
|
||||
}
|
||||
Reference in New Issue
Block a user