From 378bb3795d05341a63fe9c999679d3ae34a2069e Mon Sep 17 00:00:00 2001 From: donteatfriedrice Date: Mon, 24 Feb 2025 09:32:32 +0000 Subject: [PATCH] refactor(editor): use doc title and id as snapshot file name (#10397) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [BS-2549](https://linear.app/affine-design/issue/BS-2549/snap-shot-导出建议使用文档名称作为文件名,而不是一个-id) --- blocksuite/affine/block-root/src/transformers/zip.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blocksuite/affine/block-root/src/transformers/zip.ts b/blocksuite/affine/block-root/src/transformers/zip.ts index fdae392360..6db2c6c8fb 100644 --- a/blocksuite/affine/block-root/src/transformers/zip.ts +++ b/blocksuite/affine/block-root/src/transformers/zip.ts @@ -29,7 +29,10 @@ async function exportDocs(collection: Workspace, docs: Store[]) { snapshots .filter((snapshot): snapshot is DocSnapshot => !!snapshot) .map(async snapshot => { - const snapshotName = `${snapshot.meta.title || 'untitled'}.snapshot.json`; + // Use the title and id as the snapshot file name + const title = snapshot.meta.title || 'untitled'; + const id = snapshot.meta.id; + const snapshotName = `${title}-${id}.snapshot.json`; await zip.file(snapshotName, JSON.stringify(snapshot, null, 2)); }) ); @@ -63,6 +66,7 @@ async function exportDocs(collection: Workspace, docs: Store[]) { } const downloadBlob = await zip.generate(); + // Use the collection id as the zip file name return download(downloadBlob, `${collection.id}.bs.zip`); }