0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-09 21:41:23 -05:00

🐛 Import files with interactions correctly

This commit is contained in:
Andrés Moya 2021-10-25 17:39:12 +02:00 committed by Andrey Antukh
parent 75c8d97a6e
commit 6d28a9ad58

View file

@ -9,6 +9,7 @@
[app.common.data :as d]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.types.interactions :as cti]
[app.common.uuid :as uuid]
[app.util.color :as uc]
[app.util.json :as json]
@ -755,14 +756,23 @@
(let [interactions-node (get-data node :penpot:interactions)]
(->> (find-all-nodes interactions-node :penpot:interaction)
(mapv (fn [node]
{:event-type (get-meta node :event-type keyword)
:action-type (get-meta node :action-type keyword)
:delay (get-meta node :delay d/parse-double)
:destination (get-meta node :destination uuid/uuid)
:overlay-pos-type (get-meta node :overlay-pos-type keyword)
:overlay-position-x (get-meta node :overlay-position-x d/parse-double)
:overlay-position-y (get-meta node :overlay-position-x d/parse-double)
:url (get-meta node :url str)
:close-click-outside (get-meta node :close-click-outside str->bool)
:background-overlay (get-meta node :background-overlay str->bool)})))))
(let [interaction {:event-type (get-meta node :event-type keyword)
:action-type (get-meta node :action-type keyword)}]
(cond-> interaction
(cti/has-delay interaction)
(assoc :delay (get-meta node :delay d/parse-double))
(cti/has-destination interaction)
(assoc :destination (get-meta node :destination uuid/uuid))
(cti/has-url interaction)
(assoc :url (get-meta node :url str))
(cti/has-overlay-opts interaction)
(assoc :overlay-pos-type (get-meta node :overlay-pos-type keyword)
:overlay-position (gpt/point
(get-meta node :overlay-position-x d/parse-double)
(get-meta node :overlay-position-y d/parse-double))
:close-click-outside (get-meta node :close-click-outside str->bool)
:background-overlay (get-meta node :background-overlay str->bool)))))))))