0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-12 18:18:24 -05:00

Merge pull request #4616 from penpot/hiru-prepare-builder-for-figma-exporter

Prepare builder for figma exporter
This commit is contained in:
Alejandro 2024-05-24 14:57:15 +02:00 committed by GitHub
commit c3c6879a2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 12 deletions

View file

@ -48,6 +48,7 @@
(and add-container? (nil? component-id))
(assoc :page-id (:current-page-id file)
:frame-id (:current-frame-id file)))
valid? (ch/check-change! change)]
(when-not valid?
@ -135,13 +136,8 @@
(create-file (uuid/next) name))
([id name]
{:id id
:name name
:data (-> ctf/empty-file-data
(assoc :id id))
;; We keep the changes so we can send them to the backend
:changes []}))
(-> (ctf/make-file {:id id :name name :create-page false})
(assoc :changes [])))) ;; We keep the changes so we can send them to the backend
(defn add-page
[file data]
@ -511,9 +507,12 @@
{:type :del-media
:id id}))))
(defn start-component
([file data] (start-component file data :group))
([file data]
(let [components-v2 (dm/get-in file [:data :options :components-v2])
root-type (if components-v2 :frame :group)]
(start-component file data root-type)))
([file data root-type]
;; FIXME: data probably can be a shape instance, then we can use gsh/shape->rect
(let [selrect (or (grc/make-rect (:x data) (:y data) (:width data) (:height data))
@ -566,9 +565,11 @@
file
(cond
;; Components-v2 component we skip this step
;; In components-v2 components haven't any shape inside them.
(and component-data (:main-instance-id component-data))
file
(update file :data
(fn [data]
(ctkl/update-component data component-id dissoc :objects)))
(empty? children)
(commit-change

View file

@ -249,9 +249,18 @@
(deleteObject [_ id]
(set! file (fb/delete-object file (uuid/uuid id))))
(getId [_]
(:id file))
(getCurrentPageId [_]
(:current-page-id file))
(asMap [_]
(clj->js file))
(newId [_]
(uuid/next))
(export [_]
(->> (export-file file)
(rx/subs!
@ -261,7 +270,8 @@
(dom/trigger-download (:name file) export-blob))))))))
(defn create-file-export [^string name]
(File. (fb/create-file name)))
(binding [cfeat/*current* cfeat/default-features]
(File. (fb/create-file name))))
(defn exports []
#js {:createFile create-file-export})