mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor(editor): remove legacy blocksuite doc (#9521)
This commit is contained in:
@@ -6,12 +6,12 @@ import { Blocks } from '../store/doc/doc.js';
|
||||
import type { YBlock } from '../store/doc/index.js';
|
||||
import type { Query } from '../store/doc/query.js';
|
||||
import type { Doc, GetBlocksOptions, Workspace } from '../store/workspace.js';
|
||||
import type { AwarenessStore, BlockSuiteDoc } from '../yjs/index.js';
|
||||
import type { AwarenessStore } from '../yjs/index.js';
|
||||
|
||||
type DocOptions = {
|
||||
id: string;
|
||||
collection: Workspace;
|
||||
doc: BlockSuiteDoc;
|
||||
doc: Y.Doc;
|
||||
awarenessStore: AwarenessStore;
|
||||
};
|
||||
|
||||
@@ -43,12 +43,12 @@ export class TestDoc implements Doc {
|
||||
};
|
||||
|
||||
private readonly _initSubDoc = () => {
|
||||
let subDoc = this.rootDoc.spaces.get(this.id);
|
||||
let subDoc = this.rootDoc.getMap('spaces').get(this.id);
|
||||
if (!subDoc) {
|
||||
subDoc = new Y.Doc({
|
||||
guid: this.id,
|
||||
});
|
||||
this.rootDoc.spaces.set(this.id, subDoc);
|
||||
this.rootDoc.getMap('spaces').set(this.id, subDoc);
|
||||
this._loaded = true;
|
||||
this._onLoadSlot.emit();
|
||||
} else {
|
||||
@@ -107,7 +107,7 @@ export class TestDoc implements Doc {
|
||||
|
||||
readonly id: string;
|
||||
|
||||
readonly rootDoc: BlockSuiteDoc;
|
||||
readonly rootDoc: Y.Doc;
|
||||
|
||||
readonly slots = {
|
||||
historyUpdated: new Slot(),
|
||||
@@ -192,7 +192,7 @@ export class TestDoc implements Doc {
|
||||
this.rootDoc = doc;
|
||||
this.awarenessStore = awarenessStore;
|
||||
|
||||
this._ySpaceDoc = this._initSubDoc();
|
||||
this._ySpaceDoc = this._initSubDoc() as Y.Doc;
|
||||
|
||||
this._yBlocks = this._ySpaceDoc.getMap('blocks');
|
||||
this._collection = collection;
|
||||
@@ -353,7 +353,7 @@ export class TestDoc implements Doc {
|
||||
|
||||
remove() {
|
||||
this._destroy();
|
||||
this.rootDoc.spaces.delete(this.id);
|
||||
this.rootDoc.getMap('spaces').delete(this.id);
|
||||
}
|
||||
|
||||
resetHistory() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import clonedeep from 'lodash.clonedeep';
|
||||
import merge from 'lodash.merge';
|
||||
import { Awareness } from 'y-protocols/awareness.js';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import type { Schema } from '../schema/index.js';
|
||||
import {
|
||||
@@ -25,11 +26,7 @@ import {
|
||||
type WorkspaceMeta,
|
||||
} from '../store/index.js';
|
||||
import { type IdGenerator, nanoid } from '../utils/id-generator.js';
|
||||
import {
|
||||
AwarenessStore,
|
||||
BlockSuiteDoc,
|
||||
type RawAwarenessState,
|
||||
} from '../yjs/index.js';
|
||||
import { AwarenessStore, type RawAwarenessState } from '../yjs/index.js';
|
||||
import { TestDoc } from './test-doc.js';
|
||||
|
||||
export type DocCollectionOptions = {
|
||||
@@ -83,7 +80,7 @@ export class TestWorkspace implements Workspace {
|
||||
|
||||
readonly blockCollections = new Map<string, TestDoc>();
|
||||
|
||||
readonly doc: BlockSuiteDoc;
|
||||
readonly doc: Y.Doc;
|
||||
|
||||
readonly docSync: DocEngine;
|
||||
|
||||
@@ -123,7 +120,7 @@ export class TestWorkspace implements Workspace {
|
||||
this._schema = schema;
|
||||
|
||||
this.id = id || '';
|
||||
this.doc = new BlockSuiteDoc({ guid: id });
|
||||
this.doc = new Y.Doc({ guid: id });
|
||||
this.awarenessStore = new AwarenessStore(
|
||||
new Awareness<RawAwarenessState>(this.doc),
|
||||
merge(clonedeep(FLAGS_PRESET), defaultFlags)
|
||||
|
||||
Reference in New Issue
Block a user