chore: remove :block/title, :block/body and :block/unordered

For two reasons:

1. Reducing memory usage, both block/title and block/body are AST parsed
by Mldoc. After removing, logseq is able to handle 10k notes.

2. Simplify the db schema
This commit is contained in:
Tienson Qin
2021-12-06 19:20:56 +08:00
parent 1ca2b3fc21
commit 7822848af8
18 changed files with 92 additions and 152 deletions

View File

@@ -716,24 +716,29 @@
new-block
{:block/path-refs path-ref-pages})
(> (count blocks) 1)
(assoc :block/warning :multiple-blocks))]
(assoc :block/warning :multiple-blocks))
block (dissoc block :block/title :block/body :block/level)]
(if uuid (assoc block :block/uuid uuid) block)))))
(defn parse-title-and-body
[format pre-block? content]
(def content content)
(let [ast (format/to-edn content format nil)
content (if pre-block? content
(str (config/get-block-pattern format) " " (string/triml content)))
content (property/remove-properties format content)
ast (->> (format/to-edn content format nil)
(map first))
title (when (heading-block? (first ast))
(:title (second (first ast))))]
(cond->
{:block/body (vec (if title (rest ast) ast))}
title
(assoc :block/title title))))
([block]
(when (map? block)
(merge block
(parse-title-and-body (:block/format block)
(:block/pre-block? block)
(:block/content block)))))
([format pre-block? content]
(let [content (if pre-block? content
(str (config/get-block-pattern format) " " (string/triml content)))
content (property/remove-properties format content)
ast (->> (format/to-edn content format nil)
(map first))
title (when (heading-block? (first ast))
(:title (second (first ast))))]
(cond->
{:block/body (vec (if title (rest ast) ast))}
title
(assoc :block/title title)))))
(defn macro-subs
[macro-content arguments]