mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor(editor): rename doc to blocks (#9510)
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user