0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00

🎉 Rename selected layer via shortcut and context menu option

This commit is contained in:
Pablo Alba 2024-10-29 12:59:34 +01:00 committed by Andrey Antukh
parent b86f2ba90d
commit 48c41df054
6 changed files with 42 additions and 1 deletions

View file

@ -17,9 +17,11 @@
- Viewer role for team members [Taiga #1056 & #6590](https://tree.taiga.io/project/penpot/us/1056 & https://tree.taiga.io/project/penpot/us/6590) - Viewer role for team members [Taiga #1056 & #6590](https://tree.taiga.io/project/penpot/us/1056 & https://tree.taiga.io/project/penpot/us/6590)
- File history versions management [Taiga](https://tree.taiga.io/project/penpot/us/187?milestone=411120) - File history versions management [Taiga](https://tree.taiga.io/project/penpot/us/187?milestone=411120)
- Rename selected layer via keyboard shortcut and context menu option [Taiga #8882](https://tree.taiga.io/project/penpot/us/8882)
### :bug: Bugs fixed ### :bug: Bugs fixed
## 2.3.1 ## 2.3.1
### :bug: Bugs fixed ### :bug: Bugs fixed

View file

@ -100,6 +100,7 @@
(declare ^:private workspace-initialized) (declare ^:private workspace-initialized)
(declare ^:private libraries-fetched) (declare ^:private libraries-fetched)
(declare go-to-layout)
;; --- Initialize Workspace ;; --- Initialize Workspace
@ -810,6 +811,21 @@
(d/not-empty? hover-guides) (d/not-empty? hover-guides)
(rx/of (dwgu/remove-guides hover-guides))))))) (rx/of (dwgu/remove-guides hover-guides)))))))
;; --- Start renaming selected shape
(defn start-rename-selected
"Rename selected shape."
[]
(ptk/reify ::start-rename-selected
ptk/WatchEvent
(watch [_ state _]
(let [selected (wsh/lookup-selected state)
id (first selected)]
(when (= (count selected) 1)
(rx/of (go-to-layout :layers)
(start-rename-shape id)))))))
;; --- Shape Vertical Ordering ;; --- Shape Vertical Ordering
(def valid-vertical-locations (def valid-vertical-locations

View file

@ -129,9 +129,12 @@
:subsections [:edit] :subsections [:edit]
:fn #(st/emit! esc-pressed)} :fn #(st/emit! esc-pressed)}
;; MODIFY LAYERS ;; MODIFY LAYERS
:rename {:tooltip (ds/alt "N")
:command "alt+n"
:subsections [:edit]
:fn #(emit-when-no-readonly (dw/start-rename-selected))}
:group {:tooltip (ds/meta "G") :group {:tooltip (ds/meta "G")
:command (ds/c-mod "g") :command (ds/c-mod "g")

View file

@ -226,6 +226,16 @@
:on-click do-toggle-thumbnail}]) :on-click do-toggle-thumbnail}])
[:& menu-separator]]))) [:& menu-separator]])))
(mf/defc context-menu-rename
[{:keys [shapes]}]
(let [do-rename #(st/emit! (dw/start-rename-selected))]
(when (= (count shapes) 1)
[:*
[:& menu-separator]
[:& menu-entry {:title (tr "workspace.shape.menu.rename")
:shortcut (sc/get-tooltip :rename)
:on-click do-rename}]])))
(mf/defc context-menu-group (mf/defc context-menu-group
[{:keys [shapes]}] [{:keys [shapes]}]
@ -501,6 +511,7 @@
[:> context-menu-layer-position props] [:> context-menu-layer-position props]
[:> context-menu-flip props] [:> context-menu-flip props]
[:> context-menu-thumbnail props] [:> context-menu-thumbnail props]
[:> context-menu-rename props]
[:> context-menu-group props] [:> context-menu-group props]
[:> context-focus-mode-menu props] [:> context-focus-mode-menu props]
[:> context-menu-path props] [:> context-menu-path props]

View file

@ -5956,6 +5956,10 @@ msgstr "Bring to front"
msgid "workspace.shape.menu.go-main" msgid "workspace.shape.menu.go-main"
msgstr "Go to main component file" msgstr "Go to main component file"
#: src/app/main/ui/workspace/context_menu.cljs:234
msgid "workspace.shape.menu.rename"
msgstr "Rename"
#: src/app/main/ui/workspace/context_menu.cljs:261 #: src/app/main/ui/workspace/context_menu.cljs:261
msgid "workspace.shape.menu.group" msgid "workspace.shape.menu.group"
msgstr "Group" msgstr "Group"

View file

@ -5934,6 +5934,11 @@ msgstr "Mover al frente"
msgid "workspace.shape.menu.go-main" msgid "workspace.shape.menu.go-main"
msgstr "Ir al archivo del componente principal" msgstr "Ir al archivo del componente principal"
#: src/app/main/ui/workspace/context_menu.cljs:234
msgid "workspace.shape.menu.rename"
msgstr "Renombrar"
#: src/app/main/ui/workspace/context_menu.cljs:261 #: src/app/main/ui/workspace/context_menu.cljs:261
msgid "workspace.shape.menu.group" msgid "workspace.shape.menu.group"
msgstr "Agrupar" msgstr "Agrupar"