From 9741ecc4bdfd822d8bcbe9d6505c5c2dce06cbbb Mon Sep 17 00:00:00 2001 From: monikahedman Date: Fri, 16 Aug 2019 14:57:15 -0400 Subject: paste is working for text, images from web, and youtube links --- src/client/views/PreviewCursor.tsx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/views/PreviewCursor.tsx b/src/client/views/PreviewCursor.tsx index 162b33d5f..7bf0d8ace 100644 --- a/src/client/views/PreviewCursor.tsx +++ b/src/client/views/PreviewCursor.tsx @@ -32,43 +32,43 @@ export class PreviewCursor extends React.Component<{}> { if (PreviewCursor.Visible) { if (e.clipboardData) { let newPoint = PreviewCursor._getTransform().transformPoint(PreviewCursor._clickPoint[0], PreviewCursor._clickPoint[1]); + runInAction(() => { PreviewCursor.Visible = false; }); - //keeping these just to hold onto types of pastes - //what needs to be done with html? - // console.log(e.clipboardData.getData("text/html")); - // console.log(e.clipboardData.getData("text/csv")); - // console.log(e.clipboardData.getData("text/plain")); - // console.log(e.clipboardData.getData("image/png")); - // console.log(e.clipboardData.getData("image/jpg")); - // console.log(e.clipboardData.getData("image/jpeg")); - - // console.log(e.clipboardData.types) - - // pasting in text + // pasting in text/video from youtube if (e.clipboardData.getData("text/plain") !== "") { + if (e.clipboardData.getData("text/plain").indexOf("www.youtube.com/watch") !== -1) { + const url = e.clipboardData.getData("text/plain").replace("youtube.com/watch?v=", "youtube.com/embed/"); + PreviewCursor._addDocument(Docs.Create.VideoDocument(url, { + title: url, width: 400, height: 315, + nativeWidth: 600, nativeHeight: 472.5, + x: newPoint[0], y: newPoint[1] + }), false); + return; + } let newBox = Docs.Create.TextDocument({ width: 200, height: 100, x: newPoint[0], y: newPoint[1], - title: "-typed text-" + title: "-pasted text-" }); newBox.proto!.autoHeight = true; PreviewCursor._addLiveTextDoc(newBox); + return; } //pasting in images - else if (e.clipboardData.getData("text/html") !== "" && e.clipboardData.getData("text/html").includes(" { PreviewCursor.Visible = false; }); + return; } } -- cgit v1.2.3-70-g09d2