mirror of
https://github.com/penpot/penpot.git
synced 2025-07-25 03:17:16 +02:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
31323703a8
21 changed files with 77 additions and 53 deletions
|
@ -73,16 +73,20 @@
|
|||
(rx/map #(svg/add-svg-shapes (assoc svg-data :image-data %) position))))))
|
||||
|
||||
(defn- process-uris
|
||||
[{:keys [file-id local? name uris mtype on-image on-svg]}]
|
||||
[{:keys [file-id local? name uris mtype on-image on-svg] }]
|
||||
(letfn [(svg-url? [url]
|
||||
(or (and mtype (= mtype "image/svg+xml"))
|
||||
(str/ends-with? url ".svg")))
|
||||
|
||||
(prepare [uri]
|
||||
{:file-id file-id
|
||||
:is-local local?
|
||||
:name (or name (svg/extract-name uri))
|
||||
:url uri})
|
||||
(upload [uri]
|
||||
(->> (http/send! {:method :get :uri uri :mode :no-cors :response-type :blob})
|
||||
(rx/map :body)
|
||||
(rx/map (fn [content]
|
||||
{:file-id file-id
|
||||
:name (or name (svg/extract-name uri))
|
||||
:is-local local?
|
||||
:content content}))
|
||||
(rx/mapcat #(rp/cmd! :upload-file-media-object %))))
|
||||
|
||||
(fetch-svg [name uri]
|
||||
(->> (http/send! {:method :get :uri uri :mode :no-cors})
|
||||
|
@ -93,8 +97,7 @@
|
|||
(rx/merge
|
||||
(->> (rx/from uris)
|
||||
(rx/filter (comp not svg-url?))
|
||||
(rx/map prepare)
|
||||
(rx/mapcat #(rp/cmd! :create-file-media-object-from-url %))
|
||||
(rx/mapcat upload)
|
||||
(rx/do on-image))
|
||||
|
||||
(->> (rx/from uris)
|
||||
|
@ -142,7 +145,7 @@
|
|||
[:local? :boolean]
|
||||
[:name {:optional true} :string]
|
||||
[:data {:optional true} :any] ; FIXME
|
||||
[:uris {:optional true} [:vector :string]]
|
||||
[:uris {:optional true} [:sequential :string]]
|
||||
[:mtype {:optional true} :string]])
|
||||
|
||||
(defn- process-media-objects
|
||||
|
@ -213,8 +216,6 @@
|
|||
:on-image #(st/emit! (dwl/add-media %)))]
|
||||
(process-media-objects params)))
|
||||
|
||||
;; TODO: it is really need handle SVG here, looks like it already
|
||||
;; handled separately
|
||||
(defn upload-media-workspace
|
||||
[{:keys [position file-id] :as params}]
|
||||
(let [params (assoc params
|
||||
|
|
|
@ -458,8 +458,8 @@
|
|||
(dnd/has-type? event "text/uri-list")
|
||||
(let [data (dnd/get-data event "text/uri-list")
|
||||
lines (str/lines data)
|
||||
uris (->> lines (filter #(str/starts-with? % "http")))
|
||||
data (->> lines (filter #(str/starts-with? % "data:image/")))
|
||||
uris (filterv #(str/starts-with? % "http") lines)
|
||||
data (filterv #(str/starts-with? % "data:image/") lines)
|
||||
params {:file-id (:id file)
|
||||
:position viewport-coord}
|
||||
params (if (seq uris)
|
||||
|
|
|
@ -151,9 +151,9 @@
|
|||
(rx/tap (fn [[fonts]]
|
||||
(when (seq fonts)
|
||||
(st/emit! (df/fonts-fetched fonts)))))
|
||||
(rx/map (comp :objects second))))))
|
||||
(rx/map (fn [[_ page]] {:objects (:objects page)}))))))
|
||||
|
||||
objects (use-resource fetch-state)]
|
||||
{:keys [objects]} (use-resource fetch-state)]
|
||||
|
||||
(when objects
|
||||
(for [object-id object-ids]
|
||||
|
|
|
@ -737,12 +737,13 @@
|
|||
:fill-color-ref-file (get-meta fill-node :fill-color-ref-file uuid/uuid)
|
||||
:fill-color-ref-id (get-meta fill-node :fill-color-ref-id uuid/uuid)
|
||||
:fill-opacity (get-meta fill-node :fill-opacity d/parse-double)}))
|
||||
(mapv d/without-nils))]
|
||||
(mapv d/without-nils)
|
||||
(filterv #(not= (:fill-color %) "none")))]
|
||||
(if (seq fills)
|
||||
fills
|
||||
(->> [(-> (add-fill {} node svg-data)
|
||||
(d/without-nils))]
|
||||
(filterv not-empty)))))
|
||||
(filterv #(and (not-empty %) (not= (:fill-color %) "none")))))))
|
||||
|
||||
(defn parse-strokes
|
||||
[node svg-data]
|
||||
|
@ -761,12 +762,13 @@
|
|||
:stroke-alignment (get-meta stroke-node :stroke-alignment keyword)
|
||||
:stroke-cap-start (get-meta stroke-node :stroke-cap-start keyword)
|
||||
:stroke-cap-end (get-meta stroke-node :stroke-cap-end keyword)}))
|
||||
(mapv d/without-nils))]
|
||||
(mapv d/without-nils)
|
||||
(filterv #(not= (:stroke-color %) "none")))]
|
||||
(if (seq strokes)
|
||||
strokes
|
||||
(->> [(-> (add-stroke {} node svg-data)
|
||||
(d/without-nils))]
|
||||
(filterv #(and (not-empty %) (not= (:stroke-style %) :none)))))))
|
||||
(filterv #(and (not-empty %) (not= (:stroke-color %) "none") (not= (:stroke-style %) :none)))))))
|
||||
|
||||
(defn add-svg-content
|
||||
[props node]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue