Merge branch 'feat/db' into feat/hnswlib+transformer-js

This commit is contained in:
Tienson Qin
2025-03-16 11:52:32 +08:00
67 changed files with 3074 additions and 2586 deletions

View File

@@ -5,6 +5,7 @@
(:refer-clojure :exclude [map filter mapcat concat remove])
(:require [cljs.core.match :refer [match]]
[clojure.string :as string]
[frontend.common.file.core :as common-file]
[frontend.db :as db]
[frontend.format.mldoc :as mldoc]
[frontend.modules.file.core :as outliner-file]
@@ -12,11 +13,10 @@
[frontend.persist-db.browser :as db-browser]
[frontend.state :as state]
[frontend.util :as util :refer [concatv mapcatv removev]]
[frontend.common.file.core :as common-file]
[logseq.db :as ldb]
[malli.core :as m]
[malli.util :as mu]
[promesa.core :as p]
[logseq.db :as ldb]))
[promesa.core :as p]))
;;; TODO: split frontend.handler.export.text related states
(def ^:dynamic *state*
@@ -64,8 +64,14 @@
(outliner-file/tree->file-content {:init-level init-level})))
(defn root-block-uuids->content
[repo root-block-uuids]
(let [contents (mapv #(get-blocks-contents repo %) root-block-uuids)]
[repo root-block-uuids & {:keys [page-title-only?]}]
(let [contents (mapv (fn [id]
(if-let [page (and page-title-only?
(let [e (db/entity [:block/uuid id])]
(when (:block/name e)
e)))]
(:block/title page)
(get-blocks-contents repo id))) root-block-uuids)]
(string/join "\n" (mapv string/trim-newline contents))))
(declare remove-block-ast-pos Properties-block-ast?)

View File

@@ -506,24 +506,25 @@
"options:
:indent-style \"dashes\" | \"spaces\" | \"no-indent\"
:remove-options [:emphasis :page-ref :tag :property]
:other-options {:keep-only-level<=N int :newline-after-block bool}"
:other-options {:keep-only-level<=N int :newline-after-block bool}
:page-title-only? boolean"
[repo root-block-uuids-or-page-uuid options]
{:pre [(or (coll? root-block-uuids-or-page-uuid)
(uuid? root-block-uuids-or-page-uuid))]}
(util/profile
:export-blocks-as-markdown
(try
(let [content
(if (uuid? root-block-uuids-or-page-uuid)
:export-blocks-as-markdown
(try
(let [content
(if (uuid? root-block-uuids-or-page-uuid)
;; page
(common/get-page-content root-block-uuids-or-page-uuid)
(common/root-block-uuids->content repo root-block-uuids-or-page-uuid))
first-block (and (coll? root-block-uuids-or-page-uuid)
(db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
format (get first-block :block/format :markdown)]
(export-helper content format options))
(catch :default e
(js/console.error e)))))
(common/get-page-content root-block-uuids-or-page-uuid)
(common/root-block-uuids->content repo root-block-uuids-or-page-uuid options))
first-block (and (coll? root-block-uuids-or-page-uuid)
(db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
format (get first-block :block/format :markdown)]
(export-helper content format options))
(catch :default e
(js/console.error e)))))
(defn export-files-as-markdown
"options see also `export-blocks-as-markdown`"
@@ -531,7 +532,7 @@
(mapv
(fn [{:keys [path title content]}]
(util/profile (print-str :export-files-as-markdown title)
[(or path title) (export-helper content :markdown options)]))
[(or path title) (export-helper content :markdown options)]))
files))
(defn export-repo-as-markdown!