From e2de0e0e3dfecb473c1113094973006bebb2e9c2 Mon Sep 17 00:00:00 2001 From: congzhou09 Date: Wed, 22 Oct 2025 00:51:03 +0800 Subject: [PATCH] fix(editor): add trash state for linked-doc and synced-doc appearance (#13767) This PR updates the appearance of `embed-linked-doc-block` and `embed-synced-doc-block` to reflect the trashed state of their linked documents. Previously, these blocks showed no visual difference whether the linked document was trashed or not, despite the existing of codes for deletion-related appearance. This change ensures that the deletion appearance is properly displayed. ![after](https://github.com/user-attachments/assets/fe2d66d9-6685-4d15-95aa-0680111bc190) ## Summary by CodeRabbit * **New Features** * Documents now support trash state tracking for improved deletion management * **Bug Fixes** * Improved synchronization and refresh of embedded documents when document states change * Enhanced handling of trashed documents in embedded content --- .../embed-linked-doc-block.ts | 15 +++++++++------ .../embed-synced-doc-block.ts | 16 +++++++++++----- .../src/extension/workspace/workspace-meta.ts | 1 + 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/embed-linked-doc-block.ts b/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/embed-linked-doc-block.ts index d07627d924..a50dcdae0d 100644 --- a/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/embed-linked-doc-block.ts +++ b/blocksuite/affine/blocks/embed-doc/src/embed-linked-doc-block/embed-linked-doc-block.ts @@ -323,7 +323,8 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent { const linkedDoc = this.linkedDoc; - const isDeleted = !linkedDoc; + const trash = linkedDoc?.meta?.trash; + const isDeleted = trash || !linkedDoc; const isLoading = this._loading; const isError = this.isError; const isEmpty = this._isDocEmpty() && this.isBannerEmpty; @@ -521,11 +522,6 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent { - this._setDocUpdatedAt(); - }) - ); if (this._referenceToNode) { this._linkedDocMode = this.model.props.params?.mode ?? 'page'; @@ -554,6 +550,13 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent { + this._setDocUpdatedAt(); + this.refreshData(); + }) + ); + this._trackCitationDeleteEvent(); } diff --git a/blocksuite/affine/blocks/embed-doc/src/embed-synced-doc-block/embed-synced-doc-block.ts b/blocksuite/affine/blocks/embed-doc/src/embed-synced-doc-block/embed-synced-doc-block.ts index e52f4dbea2..7560dc564f 100644 --- a/blocksuite/affine/blocks/embed-doc/src/embed-synced-doc-block/embed-synced-doc-block.ts +++ b/blocksuite/affine/blocks/embed-doc/src/embed-synced-doc-block/embed-synced-doc-block.ts @@ -357,10 +357,14 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent { - this._load().catch(e => { - console.error(e); - this._error = true; - }); + this._load() + .then(() => { + this._isEmptySyncedDoc = isEmptyDoc(this.syncedDoc, this.editorMode); + }) + .catch(e => { + console.error(e); + this._error = true; + }); }; title$ = computed(() => { @@ -445,7 +449,8 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent { this._setDocUpdatedAt(); + this.refreshData(); }) ); diff --git a/blocksuite/framework/store/src/extension/workspace/workspace-meta.ts b/blocksuite/framework/store/src/extension/workspace/workspace-meta.ts index f0507ad552..54b4765be9 100644 --- a/blocksuite/framework/store/src/extension/workspace/workspace-meta.ts +++ b/blocksuite/framework/store/src/extension/workspace/workspace-meta.ts @@ -17,6 +17,7 @@ export interface DocMeta { createDate: number; updatedDate?: number; favorite?: boolean; + trash?: boolean; } export interface WorkspaceMeta {