0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-06 06:18:32 -05:00

Select all inside a group select only the objects at this group level

This commit is contained in:
Pablo Alba 2022-08-02 12:57:58 +02:00
parent c62427501e
commit 52cc91f4c4
2 changed files with 46 additions and 18 deletions

View file

@ -29,7 +29,8 @@
- Improved share link options. Now you can allow non-team members to comment and/or inspect [Taiga #3056] (https://tree.taiga.io/project/penpot/us/3056) - Improved share link options. Now you can allow non-team members to comment and/or inspect [Taiga #3056] (https://tree.taiga.io/project/penpot/us/3056)
- Signin/Signup from shared link [Taiga #3472](https://tree.taiga.io/project/penpot/us/3472) - Signin/Signup from shared link [Taiga #3472](https://tree.taiga.io/project/penpot/us/3472)
- Support for import/export binary format [Taiga #2991](https://tree.taiga.io/project/penpot/us/2991) - Support for import/export binary format [Taiga #2991](https://tree.taiga.io/project/penpot/us/2991)
- Comments positioning [Taiga #https://2007](tree.taiga.io/project/penpot/us/2007) - Comments positioning [Taiga #2007](https://tree.taiga.io/project/penpot/us/2007)
- Select all inside a group select only the objects at this group level [Taiga #2382](https://tree.taiga.io/project/penpot/issue/2382)
### :bug: Bugs fixed ### :bug: Bugs fixed

View file

@ -178,11 +178,18 @@
(let [objects (wsh/lookup-page-objects state)] (let [objects (wsh/lookup-page-objects state)]
(rx/of (dwc/expand-all-parents ids objects)))))) (rx/of (dwc/expand-all-parents ids objects))))))
(defn select-all
[]
(ptk/reify ::select-all (defn- select-siblings
ptk/WatchEvent [state parent]
(watch [_ state _] (let [children (wsh/lookup-shapes state (:shapes parent))
selected (into (d/ordered-set)
(comp (remove :blocked) (map :id))
children)]
(rx/of (select-shapes selected))))
(defn- select-all-frame
[state]
(let [focus (:workspace-focus-selected state) (let [focus (:workspace-focus-selected state)
objects (-> (wsh/lookup-page-objects state) objects (-> (wsh/lookup-page-objects state)
(cp/focus-objects focus)) (cp/focus-objects focus))
@ -200,7 +207,27 @@
(comp (remove :blocked) (map :id)) (comp (remove :blocked) (map :id))
selected)] selected)]
(rx/of (select-shapes selected)))))) (rx/of (select-shapes selected))))
(defn select-all
[]
(ptk/reify ::select-all
ptk/WatchEvent
(watch [_ state _]
(let [current-selection-parents (->> (wsh/lookup-selected state)
(wsh/lookup-shapes state)
(into #{} (map :parent-id)))
num-parents (count current-selection-parents)
parent (when (= num-parents 1)
(wsh/lookup-shape state (first current-selection-parents)))]
(case num-parents
0 (select-all-frame state)
1 (if (cph/frame-shape? parent)
(select-all-frame state)
(select-siblings state parent))
nil)))))
(defn deselect-all (defn deselect-all
"Clear all possible state of drawing, edition "Clear all possible state of drawing, edition