From 3c98aaed37c8ed46046677692dfe71f017c31682 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 23 Jul 2020 01:15:27 -0400
Subject: fixed droppin of web pages (or anythin that adds a uri-list to the
 clipboard)

---
 src/client/views/collections/CollectionSubView.tsx | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

(limited to 'src/client/views/collections/CollectionSubView.tsx')

diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 8a3c2144e..a147b06a3 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -220,6 +220,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
             const { dataTransfer } = e;
             const html = dataTransfer.getData("text/html");
             const text = dataTransfer.getData("text/plain");
+            const uriList = dataTransfer.getData("text/uri-list");
 
             if (text && text.startsWith("<div")) {
                 return;
@@ -312,9 +313,9 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                 }
             }
 
-            if (text) {
-                if (text.includes("www.youtube.com/watch") || text.includes("www.youtube.com/embed")) {
-                    const url = text.replace("youtube.com/watch?v=", "youtube.com/embed/").split("&")[0];
+            if (uriList || text) {
+                if ((uriList || text).includes("www.youtube.com/watch") || text.includes("www.youtube.com/embed")) {
+                    const url = (uriList || text).replace("youtube.com/watch?v=", "youtube.com/embed/").split("&")[0];
                     this.addDocument(Docs.Create.VideoDocument(url, {
                         ...options,
                         title: url,
@@ -343,6 +344,17 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                 //     return;
                 // }
             }
+            if (uriList) {
+                this.addDocument(Docs.Create.WebDocument(uriList, {
+                    ...options,
+                    title: uriList,
+                    _width: 400,
+                    _height: 315,
+                    _nativeWidth: 600,
+                    _nativeHeight: 472.5
+                }));
+                return;
+            }
 
             const { items } = e.dataTransfer;
             const { length } = items;
-- 
cgit v1.2.3-70-g09d2

