refactor(editor): remove AbstractEditor type and feature flags in test (#10308)

This commit is contained in:
Saul-Mirone
2025-02-20 07:05:35 +00:00
parent 13f1859cdf
commit 9f4311f654
19 changed files with 215 additions and 412 deletions

View File

@@ -57,6 +57,7 @@ import { customElement, property, query, state } from 'lit/decorators.js';
import * as lz from 'lz-string';
import type { Pane } from 'tweakpane';
import { createTestEditor } from '../../starter/utils/extensions.js';
import { mockEdgelessTheme } from '../mock-services.js';
import { AdaptersPanel } from './adapters-panel.js';
import type { CustomFramePanel } from './custom-frame-panel.js';
@@ -643,8 +644,7 @@ export class StarterDebugMenu extends ShadowlessElement {
).length;
if (currentEditorCount === 1) {
// Add a second editor
const newEditor = document.createElement('affine-editor-container');
newEditor.doc = this.doc;
const newEditor = createTestEditor(this.doc, this.collection);
app.append(newEditor);
app.childNodes.forEach(child => {
if (child instanceof AffineEditorContainer) {

View File

@@ -2,7 +2,6 @@ import type { DocModeProvider } from '@blocksuite/blocks';
import { assertExists } from '@blocksuite/global/utils';
import type { AffineEditorContainer } from '@blocksuite/presets';
import type { Doc, Store, Workspace } from '@blocksuite/store';
import type { LitElement } from 'lit';
export function getDocFromUrlParams(collection: Workspace, url: URL) {
let doc: Store | null = null;
@@ -41,9 +40,9 @@ export function setDocModeFromUrlParams(
export function listenHashChange(
collection: Workspace,
editor: AffineEditorContainer,
panel?: LitElement
editor: AffineEditorContainer
) {
const panel = document.querySelector('docs-panel');
window.addEventListener('hashchange', () => {
const url = new URL(location.toString());
const doc = getDocFromUrlParams(collection, url);

View File

@@ -37,10 +37,10 @@ export function removeModeFromStorage(docId: string) {
const DEFAULT_MODE: DocMode = 'page';
const slotMap = new Map<string, Slot<DocMode>>();
export function mockDocModeService(
getEditorModeCallback: () => DocMode,
setEditorModeCallback: (mode: DocMode) => void
) {
export function mockDocModeService(editor: AffineEditorContainer) {
const getEditorModeCallback: () => DocMode = () => editor.mode;
const setEditorModeCallback: (mode: DocMode) => void = mode =>
editor.switchEditor(mode);
const docModeService: DocModeProvider = {
getPrimaryMode: (docId: string) => {
try {