mirror of https://github.com/logseq/logseq
Expand fix
parent
95ac09330c
commit
306128d2d7
|
@ -35,45 +35,49 @@
|
|||
nodes))
|
||||
|
||||
(defn collapse-non-heading!
|
||||
[all-headings id]
|
||||
[id]
|
||||
(when-let [node (gdom/getElement id)]
|
||||
(let [children (next (array-seq (d/children node)))]
|
||||
(doseq [node children]
|
||||
(d/hide! node)))))
|
||||
|
||||
(defn expand-non-heading!
|
||||
[all-headings id]
|
||||
[id]
|
||||
(when-let [node (gdom/getElement id)]
|
||||
(let [children (next (array-seq (d/children node)))]
|
||||
(doseq [node children]
|
||||
(d/show! node)))))
|
||||
|
||||
(defn conj-heading!
|
||||
[heading-id]
|
||||
(let [id (uuid (string/replace heading-id "ls-heading-parent-" ""))]
|
||||
(swap! state/collapsed-headings conj id)))
|
||||
(defn disj-heading!
|
||||
[heading-id]
|
||||
(let [id (uuid (string/replace heading-id "ls-heading-parent-" ""))]
|
||||
(swap! state/collapsed-headings disj id)))
|
||||
|
||||
(defn collapse!
|
||||
[headings-id heading-id]
|
||||
(let [all-headings (get-headings headings-id)]
|
||||
(collapse-non-heading! all-headings heading-id)
|
||||
(collapse-non-heading! heading-id)
|
||||
(when-let [node (gdom/getElement heading-id)]
|
||||
(let [children (get-heading-children all-headings node)]
|
||||
(doseq [node children]
|
||||
(let [id (uuid (string/replace (gobj/get node "id") "ls-heading-parent-" ""))]
|
||||
(prn {:id id})
|
||||
(swap! state/collapsed-headings conj id))
|
||||
(conj-heading! (gobj/get node "id"))
|
||||
(d/hide! node))))
|
||||
(let [id (uuid (string/replace heading-id "ls-heading-parent-" ""))]
|
||||
(swap! state/collapsed-headings conj id))))
|
||||
(conj-heading! heading-id)))
|
||||
|
||||
(defn expand!
|
||||
[headings-id heading-id]
|
||||
(let [all-headings (get-headings headings-id)]
|
||||
(expand-non-heading! all-headings heading-id)
|
||||
(expand-non-heading! heading-id)
|
||||
(when-let [node (gdom/getElement heading-id)]
|
||||
(let [children (get-heading-children all-headings node)]
|
||||
(doseq [node children]
|
||||
(let [id (uuid (string/replace (gobj/get node "id") "ls-heading-parent-" ""))]
|
||||
(swap! state/collapsed-headings disj id))
|
||||
(disj-heading! (gobj/get node "id"))
|
||||
(d/show! node))))
|
||||
(let [id (uuid (string/replace heading-id "ls-heading-parent-" ""))]
|
||||
(swap! state/collapsed-headings disj id))))
|
||||
(disj-heading! heading-id)))
|
||||
|
||||
(defn get-control-node
|
||||
[heading]
|
||||
|
@ -86,27 +90,21 @@
|
|||
[id]
|
||||
(let [all-headings (get-headings id)
|
||||
headings (next all-headings)]
|
||||
(when (seq headings)
|
||||
(let [toggle-state @state/toggle-state]
|
||||
(doseq [heading headings]
|
||||
(prn "control node: " (get-control-node heading))
|
||||
(when-let [element (get-control-node heading)]
|
||||
(if toggle-state
|
||||
;; expand
|
||||
(do
|
||||
(d/remove-class! element "caret-right")
|
||||
(d/add-class! element "caret-down")
|
||||
(expand! id (gobj/get heading "id")))
|
||||
|
||||
(do
|
||||
(d/remove-class! element "caret-down")
|
||||
(d/add-class! element "caret-right")
|
||||
(collapse! id (gobj/get heading "id"))))))
|
||||
(swap! state/toggle-state not)
|
||||
(when toggle-state
|
||||
(reset! state/collapsed-headings #{})))))
|
||||
|
||||
(comment
|
||||
(def all-headings (get-headings "dGVzdC5vcmc="))
|
||||
(def id "Ideas")
|
||||
(collapse! all-headings id)
|
||||
(expand! all-headings id)
|
||||
)
|
||||
(reset! state/collapsed-headings #{}))
|
||||
(swap! state/toggle-state not)))))
|
||||
|
|
|
@ -249,7 +249,7 @@
|
|||
collapsed? (contains? collapsed-headings uuid)
|
||||
class "control block no-underline text-gray-700 hover:bg-gray-100 transition ease-in-out duration-150"
|
||||
class (cond
|
||||
(and @control-show? collapsed?)
|
||||
collapsed?
|
||||
(str class " caret-right")
|
||||
|
||||
(and @control-show? (not collapsed?))
|
||||
|
|
Loading…
Reference in New Issue