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:
Peng Xiao
2025-07-10 11:58:00 +08:00
committed by GitHub
parent 11a9e67bc1
commit ed6fde550f
5 changed files with 55 additions and 21 deletions
@@ -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;