mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-22 00:37:05 +08:00
refactor(editor): should not rely on doc collection type (#9501)
This commit is contained in:
@@ -53,7 +53,7 @@ todoMeta.addProperty({
|
||||
metaConfig: propertyPresets.textPropertyConfig,
|
||||
get: block => block.doc.meta?.title ?? '',
|
||||
updated: (block, callback) => {
|
||||
return block.doc.collection.meta.docMetaUpdated.on(() => {
|
||||
return block.doc.collection.slots.docListUpdated.on(() => {
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -295,7 +295,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
||||
const linkedDoc = this.linkedDoc;
|
||||
if (linkedDoc) {
|
||||
this.disposables.add(
|
||||
linkedDoc.collection.meta.docMetaUpdated.on(() => {
|
||||
linkedDoc.collection.slots.docListUpdated.on(() => {
|
||||
this._load().catch(e => {
|
||||
console.error(e);
|
||||
this.isError = true;
|
||||
@@ -328,7 +328,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
||||
|
||||
this._setDocUpdatedAt();
|
||||
this.disposables.add(
|
||||
this.doc.collection.meta.docMetaUpdated.on(() => {
|
||||
this.doc.collection.slots.docListUpdated.on(() => {
|
||||
this._setDocUpdatedAt();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -100,7 +100,7 @@ export class EmbedSyncedDocCard extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
|
||||
this.disposables.add(
|
||||
syncedDoc.collection.meta.docMetaUpdated.on(() => {
|
||||
syncedDoc.collection.slots.docListUpdated.on(() => {
|
||||
renderLinkedDocInCard(this);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -475,7 +475,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
|
||||
|
||||
this._setDocUpdatedAt();
|
||||
this.disposables.add(
|
||||
this.doc.collection.meta.docMetaUpdated.on(() => {
|
||||
this.doc.collection.slots.docListUpdated.on(() => {
|
||||
this._setDocUpdatedAt();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -221,7 +221,7 @@ export class AffineReference extends WithDisposable(ShadowlessElement) {
|
||||
const doc = this.doc;
|
||||
if (doc) {
|
||||
this._disposables.add(
|
||||
doc.collection.slots.docUpdated.on(() => this._updateRefMeta(doc))
|
||||
doc.collection.slots.docListUpdated.on(() => this._updateRefMeta(doc))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ export type Attachment = File[];
|
||||
type AttachmentToSliceSnapshotPayload = {
|
||||
file: Attachment;
|
||||
assets?: AssetsManager;
|
||||
blockVersions: Record<string, number>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,6 @@ export type Html = string;
|
||||
type HtmlToSliceSnapshotPayload = {
|
||||
file: Html;
|
||||
assets?: AssetsManager;
|
||||
blockVersions: Record<string, number>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
};
|
||||
|
||||
@@ -26,7 +26,6 @@ export type Image = File[];
|
||||
type ImageToSliceSnapshotPayload = {
|
||||
file: Image;
|
||||
assets?: AssetsManager;
|
||||
blockVersions: Record<string, number>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,6 @@ export type NotionHtml = string;
|
||||
type NotionHtmlToSliceSnapshotPayload = {
|
||||
file: NotionHtml;
|
||||
assets?: AssetsManager;
|
||||
blockVersions: Record<string, number>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
};
|
||||
|
||||
@@ -40,7 +40,6 @@ export type PlainText = string;
|
||||
type PlainTextToSliceSnapshotPayload = {
|
||||
file: PlainText;
|
||||
assets?: AssetsManager;
|
||||
blockVersions: Record<string, number>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
};
|
||||
|
||||
@@ -162,7 +162,7 @@ export class DocDisplayMetaService
|
||||
if (!title$) {
|
||||
title$ = signal(doc.meta?.title || 'Untitled');
|
||||
|
||||
const disposable = this.std.collection.meta.docMetaUpdated.on(() => {
|
||||
const disposable = this.std.collection.slots.docListUpdated.on(() => {
|
||||
title$!.value = doc.meta?.title || 'Untitled';
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { DocCollection } from '@blocksuite/store';
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
|
||||
export function createDefaultDoc(
|
||||
collection: DocCollection,
|
||||
collection: Workspace,
|
||||
options: { id?: string; title?: string } = {}
|
||||
) {
|
||||
const doc = collection.createDoc({ id: options.id });
|
||||
|
||||
@@ -31,7 +31,6 @@ export type MixText = string;
|
||||
type MixTextToSliceSnapshotPayload = {
|
||||
file: MixText;
|
||||
assets?: AssetsManager;
|
||||
blockVersions: Record<string, number>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { HtmlAdapter } from '@blocksuite/affine-shared/adapters';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
import { sha } from '@blocksuite/global/utils';
|
||||
import type { Doc, DocCollection } from '@blocksuite/store';
|
||||
import type { Doc, Workspace } from '@blocksuite/store';
|
||||
import { extMimeMap, Job } from '@blocksuite/store';
|
||||
|
||||
import { defaultBlockHtmlAdapterMatchers } from '../adapters/html/block-matcher.js';
|
||||
@@ -16,13 +16,13 @@ import {
|
||||
import { createAssetsArchive, download, Unzip } from './utils.js';
|
||||
|
||||
type ImportHTMLToDocOptions = {
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
html: string;
|
||||
fileName?: string;
|
||||
};
|
||||
|
||||
type ImportHTMLZipOptions = {
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
imported: Blob;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { MarkdownAdapter } from '@blocksuite/affine-shared/adapters';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { assertExists, sha } from '@blocksuite/global/utils';
|
||||
import type { Doc, DocCollection } from '@blocksuite/store';
|
||||
import type { Doc, Workspace } from '@blocksuite/store';
|
||||
import { extMimeMap, Job } from '@blocksuite/store';
|
||||
|
||||
import { defaultBlockMarkdownAdapterMatchers } from '../adapters/index.js';
|
||||
@@ -34,13 +34,13 @@ type ImportMarkdownToBlockOptions = {
|
||||
};
|
||||
|
||||
type ImportMarkdownToDocOptions = {
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
markdown: string;
|
||||
fileName?: string;
|
||||
};
|
||||
|
||||
type ImportMarkdownZipOptions = {
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
imported: Blob;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters';
|
||||
import { Container } from '@blocksuite/global/di';
|
||||
import { sha } from '@blocksuite/global/utils';
|
||||
import { type DocCollection, extMimeMap, Job } from '@blocksuite/store';
|
||||
import { extMimeMap, Job, type Workspace } from '@blocksuite/store';
|
||||
|
||||
import { defaultBlockNotionHtmlAdapterMatchers } from '../adapters/notion-html/block-matcher.js';
|
||||
import { notionHtmlInlineToDeltaMatchers } from '../adapters/notion-html/delta-converter/html-inline.js';
|
||||
@@ -9,7 +9,7 @@ import { defaultImageProxyMiddleware } from './middlewares.js';
|
||||
import { Unzip } from './utils.js';
|
||||
|
||||
type ImportNotionZipOptions = {
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
imported: Blob;
|
||||
};
|
||||
|
||||
@@ -26,12 +26,11 @@ const provider = container.provider();
|
||||
/**
|
||||
* Imports a Notion zip file into the BlockSuite collection.
|
||||
*
|
||||
* @param {ImportNotionZipOptions} options - The options for importing.
|
||||
* @param {DocCollection} options.collection - The BlockSuite document collection.
|
||||
* @param {Blob} options.imported - The imported zip file as a Blob.
|
||||
* @param options - The options for importing.
|
||||
* @param options.collection - The BlockSuite document collection.
|
||||
* @param options.imported - The imported zip file as a Blob.
|
||||
*
|
||||
* @returns {Promise<{entryId: string | undefined, pageIds: string[], isWorkspaceFile: boolean, hasMarkdown: boolean}>}
|
||||
* A promise that resolves to an object containing:
|
||||
* @returns A promise that resolves to an object containing:
|
||||
* - entryId: The ID of the entry page (if any).
|
||||
* - pageIds: An array of imported page IDs.
|
||||
* - isWorkspaceFile: Whether the imported file is a workspace file.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { sha } from '@blocksuite/global/utils';
|
||||
import type { Doc, DocCollection, DocSnapshot } from '@blocksuite/store';
|
||||
import type { Doc, DocSnapshot, Workspace } from '@blocksuite/store';
|
||||
import { extMimeMap, getAssetName, Job } from '@blocksuite/store';
|
||||
|
||||
import { download, Unzip, Zip } from '../transformers/utils.js';
|
||||
import { replaceIdMiddleware, titleMiddleware } from './middlewares.js';
|
||||
|
||||
async function exportDocs(collection: DocCollection, docs: Doc[]) {
|
||||
async function exportDocs(collection: Workspace, docs: Doc[]) {
|
||||
const zip = new Zip();
|
||||
const job = new Job({
|
||||
schema: collection.schema,
|
||||
@@ -50,7 +50,7 @@ async function exportDocs(collection: DocCollection, docs: Doc[]) {
|
||||
return download(downloadBlob, `${collection.id}.bs.zip`);
|
||||
}
|
||||
|
||||
async function importDocs(collection: DocCollection, imported: Blob) {
|
||||
async function importDocs(collection: Workspace, imported: Blob) {
|
||||
const unzip = new Unzip();
|
||||
await unzip.load(imported);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from '@blocksuite/affine-components/icons';
|
||||
import { openFileOrFiles } from '@blocksuite/affine-shared/utils';
|
||||
import { WithDisposable } from '@blocksuite/global/utils';
|
||||
import type { DocCollection } from '@blocksuite/store';
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
import { html, LitElement, type PropertyValues } from 'lit';
|
||||
import { query, state } from 'lit/decorators.js';
|
||||
|
||||
@@ -30,7 +30,7 @@ export class ImportDoc extends WithDisposable(LitElement) {
|
||||
static override styles = styles;
|
||||
|
||||
constructor(
|
||||
private readonly collection: DocCollection,
|
||||
private readonly collection: Workspace,
|
||||
private readonly onSuccess?: OnSuccessHandler,
|
||||
private readonly onFail?: OnFailHandler,
|
||||
private readonly abortController = new AbortController()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { DocCollection } from '@blocksuite/store';
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
ImportDoc,
|
||||
@@ -13,7 +13,7 @@ export function showImportModal({
|
||||
container = document.body,
|
||||
abortController = new AbortController(),
|
||||
}: {
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
onSuccess?: OnSuccessHandler;
|
||||
onFail?: OnFailHandler;
|
||||
multiple?: boolean;
|
||||
|
||||
@@ -138,7 +138,6 @@ export class Clipboard extends LifeCycleWatcher {
|
||||
const payload = {
|
||||
file: item,
|
||||
assets: job.assetsManager,
|
||||
blockVersions: doc.collection.meta.blockVersions,
|
||||
workspaceId: doc.collection.id,
|
||||
pageId: doc.id,
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import { applyUpdate, encodeStateAsUpdate } from 'yjs';
|
||||
import { COLLECTION_VERSION, PAGE_VERSION } from '../consts.js';
|
||||
import type { BlockModel, BlockSchemaType, Doc } from '../index.js';
|
||||
import { DocCollection, IdGeneratorType, Schema } from '../index.js';
|
||||
import type { DocMeta } from '../store/index.js';
|
||||
import type { DocMeta } from '../store/workspace.js';
|
||||
import type { BlockSuiteDoc } from '../yjs/index.js';
|
||||
import {
|
||||
NoteBlockSchema,
|
||||
@@ -432,7 +432,7 @@ describe('addBlock', () => {
|
||||
);
|
||||
|
||||
let called = false;
|
||||
collection.meta.docMetaUpdated.on(() => {
|
||||
collection.slots.docListUpdated.on(() => {
|
||||
called = true;
|
||||
});
|
||||
|
||||
|
||||
@@ -22,11 +22,16 @@ import {
|
||||
BlockSuiteDoc,
|
||||
type RawAwarenessState,
|
||||
} from '../yjs/index.js';
|
||||
import { BlockCollection, type GetDocOptions } from './doc/block-collection.js';
|
||||
import type { Doc, Query } from './doc/index.js';
|
||||
import { BlockCollection } from './doc/block-collection.js';
|
||||
import type { Doc } from './doc/index.js';
|
||||
import type { IdGeneratorType } from './id.js';
|
||||
import { pickIdGenerator } from './id.js';
|
||||
import { DocCollectionMeta } from './meta.js';
|
||||
import type {
|
||||
CreateDocOptions,
|
||||
GetDocOptions,
|
||||
Workspace,
|
||||
} from './workspace.js';
|
||||
|
||||
export type DocCollectionOptions = {
|
||||
schema: Schema;
|
||||
@@ -69,7 +74,7 @@ export interface StackItem {
|
||||
meta: Map<'cursor-location' | 'selection-state', unknown>;
|
||||
}
|
||||
|
||||
export class DocCollection {
|
||||
export class DocCollection implements Workspace {
|
||||
protected readonly _schema: Schema;
|
||||
|
||||
readonly awarenessStore: AwarenessStore;
|
||||
@@ -91,7 +96,7 @@ export class DocCollection {
|
||||
meta: DocCollectionMeta;
|
||||
|
||||
slots = {
|
||||
docUpdated: new Slot(),
|
||||
docListUpdated: new Slot(),
|
||||
docRemoved: new Slot<string>(),
|
||||
docCreated: new Slot<string>(),
|
||||
};
|
||||
@@ -161,7 +166,7 @@ export class DocCollection {
|
||||
this.blockCollections.set(doc.id, doc);
|
||||
});
|
||||
|
||||
this.meta.docMetaUpdated.on(() => this.slots.docUpdated.emit());
|
||||
this.meta.docMetaUpdated.on(() => this.slots.docListUpdated.emit());
|
||||
|
||||
this.meta.docMetaRemoved.on(id => {
|
||||
const space = this.getBlockCollection(id);
|
||||
@@ -189,8 +194,8 @@ export class DocCollection {
|
||||
* If the `init` parameter is passed, a `surface`, `note`, and `paragraph` block
|
||||
* will be created in the doc simultaneously.
|
||||
*/
|
||||
createDoc(options: { id?: string; query?: Query } = {}) {
|
||||
const { id: docId = this.idGenerator(), query } = options;
|
||||
createDoc(options: CreateDocOptions = {}) {
|
||||
const { id: docId = this.idGenerator(), query, readonly } = options;
|
||||
if (this._hasDoc(docId)) {
|
||||
throw new BlockSuiteError(
|
||||
ErrorCode.DocCollectionError,
|
||||
@@ -205,7 +210,7 @@ export class DocCollection {
|
||||
tags: [],
|
||||
});
|
||||
this.slots.docCreated.emit(docId);
|
||||
return this.getDoc(docId, { query }) as Doc;
|
||||
return this.getDoc(docId, { query, readonly }) as Doc;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Text } from '../../reactive/text.js';
|
||||
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 { DocCollection } from '../collection.js';
|
||||
import type { GetDocOptions, Workspace } from '../workspace.js';
|
||||
import { Doc } from './doc.js';
|
||||
import type { YBlock } from './index.js';
|
||||
import type { Query } from './query.js';
|
||||
@@ -24,17 +24,12 @@ export type BlockProps = BlockSysProps & Record<string, unknown>;
|
||||
|
||||
type DocOptions = {
|
||||
id: string;
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
doc: BlockSuiteDoc;
|
||||
awarenessStore: AwarenessStore;
|
||||
idGenerator?: IdGenerator;
|
||||
};
|
||||
|
||||
export type GetDocOptions = {
|
||||
query?: Query;
|
||||
readonly?: boolean;
|
||||
};
|
||||
|
||||
export class BlockCollection {
|
||||
private _awarenessUpdateDisposable: Disposable | null = null;
|
||||
|
||||
@@ -42,7 +37,7 @@ export class BlockCollection {
|
||||
|
||||
private readonly _canUndo$ = signal(false);
|
||||
|
||||
private readonly _collection: DocCollection;
|
||||
private readonly _collection: Workspace;
|
||||
|
||||
private readonly _docMap = {
|
||||
undefined: new Map<string, Doc>(),
|
||||
@@ -145,11 +140,6 @@ export class BlockCollection {
|
||||
>(),
|
||||
};
|
||||
|
||||
// So, we apply a listener at the top level for the flat structure of the current
|
||||
get awarenessSync() {
|
||||
return this.collection.awarenessSync;
|
||||
}
|
||||
|
||||
get blobSync() {
|
||||
return this.collection.blobSync;
|
||||
}
|
||||
|
||||
@@ -4,3 +4,4 @@ export type * from './doc/block-collection.js';
|
||||
export * from './doc/index.js';
|
||||
export * from './id.js';
|
||||
export type * from './meta.js';
|
||||
export * from './workspace.js';
|
||||
|
||||
@@ -4,26 +4,12 @@ import type * as Y from 'yjs';
|
||||
import { COLLECTION_VERSION, PAGE_VERSION } from '../consts.js';
|
||||
import type { BlockSuiteDoc } from '../yjs/index.js';
|
||||
import type { DocCollection } from './collection.js';
|
||||
import type {
|
||||
DocMeta,
|
||||
DocsPropertiesMeta,
|
||||
WorkspaceMeta,
|
||||
} from './workspace.js';
|
||||
|
||||
// please use `declare module '@blocksuite/store'` to extend this interface
|
||||
export interface DocMeta {
|
||||
id: string;
|
||||
title: string;
|
||||
tags: string[];
|
||||
createDate: number;
|
||||
updatedDate?: number;
|
||||
}
|
||||
|
||||
export type Tag = {
|
||||
id: string;
|
||||
value: string;
|
||||
color: string;
|
||||
};
|
||||
export type DocsPropertiesMeta = {
|
||||
tags?: {
|
||||
options: Tag[];
|
||||
};
|
||||
};
|
||||
export type DocCollectionMetaState = {
|
||||
pages?: unknown[];
|
||||
properties?: DocsPropertiesMeta;
|
||||
@@ -34,7 +20,7 @@ export type DocCollectionMetaState = {
|
||||
avatar?: string;
|
||||
};
|
||||
|
||||
export class DocCollectionMeta {
|
||||
export class DocCollectionMeta implements WorkspaceMeta {
|
||||
private readonly _handleDocCollectionMetaEvents = (
|
||||
events: Y.YEvent<Y.Array<unknown> | Y.Text | Y.Map<unknown>>[]
|
||||
) => {
|
||||
|
||||
86
blocksuite/framework/store/src/store/workspace.ts
Normal file
86
blocksuite/framework/store/src/store/workspace.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import type { Slot } from '@blocksuite/global/utils';
|
||||
import type { BlobEngine, DocEngine } from '@blocksuite/sync';
|
||||
|
||||
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 { BlockCollection } from './doc/index.js';
|
||||
import type { Query } from './doc/query.js';
|
||||
|
||||
export type Tag = {
|
||||
id: string;
|
||||
value: string;
|
||||
color: string;
|
||||
};
|
||||
export type DocsPropertiesMeta = {
|
||||
tags?: {
|
||||
options: Tag[];
|
||||
};
|
||||
};
|
||||
export interface DocMeta {
|
||||
id: string;
|
||||
title: string;
|
||||
tags: string[];
|
||||
createDate: number;
|
||||
updatedDate?: number;
|
||||
favorite?: boolean;
|
||||
}
|
||||
|
||||
export type GetDocOptions = {
|
||||
query?: Query;
|
||||
readonly?: boolean;
|
||||
};
|
||||
export type CreateDocOptions = GetDocOptions & {
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export interface WorkspaceMeta {
|
||||
get docMetas(): DocMeta[];
|
||||
|
||||
getDocMeta(id: string): DocMeta | undefined;
|
||||
setDocMeta(id: string, props: Partial<DocMeta>): void;
|
||||
removeDocMeta(id: string): void;
|
||||
|
||||
get properties(): DocsPropertiesMeta;
|
||||
setProperties(meta: DocsPropertiesMeta): void;
|
||||
|
||||
get avatar(): string | undefined;
|
||||
setAvatar(avatar: string): void;
|
||||
|
||||
get name(): string | undefined;
|
||||
setName(name: string): void;
|
||||
|
||||
commonFieldsUpdated: Slot;
|
||||
|
||||
hasVersion: boolean;
|
||||
writeVersion(workspace: Workspace): void;
|
||||
get docs(): unknown[] | undefined;
|
||||
initialize(): void;
|
||||
}
|
||||
|
||||
export interface Workspace {
|
||||
readonly id: string;
|
||||
readonly meta: WorkspaceMeta;
|
||||
readonly idGenerator: IdGenerator;
|
||||
readonly docSync: DocEngine;
|
||||
readonly blobSync: BlobEngine;
|
||||
readonly awarenessStore: AwarenessStore;
|
||||
|
||||
get schema(): Schema;
|
||||
get doc(): BlockSuiteDoc;
|
||||
get docs(): Map<string, BlockCollection>;
|
||||
|
||||
slots: {
|
||||
docListUpdated: Slot;
|
||||
docCreated: Slot<string>;
|
||||
docRemoved: Slot<string>;
|
||||
};
|
||||
|
||||
createDoc(options?: CreateDocOptions): Doc;
|
||||
getDoc(docId: string, options?: GetDocOptions): Doc | null;
|
||||
removeDoc(docId: string): void;
|
||||
|
||||
dispose(): void;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { Doc } from '../store/doc/doc.js';
|
||||
import type { DocMeta, DocsPropertiesMeta } from '../store/meta.js';
|
||||
import type { DocMeta, DocsPropertiesMeta } from '../store/workspace.js';
|
||||
|
||||
export type BlockSnapshot = {
|
||||
type: 'block';
|
||||
|
||||
@@ -110,7 +110,7 @@ export class DocsPanel extends WithDisposable(ShadowlessElement) {
|
||||
});
|
||||
|
||||
this.disposables.add(
|
||||
this.editor.doc.collection.slots.docUpdated.on(() => {
|
||||
this.editor.doc.collection.slots.docListUpdated.on(() => {
|
||||
this.requestUpdate();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { replaceIdMiddleware } from '@blocksuite/blocks';
|
||||
import { type DocCollection, type DocSnapshot, Job } from '@blocksuite/store';
|
||||
import { type DocSnapshot, Job, type Workspace } from '@blocksuite/store';
|
||||
|
||||
export async function importFromSnapshot(
|
||||
collection: DocCollection,
|
||||
collection: Workspace,
|
||||
snapshot: DocSnapshot
|
||||
) {
|
||||
const job = new Job({
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
} from '@blocksuite/block-std';
|
||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import type { StarterDebugMenu } from '@playground/apps/_common/components/starter-debug-menu.js';
|
||||
import type { BlockModel, Doc, DocCollection, Job } from '@store/index.js';
|
||||
import type { BlockModel, Doc, Job, Workspace } from '@store/index.js';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -36,7 +36,7 @@ declare global {
|
||||
mockDocModeService: typeof import('../../packages/playground/apps/_common/mock-services.js').mockDocModeService;
|
||||
};
|
||||
};
|
||||
collection: DocCollection;
|
||||
collection: Workspace;
|
||||
blockSchema: Record<string, typeof BlockModel>;
|
||||
doc: Doc;
|
||||
debugMenu: StarterDebugMenu;
|
||||
|
||||
Reference in New Issue
Block a user