]> BookStack Code Mirror - bookstack/commitdiff
Attachment List: Fixed broken ctrl-click functionality
authorDan Brown <redacted>
Tue, 23 Jan 2024 15:01:07 +0000 (15:01 +0000)
committerDan Brown <redacted>
Tue, 23 Jan 2024 15:01:07 +0000 (15:01 +0000)
Fixes #4782

resources/js/components/attachments-list.js
resources/views/attachments/list.blade.php

index 4db09977fec7ff0d20bf10192b4b59ca3caad1aa..665904f86163998503bd2cdd23c341f3c07d6aa4 100644 (file)
@@ -9,6 +9,8 @@ export class AttachmentsList extends Component {
 
     setup() {
         this.container = this.$el;
+        this.fileLinks = this.$manyRefs.linkTypeFile;
+
         this.setupListeners();
     }
 
@@ -27,8 +29,7 @@ export class AttachmentsList extends Component {
     }
 
     addOpenQueryToLinks() {
-        const links = this.container.querySelectorAll('a.attachment-file');
-        for (const link of links) {
+        for (const link of this.fileLinks) {
             if (link.href.split('?')[1] !== 'open=true') {
                 link.href += '?open=true';
                 link.setAttribute('target', '_blank');
@@ -37,8 +38,7 @@ export class AttachmentsList extends Component {
     }
 
     removeOpenQueryFromLinks() {
-        const links = this.container.querySelectorAll('a.attachment-file');
-        for (const link of links) {
+        for (const link of this.fileLinks) {
             link.href = link.href.split('?')[0];
             link.removeAttribute('target');
         }
index a6ffb709b4dc097ecf4b14d0785aa7e585b77e94..71197cc19c0eaff2aa897064f8294b149f6db394 100644 (file)
@@ -2,7 +2,9 @@
     @foreach($attachments as $attachment)
         <div class="attachment icon-list">
             <div class="split-icon-list-item attachment-{{ $attachment->external ? 'link' : 'file' }}">
-                <a href="{{ $attachment->getUrl() }}" @if($attachment->external) target="_blank" @endif>
+                <a href="{{ $attachment->getUrl() }}"
+                   refs="attachments-list@link-type-{{ $attachment->external ? 'link' : 'file' }}"
+                   @if($attachment->external) target="_blank" @endif>
                     <div class="icon">@icon($attachment->external ? 'export' : 'file')</div>
                     <div class="label">{{ $attachment->name }}</div>
                 </a>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.