From 02bb8d78fc8fa0827bf61b6a2ee5ef63bd6d1984 Mon Sep 17 00:00:00 2001
From: Tamara Steinwender <tamara.steinwender@tugraz.at>
Date: Mon, 26 Apr 2021 11:43:52 +0200
Subject: [PATCH] Improve clipboard

---
 .../src/dbp-file-handling-clipboard.js        | 36 ++++++++++---------
 .../src/i18n/de/translation.json              |  2 +-
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/packages/file-handling/src/dbp-file-handling-clipboard.js b/packages/file-handling/src/dbp-file-handling-clipboard.js
index f3a29759..86875687 100644
--- a/packages/file-handling/src/dbp-file-handling-clipboard.js
+++ b/packages/file-handling/src/dbp-file-handling-clipboard.js
@@ -207,6 +207,7 @@ export class FileHandlingClipboard extends ScopedElementsMixin(DBPLitElement) {
             }
         });
         if (!this.clipboardSource) {
+            window.removeEventListener('beforeunload', this._onReceiveBeforeUnload);
             window.addEventListener('beforeunload', this._onReceiveBeforeUnload);
         }
 
@@ -542,28 +543,29 @@ export class FileHandlingClipboard extends ScopedElementsMixin(DBPLitElement) {
                             <p>${i18n.t('file-sink.save-to-clipboard-warning')}</p>
                         </div>
 
-                        <div class="${classMap({"hidden": this.clipboardFiles.files.length === 0})}">
-                        <button id="clipboard-download-button"
+                        
+                        
+                        <div class="clipboard-data ${classMap({"hidden": this.clipboardFiles.files.length === 0})}">
+                            <h4>${i18n.t('file-sink.clipboard-files')}</h4>
+                            <div class="${classMap({"hidden": this.clipboardFiles.files.length === 0})}">
+                                <button id="clipboard-download-button"
                                     class="button is-right clipboard-btn"
                                     @click="${this.openClipboardFileSink}"
                                     >${i18n.t('clipboard.save-from-clipboard-btn')}</button>
-                        </div>
-                        
-                        <dbp-file-sink id="file-sink-clipboard"
-                        context="${i18n.t('clipboard.save-files-from-clipboard', {count: this.clipboardFiles ? this.clipboardFiles.files.length : 0})}"
-                        filename="clipboard-documents.zip"
-                        enabled-targets="local,nextcloud"
-                        nextcloud-auth-url="${this.nextcloudAuthUrl}"
-                        nextcloud-web-dav-url="${this.nextcloudWebDavUrl}"
-                        nextcloud-name="${this.nextcloudName}"
-                        nextcloud-file-url="${this.nextcloudFileURL}"
-                        fullsize-modal="true"
-                        lang="${this.lang}"
-                        ></dbp-file-sink>
+                            </div>
                         
+                            <dbp-file-sink id="file-sink-clipboard"
+                            context="${i18n.t('clipboard.save-files-from-clipboard', {count: this.clipboardFiles ? this.clipboardFiles.files.length : 0})}"
+                            filename="clipboard-documents.zip"
+                            enabled-targets="local,nextcloud"
+                            nextcloud-auth-url="${this.nextcloudAuthUrl}"
+                            nextcloud-web-dav-url="${this.nextcloudWebDavUrl}"
+                            nextcloud-name="${this.nextcloudName}"
+                            nextcloud-file-url="${this.nextcloudFileURL}"
+                            fullsize-modal="true"
+                            lang="${this.lang}"
+                            ></dbp-file-sink>
                         
-                        <div class="clipboard-data ${classMap({"hidden": this.clipboardFiles.files.length === 0})}">
-                            <h4>${i18n.t('file-sink.clipboard-files')}</h4>
                             <p>${i18n.t('file-sink.clipboard-files-overwrite')}</p>
                             ${this.getClipboardFileList()}
                         </div>
diff --git a/packages/file-handling/src/i18n/de/translation.json b/packages/file-handling/src/i18n/de/translation.json
index c053bad5..ea46dd9d 100644
--- a/packages/file-handling/src/i18n/de/translation.json
+++ b/packages/file-handling/src/i18n/de/translation.json
@@ -41,7 +41,7 @@
     "save-to-clipboard-text": "Hier können Sie Dateien temporär ablegen.",
     "save-to-clipboard-warning": "Vorsicht! Wenn Sie den Browser schließen, die Seite neu laden oder neue Dateien hinzufügen, wird die bestehende Zwischenablage automatisch verworfen!",
     "clipboard-files": "Aktuell vorhandene Dateien in der Zwischenablage",
-    "clipboard-files-overwrite": "Folgende Dateien werden verworfen:"
+    "clipboard-files-overwrite": "Folgende Dateien werden verworfen, wenn Sie neue Dateien ins Clipboard legen:"
   },
   "nextcloud-file-picker": {
     "open": "Nextcloud",
-- 
GitLab