mirror of
https://github.com/logseq/logseq.git
synced 2026-04-30 00:46:23 +00:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user