add more context menu actions

pull/9926/head
Konstantinos Kaloutas 2023-07-10 19:28:56 +03:00 committed by Tienson Qin
parent bf17c700c8
commit d47c4d2c28
2 changed files with 12 additions and 3 deletions

View File

@ -181,8 +181,12 @@
(state/clear-sidebar-blocks!) (state/clear-sidebar-blocks!)
(state/hide-right-sidebar!))} "Close all" nil) (state/hide-right-sidebar!))} "Close all" nil)
[:hr.menu-separator] [:hr.menu-separator]
(ui/menu-link {:on-click #(state/sidebar-block-toggle-collapse! db-id)} (if collapsed? "Expand" "Collapse") nil) (when-not collapsed? (ui/menu-link {:on-click #(state/sidebar-block-toggle-collapse! db-id)} "Collapse" nil))
(ui/menu-link {:on-click #(state/sidebar-block-collapse-rest! db-id)} "Collapse others" nil) (ui/menu-link {:on-click #(state/sidebar-block-collapse-rest! db-id)} "Collapse others" nil)
(ui/menu-link {:on-click #(state/sidebar-block-set-collapsed-all! true)} "Collapse all" nil)
[:hr.menu-separator]
(when collapsed? (ui/menu-link {:on-click #(state/sidebar-block-toggle-collapse! db-id)} "Expand" nil))
(ui/menu-link {:on-click #(state/sidebar-block-set-collapsed-all! false)} "Expand all" nil)
(when (integer? db-id) [:hr.menu-separator]) (when (integer? db-id) [:hr.menu-separator])
(when (integer? db-id) (when (integer? db-id)
(let [name (:block/name (db/entity db-id))] (let [name (:block/name (db/entity db-id))]
@ -218,7 +222,6 @@
(reset! *drag-from nil)) (reset! *drag-from nil))
:on-click (fn [event] :on-click (fn [event]
(.preventDefault event) (.preventDefault event)
(js/console.log event.which)
(state/sidebar-block-toggle-collapse! db-id)) (state/sidebar-block-toggle-collapse! db-id))
:on-mouse-up (fn [event] :on-mouse-up (fn [event]
(when (= (.-which (.-nativeEvent event)) 2) (when (= (.-which (.-nativeEvent event)) 2)

View File

@ -1130,7 +1130,13 @@ Similar to re-frame subscriptions"
(defn sidebar-block-collapse-rest! (defn sidebar-block-collapse-rest!
[db-id] [db-id]
(let [items (disj (set (map second (:sidebar/blocks @state))) db-id)] (let [items (disj (set (map second (:sidebar/blocks @state))) db-id)]
(for [item items] (set-state! [:ui/sidebar-collapsed-blocks item] true)))) (doseq [item items] (set-state! [:ui/sidebar-collapsed-blocks item] true))))
(defn sidebar-block-set-collapsed-all!
[collapsed?]
(let [items (map second (:sidebar/blocks @state))]
(doseq [item items]
(set-state! [:ui/sidebar-collapsed-blocks item] collapsed?))))
(defn get-edit-block (defn get-edit-block
[] []