From 42a55015fa7ff01bfdb21d03e550ba8361b1b490 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 11 Feb 2021 13:03:41 +0100 Subject: [PATCH] :bug: Fixes problem when pasting URL's from the browser address bar --- CHANGES.md | 1 + frontend/src/app/main/data/workspace.cljs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 82508934e..1e1204380 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,7 @@ - Fix apply a color to a text selection from color palette was not working - Fix logo icon in viewer should go to dashboard - Fix text alignment in preview [#594](https://github.com/penpot/penpot/issues/594) +- Fix problem when pasting URL's copied from the browser url bar ### Community contributions by (Thank you! :heart:) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index acb58b487..79d370c33 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1481,11 +1481,16 @@ ptk/WatchEvent (watch [_ state stream] (try - (let [paste-data (wapi/read-from-paste-event event) + (let [objects (dwc/lookup-page-objects state) + paste-data (wapi/read-from-paste-event event) image-data (wapi/extract-images paste-data) text-data (wapi/extract-text paste-data) decoded-data (and (t/transit? text-data) - (t/decode text-data))] + (t/decode text-data)) + + edit-id (get-in state [:workspace-local :edition]) + is-editing-text? (and edit-id (= :text (get-in objects [edit-id :type])))] + (cond (seq image-data) (rx/from (map paste-image image-data)) @@ -1495,7 +1500,9 @@ (rx/filter #(= :copied-shapes (:type %))) (rx/map #(paste-shape % in-viewport?))) - (string? text-data) + ;; Some paste events can be fired while we're editing a text + ;; we forbid that scenario so the default behaviour is executed + (and (string? text-data) (not is-editing-text?)) (rx/of (paste-text text-data)) :else