mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
chore(editor): move legacy doc collection to test workspace (#9507)
This commit is contained in:
@@ -14,17 +14,18 @@ import {
|
||||
titleMiddleware,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import type { JobMiddleware, Schema } from '@blocksuite/affine/store';
|
||||
import { Job } from '@blocksuite/affine/store';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import type {
|
||||
BlockModel,
|
||||
BlockSnapshot,
|
||||
Doc,
|
||||
DraftModel,
|
||||
JobMiddleware,
|
||||
Schema,
|
||||
Slice,
|
||||
SliceSnapshot,
|
||||
} from '@blocksuite/store';
|
||||
} from '@blocksuite/affine/store';
|
||||
import { Job } from '@blocksuite/affine/store';
|
||||
|
||||
const updateSnapshotText = (
|
||||
point: TextRangePoint,
|
||||
|
||||
@@ -4,7 +4,8 @@ import {
|
||||
markdownInlineToDeltaMatchers,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { Container } from '@blocksuite/affine/global/di';
|
||||
import { DocCollection, Schema } from '@blocksuite/affine/store';
|
||||
import { Schema } from '@blocksuite/store';
|
||||
import { TestWorkspace } from '@blocksuite/store/test';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import { markdownToMindmap } from '../mindmap-preview.js';
|
||||
@@ -28,7 +29,7 @@ describe('markdownToMindmap: convert markdown list to a mind map tree', () => {
|
||||
- Text D
|
||||
- Text E
|
||||
`;
|
||||
const collection = new DocCollection({ schema: new Schema() });
|
||||
const collection = new TestWorkspace({ schema: new Schema() });
|
||||
collection.meta.initialize();
|
||||
const doc = collection.createDoc();
|
||||
const nodes = markdownToMindmap(markdown, doc, provider);
|
||||
@@ -66,7 +67,7 @@ describe('markdownToMindmap: convert markdown list to a mind map tree', () => {
|
||||
- Text D
|
||||
- Text E
|
||||
`;
|
||||
const collection = new DocCollection({ schema: new Schema() });
|
||||
const collection = new TestWorkspace({ schema: new Schema() });
|
||||
collection.meta.initialize();
|
||||
const doc = collection.createDoc();
|
||||
const nodes = markdownToMindmap(markdown, doc, provider);
|
||||
@@ -98,7 +99,7 @@ describe('markdownToMindmap: convert markdown list to a mind map tree', () => {
|
||||
|
||||
test('empty case', () => {
|
||||
const markdown = '';
|
||||
const collection = new DocCollection({ schema: new Schema() });
|
||||
const collection = new TestWorkspace({ schema: new Schema() });
|
||||
collection.meta.initialize();
|
||||
const doc = collection.createDoc();
|
||||
const nodes = markdownToMindmap(markdown, doc, provider);
|
||||
|
||||
@@ -12,13 +12,7 @@ import {
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { ServiceProvider } from '@blocksuite/affine/global/di';
|
||||
import { WithDisposable } from '@blocksuite/affine/global/utils';
|
||||
import {
|
||||
type Doc,
|
||||
type DocCollectionOptions,
|
||||
IdGeneratorType,
|
||||
Job,
|
||||
Schema,
|
||||
} from '@blocksuite/affine/store';
|
||||
import { type Doc, Job, Schema } from '@blocksuite/affine/store';
|
||||
import { css, html, LitElement, nothing } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
@@ -102,14 +96,11 @@ export class MiniMindmapPreview extends WithDisposable(LitElement) {
|
||||
private _createTemporaryDoc() {
|
||||
const schema = new Schema();
|
||||
schema.register(MiniMindmapSchema);
|
||||
const options: DocCollectionOptions = {
|
||||
|
||||
const collection = new WorkspaceImpl({
|
||||
id: 'MINI_MINDMAP_TEMPORARY',
|
||||
schema,
|
||||
idGenerator: IdGeneratorType.NanoID,
|
||||
awarenessSources: [],
|
||||
};
|
||||
|
||||
const collection = new WorkspaceImpl(options);
|
||||
});
|
||||
collection.meta.initialize();
|
||||
collection.start();
|
||||
|
||||
|
||||
@@ -6,20 +6,21 @@ import 'fake-indexeddb/auto';
|
||||
import { AffineSchemas } from '@blocksuite/affine/blocks/schemas';
|
||||
import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import type { Doc } from '@blocksuite/affine/store';
|
||||
import { DocCollection, Schema } from '@blocksuite/affine/store';
|
||||
import { Schema } from '@blocksuite/store';
|
||||
import { TestWorkspace } from '@blocksuite/store/test';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
|
||||
import { useBlockSuitePagePreview } from '../use-block-suite-page-preview';
|
||||
let docCollection: DocCollection;
|
||||
let docCollection: TestWorkspace;
|
||||
|
||||
const schema = new Schema();
|
||||
schema.register(AffineSchemas);
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.useFakeTimers({ toFake: ['requestIdleCallback'] });
|
||||
docCollection = new DocCollection({ id: 'test', schema });
|
||||
docCollection = new TestWorkspace({ id: 'test', schema });
|
||||
docCollection.meta.initialize();
|
||||
const initPage = async (page: Doc) => {
|
||||
page.load();
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
type LinkedWidgetConfig,
|
||||
LinkedWidgetUtils,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import type { DocMeta } from '@blocksuite/affine/store';
|
||||
import { Text } from '@blocksuite/affine/store';
|
||||
import { createSignalFromObservable } from '@blocksuite/affine-shared/utils';
|
||||
import type { EditorHost } from '@blocksuite/block-std';
|
||||
@@ -17,7 +18,6 @@ import {
|
||||
NewXxxEdgelessIcon,
|
||||
NewXxxPageIcon,
|
||||
} from '@blocksuite/icons/lit';
|
||||
import type { DocMeta } from '@blocksuite/store';
|
||||
import { computed } from '@preact/signals-core';
|
||||
import { Service } from '@toeverything/infra';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
|
||||
Reference in New Issue
Block a user