mirror of
https://github.com/penpot/penpot.git
synced 2025-01-04 13:50:12 -05:00
🐛 Fix path edition for plugins
This commit is contained in:
parent
b8ebbe8c3c
commit
2d512ef273
2 changed files with 3 additions and 75 deletions
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue