refactor(editor): rename doc to blocks (#9510)

This commit is contained in:
Saul-Mirone
2025-01-03 12:49:33 +00:00
parent 2074bda8ff
commit 4457cb7266
99 changed files with 271 additions and 256 deletions
@@ -1,7 +1,7 @@
import { DebugLogger } from '@affine/debug';
import { BlockStdScope } from '@blocksuite/affine/block-std';
import { PageEditorBlockSpecs } from '@blocksuite/affine/blocks';
import type { Doc } from '@blocksuite/affine/store';
import type { Blocks } from '@blocksuite/affine/store';
import { LiveData } from '@toeverything/infra';
import { useMemo } from 'react';
import { Observable } from 'rxjs';
@@ -42,7 +42,7 @@ export function signalToLiveData<T>(
}
// todo(pengx17): use rc pool?
export function createBlockStdScope(doc: Doc) {
export function createBlockStdScope(doc: Blocks) {
logger.debug('createBlockStdScope', doc.id);
const std = new BlockStdScope({
doc,
@@ -51,6 +51,6 @@ export function createBlockStdScope(doc: Doc) {
return std;
}
export function useBlockStdScope(doc: Doc) {
export function useBlockStdScope(doc: Blocks) {
return useMemo(() => createBlockStdScope(doc), [doc]);
}
@@ -5,7 +5,7 @@ import {
DefaultInlineManagerExtension,
RichText,
} from '@blocksuite/affine/blocks';
import type { Doc } from '@blocksuite/affine/store';
import type { Blocks } from '@blocksuite/affine/store';
import { TextIcon } from '@blocksuite/icons/rc';
import { type LiveData, useLiveData } from '@toeverything/infra';
import { type CSSProperties, useEffect, useRef, useState } from 'react';
@@ -23,7 +23,7 @@ const renderRichText = ({
}: {
std: BlockStdScope;
text: Y.Text;
doc: Doc;
doc: Blocks;
}) => {
const inlineManager = std.get(DefaultInlineManagerExtension.identifier);
@@ -1,4 +1,4 @@
import type { Doc as BlockSuiteDoc } from '@blocksuite/affine/store';
import type { Blocks as BlockSuiteDoc } from '@blocksuite/affine/store';
import { Scope } from '@toeverything/infra';
import type { DocRecord } from '../entities/record';
@@ -7,9 +7,9 @@ import { NoopLogger, Slot } from '@blocksuite/affine/global/utils';
import {
AwarenessStore,
BlockCollection,
type Blocks,
BlockSuiteDoc,
type CreateDocOptions,
type Doc,
DocCollectionMeta,
type GetDocOptions,
type IdGenerator,
@@ -168,7 +168,7 @@ export class WorkspaceImpl implements Workspace {
tags: [],
});
this.slots.docCreated.emit(docId);
return this.getDoc(docId, { query, readonly }) as Doc;
return this.getDoc(docId, { query, readonly }) as Blocks;
}
dispose() {
@@ -190,7 +190,7 @@ export class WorkspaceImpl implements Workspace {
return space ?? null;
}
getDoc(docId: string, options?: GetDocOptions): Doc | null {
getDoc(docId: string, options?: GetDocOptions): Blocks | null {
const collection = this.getBlockCollection(docId);
return collection?.getDoc(options) ?? null;
}