diff --git a/common/src/app/common/files/builder.cljc b/common/src/app/common/files/builder.cljc index f5519f736..811f372b5 100644 --- a/common/src/app/common/files/builder.cljc +++ b/common/src/app/common/files/builder.cljc @@ -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 diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index b1e743f64..41ff059a7 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -240,6 +240,7 @@ (when-not ^boolean (-validate s value) (let [hint (d/nilv dm/*assert-context* "check error") explain (-explain s value)] + (println (humanize-explain explain)) (throw (ex-info hint {:type :assertion :code :data-validation :hint hint diff --git a/frontend/src/app/libs/file_builder.cljs b/frontend/src/app/libs/file_builder.cljs index ea046e255..63df0eb87 100644 --- a/frontend/src/app/libs/file_builder.cljs +++ b/frontend/src/app/libs/file_builder.cljs @@ -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})