mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 10:06:17 +08:00
fix(core): some comment editor ux enhancements (#13126)
fix AF-2726, AF-2729 #### PR Dependency Tree * **PR #13126** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added drag-and-drop support for file attachments in the comment editor. * Improved user feedback with notifications and toasts when downloading attachments. * **Bug Fixes** * Enhanced error handling and reporting for attachment downloads. * **Improvements** * Optimized file download process for same-origin resources to improve performance. * Updated default comment filter to show all comments, not just those for the current mode. * **Documentation** * Updated English localization to provide clearer instructions when no comments are present. <!-- end of auto-generated comment: release notes by coderabbit.ai --> #### PR Dependency Tree * **PR #13126** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -33,7 +33,22 @@ export async function downloadBlob(blob: Blob, filename: string) {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
}
|
||||
|
||||
export function downloadFile(url: string, filename: string) {
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.target = '_blank';
|
||||
a.click();
|
||||
}
|
||||
|
||||
export async function downloadResourceWithUrl(url: string, filename: string) {
|
||||
// 1. if url is not same origin, fetch it to blob and download it
|
||||
// 2. otherwise, download it directly
|
||||
const sameOrigin = new URL(url).origin === window.location.origin;
|
||||
if (sameOrigin) {
|
||||
downloadFile(url, filename);
|
||||
return;
|
||||
}
|
||||
// given input url may not have correct mime type
|
||||
const blob = await resourceUrlToBlob(url);
|
||||
if (!blob) return;
|
||||
|
||||
Reference in New Issue
Block a user