diff --git a/backend/src/app/features/components_v2.clj b/backend/src/app/features/components_v2.clj index 9e142aeb3..f4e88ddd8 100644 --- a/backend/src/app/features/components_v2.clj +++ b/backend/src/app/features/components_v2.clj @@ -13,6 +13,7 @@ [app.common.files.changes-builder :as fcb] [app.common.files.helpers :as cfh] [app.common.files.migrations :as fmg] + [app.common.files.shapes-builder :as sbuilder] [app.common.files.shapes-helpers :as cfsh] [app.common.files.validate :as cfv] [app.common.fressian :as fres] @@ -25,7 +26,6 @@ [app.common.math :as mth] [app.common.schema :as sm] [app.common.svg :as csvg] - [app.common.svg.shapes-builder :as sbuilder] [app.common.types.color :as ctc] [app.common.types.component :as ctk] [app.common.types.components-list :as ctkl] diff --git a/common/src/app/common/svg/shapes_builder.cljc b/common/src/app/common/files/shapes_builder.cljc similarity index 99% rename from common/src/app/common/svg/shapes_builder.cljc rename to common/src/app/common/files/shapes_builder.cljc index aa0a49548..78cde6c76 100644 --- a/common/src/app/common/svg/shapes_builder.cljc +++ b/common/src/app/common/files/shapes_builder.cljc @@ -4,7 +4,7 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns app.common.svg.shapes-builder +(ns app.common.files.shapes-builder "A SVG to Shapes builder." (:require [app.common.colors :as clr] @@ -21,7 +21,7 @@ [app.common.math :as mth] [app.common.schema :as sm :refer [max-safe-int min-safe-int]] [app.common.svg :as csvg] - [app.common.svg.path :as path] + [app.common.types.path :as path] [app.common.types.path.segment :as path.segm] [app.common.types.shape :as cts] [app.common.uuid :as uuid] @@ -219,7 +219,7 @@ (defn create-path-shape [name frame-id svg-data {:keys [attrs] :as data}] (when (and (contains? attrs :d) (seq (:d attrs))) (let [transform (csvg/parse-transform (:transform attrs)) - content (cond-> (path/parse (:d attrs)) + content (cond-> (path/from-string (:d attrs)) (some? transform) (path.segm/transform-content transform)) diff --git a/common/src/app/common/types/path.cljc b/common/src/app/common/types/path.cljc index bdbbd9e39..27e0136cf 100644 --- a/common/src/app/common/types/path.cljc +++ b/common/src/app/common/types/path.cljc @@ -36,6 +36,10 @@ [data] (impl/from-bytes data)) +(defn from-string + [data] + (impl/from-string data)) + (defn check-path-content [content] (impl/check-content-like content)) diff --git a/frontend/src/app/main/data/workspace/media.cljs b/frontend/src/app/main/data/workspace/media.cljs index a2a7968c0..60c4ff25b 100644 --- a/frontend/src/app/main/data/workspace/media.cljs +++ b/frontend/src/app/main/data/workspace/media.cljs @@ -12,10 +12,10 @@ [app.common.exceptions :as ex] [app.common.files.builder :as fb] [app.common.files.changes-builder :as pcb] + [app.common.files.shapes-builder :as sb] [app.common.logging :as log] [app.common.math :as mth] [app.common.schema :as sm] - [app.common.svg.shapes-builder :as csvg.shapes-builder] [app.common.types.container :as ctn] [app.common.types.shape :as cts] [app.common.uuid :as uuid] @@ -299,7 +299,7 @@ process-svg (fn [svg-data] (let [[root-svg-shape children] - (csvg.shapes-builder/create-svg-shapes svg-data pos objects uuid/zero nil #{} false) + (sb/create-svg-shapes svg-data pos objects uuid/zero nil #{} false) frame-shape (cts/setup-shape diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index 8374a9c41..1e1b0a098 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -10,8 +10,8 @@ [app.common.data.macros :as dm] [app.common.files.changes-builder :as pcb] [app.common.files.helpers :as cfh] + [app.common.files.shapes-builder :as sb] [app.common.svg :as csvg] - [app.common.svg.shapes-builder :as csvg.shapes-builder] [app.common.types.shape-tree :as ctst] [app.common.uuid :as uuid] [app.main.data.changes :as dch] @@ -92,7 +92,7 @@ base-id) [new-shape new-children] - (csvg.shapes-builder/create-svg-shapes id svg-data position objects frame-id parent-id selected true) + (sb/create-svg-shapes id svg-data position objects frame-id parent-id selected true) changes (-> (pcb/empty-changes it page-id) (pcb/with-objects objects)