aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/utils/dragUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/utils/dragUtils.ts')
-rw-r--r--apps/files/src/utils/dragUtils.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/files/src/utils/dragUtils.ts b/apps/files/src/utils/dragUtils.ts
new file mode 100644
index 00000000000..0722e313089
--- /dev/null
+++ b/apps/files/src/utils/dragUtils.ts
@@ -0,0 +1,25 @@
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+import type { Node } from '@nextcloud/files'
+import DragAndDropPreview from '../components/DragAndDropPreview.vue'
+import Vue from 'vue'
+
+const Preview = Vue.extend(DragAndDropPreview)
+let preview: Vue
+
+export const getDragAndDropPreview = async (nodes: Node[]): Promise<Element> => {
+ return new Promise((resolve) => {
+ if (!preview) {
+ preview = new Preview().$mount()
+ document.body.appendChild(preview.$el)
+ }
+
+ preview.update(nodes)
+ preview.$on('loaded', () => {
+ resolve(preview.$el)
+ preview.$off('loaded')
+ })
+ })
+}