Add a link to view uploaded non-image attachments
authorAlexander Ebert <ebert@woltlab.com>
Wed, 9 Oct 2024 11:00:37 +0000 (13:00 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 9 Oct 2024 11:00:37 +0000 (13:00 +0200)
Closes #6011

ts/WoltLabSuite/Core/Component/Attachment/Entry.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Attachment/Entry.js

index 494310421fb9bfaffbca646b7dcf5c7df168a5ed..144caf80780d82cd0e7198acb619cfe3fbcfdf90 100644 (file)
@@ -75,6 +75,17 @@ function fileInitializationCompleted(element: HTMLElement, file: WoltlabCoreFile
       file.isImage() && file.link ? file.link : "",
       editor,
     );
+
+    if (file.link !== undefined && file.filename !== undefined) {
+      const link = document.createElement("a");
+      link.target = "_blank";
+      link.href = file.link;
+      link.textContent = file.filename;
+
+      const filename = element.querySelector(".fileList__item__filename")!;
+      filename.innerHTML = "";
+      filename.append(link);
+    }
   }
 
   const dropdownMenu = document.createElement("ul");
index 0dae49ed027fa52b2b9023e26119252b25cf6766..d5bfeb4d6e5237a82474ba739f5ab6c2dbbefcf3 100644 (file)
@@ -54,6 +54,15 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Ui/Dropdown/Simple", "
         }
         else {
             insertButton = getInsertButton(data.attachmentID, file.isImage() && file.link ? file.link : "", editor);
+            if (file.link !== undefined && file.filename !== undefined) {
+                const link = document.createElement("a");
+                link.target = "_blank";
+                link.href = file.link;
+                link.textContent = file.filename;
+                const filename = element.querySelector(".fileList__item__filename");
+                filename.innerHTML = "";
+                filename.append(link);
+            }
         }
         const dropdownMenu = document.createElement("ul");
         dropdownMenu.classList.add("dropdownMenu");