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

View File

@@ -2,7 +2,7 @@ import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { nextTick, Slot } from '@blocksuite/global/utils';
import type { BlockModel, BlockSchemaType, Schema } from '../schema/index.js';
import type { Doc } from '../store/index.js';
import type { Blocks } from '../store/index.js';
import { AssetsManager } from './assets.js';
import { BaseBlockTransformer } from './base.js';
import type { DraftModel } from './draft.js';
@@ -78,7 +78,7 @@ export class Job {
}
};
docToSnapshot = (doc: Doc): DocSnapshot | undefined => {
docToSnapshot = (doc: Blocks): DocSnapshot | undefined => {
try {
this._slots.beforeExport.emit({
type: 'page',
@@ -154,7 +154,7 @@ export class Job {
snapshotToBlock = async (
snapshot: BlockSnapshot,
doc: Doc,
doc: Blocks,
parent?: string,
index?: number
): Promise<BlockModel | undefined> => {
@@ -170,7 +170,9 @@ export class Job {
}
};
snapshotToDoc = async (snapshot: DocSnapshot): Promise<Doc | undefined> => {
snapshotToDoc = async (
snapshot: DocSnapshot
): Promise<Blocks | undefined> => {
try {
this._slots.beforeImport.emit({
type: 'page',
@@ -222,7 +224,7 @@ export class Job {
snapshotToSlice = async (
snapshot: SliceSnapshot,
doc: Doc,
doc: Blocks,
parent?: string,
index?: number
): Promise<Slice | undefined> => {
@@ -418,7 +420,7 @@ export class Job {
}
}
private _exportDocMeta(doc: Doc): DocSnapshot['meta'] {
private _exportDocMeta(doc: Blocks): DocSnapshot['meta'] {
const docMeta = doc.meta;
if (!docMeta) {
@@ -466,7 +468,7 @@ export class Job {
private async _insertBlockTree(
nodes: DraftBlockTreeNode[],
doc: Doc,
doc: Blocks,
parentId?: string,
startIndex?: number,
counter: number = 0
@@ -555,7 +557,7 @@ export class Job {
private async _snapshotToBlock(
snapshot: BlockSnapshot,
doc: Doc,
doc: Blocks,
parent?: string,
index?: number
): Promise<BlockModel | null> {

View File

@@ -1,6 +1,6 @@
import type { Slot } from '@blocksuite/global/utils';
import type { Doc } from '../store/index.js';
import type { Blocks } from '../store/index.js';
import type { AssetsManager } from './assets.js';
import type { DraftModel } from './draft.js';
import type { Slice } from './slice.js';
@@ -38,7 +38,7 @@ export type BeforeExportPayload =
type: 'block';
}
| {
page: Doc;
page: Blocks;
type: 'page';
}
| {
@@ -60,7 +60,7 @@ export type FinalPayload =
| {
snapshot: DocSnapshot;
type: 'page';
page: Doc;
page: Blocks;
}
| {
snapshot: SliceSnapshot;

View File

@@ -1,4 +1,4 @@
import type { Doc } from '../store/index.js';
import type { Blocks } from '../store/index.js';
import type { DraftModel } from './draft.js';
type SliceData = {
@@ -22,7 +22,7 @@ export class Slice {
constructor(readonly data: SliceData) {}
static fromModels(doc: Doc, models: DraftModel[]) {
static fromModels(doc: Blocks, models: DraftModel[]) {
return new Slice({
content: models,
workspaceId: doc.collection.id,

View File

@@ -1,6 +1,6 @@
import { z } from 'zod';
import type { Doc } from '../store/doc/doc.js';
import type { Blocks } from '../store/doc/doc.js';
import type { DocMeta, DocsPropertiesMeta } from '../store/workspace.js';
export type BlockSnapshot = {
@@ -75,7 +75,7 @@ export interface BlobCRUD {
}
export interface DocCRUD {
create: (id: string) => Doc;
get: (id: string) => Doc | null;
create: (id: string) => Blocks;
get: (id: string) => Blocks | null;
delete: (id: string) => void;
}