mirror of https://github.com/logseq/logseq
fix: missing refs for property text values when creating a page
parent
85e65bd95e
commit
b5f0f58efc
|
@ -149,6 +149,17 @@
|
|||
properties)
|
||||
[]))
|
||||
|
||||
(defn- extract-refs-from-property-value
|
||||
[value format]
|
||||
(cond
|
||||
(coll? value)
|
||||
(filter (fn [v] (and (string? v) (not (string/blank? v)))) value)
|
||||
(string? value)
|
||||
(let [ast (gp-mldoc/inline->edn value (gp-mldoc/default-config format))]
|
||||
(text/extract-refs-from-mldoc-ast ast))
|
||||
:else
|
||||
nil))
|
||||
|
||||
(defn- get-page-ref-names-from-properties
|
||||
[properties user-config]
|
||||
(let [page-refs (->>
|
||||
|
@ -162,8 +173,9 @@
|
|||
(keyword k))))
|
||||
;; get links ast
|
||||
(map last)
|
||||
(mapcat (or (:extract-refs-from-property-value-fn user-config)
|
||||
text/extract-refs-from-mldoc-ast))
|
||||
(mapcat (fn [value]
|
||||
(let [f (or (:extract-refs-from-property-value-fn user-config) extract-refs-from-property-value)]
|
||||
(f value (get user-config :format :markdown)))))
|
||||
;; comma separated collections
|
||||
(concat (->> (map second properties)
|
||||
(filter coll?)
|
||||
|
@ -513,11 +525,7 @@
|
|||
id (get-custom-id-or-new-id {:properties properties})
|
||||
property-refs (->> (get-page-refs-from-properties
|
||||
properties db date-formatter
|
||||
(assoc user-config
|
||||
:extract-refs-from-property-value-fn
|
||||
(fn [refs]
|
||||
(when (coll? refs)
|
||||
refs))))
|
||||
user-config)
|
||||
(map :block/original-name))
|
||||
pre-block? (if (:heading properties) false true)
|
||||
block {:block/uuid id
|
||||
|
|
|
@ -660,7 +660,7 @@
|
|||
refs (gp-block/get-page-refs-from-properties properties
|
||||
(db/get-db (state/get-current-repo))
|
||||
(state/get-date-formatter)
|
||||
(state/get-config))]
|
||||
(assoc (state/get-config) :format format))]
|
||||
{:block/pre-block? true
|
||||
:block/uuid (db/new-block-id)
|
||||
:block/properties properties
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
last-txs (build-page-tx format properties (last pages) journal? whiteboard?)
|
||||
txs (concat txs last-txs)]
|
||||
(when (seq txs)
|
||||
(db/transact! txs)))
|
||||
(db/transact! repo txs {:outliner-op :create-page})))
|
||||
|
||||
(when create-first-block?
|
||||
(when (or
|
||||
|
|
Loading…
Reference in New Issue