0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-14 16:51:18 -05:00

Merge pull request #5096 from penpot/alotor-bugfixes

Bugfixes
This commit is contained in:
Aitor Moreno 2024-09-17 16:14:59 +02:00 committed by GitHub
commit aae1571a5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 56 additions and 15 deletions

View file

@ -83,6 +83,8 @@
- Fix problem when dismissing shared library update [Taiga #8669](https://tree.taiga.io/project/penpot/issue/8669)
- Fix visual problem with stroke cap menu [Taiga #8730](https://tree.taiga.io/project/penpot/issue/8730)
- Fix issue when exporting libraries when merging libraries [Taiga #8758](https://tree.taiga.io/project/penpot/issue/8758)
- Fix problem with comments max length [Taiga #8778](https://tree.taiga.io/project/penpot/issue/8778)
- Fix copy/paste images in Safari [Taiga #8771](https://tree.taiga.io/project/penpot/issue/8771)
## 2.1.5

View file

@ -292,7 +292,7 @@
[:map {:title "create-comment-thread"}
[:file-id ::sm/uuid]
[:position ::gpt/point]
[:content [:string {:max 250}]]
[:content [:string {:max 750}]]
[:page-id ::sm/uuid]
[:frame-id ::sm/uuid]
[:share-id {:optional true} [:maybe ::sm/uuid]]])

View file

@ -85,7 +85,8 @@
[beicon.v2.core :as rx]
[cljs.spec.alpha :as s]
[cuerdas.core :as str]
[potok.v2.core :as ptk]))
[potok.v2.core :as ptk]
[promesa.core :as p]))
(def default-workspace-local {:zoom 1})
(log/set-level! :debug)
@ -1551,6 +1552,31 @@
shapes (->> (cfh/selected-with-children objects selected)
(keep (d/getf objects)))]
;; The clipboard API doesn't handle well asynchronous calls because it expects to use
;; the clipboard in an user interaction. If you do an async call the callback is outside
;; the thread of the UI and so Safari blocks the copying event.
;; We use the API `ClipboardItem` that allows promises to be passed and so the event
;; will wait for the promise to resolve and everything should work as expected.
;; This only works in the current versions of the browsers.
(if (some? (unchecked-get ug/global "ClipboardItem"))
(let [resolve-data-promise
(p/create
(fn [resolve reject]
(->> (rx/from shapes)
(rx/merge-map (partial prepare-object objects frame-id))
(rx/reduce collect-data initial)
(rx/map (partial sort-selected state))
(rx/map (partial advance-copies state selected))
(rx/map #(t/encode-str % {:type :json-verbose}))
(rx/map #(wapi/create-blob % "text/plain"))
(rx/subs! resolve reject))))]
(->> (rx/from (wapi/write-to-clipboard-promise "text/plain" resolve-data-promise))
(rx/catch on-copy-error)
(rx/ignore)))
;; FIXME: this is to support Firefox versions below 116 that don't support `ClipboardItem`
;; after the version 116 is less common we could remove this.
;; https://caniuse.com/?search=ClipboardItem
(->> (rx/from shapes)
(rx/merge-map (partial prepare-object objects frame-id))
(rx/reduce collect-data initial)
@ -1559,7 +1585,7 @@
(rx/map #(t/encode-str % {:type :json-verbose}))
(rx/map wapi/write-to-clipboard)
(rx/catch on-copy-error)
(rx/ignore)))))))))
(rx/ignore))))))))))
(declare ^:private paste-transit)
(declare ^:private paste-text)

View file

@ -35,6 +35,7 @@
on-focus (unchecked-get props "on-focus")
on-blur (unchecked-get props "on-blur")
placeholder (unchecked-get props "placeholder")
max-length (unchecked-get props "max-length")
on-change (unchecked-get props "on-change")
on-esc (unchecked-get props "on-esc")
on-ctrl-enter (unchecked-get props "on-ctrl-enter")
@ -88,7 +89,8 @@
:on-blur on-blur
:value value
:placeholder placeholder
:on-change on-change*}]))
:on-change on-change*
:max-length max-length}]))
(mf/defc reply-form
[{:keys [thread] :as props}]
@ -128,7 +130,8 @@
:on-focus on-focus
:select-on-focus? false
:on-ctrl-enter on-submit
:on-change on-change}]
:on-change on-change
:max-length 750}]
(when (or @show-buttons? (seq @content))
[:div {:class (stl/css :buttons-wrapper)}
[:input.btn-secondary
@ -196,7 +199,8 @@
:select-on-focus? false
:on-esc on-esc
:on-change on-change
:on-ctrl-enter on-submit}]
:on-ctrl-enter on-submit
:max-length 750}]
[:div {:class (stl/css :buttons-wrapper)}
[:input {:on-click on-esc
@ -233,7 +237,8 @@
:select-on-focus true
:select-on-focus? false
:on-ctrl-enter on-submit*
:on-change on-change}]
:on-change on-change
:max-length 750}]
[:div {:class (stl/css :buttons-wrapper)}
[:input {:type "button"
:value "Cancel"

View file

@ -103,6 +103,14 @@
(let [cboard (unchecked-get js/navigator "clipboard")]
(.writeText ^js cboard data)))
(defn write-to-clipboard-promise
[mimetype promise]
(let [cboard (unchecked-get js/navigator "clipboard")
data (js/ClipboardItem.
(-> (obj/create)
(obj/set! mimetype promise)))]
(.write ^js cboard #js [data])))
(defn read-from-clipboard
[]
(try