mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 06:31:39 +02:00
♻️ Refactor paste function
This commit is contained in:
parent
6186d82151
commit
e581cf8aeb
1 changed files with 9 additions and 11 deletions
|
@ -1260,17 +1260,15 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(try
|
(try
|
||||||
(let [paste-data (wapi/read-from-paste-event event)]
|
(let [paste-data (wapi/read-from-paste-event event)
|
||||||
(when paste-data
|
image-data (wapi/extract-images paste-data)
|
||||||
(let [text-data (wapi/extract-text paste-data)
|
text-data (wapi/extract-text paste-data)
|
||||||
decoded-data (when (and paste-data (t/transit? text-data))
|
decoded-data (and (t/transit? text-data) (t/decode text-data))]
|
||||||
(t/decode text-data))]
|
(cond
|
||||||
(if (and decoded-data (= (:type decoded-data) :copied-shapes))
|
(seq image-data) (rx/from (map paste-image image-data))
|
||||||
(rx/of (paste-shape decoded-data))
|
decoded-data (rx/of (paste-shape decoded-data))
|
||||||
(if-not (empty? text-data)
|
(string? text-data) (rx/of (paste-text text-data))
|
||||||
(rx/of (paste-text text-data))
|
:else (rx/empty)))
|
||||||
(let [images (wapi/extract-images paste-data)]
|
|
||||||
(rx/from (map paste-image images))))))))
|
|
||||||
(catch :default err
|
(catch :default err
|
||||||
(js/console.error "Clipboard error:" err))))))
|
(js/console.error "Clipboard error:" err))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue