mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
🐛 Fix problem with copy/paste in Safari
This commit is contained in:
parent
0ed23f94c7
commit
620efcb5cb
2 changed files with 32 additions and 9 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
- Fix crash on iOS when displaying viewer [#1522](https://github.com/penpot/penpot/issues/1522)
|
- Fix crash on iOS when displaying viewer [#1522](https://github.com/penpot/penpot/issues/1522)
|
||||||
- Fix problems with trackpad zoom and scroll in MacOS [#1161](https://github.com/penpot/penpot/issues/1161)
|
- Fix problems with trackpad zoom and scroll in MacOS [#1161](https://github.com/penpot/penpot/issues/1161)
|
||||||
|
- Fix problem with copy/paste in Safari [#1209](https://github.com/penpot/penpot/issues/1209)
|
||||||
|
|
||||||
## 1.12.3-beta
|
## 1.12.3-beta
|
||||||
|
|
||||||
|
|
|
@ -1548,13 +1548,10 @@
|
||||||
[]
|
[]
|
||||||
(letfn [;; Sort objects so they have the same relative ordering
|
(letfn [;; Sort objects so they have the same relative ordering
|
||||||
;; when pasted later.
|
;; when pasted later.
|
||||||
(sort-selected [state data]
|
(sort-selected-async [state data]
|
||||||
(let [selected (:selected data)
|
(let [selected (wsh/lookup-selected state)
|
||||||
page-id (:current-page-id state)
|
objects (wsh/lookup-page-objects state)
|
||||||
objects (get-in state [:workspace-data
|
page-id (:current-page-id state)]
|
||||||
:pages-index
|
|
||||||
page-id
|
|
||||||
:objects])]
|
|
||||||
(->> (uw/ask! {:cmd :selection/query-z-index
|
(->> (uw/ask! {:cmd :selection/query-z-index
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:objects objects
|
:objects objects
|
||||||
|
@ -1566,6 +1563,24 @@
|
||||||
(map first)
|
(map first)
|
||||||
(into (d/ordered-set)))))))))
|
(into (d/ordered-set)))))))))
|
||||||
|
|
||||||
|
;; We cannot call to a remote procedure in Safari (for the copy) so we need
|
||||||
|
;; to calculate it here instead of on the worker
|
||||||
|
(sort-selected-sync [state data]
|
||||||
|
(let [selected (wsh/lookup-selected state)
|
||||||
|
objects (wsh/lookup-page-objects state)
|
||||||
|
z-index (cp/calculate-z-index objects)
|
||||||
|
z-values (->> selected
|
||||||
|
(map #(vector %
|
||||||
|
(+ (get z-index %)
|
||||||
|
(get z-index (get-in objects [% :frame-id]))))))
|
||||||
|
selected
|
||||||
|
(->> z-values
|
||||||
|
(sort-by second)
|
||||||
|
(map first)
|
||||||
|
(into (d/ordered-set)))]
|
||||||
|
|
||||||
|
(assoc data :selected selected)))
|
||||||
|
|
||||||
;; Retrieve all ids of selected shapes with corresponding
|
;; Retrieve all ids of selected shapes with corresponding
|
||||||
;; children; this is needed because each shape should be
|
;; children; this is needed because each shape should be
|
||||||
;; processed one by one because of async events (data url
|
;; processed one by one because of async events (data url
|
||||||
|
@ -1627,11 +1642,18 @@
|
||||||
:file-id (:current-file-id state)
|
:file-id (:current-file-id state)
|
||||||
:selected selected
|
:selected selected
|
||||||
:objects {}
|
:objects {}
|
||||||
:images #{}}]
|
:images #{}}
|
||||||
|
|
||||||
|
sort-results
|
||||||
|
(fn [obs]
|
||||||
|
;; Safari doesn't allow asynchronous sorting on the copy
|
||||||
|
(if (cfg/check-browser? :safari)
|
||||||
|
(rx/map (partial sort-selected-sync state) obs)
|
||||||
|
(rx/mapcat (partial sort-selected-async state) obs)))]
|
||||||
(->> (rx/from (seq (vals pdata)))
|
(->> (rx/from (seq (vals pdata)))
|
||||||
(rx/merge-map (partial prepare-object objects selected))
|
(rx/merge-map (partial prepare-object objects selected))
|
||||||
(rx/reduce collect-data initial)
|
(rx/reduce collect-data initial)
|
||||||
(rx/mapcat (partial sort-selected state))
|
(sort-results)
|
||||||
(rx/map t/encode-str)
|
(rx/map t/encode-str)
|
||||||
(rx/map wapi/write-to-clipboard)
|
(rx/map wapi/write-to-clipboard)
|
||||||
(rx/catch on-copy-error)
|
(rx/catch on-copy-error)
|
||||||
|
|
Loading…
Reference in a new issue