mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
refactor(editor): remove legacy blocksuite doc (#9521)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Blocks as BlockSuiteDoc } from '@blocksuite/affine/store';
|
||||
import type { Blocks } from '@blocksuite/affine/store';
|
||||
import { Scope } from '@toeverything/infra';
|
||||
|
||||
import type { DocRecord } from '../entities/record';
|
||||
@@ -6,5 +6,5 @@ import type { DocRecord } from '../entities/record';
|
||||
export class DocScope extends Scope<{
|
||||
docId: string;
|
||||
record: DocRecord;
|
||||
blockSuiteDoc: BlockSuiteDoc;
|
||||
blockSuiteDoc: Blocks;
|
||||
}> {}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { type Disposable, Slot } from '@blocksuite/affine/global/utils';
|
||||
import {
|
||||
type AwarenessStore,
|
||||
Blocks,
|
||||
type BlockSuiteDoc,
|
||||
type Doc,
|
||||
type GetBlocksOptions,
|
||||
type Query,
|
||||
@@ -15,7 +14,7 @@ import * as Y from 'yjs';
|
||||
type DocOptions = {
|
||||
id: string;
|
||||
collection: Workspace;
|
||||
doc: BlockSuiteDoc;
|
||||
doc: Y.Doc;
|
||||
awarenessStore: AwarenessStore;
|
||||
};
|
||||
|
||||
@@ -47,12 +46,12 @@ export class DocImpl 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 {
|
||||
@@ -111,7 +110,7 @@ export class DocImpl implements Doc {
|
||||
|
||||
readonly id: string;
|
||||
|
||||
readonly rootDoc: BlockSuiteDoc;
|
||||
readonly rootDoc: Y.Doc;
|
||||
|
||||
readonly slots = {
|
||||
historyUpdated: new Slot(),
|
||||
@@ -188,7 +187,7 @@ export class DocImpl 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;
|
||||
@@ -349,7 +348,7 @@ export class DocImpl implements Doc {
|
||||
|
||||
remove() {
|
||||
this._destroy();
|
||||
this.rootDoc.spaces.delete(this.id);
|
||||
this.rootDoc.getMap('spaces').delete(this.id);
|
||||
}
|
||||
|
||||
resetHistory() {
|
||||
|
||||
@@ -7,7 +7,6 @@ import { NoopLogger, Slot } from '@blocksuite/affine/global/utils';
|
||||
import {
|
||||
AwarenessStore,
|
||||
type Blocks,
|
||||
BlockSuiteDoc,
|
||||
type CreateBlocksOptions,
|
||||
type Doc,
|
||||
DocCollectionMeta,
|
||||
@@ -27,6 +26,7 @@ import {
|
||||
NoopDocSource,
|
||||
} from '@blocksuite/affine/sync';
|
||||
import { Awareness } from 'y-protocols/awareness.js';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import { DocImpl } from './doc';
|
||||
|
||||
@@ -67,7 +67,7 @@ export class WorkspaceImpl implements Workspace {
|
||||
|
||||
readonly blockCollections = new Map<string, Doc>();
|
||||
|
||||
readonly doc: BlockSuiteDoc;
|
||||
readonly doc: Y.Doc;
|
||||
|
||||
readonly docSync: DocEngine;
|
||||
|
||||
@@ -95,7 +95,7 @@ export class WorkspaceImpl 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(this.doc), {
|
||||
...FLAGS_PRESET,
|
||||
readonly: {},
|
||||
|
||||
Reference in New Issue
Block a user