mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
Merge pull request #3542 from penpot/niwinz-bugfixes-1
🐛 Fix inconsistencies on handlong :file-image attr on import and file-gc task
This commit is contained in:
commit
ab87db099a
3 changed files with 17 additions and 7 deletions
|
@ -516,6 +516,9 @@
|
||||||
:media (count media)
|
:media (count media)
|
||||||
::l/sync? true)
|
::l/sync? true)
|
||||||
|
|
||||||
|
(doseq [item media]
|
||||||
|
(l/debug :hint "write penpot file media object" :id (:id item) ::l/sync? true))
|
||||||
|
|
||||||
(doto output
|
(doto output
|
||||||
(write-obj! file)
|
(write-obj! file)
|
||||||
(write-obj! media))
|
(write-obj! media))
|
||||||
|
@ -770,7 +773,7 @@
|
||||||
(defn- lookup-index
|
(defn- lookup-index
|
||||||
[id]
|
[id]
|
||||||
(let [val (get-in @*state* [:index id])]
|
(let [val (get-in @*state* [:index id])]
|
||||||
(l/trace :fn "lookup-index" :id id :val val ::l/sync? true)
|
(l/debug :fn "lookup-index" :id id :val val ::l/sync? true)
|
||||||
(when (and (not (::ignore-index-errors? *options*)) (not val))
|
(when (and (not (::ignore-index-errors? *options*)) (not val))
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :incomplete-index
|
:code :incomplete-index
|
||||||
|
@ -783,7 +786,7 @@
|
||||||
index index]
|
index index]
|
||||||
(if-let [id (first items)]
|
(if-let [id (first items)]
|
||||||
(let [new-id (if (::overwrite? *options*) id (uuid/next))]
|
(let [new-id (if (::overwrite? *options*) id (uuid/next))]
|
||||||
(l/trace :fn "update-index" :id id :new-id new-id ::l/sync? true)
|
(l/debug :fn "update-index" :id id :new-id new-id ::l/sync? true)
|
||||||
(recur (rest items)
|
(recur (rest items)
|
||||||
(assoc index id new-id)))
|
(assoc index id new-id)))
|
||||||
index)))
|
index)))
|
||||||
|
@ -801,8 +804,7 @@
|
||||||
(update-in [:metadata :id] lookup-index)
|
(update-in [:metadata :id] lookup-index)
|
||||||
|
|
||||||
;; Relink paths with fill image
|
;; Relink paths with fill image
|
||||||
(and (map? (:fill-image form))
|
(map? (:fill-image form))
|
||||||
(= :path (:type form)))
|
|
||||||
(update-in [:fill-image :id] lookup-index)
|
(update-in [:fill-image :id] lookup-index)
|
||||||
|
|
||||||
;; This covers old shapes and the new :fills.
|
;; This covers old shapes and the new :fills.
|
||||||
|
|
|
@ -113,8 +113,15 @@
|
||||||
(mapcat vals)
|
(mapcat vals)
|
||||||
(keep (fn [{:keys [type] :as obj}]
|
(keep (fn [{:keys [type] :as obj}]
|
||||||
(case type
|
(case type
|
||||||
:path (get-in obj [:fill-image :id])
|
:path (get-in obj [:fill-image :id])
|
||||||
|
:bool (get-in obj [:fill-image :id])
|
||||||
|
;; NOTE: because of some bug, we ended with
|
||||||
|
;; many shape types having the ability to
|
||||||
|
;; have fill-image attribute (which initially
|
||||||
|
;; designed for :path shapes).
|
||||||
|
:group (get-in obj [:fill-image :id])
|
||||||
:image (get-in obj [:metadata :id])
|
:image (get-in obj [:metadata :id])
|
||||||
|
|
||||||
nil))))
|
nil))))
|
||||||
pages (concat
|
pages (concat
|
||||||
(vals (:pages-index data))
|
(vals (:pages-index data))
|
||||||
|
|
|
@ -97,11 +97,12 @@
|
||||||
(defn- svg-update-image!
|
(defn- svg-update-image!
|
||||||
"Updates an image in an SVG to a Data URI."
|
"Updates an image in an SVG to a Data URI."
|
||||||
[image]
|
[image]
|
||||||
(when-let [href (dom/get-attribute image "href")]
|
(if-let [href (dom/get-attribute image "href")]
|
||||||
(->> (fetch-as-data-uri href)
|
(->> (fetch-as-data-uri href)
|
||||||
(rx/map (fn [url]
|
(rx/map (fn [url]
|
||||||
(dom/set-attribute! image "href" url)
|
(dom/set-attribute! image "href" url)
|
||||||
image)))))
|
image)))
|
||||||
|
(rx/empty)))
|
||||||
|
|
||||||
(defn- svg-resolve-images!
|
(defn- svg-resolve-images!
|
||||||
"Resolves all images in an SVG to Data URIs."
|
"Resolves all images in an SVG to Data URIs."
|
||||||
|
|
Loading…
Add table
Reference in a new issue