mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor(editor): rename doc to blocks (#9510)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
|
||||
import type { Doc } from '@blocksuite/store';
|
||||
import type { Blocks } from '@blocksuite/store';
|
||||
import { html } from 'lit';
|
||||
import { customElement, property } from 'lit/decorators.js';
|
||||
|
||||
@@ -32,7 +32,7 @@ export class TestEditorContainer extends SignalWatcher(
|
||||
}
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor doc!: Doc;
|
||||
accessor doc!: Blocks;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor specs: ExtensionType[] = [];
|
||||
|
||||
@@ -2,8 +2,8 @@ import type { ServiceProvider } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import type {
|
||||
BaseAdapter,
|
||||
Blocks,
|
||||
BlockSnapshot,
|
||||
Doc,
|
||||
Job,
|
||||
JobMiddleware,
|
||||
Slice,
|
||||
@@ -110,7 +110,7 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
|
||||
private readonly _getSnapshotByPriority = async (
|
||||
getItem: (type: string) => string | File[],
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
parent?: string,
|
||||
index?: number
|
||||
) => {
|
||||
@@ -182,7 +182,7 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
|
||||
duplicateSlice = async (
|
||||
slice: Slice,
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
parent?: string,
|
||||
index?: number,
|
||||
type = 'BLOCKSUITE/SNAPSHOT'
|
||||
@@ -201,7 +201,7 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
|
||||
paste = async (
|
||||
event: ClipboardEvent,
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
parent?: string,
|
||||
index?: number
|
||||
) => {
|
||||
@@ -238,7 +238,7 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
|
||||
pasteBlockSnapshot = async (
|
||||
snapshot: BlockSnapshot,
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
parent?: string,
|
||||
index?: number
|
||||
) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
getBoundWithRotation,
|
||||
intersects,
|
||||
} from '@blocksuite/global/utils';
|
||||
import type { BlockModel, Doc } from '@blocksuite/store';
|
||||
import type { BlockModel, Blocks } from '@blocksuite/store';
|
||||
|
||||
import { compare } from '../utils/layer.js';
|
||||
import { GfxBlockElementModel } from './model/gfx-block-model.js';
|
||||
@@ -361,7 +361,7 @@ export class GridManager {
|
||||
this.add(element);
|
||||
}
|
||||
|
||||
watch(blocks: { doc?: Doc; surface?: SurfaceBlockModel | null }) {
|
||||
watch(blocks: { doc?: Blocks; surface?: SurfaceBlockModel | null }) {
|
||||
const disposables: { dispose: () => void }[] = [];
|
||||
const { doc, surface } = blocks;
|
||||
const isRenderableBlock = (
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
last,
|
||||
Slot,
|
||||
} from '@blocksuite/global/utils';
|
||||
import type { Doc } from '@blocksuite/store';
|
||||
import type { Blocks } from '@blocksuite/store';
|
||||
import { generateKeyBetween } from 'fractional-indexing';
|
||||
|
||||
import {
|
||||
@@ -100,7 +100,7 @@ export class LayerManager {
|
||||
};
|
||||
|
||||
constructor(
|
||||
private readonly _doc: Doc,
|
||||
private readonly _doc: Blocks,
|
||||
private _surface: SurfaceBlockModel | null,
|
||||
options: {
|
||||
watch: boolean;
|
||||
@@ -775,7 +775,7 @@ export class LayerManager {
|
||||
}
|
||||
}
|
||||
|
||||
watch(blocks: { doc?: Doc; surface: SurfaceBlockModel | null }) {
|
||||
watch(blocks: { doc?: Blocks; surface: SurfaceBlockModel | null }) {
|
||||
const { doc, surface } = blocks;
|
||||
|
||||
if (doc) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ServiceProvider } from '@blocksuite/global/di';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { type Doc, Job, type JobMiddleware } from '@blocksuite/store';
|
||||
import { type Blocks, Job, type JobMiddleware } from '@blocksuite/store';
|
||||
|
||||
import { Clipboard } from '../clipboard/index.js';
|
||||
import { CommandManager } from '../command/index.js';
|
||||
@@ -31,7 +31,7 @@ import { EditorHost } from '../view/element/index.js';
|
||||
import { ViewStore } from '../view/view-store.js';
|
||||
|
||||
export interface BlockStdOptions {
|
||||
doc: Doc;
|
||||
doc: Blocks;
|
||||
extensions: ExtensionType[];
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class BlockStdScope {
|
||||
|
||||
readonly container: Container;
|
||||
|
||||
readonly doc: Doc;
|
||||
readonly doc: Blocks;
|
||||
|
||||
readonly provider: ServiceProvider;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { Doc } from '@blocksuite/store';
|
||||
import type { Blocks } from '@blocksuite/store';
|
||||
import { effect } from '@preact/signals-core';
|
||||
|
||||
import { SurfaceBlockModel } from '../gfx/model/surface/surface-model.js';
|
||||
|
||||
export function onSurfaceAdded(
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
callback: (model: SurfaceBlockModel | null) => void
|
||||
) {
|
||||
let found = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { nToLast } from '@blocksuite/global/utils';
|
||||
import type { Doc } from '@blocksuite/store';
|
||||
import type { Blocks } from '@blocksuite/store';
|
||||
|
||||
import type { GfxLocalElementModel } from '../gfx/index.js';
|
||||
import type { Layer } from '../gfx/layer.js';
|
||||
@@ -82,7 +82,7 @@ export function isInRange(edges: [GfxModel, GfxModel], target: GfxModel) {
|
||||
}
|
||||
|
||||
export function renderableInEdgeless(
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
surface: SurfaceBlockModel,
|
||||
block: GfxBlockElementModel
|
||||
) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Doc } from '@blocksuite/store';
|
||||
import type { Blocks } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
type GfxCompatibleInterface,
|
||||
@@ -124,13 +124,16 @@ export function isLockedImpl(element: GfxCompatibleInterface): boolean {
|
||||
return isLockedBySelfImpl(element) || isLockedByAncestorImpl(element);
|
||||
}
|
||||
|
||||
export function lockElementImpl(doc: Doc, element: GfxCompatibleInterface) {
|
||||
export function lockElementImpl(doc: Blocks, element: GfxCompatibleInterface) {
|
||||
doc.transact(() => {
|
||||
element.lockedBySelf = true;
|
||||
});
|
||||
}
|
||||
|
||||
export function unlockElementImpl(doc: Doc, element: GfxCompatibleInterface) {
|
||||
export function unlockElementImpl(
|
||||
doc: Blocks,
|
||||
element: GfxCompatibleInterface
|
||||
) {
|
||||
doc.transact(() => {
|
||||
element.lockedBySelf = false;
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
|
||||
import { type BlockModel, BlockViewType, Doc } from '@blocksuite/store';
|
||||
import { type BlockModel, Blocks, BlockViewType } from '@blocksuite/store';
|
||||
import { consume, provide } from '@lit/context';
|
||||
import { computed } from '@preact/signals-core';
|
||||
import { nothing, type TemplateResult } from 'lit';
|
||||
@@ -23,7 +23,7 @@ import { ShadowlessElement } from './shadowless-element.js';
|
||||
import type { WidgetComponent } from './widget-component.js';
|
||||
|
||||
@requiredProperties({
|
||||
doc: PropTypes.instanceOf(Doc),
|
||||
doc: PropTypes.instanceOf(Blocks),
|
||||
std: PropTypes.object,
|
||||
widgets: PropTypes.recordOf(PropTypes.object),
|
||||
})
|
||||
@@ -307,7 +307,7 @@ export class BlockComponent<
|
||||
private accessor _service: Service | null = null;
|
||||
|
||||
@consume({ context: docContext })
|
||||
accessor doc!: Doc;
|
||||
accessor doc!: Blocks;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor viewType: BlockViewType = BlockViewType.Display;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
handleError,
|
||||
} from '@blocksuite/global/exceptions';
|
||||
import { SignalWatcher, Slot, WithDisposable } from '@blocksuite/global/utils';
|
||||
import { type BlockModel, BlockViewType, Doc } from '@blocksuite/store';
|
||||
import { type BlockModel, Blocks, BlockViewType } from '@blocksuite/store';
|
||||
import { createContext, provide } from '@lit/context';
|
||||
import { css, LitElement, nothing, type TemplateResult } from 'lit';
|
||||
import { property } from 'lit/decorators.js';
|
||||
@@ -22,11 +22,11 @@ import type { ViewStore } from '../view-store.js';
|
||||
import { BLOCK_ID_ATTR, WIDGET_ID_ATTR } from './consts.js';
|
||||
import { ShadowlessElement } from './shadowless-element.js';
|
||||
|
||||
export const docContext = createContext<Doc>('doc');
|
||||
export const docContext = createContext<Blocks>('doc');
|
||||
export const stdContext = createContext<BlockStdScope>('std');
|
||||
|
||||
@requiredProperties({
|
||||
doc: PropTypes.instanceOf(Doc),
|
||||
doc: PropTypes.instanceOf(Blocks),
|
||||
std: PropTypes.object,
|
||||
})
|
||||
export class EditorHost extends SignalWatcher(
|
||||
@@ -189,7 +189,7 @@ export class EditorHost extends SignalWatcher(
|
||||
|
||||
@provide({ context: docContext })
|
||||
@property({ attribute: false })
|
||||
accessor doc!: Doc;
|
||||
accessor doc!: Blocks;
|
||||
|
||||
@provide({ context: stdContext })
|
||||
@property({ attribute: false })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
|
||||
import type { BlockModel, Doc } from '@blocksuite/store';
|
||||
import type { BlockModel, Blocks } from '@blocksuite/store';
|
||||
import { consume } from '@lit/context';
|
||||
import { LitElement } from 'lit';
|
||||
|
||||
@@ -94,7 +94,7 @@ export class WidgetComponent<
|
||||
}
|
||||
|
||||
@consume({ context: docContext })
|
||||
private accessor _doc!: Doc;
|
||||
private accessor _doc!: Blocks;
|
||||
|
||||
@consume({ context: modelContext })
|
||||
private accessor _model!: Model;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { assert, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { applyUpdate, encodeStateAsUpdate } from 'yjs';
|
||||
|
||||
import { COLLECTION_VERSION, PAGE_VERSION } from '../consts.js';
|
||||
import type { BlockModel, BlockSchemaType, Doc } from '../index.js';
|
||||
import type { BlockModel, Blocks, BlockSchemaType } from '../index.js';
|
||||
import { Schema } from '../index.js';
|
||||
import type { DocMeta } from '../store/workspace.js';
|
||||
import { TestWorkspace } from '../test/test-workspace.js';
|
||||
@@ -54,7 +54,7 @@ function waitOnce<T>(slot: Slot<T>) {
|
||||
return new Promise<T>(resolve => slot.once(val => resolve(val)));
|
||||
}
|
||||
|
||||
function createRoot(doc: Doc) {
|
||||
function createRoot(doc: Blocks) {
|
||||
doc.addBlock('affine:page');
|
||||
if (!doc.root) throw new Error('root not found');
|
||||
return doc.root;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BlockSuiteError } from '@blocksuite/global/exceptions';
|
||||
|
||||
import type { Doc } from '../store/index.js';
|
||||
import type { Blocks } from '../store/index.js';
|
||||
import type { AssetsManager } from '../transformer/assets.js';
|
||||
import type { DraftModel, Job, Slice } from '../transformer/index.js';
|
||||
import type {
|
||||
@@ -93,7 +93,7 @@ export abstract class BaseAdapter<AdapterTarget = unknown> {
|
||||
| Promise<FromBlockSnapshotResult<AdapterTarget>>
|
||||
| FromBlockSnapshotResult<AdapterTarget>;
|
||||
|
||||
async fromDoc(doc: Doc) {
|
||||
async fromDoc(doc: Blocks) {
|
||||
try {
|
||||
const docSnapshot = this.job.docToSnapshot(doc);
|
||||
if (!docSnapshot) return;
|
||||
@@ -138,7 +138,7 @@ export abstract class BaseAdapter<AdapterTarget = unknown> {
|
||||
|
||||
async toBlock(
|
||||
payload: ToBlockSnapshotPayload<AdapterTarget>,
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
parent?: string,
|
||||
index?: number
|
||||
) {
|
||||
@@ -175,7 +175,7 @@ export abstract class BaseAdapter<AdapterTarget = unknown> {
|
||||
|
||||
async toSlice(
|
||||
payload: ToSliceSnapshotPayload<AdapterTarget>,
|
||||
doc: Doc,
|
||||
doc: Blocks,
|
||||
parent?: string,
|
||||
index?: number
|
||||
) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
||||
import { Boxed } from '../reactive/boxed.js';
|
||||
import { Text } from '../reactive/text.js';
|
||||
import type { YBlock } from '../store/doc/block/index.js';
|
||||
import type { Doc } from '../store/index.js';
|
||||
import type { Blocks } from '../store/index.js';
|
||||
import type { BaseBlockTransformer } from '../transformer/base.js';
|
||||
|
||||
const FlavourSchema = z.string();
|
||||
@@ -160,7 +160,7 @@ export class BlockModel<
|
||||
/**
|
||||
* @deprecated use doc instead
|
||||
*/
|
||||
page!: Doc;
|
||||
page!: Blocks;
|
||||
|
||||
private readonly _childModels = computed(() => {
|
||||
const value: BlockModel[] = [];
|
||||
@@ -224,7 +224,7 @@ export class BlockModel<
|
||||
return this.page;
|
||||
}
|
||||
|
||||
set doc(doc: Doc) {
|
||||
set doc(doc: Blocks) {
|
||||
this.page = doc;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { BlockModel } from '../../schema/base.js';
|
||||
import type { IdGenerator } from '../../utils/id-generator.js';
|
||||
import type { AwarenessStore, BlockSuiteDoc } from '../../yjs/index.js';
|
||||
import type { GetDocOptions, Workspace } from '../workspace.js';
|
||||
import { Doc } from './doc.js';
|
||||
import { Blocks } from './doc.js';
|
||||
import type { YBlock } from './index.js';
|
||||
import type { Query } from './query.js';
|
||||
|
||||
@@ -40,9 +40,9 @@ export class BlockCollection {
|
||||
private readonly _collection: Workspace;
|
||||
|
||||
private readonly _docMap = {
|
||||
undefined: new Map<string, Doc>(),
|
||||
true: new Map<string, Doc>(),
|
||||
false: new Map<string, Doc>(),
|
||||
undefined: new Map<string, Blocks>(),
|
||||
true: new Map<string, Blocks>(),
|
||||
false: new Map<string, Blocks>(),
|
||||
};
|
||||
|
||||
// doc/space container.
|
||||
@@ -324,7 +324,7 @@ export class BlockCollection {
|
||||
return this._docMap[readonlyKey].get(key)!;
|
||||
}
|
||||
|
||||
const doc = new Doc({
|
||||
const doc = new Blocks({
|
||||
blockCollection: this,
|
||||
schema: this.collection.schema,
|
||||
readonly,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Schema } from '../../../schema/index.js';
|
||||
import { BlockViewType } from '../consts.js';
|
||||
import type { Doc } from '../doc.js';
|
||||
import type { Blocks } from '../doc.js';
|
||||
import { SyncController } from './sync-controller.js';
|
||||
import type { BlockOptions, YBlock } from './types.js';
|
||||
|
||||
@@ -38,7 +38,7 @@ export class Block {
|
||||
constructor(
|
||||
readonly schema: Schema,
|
||||
readonly yBlock: YBlock,
|
||||
readonly doc?: Doc,
|
||||
readonly doc?: Blocks,
|
||||
readonly options: BlockOptions = {}
|
||||
) {
|
||||
const onChange = !options.onChange
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from '../../../reactive/index.js';
|
||||
import { BlockModel, internalPrimitives } from '../../../schema/base.js';
|
||||
import type { Schema } from '../../../schema/schema.js';
|
||||
import type { Doc } from '../doc.js';
|
||||
import type { Blocks } from '../doc.js';
|
||||
import type { YBlock } from './types.js';
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ export class SyncController {
|
||||
constructor(
|
||||
readonly schema: Schema,
|
||||
readonly yBlock: YBlock,
|
||||
readonly doc?: Doc,
|
||||
readonly doc?: Blocks,
|
||||
readonly onChange?: (key: string, value: unknown) => void
|
||||
) {
|
||||
const { id, flavour, version, yChildren, props } = this._parseYBlock();
|
||||
|
||||
@@ -18,7 +18,7 @@ type DocOptions = {
|
||||
query?: Query;
|
||||
};
|
||||
|
||||
export class Doc {
|
||||
export class Blocks {
|
||||
private readonly _runQuery = (block: Block) => {
|
||||
runQuery(this._query, block);
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Schema } from '../schema/schema.js';
|
||||
import type { IdGenerator } from '../utils/id-generator.js';
|
||||
import type { AwarenessStore } from '../yjs/awareness.js';
|
||||
import type { BlockSuiteDoc } from '../yjs/doc.js';
|
||||
import type { Doc } from './doc/doc.js';
|
||||
import type { Blocks } from './doc/doc.js';
|
||||
import type { BlockCollection } from './doc/index.js';
|
||||
import type { Query } from './doc/query.js';
|
||||
|
||||
@@ -78,8 +78,8 @@ export interface Workspace {
|
||||
docRemoved: Slot<string>;
|
||||
};
|
||||
|
||||
createDoc(options?: CreateDocOptions): Doc;
|
||||
getDoc(docId: string, options?: GetDocOptions): Doc | null;
|
||||
createDoc(options?: CreateDocOptions): Blocks;
|
||||
getDoc(docId: string, options?: GetDocOptions): Blocks | null;
|
||||
removeDoc(docId: string): void;
|
||||
|
||||
dispose(): void;
|
||||
|
||||
@@ -18,8 +18,8 @@ import { Awareness } from 'y-protocols/awareness.js';
|
||||
import type { Schema } from '../schema/index.js';
|
||||
import {
|
||||
BlockCollection,
|
||||
type Blocks,
|
||||
type CreateDocOptions,
|
||||
type Doc,
|
||||
DocCollectionMeta,
|
||||
type GetDocOptions,
|
||||
type Workspace,
|
||||
@@ -208,7 +208,7 @@ export class TestWorkspace 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() {
|
||||
@@ -230,7 +230,7 @@ export class TestWorkspace 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;
|
||||
}
|
||||
|
||||
@@ -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