refactor(editor): should not rely on doc collection type (#9501)

This commit is contained in:
Saul-Mirone
2025-01-03 06:30:27 +00:00
parent cb5d7eaabc
commit 897c7d4284
55 changed files with 200 additions and 158 deletions
@@ -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 });