Repository: penpot/penpot
File: frontend/src/app/plugins/shape.cljs (ClojureScript)

Code before:
                   (let [id (obj/get self "$id")
                         value (keyword value)]
                     (cond
                       (not (contains? #{:fix :auto} value))
                       (u/display-not-valid :verticalSizing value)

                       (not (r/check-permission plugin-id "content:write"))
                       (u/display-not-valid :verticalSizing "Plugin doesn't have 'content:write' permission")

                       :else
                       (st/emit! (dwsl/update-layout #{id} {:layout-item-v-sizing value})))))}


                {:name "variants"
                 :enumerable false
                 :get
                 (fn [self]
                   (let [shape (-> self u/proxy->shape)]
                     (when (ctk/is-variant-container? shape)
                       (variant-proxy plugin-id file-id (:id shape)))))})))

         (cond-> (cfh/text-shape? data) (text/add-text-props plugin-id))

         (cond-> (or (cfh/path-shape? data) (cfh/bool-shape? data))
           (crc/add-properties!
            {:name "content"
             :get #(-> % u/proxy->shape :content str)
             :set
             (fn [_ value]
               (let [segments (if (string? value)
                                (svg.path/parse value)
                                value)]
                 (cond
                   (not (r/check-permission plugin-id "content:write"))
                   (u/display-not-valid :content "Plugin doesn't have 'content:write' permission")

                   (not (cfh/path-shape? data))
                   (u/display-not-valid :content-type type)

                   (not (sm/validate path/schema:segments segments))
                   (u/display-not-valid :content segments)

                   :else
                   (let [selrect (path/calc-selrect segments)
                         content (path/from-plain segments)
                         points  (grc/rect->points selrect)]
                     (st/emit! (dwsh/update-shapes [id]
                                                   (fn [shape]
                                                     (-> shape
                                                         (assoc :content content)
                                                         (assoc :selrect selrect)

Review comment (suggestion):
The properties that have only `get` should be defined as `readonly` in the plugin-types.

Code after:
                       (not (r/check-permission plugin-id "content:write"))
                       (u/display-not-valid :horizontalSizing "Plugin doesn't have 'content:write' permission")

                       :else
                       (st/emit! (dwsl/update-layout #{id} {:layout-item-h-sizing value})))))}

                {:name "verticalSizing"
                 :get #(-> % u/proxy->shape :layout-item-v-sizing (d/nilv :fix) d/name)
                 :set
                 (fn [self value]
                   (let [id (obj/get self "$id")
                         value (keyword value)]
                     (cond
                       (not (contains? #{:fix :auto} value))
                       (u/display-not-valid :verticalSizing value)

                       (not (r/check-permission plugin-id "content:write"))
                       (u/display-not-valid :verticalSizing "Plugin doesn't have 'content:write' permission")

                       :else
                       (st/emit! (dwsl/update-layout #{id} {:layout-item-v-sizing value})))))}

                {:name "variants"
                 :enumerable false
                 :get
                 (fn [self]
                   (let [shape (-> self u/proxy->shape)]
                     (when (ctk/is-variant-container? shape)
                       (variant-proxy plugin-id file-id (:id shape)))))})))

         (cond-> (cfh/text-shape? data) (text/add-text-props plugin-id))

         (cond-> (or (cfh/path-shape? data) (cfh/bool-shape? data))
           (crc/add-properties!
            {:name "content"
             :get #(-> % u/proxy->shape :content str)
             :set
             (fn [_ value]
               (let [segments (if (string? value)
                                (svg.path/parse value)
                                value)]
                 (cond
                   (not (r/check-permission plugin-id "content:write"))
                   (u/display-not-valid :content "Plugin doesn't have 'content:write' permission")

                   (not (cfh/path-shape? data))
                   (u/display-not-valid :content-type type)

                   (not (sm/validate path/schema:segments segments))
                   (u/display-not-valid :content segments)