Merge branch 'feat/db' into fix/multiple-tabs

This commit is contained in:
Tienson Qin
2025-04-23 07:32:05 +08:00
6 changed files with 34 additions and 24 deletions

View File

@@ -110,7 +110,7 @@
(def private-tags
"Built-in classes that are private and should not be used by a user directly.
These used to be in block/type"
(set/union internal-tags
(set/union (disj internal-tags :logseq.class/Root)
#{:logseq.class/Journal :logseq.class/Whiteboard}))
(def hidden-tags

View File

@@ -103,24 +103,22 @@
[:div
[:a.font-medium {:on-click #(export/export-repo-as-zip! current-repo)}
(t :export-zip)]])
(when db-based?
[:div
[:a.font-medium {:on-click #(db-export-handler/export-repo-as-db-edn! current-repo)}
(t :export-db-edn)]])
(when db-based?
(when-not (mobile-util/native-platform?)
[:div
[:a.font-medium {:on-click #(export/export-repo-as-debug-transit! current-repo)}
"Export debug transit file"]
[:p.text-sm.opacity-70 "Any sensitive data will be removed in the exported transit file, you can send it to us for debugging."]])
[:a.font-medium {:on-click #(export-text/export-repo-as-markdown! current-repo)}
(t :export-markdown)]])
(when (util/electron?)
[:div
[:a.font-medium {:on-click #(export/download-repo-as-html! current-repo)}
(t :export-public-pages)]])
(when-not (or (mobile-util/native-platform?) db-based?)
[:div
[:a.font-medium {:on-click #(export-text/export-repo-as-markdown! current-repo)}
(t :export-markdown)]])
(when-not (or (mobile-util/native-platform?) db-based?)
[:div
[:a.font-medium {:on-click #(export-opml/export-repo-as-opml! current-repo)}
@@ -129,6 +127,11 @@
[:div
[:a.font-medium {:on-click #(export/export-repo-as-roam-json! current-repo)}
(t :export-roam-json)]])
(when db-based?
[:div
[:a.font-medium {:on-click #(export/export-repo-as-debug-transit! current-repo)}
"Export debug transit file"]
[:p.text-sm.opacity-70.mb-0 "Any sensitive data will be removed in the exported transit file, you can send it to us for debugging."]])
(when (and db-based? util/web-platform? (utils/nfsSupported))
[:div

View File

@@ -195,12 +195,13 @@
(state/<invoke-db-worker :thread-api/export-get-debug-datoms repo))
(defn <get-all-page->content
[repo]
(state/<invoke-db-worker :thread-api/export-get-all-page->content repo))
[repo options]
(state/<invoke-db-worker :thread-api/export-get-all-page->content repo options))
(defn <get-file-contents
[repo suffix]
(p/let [page->content (<get-all-page->content repo)]
(p/let [page->content (<get-all-page->content repo
{:export-bullet-indentation (state/get-export-bullet-indentation)})]
(clojure.core/map (fn [[page-title content]]
{:path (str page-title "." suffix)
:content content

View File

@@ -1,6 +1,5 @@
(ns frontend.handler.export.text
"export blocks/pages as text"
(:refer-clojure :exclude [map filter mapcat concat remove newline])
(:require [clojure.string :as string]
[frontend.config :as config]
[frontend.db :as db]
@@ -545,9 +544,9 @@
(defn export-repo-as-markdown!
"TODO: indent-style and remove-options"
[repo]
(p/let [files (util/profile :get-file-content (common/<get-file-contents repo "md"))]
(when (seq files)
(let [files (export-files-as-markdown files nil)
(p/let [files* (util/profile :get-file-content (common/<get-file-contents repo "md"))]
(when (seq files*)
(let [files (export-files-as-markdown files* nil)
repo' (if (config/db-based-graph? repo)
(string/replace repo config/db-version-prefix "")
(path/basename repo))

View File

@@ -729,9 +729,9 @@
(worker-export/get-all-pages repo @conn)))
(def-thread-api :thread-api/export-get-all-page->content
[repo]
[repo options]
(when-let [conn (worker-state/get-datascript-conn repo)]
(worker-export/get-all-page->content repo @conn)))
(worker-export/get-all-page->content repo @conn options)))
(def-thread-api :thread-api/validate-db
[repo]

View File

@@ -6,7 +6,8 @@
[logseq.db :as ldb]
[logseq.db.sqlite.util :as sqlite-util]
[logseq.graph-parser.property :as gp-property]
[logseq.outliner.tree :as otree]))
[logseq.outliner.tree :as otree]
[logseq.db.sqlite.create-graph :as sqlite-create-graph]))
(defn- safe-keywordize
[block]
@@ -45,12 +46,18 @@
(assoc page' :block/children children))))))
(defn get-all-page->content
[repo db]
(->> (d/datoms db :avet :block/name)
(map (fn [d]
(let [e (d/entity db (:e d))]
[repo db options]
(let [filter-fn (if (ldb/db-based-graph? db)
(fn [ent]
(or (not (:logseq.property/built-in? ent))
(contains? sqlite-create-graph/built-in-pages-names (:block/title ent))))
(constantly true))]
(->> (d/datoms db :avet :block/name)
(map #(d/entity db (:e %)))
(filter filter-fn)
(map (fn [e]
[(:block/title e)
(common-file/block->content repo db (:block/uuid e) {} {})])))))
(common-file/block->content repo db (:block/uuid e) {} options)])))))
(defn get-debug-datoms
[conn ^Object db]