Merge branch 'feat/db' into enhance/code-type-block

This commit is contained in:
Tienson Qin
2024-10-03 18:35:31 +08:00
12 changed files with 254 additions and 152 deletions

View File

@@ -29,13 +29,13 @@ and handles unexpected failure."
:db-graph-mode? (config/db-based-graph? repo)})]
(if (config/db-based-graph? repo)
(map (fn [block]
(cond-> (dissoc block :block/properties :block/macros :block/properties-order)
(:block/properties block)
(merge (update-keys (:block/properties block)
(fn [k]
(or ({:heading :logseq.property/heading} k)
(throw (ex-info (str "Don't know how to save graph-parser property " (pr-str k)) {}))))))))
blocks)
(cond-> (dissoc block :block/properties :block/macros :block/properties-order)
(:block/properties block)
(merge (update-keys (:block/properties block)
(fn [k]
(or ({:heading :logseq.property/heading} k)
(throw (ex-info (str "Don't know how to save graph-parser property " (pr-str k)) {}))))))))
blocks)
blocks))
(catch :default e
(log/error :exception e)
@@ -78,7 +78,12 @@ and handles unexpected failure."
format (or format :markdown)
parse-config (mldoc/get-default-config format)
ast (format/to-edn title format parse-config)
blocks (extract-blocks ast title format {:parse-block block})
;; Disable extraction for display-type blocks as there isn't a reason to have
;; it enabled yet and can cause visible bugs when '#' is used
blocks (if (and (config/db-based-graph? (state/get-current-repo))
(:logseq.property.node/display-type block))
[block]
(extract-blocks ast title format {:parse-block block}))
new-block (first blocks)
block (cond->
(merge block new-block)
@@ -126,13 +131,13 @@ and handles unexpected failure."
(if (= typ "Paragraph")
(let [indexed-paras (map-indexed vector paras)]
[typ (->> (filter
#(let [[index value] %]
(not (and (> index 0)
(= value ["Break_Line"])
(contains? #{"Timestamp" "Macro"}
(first (nth paras (dec index)))))))
indexed-paras)
(map #(last %)))])
#(let [[index value] %]
(not (and (> index 0)
(= value ["Break_Line"])
(contains? #{"Timestamp" "Macro"}
(first (nth paras (dec index)))))))
indexed-paras)
(map #(last %)))])
ast)))
(defn trim-break-lines!