diff --git a/deps/graph-parser/src/logseq/graph_parser/block.cljs b/deps/graph-parser/src/logseq/graph_parser/block.cljs index 1caad7cfc..e72430a77 100644 --- a/deps/graph-parser/src/logseq/graph_parser/block.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/block.cljs @@ -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 diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 6bf73a802..7905b7ae2 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -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 diff --git a/src/main/frontend/handler/page.cljs b/src/main/frontend/handler/page.cljs index 4f786c753..2562aeef1 100644 --- a/src/main/frontend/handler/page.cljs +++ b/src/main/frontend/handler/page.cljs @@ -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