mirror of
https://github.com/logseq/logseq.git
synced 2026-04-26 07:05:10 +00:00
fix: display class properties
This commit is contained in:
@@ -10,52 +10,21 @@
|
||||
[frontend.state :as state]
|
||||
[logseq.graph-parser.block :as gp-block]
|
||||
[logseq.graph-parser.property :as gp-property]
|
||||
[frontend.handler.db-based.property.util :as db-pu]
|
||||
[lambdaisland.glogi :as log]
|
||||
[datascript.core :as d]
|
||||
[logseq.db.frontend.property :as db-property]
|
||||
[frontend.format.mldoc :as mldoc]))
|
||||
|
||||
(defn- update-extracted-block-properties
|
||||
"Updates DB graph blocks to ensure that built-in properties are using uuids
|
||||
for property ids"
|
||||
[blocks]
|
||||
(let [repo (state/get-current-repo)
|
||||
update-properties (fn [props]
|
||||
(update-keys props #(if (contains? db-property/built-in-properties-keys %)
|
||||
(db-pu/get-built-in-property-uuid repo %)
|
||||
%)))]
|
||||
(if (config/db-based-graph? repo)
|
||||
(->> blocks
|
||||
(map (fn [b]
|
||||
(if (:block/properties b)
|
||||
(-> b
|
||||
(dissoc :block/properties-order)
|
||||
(update :block/properties update-properties))
|
||||
b)))
|
||||
(map (fn [b]
|
||||
(if (:block/macros b)
|
||||
(update b :block/macros
|
||||
(fn [macros]
|
||||
(map #(-> %
|
||||
(assoc :block/uuid (d/squuid))
|
||||
(update :block/properties update-properties)) macros)))
|
||||
b))))
|
||||
blocks)))
|
||||
|
||||
(defn extract-blocks
|
||||
"Wrapper around logseq.graph-parser.block/extract-blocks that adds in system state
|
||||
and handles unexpected failure."
|
||||
[blocks content format {:keys [with-id? page-name]
|
||||
:or {with-id? true}}]
|
||||
(try
|
||||
(update-extracted-block-properties
|
||||
(gp-block/extract-blocks blocks content with-id? format
|
||||
{:user-config (state/get-config)
|
||||
:block-pattern (config/get-block-pattern format)
|
||||
:db (db/get-db (state/get-current-repo))
|
||||
:date-formatter (state/get-date-formatter)
|
||||
:page-name page-name}))
|
||||
(gp-block/extract-blocks blocks content with-id? format
|
||||
{:user-config (state/get-config)
|
||||
:block-pattern (config/get-block-pattern format)
|
||||
:db (db/get-db (state/get-current-repo))
|
||||
:date-formatter (state/get-date-formatter)
|
||||
:page-name page-name})
|
||||
(catch :default e
|
||||
(log/error :exception e)
|
||||
(state/pub-event! [:capture-error {:error e
|
||||
|
||||
Reference in New Issue
Block a user