From 2d512ef273d588b42d49eda50318fc31efac9e51 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 17 Dec 2024 16:52:08 +0100 Subject: [PATCH] :bug: Fix path edition for plugins --- frontend/src/app/plugins/parser.cljs | 70 ---------------------------- frontend/src/app/plugins/shape.cljs | 8 ++-- 2 files changed, 3 insertions(+), 75 deletions(-) diff --git a/frontend/src/app/plugins/parser.cljs b/frontend/src/app/plugins/parser.cljs index c58e6f1ea..4731528ab 100644 --- a/frontend/src/app/plugins/parser.cljs +++ b/frontend/src/app/plugins/parser.cljs @@ -340,76 +340,6 @@ (when (some? guides) (into [] (map parse-frame-guide) guides))) -;;interface PathCommand { -;; command: -;; | 'M' | 'move-to' -;; | 'Z' | 'close-path' -;; | 'L' | 'line-to' -;; | 'H' | 'line-to-horizontal' -;; | 'V' | 'line-to-vertical' -;; | 'C' | 'curve-to' -;; | 'S' | 'smooth-curve-to' -;; | 'Q' | 'quadratic-bezier-curve-to' -;; | 'T' | 'smooth-quadratic-bezier-curve-to' -;; | 'A' | 'elliptical-arc'; -;; -;; params?: { -;; x?: number; -;; y?: number; -;; c1x: number; -;; c1y: number; -;; c2x: number; -;; c2y: number; -;; rx?: number; -;; ry?: number; -;; xAxisRotation?: number; -;; largeArcFlag?: boolean; -;; sweepFlag?: boolean; -;; }; -;;} -(defn parse-command-type - [^string command-type] - (case command-type - "M" :move-to - "Z" :close-path - "L" :line-to - "H" :line-to-horizontal - "V" :line-to-vertical - "C" :curve-to - "S" :smooth-curve-to - "Q" :quadratic-bezier-curve-to - "T" :smooth-quadratic-bezier-curve-to - "A" :elliptical-arc - (parse-keyword command-type))) - -(defn parse-command-params - [^js params] - (when (some? params) - (d/without-nils - {:x (obj/get params "x") - :y (obj/get params "y") - :c1x (obj/get params "c1x") - :c1y (obj/get params "c1y") - :c2x (obj/get params "c2x") - :c2y (obj/get params "c2y") - :rx (obj/get params "rx") - :ry (obj/get params "ry") - :x-axis-rotation (obj/get params "xAxisRotation") - :large-arc-flag (obj/get params "largeArcFlag") - :sweep-flag (obj/get params "sweepFlag")}))) - -(defn parse-command - [^js command] - (when (some? command) - (d/without-nils - {:command (-> (obj/get command "command") parse-command-type) - :params (-> (obj/get command "params") parse-command-params)}))) - -(defn parse-path-content - [^js content] - (when (some? content) - (into [] (map parse-command) content))) - ;; export interface Dissolve { ;; type: 'dissolve'; ;; duration: number; diff --git a/frontend/src/app/plugins/shape.cljs b/frontend/src/app/plugins/shape.cljs index b93438b2d..bfcf2412d 100644 --- a/frontend/src/app/plugins/shape.cljs +++ b/frontend/src/app/plugins/shape.cljs @@ -15,7 +15,7 @@ [app.common.record :as crc] [app.common.schema :as sm] [app.common.spec :as us] - [app.common.svg.path.legacy-parser2 :as spp] + [app.common.svg.path :as path] [app.common.text :as txt] [app.common.types.component :as ctk] [app.common.types.container :as ctn] @@ -1326,12 +1326,10 @@ (cond-> (or (cfh/path-shape? data) (cfh/bool-shape? data)) (crc/add-properties! {:name "content" - :get #(-> % u/proxy->shape :content format/format-path-content) + :get #(-> % u/proxy->shape :content upf/format-path) :set (fn [_ value] - (let [content - (->> (parser/parse-path-content value) - (spp/simplify-commands))] + (let [content (->> (path/parse value))] (cond (not (cfh/path-shape? data)) (u/display-not-valid :content-type type)