mirror of
https://github.com/logseq/logseq.git
synced 2026-04-25 22:54:48 +00:00
Merge remote-tracking branch 'upstream/master' into whiteboards
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
(defn extract-blocks
|
||||
"Wrapper around logseq.graph-parser.block/extract-blocks that adds in system state
|
||||
and handles unexpected failure."
|
||||
[blocks content with-id? format]
|
||||
[blocks content format {:keys [with-id?]
|
||||
:or {with-id? true}}]
|
||||
(try
|
||||
(gp-block/extract-blocks blocks content with-id? format
|
||||
{:user-config (state/get-config)
|
||||
@@ -38,25 +39,15 @@ and handles unexpected failure."
|
||||
(defn parse-block
|
||||
([block]
|
||||
(parse-block block nil))
|
||||
([{:block/keys [uuid content page format] :as block} {:keys [with-id?]
|
||||
([{:block/keys [uuid content format] :as block} {:keys [with-id?]
|
||||
:or {with-id? true}}]
|
||||
(when-not (string/blank? content)
|
||||
(let [block (dissoc block :block/pre-block?)
|
||||
ast (format/to-edn content format nil)
|
||||
blocks (extract-blocks ast content with-id? format)
|
||||
blocks (extract-blocks ast content format {:with-id? with-id?})
|
||||
new-block (first blocks)
|
||||
parent-refs (->> (db/get-block-parent (state/get-current-repo) uuid)
|
||||
:block/path-refs
|
||||
(map :db/id))
|
||||
{:block/keys [refs]} new-block
|
||||
ref-pages (filter :block/name refs)
|
||||
path-ref-pages (->> (concat ref-pages parent-refs [(:db/id page)])
|
||||
(remove nil?))
|
||||
block (cond->
|
||||
(merge
|
||||
block
|
||||
new-block
|
||||
{:block/path-refs path-ref-pages})
|
||||
(merge block new-block)
|
||||
(> (count blocks) 1)
|
||||
(assoc :block/warning :multiple-blocks))
|
||||
block (dissoc block :block/title :block/body :block/level)]
|
||||
|
||||
Reference in New Issue
Block a user