diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc index 0d68b7dcd2..35e0fdfb3f 100644 --- a/common/src/app/common/files/validate.cljc +++ b/common/src/app/common/files/validate.cljc @@ -353,19 +353,19 @@ "This shape has children with the same swap slot" shape file page))) -(defn- check-valid-touched - "Validate that the text touched flags are coherent." - [shape file page] - (let [touched-groups (ctk/normal-touched-groups shape) - content-touched? (touched-groups :content-group) - text-touched? (or (touched-groups :text-content-text) - (touched-groups :text-content-attribute) - (touched-groups :text-content-structure))] +#_(defn- check-valid-touched + "Validate that the text touched flags are coherent." + [shape file page] + (let [touched-groups (ctk/normal-touched-groups shape) + content-touched? (touched-groups :content-group) + text-touched? (or (touched-groups :text-content-text) + (touched-groups :text-content-attribute) + (touched-groups :text-content-structure))] ;; For now we only check this combination, that has been reported in some bugs - (when (and text-touched? (not content-touched?)) - (report-error :invalid-text-touched - "This thape has text type touched but not content touched" - shape file page)))) + (when (and text-touched? (not content-touched?)) + (report-error :invalid-text-touched + "This thape has text type touched but not content touched" + shape file page)))) (defn- check-shape-main-root-top "Root shape of a top main instance: @@ -409,7 +409,7 @@ (check-ref-is-head shape file page libraries) (check-empty-swap-slot shape file page) (check-duplicate-swap-slot shape file page) - (check-valid-touched shape file page) + #_(check-valid-touched shape file page) ;; TODO: activate this again after we add a migration that repairs files automatically (run! #(check-shape % file page libraries :context :copy-top :library-exists library-exists) (:shapes shape)))) (defn- check-shape-copy-root-nested @@ -420,7 +420,7 @@ [shape file page libraries library-exists] (check-component-not-main-head shape file page libraries) (check-component-not-root shape file page) - (check-valid-touched shape file page) + #_(check-valid-touched shape file page) ;; We can have situations where the nested copy and the ancestor copy come from different libraries and some of them have been dettached ;; so we only validate the shape-ref if the ancestor is from a valid library (when library-exists @@ -445,7 +445,7 @@ (check-component-ref shape file page libraries) (check-ref-is-not-head shape file page libraries) (check-empty-swap-slot shape file page) - (check-valid-touched shape file page) + #_(check-valid-touched shape file page) (run! #(check-shape % file page libraries :context :copy-any) (:shapes shape))) (defn- check-shape-not-component diff --git a/frontend/src/app/main/data/workspace/shortcuts.cljs b/frontend/src/app/main/data/workspace/shortcuts.cljs index c1741df475..b36a28006b 100644 --- a/frontend/src/app/main/data/workspace/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/shortcuts.cljs @@ -213,22 +213,22 @@ :fn #(emit-when-no-readonly (dw/vertical-order-selected :bottom))} :move-fast-up {:tooltip (ds/shift ds/up-arrow) - :command ["shift+up"] + :command ["shift+up" "shift+alt+up"] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwt/move-selected :up true))} :move-fast-down {:tooltip (ds/shift ds/down-arrow) - :command ["shift+down"] + :command ["shift+down" "shift+alt+down"] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwt/move-selected :down true))} :move-fast-right {:tooltip (ds/shift ds/right-arrow) - :command ["shift+right" "shift+alt+right" "alt+shift+right"] + :command ["shift+right" "shift+alt+right"] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwt/move-selected :right true))} :move-fast-left {:tooltip (ds/shift ds/left-arrow) - :command ["shift+left" "shift+alt+left" "alt+shift+left"] + :command ["shift+left" "shift+alt+left"] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwt/move-selected :left true))} diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 87d8a50dd9..0e0f1b8558 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -569,8 +569,7 @@ (let [single? (= (count shapes) 1) objects (deref refs/workspace-page-objects) can-make-component (every? true? (map #(ctn/valid-shape-for-component? objects %) shapes)) - heads (filter ctk/instance-head? shapes) - components-menu-entries (cmm/generate-components-menu-entries heads) + components-menu-entries (cmm/generate-components-menu-entries shapes) variant-container? (and single? (ctk/is-variant-container? (first shapes))) all-main? (every? ctk/main-instance? shapes) any-variant? (some ctk/is-variant? shapes) diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs index 2fb9829c1d..e7d5647cc2 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs @@ -34,7 +34,7 @@ [app.util.array :as array] [app.util.dom :as dom] [app.util.dom.dnd :as dnd] - [app.util.i18n :as i18n :refer [tr c]] + [app.util.i18n :as i18n :refer [c tr]] [app.util.strings :refer [matches-search]] [app.util.timers :as ts] [cljs.spec.alpha :as s] @@ -358,8 +358,10 @@ ;; For when it's only one shape shape (first shapes) - id (:id shape) + shape-id (:id shape) + main-instance? (ctk/main-instance? shape) + variant-container? (ctk/is-variant-container? shape) component-id (:component-id shape) variant-id (:variant-id shape) @@ -409,7 +411,7 @@ #(st/emit! (dwl/reset-components (map :id touched-not-dangling))) do-update-component-sync - #(st/emit! (dwl/update-component-sync id library-id)) + #(st/emit! (dwl/update-component-sync shape-id library-id)) do-update-remote-component (fn [] @@ -429,21 +431,24 @@ (do-update-remote-component)) do-show-in-assets - #(st/emit! (dw/show-component-in-assets component-id)) + (let [component-id (if variant-container? + (->> (:shapes shape) (mapv #(get objects %)) first :component-id) + component-id)] + #(st/emit! (dw/show-component-in-assets component-id))) do-create-annotation - #(st/emit! (dw/set-annotations-id-for-create id)) + #(st/emit! (dw/set-annotations-id-for-create shape-id)) do-add-variant #(if (ctk/is-variant? shape) (st/emit! (ptk/event ::ev/event {::ev/name "add-new-variant" :trigger (if for-design-tab? "design-tab-menu-variant" "context-menu-variant")}) - (dwv/add-new-variant id)) + (dwv/add-new-variant shape-id)) (st/emit! (ptk/event ::ev/event {::ev/name "transform-in-variant" :trigger (if for-design-tab? "design-tab-menu" "context-menu")}) - (dwv/transform-in-variant id))) + (dwv/transform-in-variant shape-id))) do-add-new-property #(st/emit! @@ -478,7 +483,8 @@ (when (= 1 (count comps-to-restore)) (ts/schedule 1000 #(do-show-component nil true))))) - menu-entries [(when (and (or (not multi) same-variant?) main-instance?) + menu-entries [(when (or (and (not multi) (or variant-container? main-instance?)) + (and multi same-variant?)) {:title (tr "workspace.shape.menu.show-in-assets") :action do-show-in-assets}) (when (and (not multi) main-instance? local-component? lacks-annotation?) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index 087f62e74a..46c431ef3a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.workspace.sidebar.options.menus.component (:require-macros [app.main.style :as stl]) (:require - [app.common.data :as d] [app.common.data.macros :as dm] [app.common.files.helpers :as cfh] @@ -1069,13 +1068,14 @@ variants (mapv #(get objects %) (:shapes shape)) variant-id (:variant-id (first variants)) + variant-components (cfv/find-variant-components data objects variant-id) malformed-ids (->> variants (filterv #(some? (:variant-error %))) (mapv :id)) malformed? (d/not-empty? malformed-ids) - duplicated-ids (->> (cfv/find-variant-components data objects variant-id) + duplicated-ids (->> variant-components get-main-ids-with-duplicated-variant-props-and-values) duplicated? (d/not-empty? duplicated-ids) @@ -1088,6 +1088,11 @@ menu-open* (mf/use-state false) menu-open? (deref menu-open*) + show-in-assets-panel + (mf/use-fn + (mf/deps variants) + #(st/emit! (dw/show-component-in-assets (:component-id (first variants))))) + create-variant (mf/use-fn (mf/deps shape) @@ -1104,10 +1109,12 @@ (dwv/add-new-property variant-id {:property-value "Value 1" :editing? true})))) - menu-entries [{:title (tr "workspace.shape.menu.add-variant-property") - :action (partial add-new-property "design-tab-menu-component")} + menu-entries [{:title (tr "workspace.shape.menu.show-in-assets") + :action show-in-assets-panel} {:title (tr "workspace.shape.menu.add-variant") - :action (partial create-variant "design-tab-menu-component")}] + :action (partial create-variant "design-tab-menu-component")} + {:title (tr "workspace.shape.menu.add-variant-property") + :action (partial add-new-property "design-tab-menu-component")}] toggle-content (mf/use-fn