mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 18:36:43 +00:00
feat: add data-refs to empower css mods
The discussion thread: https://discuss.logseq.com/t/propositions-to-empower-css-mods/289
This commit is contained in:
@@ -15,7 +15,14 @@
|
||||
(dissoc h :block/meta))) col)
|
||||
parent? (fn [item children]
|
||||
(and (seq children)
|
||||
(every? #(< (:block/level item) (:block/level %)) children)))]
|
||||
(every? #(< (:block/level item) (:block/level %)) children)))
|
||||
get-all-refs (fn [block]
|
||||
(let [refs (if-let [refs (seq (:block/refs-with-children block))]
|
||||
refs
|
||||
(concat
|
||||
(:block/ref-pages block)
|
||||
(:block/tags block)))]
|
||||
(distinct refs)))]
|
||||
(loop [col (reverse col)
|
||||
children (list)]
|
||||
(if (empty? col)
|
||||
@@ -23,7 +30,8 @@
|
||||
(let [[item & others] col
|
||||
cur-level (:block/level item)
|
||||
bottom-level (:block/level (first children))
|
||||
pre-block? (:block/pre-block? item)]
|
||||
pre-block? (:block/pre-block? item)
|
||||
item (assoc item :block/refs-with-children (get-all-refs item))]
|
||||
(cond
|
||||
(empty? children)
|
||||
(recur others (list item))
|
||||
@@ -38,9 +46,12 @@
|
||||
(let [[children other-children] (split-with (fn [h]
|
||||
(> (:block/level h) cur-level))
|
||||
children)
|
||||
|
||||
refs-with-children (-> (mapcat get-all-refs (cons item children))
|
||||
distinct)
|
||||
children (cons
|
||||
(assoc item :block/children children)
|
||||
(assoc item
|
||||
:block/children children
|
||||
:block/refs-with-children refs-with-children)
|
||||
other-children)]
|
||||
(recur others children))))))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user