enhance: replace inline tags with node references

This commit is contained in:
Tienson Qin
2024-08-09 10:50:17 +08:00
parent a2df9564c6
commit b62715ebd8
3 changed files with 37 additions and 38 deletions

View File

@@ -18,7 +18,8 @@
[frontend.format.mldoc :as mldoc]
[lambdaisland.glogi :as log]
[promesa.core :as p]
[frontend.config :as config]))
[frontend.config :as config]
[logseq.db.frontend.content :as db-content]))
(defn- paste-text-parseable
[format text]
@@ -28,7 +29,16 @@
(mldoc/->edn text format)
text format
{:page-name (:block/name (db/entity page-id))})
blocks' (gp-block/with-parent-and-order page-id blocks)]
db-based? (config/db-based-graph? (state/get-current-repo))
blocks' (cond->> (gp-block/with-parent-and-order page-id blocks)
db-based?
(map (fn [block]
(let [refs (:block/refs block)]
(-> block
(dissoc :block/tags)
(update :block/title (fn [title]
(-> (db-content/replace-tags-with-page-refs title refs)
(db-content/page-ref->special-id-ref refs)))))))))]
(editor-handler/paste-blocks blocks' {:keep-uuid? true}))))
(defn- paste-segmented-text