mirror of https://github.com/logseq/logseq
chore: remove unused fns
parent
10f7f078f7
commit
f6964065b6
|
@ -667,7 +667,6 @@
|
|||
(let [block (db-utils/entity repo [:block/uuid block-uuid])]
|
||||
(some-> (react/q repo [:block/block block-uuid]
|
||||
{:use-cache? use-cache?
|
||||
|
||||
:transform-fn #(block-and-children-transform % repo block-uuid)}
|
||||
'[:find (pull ?c [*])
|
||||
:in $ ?id %
|
||||
|
|
|
@ -12,83 +12,6 @@
|
|||
[frontend.format.block :as block]
|
||||
[frontend.debug :as debug]))
|
||||
|
||||
(defn blocks->vec-tree
|
||||
"Deprecated: use frontend.modules.outliner.core/blocks->vec-tree instead."
|
||||
[col]
|
||||
(let [col (map (fn [h] (cond->
|
||||
h
|
||||
(not (:block/dummy? h))
|
||||
(dissoc h :block/meta))) col)
|
||||
parent? (fn [item children]
|
||||
(and (seq 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/refs block)
|
||||
(:block/tags block)))]
|
||||
(distinct refs)))]
|
||||
(loop [col (reverse col)
|
||||
children (list)]
|
||||
(if (empty? col)
|
||||
children
|
||||
(let [[item & others] col
|
||||
cur-level (:block/level item)
|
||||
bottom-level (:block/level (first children))
|
||||
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))
|
||||
|
||||
(<= bottom-level cur-level)
|
||||
(recur others (conj children item))
|
||||
|
||||
pre-block?
|
||||
(recur others (cons item children))
|
||||
|
||||
(> bottom-level cur-level) ; parent
|
||||
(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
|
||||
:block/refs-with-children refs-with-children)
|
||||
other-children)]
|
||||
(recur others children))))))))
|
||||
|
||||
|
||||
;; recursively with children content for tree
|
||||
(defn get-block-content-rec
|
||||
([block]
|
||||
(get-block-content-rec block (fn [block] (:block/content block))))
|
||||
([block transform-fn]
|
||||
(let [contents (atom [])
|
||||
_ (walk/prewalk
|
||||
(fn [form]
|
||||
(when (map? form)
|
||||
(when-let [content (:block/content form)]
|
||||
(swap! contents conj (transform-fn form))))
|
||||
form)
|
||||
block)]
|
||||
(apply util/join-newline @contents))))
|
||||
|
||||
(defn get-block-end-pos-rec
|
||||
[repo block]
|
||||
(let [children (:block/children block)]
|
||||
(if (seq children)
|
||||
(get-block-end-pos-rec repo (last children))
|
||||
(if-let [end-pos (get-in block [:block/meta :end-pos])]
|
||||
end-pos
|
||||
(when-let [block (db/entity repo [:block/uuid (:block/uuid block)])]
|
||||
(get-in block [:block/meta :end-pos]))))))
|
||||
|
||||
(defn get-block-ids
|
||||
[block]
|
||||
(let [ids (atom [])
|
||||
|
|
Loading…
Reference in New Issue