enhance: make select-all-blocks work globally

This commit is contained in:
Weihua Lu
2021-06-16 12:51:03 +08:00
committed by Tienson Qin
parent f37ee5e584
commit af9f583521
2 changed files with 18 additions and 17 deletions

View File

@@ -946,14 +946,6 @@
first)]
(state/exit-editing-and-set-selected-blocks! [block])))
(defn select-all-blocks!
[]
(when-let [current-input-id (state/get-edit-input-id)]
(let [input (gdom/getElement current-input-id)
blocks-container (util/rec-get-blocks-container input)
blocks (dom/by-class blocks-container "ls-block")]
(state/exit-editing-and-set-selected-blocks! blocks))))
(defn- get-selected-blocks-with-children
[]
(when-let [blocks (seq (state/get-selection-blocks))]
@@ -3056,3 +3048,14 @@
(if all-collapsed?
(expand-all!)
(collapse-all!))))
(defn select-all-blocks!
[]
(if-let [current-input-id (state/get-edit-input-id)]
(let [input (gdom/getElement current-input-id)
blocks-container (util/rec-get-blocks-container input)
blocks (dom/by-class blocks-container "ls-block")]
(state/exit-editing-and-set-selected-blocks! blocks))
(-> (gdom/getElementsByClass "ls-block")
array-seq
state/exit-editing-and-set-selected-blocks!)))