chore: merge latest changes to filters

This commit is contained in:
Tienson Qin
2021-03-04 21:41:21 +08:00
159 changed files with 11205 additions and 5141 deletions

View File

@@ -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,9 @@
(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)
(remove nil?)))]
(cond
(empty? children)
(recur others (list item))
@@ -38,9 +47,13 @@
(let [[children other-children] (split-with (fn [h]
(> (:block/level h) cur-level))
children)
refs-with-children (->> (mapcat get-all-refs (cons item children))
(remove nil?)
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))))))))