chore(editor): move legacy doc collection to test workspace (#9507)

This commit is contained in:
Saul-Mirone
2025-01-03 09:40:33 +00:00
parent cfd64f1fa5
commit 51b109ee53
26 changed files with 128 additions and 193 deletions

View File

@@ -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,

View File

@@ -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);

View File

@@ -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();