mirror of
https://github.com/penpot/penpot.git
synced 2025-02-14 19:19:09 -05:00
Merge pull request #4616 from penpot/hiru-prepare-builder-for-figma-exporter
Prepare builder for figma exporter
This commit is contained in:
commit
c3c6879a2f
2 changed files with 23 additions and 12 deletions
|
@ -48,6 +48,7 @@
|
||||||
(and add-container? (nil? component-id))
|
(and add-container? (nil? component-id))
|
||||||
(assoc :page-id (:current-page-id file)
|
(assoc :page-id (:current-page-id file)
|
||||||
:frame-id (:current-frame-id file)))
|
:frame-id (:current-frame-id file)))
|
||||||
|
|
||||||
valid? (ch/check-change! change)]
|
valid? (ch/check-change! change)]
|
||||||
|
|
||||||
(when-not valid?
|
(when-not valid?
|
||||||
|
@ -135,13 +136,8 @@
|
||||||
(create-file (uuid/next) name))
|
(create-file (uuid/next) name))
|
||||||
|
|
||||||
([id name]
|
([id name]
|
||||||
{:id id
|
(-> (ctf/make-file {:id id :name name :create-page false})
|
||||||
:name name
|
(assoc :changes [])))) ;; We keep the changes so we can send them to the backend
|
||||||
:data (-> ctf/empty-file-data
|
|
||||||
(assoc :id id))
|
|
||||||
|
|
||||||
;; We keep the changes so we can send them to the backend
|
|
||||||
:changes []}))
|
|
||||||
|
|
||||||
(defn add-page
|
(defn add-page
|
||||||
[file data]
|
[file data]
|
||||||
|
@ -511,9 +507,12 @@
|
||||||
{:type :del-media
|
{:type :del-media
|
||||||
:id id}))))
|
:id id}))))
|
||||||
|
|
||||||
|
|
||||||
(defn start-component
|
(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]
|
([file data root-type]
|
||||||
;; FIXME: data probably can be a shape instance, then we can use gsh/shape->rect
|
;; 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))
|
(let [selrect (or (grc/make-rect (:x data) (:y data) (:width data) (:height data))
|
||||||
|
@ -566,9 +565,11 @@
|
||||||
|
|
||||||
file
|
file
|
||||||
(cond
|
(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))
|
(and component-data (:main-instance-id component-data))
|
||||||
file
|
(update file :data
|
||||||
|
(fn [data]
|
||||||
|
(ctkl/update-component data component-id dissoc :objects)))
|
||||||
|
|
||||||
(empty? children)
|
(empty? children)
|
||||||
(commit-change
|
(commit-change
|
||||||
|
|
|
@ -249,9 +249,18 @@
|
||||||
(deleteObject [_ id]
|
(deleteObject [_ id]
|
||||||
(set! file (fb/delete-object file (uuid/uuid id))))
|
(set! file (fb/delete-object file (uuid/uuid id))))
|
||||||
|
|
||||||
|
(getId [_]
|
||||||
|
(:id file))
|
||||||
|
|
||||||
|
(getCurrentPageId [_]
|
||||||
|
(:current-page-id file))
|
||||||
|
|
||||||
(asMap [_]
|
(asMap [_]
|
||||||
(clj->js file))
|
(clj->js file))
|
||||||
|
|
||||||
|
(newId [_]
|
||||||
|
(uuid/next))
|
||||||
|
|
||||||
(export [_]
|
(export [_]
|
||||||
(->> (export-file file)
|
(->> (export-file file)
|
||||||
(rx/subs!
|
(rx/subs!
|
||||||
|
@ -261,7 +270,8 @@
|
||||||
(dom/trigger-download (:name file) export-blob))))))))
|
(dom/trigger-download (:name file) export-blob))))))))
|
||||||
|
|
||||||
(defn create-file-export [^string name]
|
(defn create-file-export [^string name]
|
||||||
(File. (fb/create-file name)))
|
(binding [cfeat/*current* cfeat/default-features]
|
||||||
|
(File. (fb/create-file name))))
|
||||||
|
|
||||||
(defn exports []
|
(defn exports []
|
||||||
#js {:createFile create-file-export})
|
#js {:createFile create-file-export})
|
||||||
|
|
Loading…
Add table
Reference in a new issue