diff --git a/CHANGES.md b/CHANGES.md index be559d20ad..18f2224ed6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -103,6 +103,7 @@ example. It's still usable as before, we just removed the example. - Fix problem with plugins generating code for pages different than current one [Taiga #12312](https://tree.taiga.io/project/penpot/issue/12312) - Fix input confirmation behavior is not uniform [Taiga #12294](https://tree.taiga.io/project/penpot/issue/12294) - Fix copy/pasting application/transit+json [Taiga #12721](https://tree.taiga.io/project/penpot/issue/12721) +- Fix problem with plugins content attribute [Plugins #209](https://github.com/penpot/penpot-plugins/issues/209) ## 2.11.1 diff --git a/common/src/app/common/types/path.cljc b/common/src/app/common/types/path.cljc index c33d80095b..7007d08cb2 100644 --- a/common/src/app/common/types/path.cljc +++ b/common/src/app/common/types/path.cljc @@ -267,3 +267,4 @@ (-> (stp/convert-to-path shape objects) (update :content impl/path-data)))) +(dm/export impl/decode-segments) diff --git a/common/src/app/common/types/path/impl.cljc b/common/src/app/common/types/path/impl.cljc index def765f17f..8b2ed4a315 100644 --- a/common/src/app/common/types/path/impl.cljc +++ b/common/src/app/common/types/path/impl.cljc @@ -565,6 +565,9 @@ (def check-content (sm/check-fn schema:content)) +(def decode-segments + (sm/lazy-decoder schema:segments sm/json-transformer)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CONSTRUCTORS & PREDICATES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/frontend/src/app/main/ui/inspect/right_sidebar.scss b/frontend/src/app/main/ui/inspect/right_sidebar.scss index 74cc399982..84ec4ec31b 100644 --- a/frontend/src/app/main/ui/inspect/right_sidebar.scss +++ b/frontend/src/app/main/ui/inspect/right_sidebar.scss @@ -124,8 +124,7 @@ .inspect-tab-switcher-label { @include use-typography("body-medium"); color: var(--color-foreground-primary); - flex: 0; - min-inline-size: fit-content; + flex: 0 1 40%; } .inspect-tab-switcher-controls { diff --git a/frontend/src/app/plugins/parser.cljs b/frontend/src/app/plugins/parser.cljs index 0033246e49..5d4148662d 100644 --- a/frontend/src/app/plugins/parser.cljs +++ b/frontend/src/app/plugins/parser.cljs @@ -7,6 +7,8 @@ (ns app.plugins.parser (:require [app.common.data :as d] + [app.common.json :as json] + [app.common.types.path :as path] [app.common.uuid :as uuid] [app.util.object :as obj] [cuerdas.core :as str])) @@ -514,3 +516,8 @@ (case axis "horizontal" :y "vertical" :x)) + +(defn parse-commands + [commands] + (-> (json/->clj commands) + (path/decode-segments))) diff --git a/frontend/src/app/plugins/shape.cljs b/frontend/src/app/plugins/shape.cljs index 6c3e60a32d..b047954397 100644 --- a/frontend/src/app/plugins/shape.cljs +++ b/frontend/src/app/plugins/shape.cljs @@ -1034,8 +1034,8 @@ (fn [] (let [shape (u/locate-shape file-id page-id id)] (cond - (not (cfh/path-shape? shape)) - (u/display-not-valid :makeMask (:type shape)) + (and (not (cfh/path-shape? shape)) (not (cfh/bool-shape? shape))) + (u/display-not-valid :toD (:type shape)) :else (.toString (:content shape))))) @@ -1488,13 +1488,37 @@ (cond-> (or (cfh/path-shape? data) (cfh/bool-shape? data)) (crc/add-properties! - {:name "content" + {:name "commands" + :get #(-> % u/proxy->shape :content format/format-path-content) + :set + (fn [_ value] + (let [segments (parser/parse-commands value)] + (cond + (not (r/check-permission plugin-id "content:write")) + (u/display-not-valid :content "Plugin doesn't have 'content:write' permission") + + (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) + (assoc :points points)))))))))} + {:name "d" :get #(-> % u/proxy->shape :content str) :set (fn [_ value] - (let [segments (if (string? value) - (svg.path/parse value) - 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") @@ -1514,4 +1538,7 @@ (-> shape (assoc :content content) (assoc :selrect selrect) - (assoc :points points)))))))))})))))) + (assoc :points points)))))))))} + {:name "content" + :get #(.-d %) + :set (fn [self value] (set! (.-d self) value))})))))) diff --git a/frontend/translations/en.po b/frontend/translations/en.po index d2fd9da755..0a5c4a727f 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -1853,7 +1853,7 @@ msgstr "Select a shape, board or group to inspect their properties and code" #: src/app/main/ui/inspect/right_sidebar.cljs:166 msgid "inspect.layer-info" -msgstr "Select inspect tab" +msgstr "Layer info" #: src/app/main/ui/inspect/right_sidebar.cljs:137 msgid "inspect.multiple-selected" diff --git a/frontend/translations/lv.po b/frontend/translations/lv.po index 767c631f97..ebe6191634 100644 --- a/frontend/translations/lv.po +++ b/frontend/translations/lv.po @@ -1819,7 +1819,7 @@ msgstr "Jāatlasa apveids, plātne vai kopa, lai apskatītu to īpašības un ko #: src/app/main/ui/inspect/right_sidebar.cljs:166 msgid "inspect.layer-info" -msgstr "Atlasīt izpētīšanas cilni" +msgstr "Slāņa informācija" #: src/app/main/ui/inspect/right_sidebar.cljs:137 msgid "inspect.multiple-selected"