0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

🐛 Fixed paste with middle button in firefox

This commit is contained in:
alonso.torres 2021-01-13 12:37:15 +01:00 committed by Andrey Antukh
parent ad2d8c8ee0
commit 79fc3cbf12
2 changed files with 10 additions and 1 deletions

View file

@ -53,6 +53,7 @@
button (.-which (.-nativeEvent event))
shift? (kbd/shift? event)
ctrl? (kbd/ctrl? event)]
(dom/prevent-default event)
(when-not blocked
(cond
(or (not= 1 button) drawing? ctrl?)

View file

@ -252,6 +252,7 @@
viewport-ref (mf/use-ref nil)
zoom-view-ref (mf/use-ref nil)
last-position (mf/use-var nil)
disable-paste (mf/use-var false)
drawing (mf/deref refs/workspace-drawing)
drawing-tool (:tool drawing)
drawing-obj (:object drawing)
@ -301,6 +302,10 @@
(when (= 2 (.-which event))
(do
(dom/prevent-default event)
;; We store this so in Firefox the middle button won't do a paste of the content
(reset! disable-paste true)
(timers/schedule #(reset! disable-paste false))
(st/emit! dw/finish-pan
::finish-positioning))))))
@ -529,7 +534,10 @@
on-paste
(mf/use-callback
(fn [event]
(st/emit! (dw/paste-from-event event))))
;; We disable the paste just after mouse-up of a middle button so when panning won't
;; paste the content into the workspace
(when (not @disable-paste)
(st/emit! (dw/paste-from-event event)))))
on-resize
(mf/use-callback