more cleanup

This commit is contained in:
Tienson Qin
2025-12-25 21:48:46 +08:00
parent f419fbea8b
commit eceaa7396c
35 changed files with 303 additions and 954 deletions

View File

@@ -18,13 +18,6 @@
:skip-async-load? true
:with-tags? false} row))
:type :string}
(when (not (config/db-based-graph? (state/get-current-repo)))
{:id :block/type
:name "Page type"
:cell (fn [_table row _column]
(let [type (get row :block/type)]
[:div.capitalize type]))
:type :string})
{:id :block.temp/refs-count
:name (t :page/backlinks)
:cell (fn [_table row _column]

View File

@@ -1417,17 +1417,6 @@
:map-inline map-inline
:inline inline}))
;;;; Macro component render functions
(defn- macro-query-cp
[config arguments]
[:div.dsl-query.pr-3.sm:pr-0
(let [query (->> (string/join ", " arguments)
(string/trim))
build-option (assoc (:block config) :file-version/query-macro-title query)]
(query/custom-query (wrap-query-components (assoc config :dsl-query? true))
{:builder (query-builder-component/builder build-option {})
:query query}))])
(rum/defc macro-function-cp < rum/reactive
[config arguments]
(or
@@ -2793,7 +2782,7 @@
[config repo block-id {:keys [show-page? indent? end-separator? _navigating-block disabled?]
:or {show-page? true}
:as opts}]
(let [from-property (when (and block-id (config/db-based-graph? repo))
(let [from-property (when block-id
(:logseq.property/created-from-property (db/entity [:block/uuid block-id])))
parents (db/get-block-parents repo block-id {:depth 1000})
parents (cond-> (remove nil? (concat parents [from-property]))
@@ -3759,12 +3748,8 @@
["Example" l]
[:pre.pre-wrap-white-space
(join-lines l)]
["Quote" l]
(if (config/db-based-graph? (state/get-current-repo))
[:div.warning "#+BEGIN_QUOTE is deprecated. Use '/Quote' command instead."]
(->elem
:blockquote
(markup-elements-cp config l)))
["Quote" _l]
[:div.warning "#+BEGIN_QUOTE is deprecated. Use '/Quote' command instead."]
["Raw_Html" content]
(when (not html-export?)
[:div.raw_html {:dangerouslySetInnerHTML
@@ -3783,19 +3768,10 @@
["Export" "latex" _options content]
(if html-export?
(latex/html-export content true false)
(if (config/db-based-graph? (state/get-current-repo))
[:div.warning "'#+BEGIN_EXPORT latex' is deprecated. Use '/Math block' command instead."]
(latex/latex content true false)))
[:div.warning "'#+BEGIN_EXPORT latex' is deprecated. Use '/Math block' command instead."])
["Custom" "query" _options _result content]
(if (config/db-based-graph? (state/get-current-repo))
[:div.warning "#+BEGIN_QUERY is deprecated. Use '/Advanced Query' command instead."]
(try
(let [query (common-util/safe-read-map-string content)]
(query/custom-query (wrap-query-components config) query))
(catch :default e
(log/error :read-string-error e)
(ui/block-error "Invalid query:" {:content content}))))
["Custom" "query" _options _result _content]
[:div.warning "#+BEGIN_QUERY is deprecated. Use '/Advanced Query' command instead."]
["Custom" "note" _options result _content]
(ui/admonition "note" (markup-elements-cp config result))

View File

@@ -2,7 +2,6 @@
"Logseq macros that render and evaluate in blocks"
(:require [clojure.walk :as walk]
[datascript.core :as d]
[frontend.config :as config]
[frontend.db.conn :as db-conn]
[frontend.extensions.sci :as sci]
[frontend.handler.common :as common-handler]
@@ -43,27 +42,18 @@
(first f)
(list 'map (second f) 'result)))
f))
ast*)
db-based-graph? (config/db-based-graph? repo)
;; These keyword aliases should be the same as those used in the query-table for sorting
special-file-graph-keywords
{:block :block/title
:page :block/name
:created-at :block/created-at
:updated-at :block/updated-at}]
ast*)]
(walk/postwalk
(fn [f]
(cond
(keyword? f)
(if-let [kw (and (not db-based-graph?) (get special-file-graph-keywords f))]
kw
(let [vals (map #(get-in % [:block/properties f]) result)
int? (some integer? vals)]
`(~'fn [~'b]
(~'let [~'result-str (~'get-in ~'b [:block/properties ~f])
~'result-num (~'parseFloat ~'result-str)
~'result (if (~'isNaN ~'result-num) ~'result-str ~'result-num)]
(~'or ~'result (~'when ~int? 0))))))
(let [vals (map #(get-in % [:block/properties f]) result)
int? (some integer? vals)]
`(~'fn [~'b]
(~'let [~'result-str (~'get-in ~'b [:block/properties ~f])
~'result-num (~'parseFloat ~'result-str)
~'result (if (~'isNaN ~'result-num) ~'result-str ~'result-num)]
(~'or ~'result (~'when ~int? 0)))))
:else
f))
@@ -78,11 +68,9 @@
query-result*)
repo (state/get-current-repo)
db (db-conn/get-db repo)
query-result' (if (config/db-based-graph? repo)
(->> query-result
(map #(d/entity db (:db/id %)))
(map #(hash-map :block/properties (properties-by-name db %))))
query-result)
query-result' (->> query-result
(map #(d/entity db (:db/id %)))
(map #(hash-map :block/properties (properties-by-name db %))))
fn-string (-> (gstring/format "(fn [result] %s)" (first arguments))
(common-handler/safe-read-string "failed to parse function")
(normalize-query-function repo query-result')

View File

@@ -755,12 +755,10 @@
(p/let [page (some-> (get-highlighted-page-uuid-or-name state) db/get-page)
_ (db-async/<get-block repo (:block/uuid page) :children? false)
page' (db/entity repo [:block/uuid (:block/uuid page)])
link (if (config/db-based-graph? repo)
(some (fn [[k v]]
(when (= :url (:logseq.property/type (db/entity repo k)))
(:block/title v)))
(:block/properties page'))
(some #(re-find editor-handler/url-regex (val %)) (:block/properties page')))]
link (some (fn [[k v]]
(when (= :url (:logseq.property/type (db/entity repo k)))
(:block/title v)))
(:block/properties page'))]
(if link
(js/window.open link)
(notification/show! "No link found in this page's properties." :warning)))

View File

@@ -7,14 +7,11 @@
[frontend.components.editor :as editor]
[frontend.components.export :as export]
[frontend.components.page-menu :as page-menu]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
[frontend.extensions.fsrs :as fsrs]
[frontend.handler.common.developer :as dev-common-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.notification :as notification]
[frontend.handler.page :as page-handler]
[frontend.handler.property :as property-handler]
[frontend.handler.property.util :as pu]
[frontend.modules.shortcut.core :as shortcut]
@@ -35,8 +32,7 @@
(rum/defc custom-context-menu-content
[]
(let [repo (state/get-current-repo)
db-based? (config/db-based-graph? repo)]
(let [repo (state/get-current-repo)]
[:<>
(ui/menu-background-color #(property-handler/batch-set-block-property! repo
(state/get-selection-block-ids)
@@ -88,12 +84,6 @@
:on-click editor-handler/copy-block-refs}
(t :content/copy-block-ref))
(when-not db-based?
(shui/dropdown-menu-item
{:key "copy block embeds"
:on-click editor-handler/copy-block-embeds}
(t :content/copy-block-emebed)))
(shui/dropdown-menu-separator)
(when (state/enable-flashcards?)
@@ -131,78 +121,10 @@
(t :editor/collapse-block-children)
(shui/dropdown-menu-shortcut (ui/keyboard-shortcut-from-config :editor/collapse-block-children)))]))
(defonce *template-including-parent? (atom nil))
(rum/defc template-checkbox
[template-including-parent?]
[:div.flex.flex-row.w-auto.items-center
[:p.text-medium.mr-2 (t :context-menu/template-include-parent-block)]
(ui/toggle template-including-parent?
#(swap! *template-including-parent? not))])
(rum/defcs block-template < rum/reactive
shortcut/disable-all-shortcuts
(rum/local false ::edit?)
(rum/local "" ::input)
{:will-unmount (fn [state]
(reset! *template-including-parent? nil)
state)}
[state block-id]
(let [edit? (get state ::edit?)
input (get state ::input)
template-including-parent? (rum/react *template-including-parent?)
block-id (if (string? block-id) (uuid block-id) block-id)
block (db/entity [:block/uuid block-id])
has-children? (seq (:block/_parent block))
repo (state/get-current-repo)]
(when (and (nil? template-including-parent?) has-children?)
(reset! *template-including-parent? true))
(if @edit?
(let [submit! (fn []
(let [title (string/trim @input)]
(when (not (string/blank? title))
(p/let [exists? (page-handler/<template-exists? title)]
(if exists?
(notification/show!
[:p (t :context-menu/template-exists-warning)]
:error)
(p/do!
(property-handler/set-block-property! repo block-id (pu/get-pid :logseq.property/template) title)
(when (false? template-including-parent?)
(property-handler/set-block-property! repo block-id
(pu/get-pid :logseq.property/template-including-parent)
false))
(shui/popup-hide!)))))))]
(state/clear-edit!)
[:<>
[:div.px-4.py-2.text-sm {:on-click (fn [e] (util/stop e))}
[:p (t :context-menu/input-template-name)]
[:input#new-template.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
{:auto-focus true
:on-key-down (fn [e]
(util/stop-propagation e)
(when (and (= "Enter" (util/ekey e))
(not (string/blank? (util/trim-safe @input))))
(submit!)))
:on-change (fn [e]
(reset! input (util/evalue e)))}]
(when has-children?
(template-checkbox template-including-parent?))
(ui/button (t :submit) :on-click submit!)]
(shui/dropdown-menu-separator)])
(shui/dropdown-menu-item
{:key "Make a Template"
:on-click (fn [e]
(util/stop e)
(reset! edit? true))}
(t :context-menu/make-a-template)))))
(rum/defc ^:large-vars/cleanup-todo block-context-menu-content <
shortcut/disable-all-shortcuts
[_target block-id property-default-value?]
(let [repo (state/get-current-repo)
db? (config/db-based-graph? repo)]
(let [repo (state/get-current-repo)]
(when-let [block (db/entity [:block/uuid block-id])]
(let [heading (or (pu/lookup block :logseq.property/heading)
false)]
@@ -235,13 +157,6 @@
(editor-handler/copy-block-ref! block-id ref/->block-ref))}
(t :content/copy-block-ref))
(when-not db?
(shui/dropdown-menu-item
{:key "Copy block embed"
:on-click (fn [_e]
(editor-handler/copy-block-ref! block-id #(util/format "{{embed ((%s))}}" %)))}
(t :content/copy-block-emebed)))
;; TODO Logseq protocol mobile support
(when (util/electron?)
(shui/dropdown-menu-item
@@ -278,9 +193,6 @@
(shui/dropdown-menu-separator)
(when-not db?
(block-template block-id))
(cond
(state/enable-flashcards?)
(shui/dropdown-menu-item

View File

@@ -50,7 +50,7 @@
commands))
(defn node-render
[block q {:keys [db-tag? db-based?]}]
[block q {:keys [db-tag?]}]
(let [block' (if-let [id (:block/uuid block)]
(if-let [e (db/entity [:block/uuid id])]
(assoc e
@@ -66,7 +66,7 @@
(breadcrumb {:search? true} (state/get-current-repo) (:block/uuid block')
{:disabled? true})]))
[:div.flex.flex-row.items-start
(when-not (or db-tag? (not db-based?))
(when-not db-tag?
[:div.flex.items-center.h-5.mr-1.opacity-50
(cond
(:nlp-date? block')
@@ -192,7 +192,7 @@
partial-matched-pages)))))
(defn- search-pages
[q db-tag? db-based? set-matched-pages!]
[q db-tag? set-matched-pages!]
(when-not (string/blank? q)
(p/let [block (db-async/<get-block (state/get-current-repo) q {:children? false})
result (if db-tag?
@@ -207,25 +207,23 @@
:friendly-title (util/format "Convert \"%s\" to tag" q)} classes)
classes))
(editor-handler/<get-matched-blocks q {:nlp-pages? true
:page-only? (not db-based?)}))]
:page-only? false}))]
(set-matched-pages! result))))
(rum/defc page-search-aux
[id format embed? db-tag? q current-pos input pos]
(let [db-based? (config/db-based-graph? (state/get-current-repo))
q (string/trim q)
(let [q (string/trim q)
[matched-pages set-matched-pages!] (rum/use-state nil)
search-f #(search-pages q db-tag? db-based? set-matched-pages!)]
search-f #(search-pages q db-tag? set-matched-pages!)]
(hooks/use-effect! search-f [(hooks/use-debounced-value q 150)])
(let [matched-pages' (if (string/blank? q)
(when db-based?
(if db-tag?
(db-model/get-all-classes (state/get-current-repo) {:except-root-class? true})
(->> (map (fn [title] {:block/title title
:nlp-date? true})
date/nlp-pages)
(take 10))))
(if db-tag?
(db-model/get-all-classes (state/get-current-repo) {:except-root-class? true})
(->> (map (fn [title] {:block/title title
:nlp-date? true})
date/nlp-pages)
(take 10)))
;; reorder, shortest and starts-with first.
(if (and (seq matched-pages)
(gstring/caseInsensitiveStartsWith (:block/title (first matched-pages)) q))
@@ -239,14 +237,13 @@
:on-enter (fn []
(page-handler/page-not-exists-handler input id q current-pos))
:item-render (fn [block _chosen?]
(node-render block q {:db-tag? db-tag?
:db-based? db-based?}))
(node-render block q {:db-tag? db-tag?}))
:empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 (if db-tag?
"Search for a tag"
"Search for a node")]
:class "black"})
(when (and db-based? db-tag?
(when (and db-tag?
(not (string/blank? q))
(not= "page" (string/lower-case q)))
[:p.px-1.opacity-50.text-sm
@@ -262,10 +259,9 @@
"Page or tag searching popup"
[state id format]
(let [action (state/sub :editor/action)
db? (config/db-based-graph? (state/get-current-repo))
embed? (and db? (= @commands/*current-command "Page embed"))
embed? (= @commands/*current-command "Page embed")
tag? (= action :page-search-hashtag)
db-tag? (and db? tag?)
db-tag? tag?
pos (::pos state)
input (gdom/getElement id)]
(when input
@@ -321,8 +317,7 @@
[state _edit-block input id q format selected-text]
(let [result (->> (rum/react (get state ::result))
(remove (fn [b] (nil? (:block/uuid b)))))
db? (config/db-based-graph? (state/get-current-repo))
embed? (and db? (= @commands/*current-command "Block embed"))
embed? (= @commands/*current-command "Block embed")
chosen-handler (block-on-chosen-handler embed? input id q format selected-text)
non-exist-block-handler (editor-handler/block-non-exist-handler input)]
(ui/auto-complete
@@ -331,8 +326,7 @@
:on-enter non-exist-block-handler
:empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 (t :editor/block-search)]
:item-render (fn [block]
(node-render block q {:db-tag? false
:db-based? db?}))
(node-render block q {:db-tag? false}))
:class "ac-block-search"})))
(rum/defcs block-search < rum/reactive
@@ -353,8 +347,7 @@
(when (>= (count edit-content) current-pos)
(subs edit-content pos current-pos)))]
(when input
(let [db? (config/db-based-graph? (state/get-current-repo))
embed? (and db? (= @commands/*current-command "Block embed"))
(let [embed? (= @commands/*current-command "Block embed")
page (when embed? (page-ref/get-page-name edit-content))
embed-block-id (when (and embed? page (common-util/uuid-string? page))
(uuid page))]

View File

@@ -2,7 +2,6 @@
(:require ["/frontend/utils" :as utils]
[cljs-time.core :as t]
[cljs.pprint :as pprint]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
[frontend.handler.block :as block-handler]
@@ -86,65 +85,44 @@
(rum/defc export
[]
(when-let [current-repo (state/get-current-repo)]
(let [db-based? (config/db-based-graph? current-repo)]
[:div.export
[:h1.title.mb-8 (t :export)]
[:div.export
[:h1.title.mb-8 (t :export)]
[:div.flex.flex-col.gap-4.ml-1
(when-not db-based?
[:div
[:a.font-medium {:on-click #(export/export-repo-as-edn! current-repo)}
(t :export-edn)]])
(when-not db-based?
[:div
[:a.font-medium {:on-click #(export/export-repo-as-json! current-repo)}
(t :export-json)]])
(when db-based?
[:div
[:a.font-medium {:on-click #(export/export-repo-as-sqlite-db! current-repo)}
(t :export-sqlite-db)]
[:p.text-sm.opacity-70.mb-0 "Primary way to backup graph's content to a single .sqlite file."]])
(when db-based?
[:div
[:a.font-medium {:on-click #(export/export-repo-as-zip! current-repo)}
(t :export-zip)]
[:p.text-sm.opacity-70.mb-0 "Primary way to backup graph's content and assets to a .zip file."]])
[:div.flex.flex-col.gap-4.ml-1
[:div
[:a.font-medium {:on-click #(export/export-repo-as-sqlite-db! current-repo)}
(t :export-sqlite-db)]
[:p.text-sm.opacity-70.mb-0 "Primary way to backup graph's content to a single .sqlite file."]]
[:div
[:a.font-medium {:on-click #(export/export-repo-as-zip! current-repo)}
(t :export-zip)]
[:p.text-sm.opacity-70.mb-0 "Primary way to backup graph's content and assets to a .zip file."]]
(when (and db-based? (not (util/mobile?)))
[:div
[:a.font-medium {:on-click #(db-export-handler/export-repo-as-db-edn! current-repo)}
(t :export-db-edn)]
[:p.text-sm.opacity-70.mb-0 "Exports to a readable and editable .edn file. Don't rely on this as a primary backup."]])
(when-not (mobile-util/native-platform?)
[:div
[:a.font-medium {:on-click #(export-text/export-repo-as-markdown! current-repo)}
(t :export-markdown)]])
(when-not (util/mobile?)
[:div
[:a.font-medium {:on-click #(db-export-handler/export-repo-as-db-edn! current-repo)}
(t :export-db-edn)]
[:p.text-sm.opacity-70.mb-0 "Exports to a readable and editable .edn file. Don't rely on this as a primary backup."]])
(when-not (mobile-util/native-platform?)
[:div
[: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 (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-opml/export-repo-as-opml! current-repo)}
(t :export-opml)]])
(when-not (or (mobile-util/native-platform?) db-based?)
[: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 "Exports to a .transit file to send to us for debugging. Any sensitive data will be removed in the exported file."]])
[: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 "Exports to a .transit file to send to us for debugging. Any sensitive data will be removed in the exported file."]]
(when (and db-based?
util/web-platform?
(not (util/mobile?)))
[:div
[:hr]
(auto-backup)])]])))
(when (and util/web-platform?
(not (util/mobile?)))
[:div
[:hr]
(auto-backup)])]]))
(def *export-block-type (atom :text))
@@ -282,15 +260,14 @@
:on-click #(do (reset! *export-block-type :png)
(reset! *content nil)
(get-image-blob top-level-uuids (merge options {:transparent-bg? false}) (fn [blob] (reset! *content blob))))))
(when (config/db-based-graph?)
(ui/button "EDN"
:class "w-20"
:on-click #(do (reset! *export-block-type :edn)
(p/let [result (<export-edn-helper top-level-uuids export-type)
pull-data (with-out-str (pprint/pprint result))]
(if (:export-edn-error result)
(notification/show! (:export-edn-error result) :error)
(reset! *content pull-data))))))])
(ui/button "EDN"
:class "w-20"
:on-click #(do (reset! *export-block-type :edn)
(p/let [result (<export-edn-helper top-level-uuids export-type)
pull-data (with-out-str (pprint/pprint result))]
(if (:export-edn-error result)
(notification/show! (:export-edn-error result) :error)
(reset! *content pull-data)))))])
(if (= :png tp)
[:div.flex.items-center.justify-center.relative
(when (not @*content) [:div.absolute (ui/loading "")])

View File

@@ -86,9 +86,7 @@
:else
[repo-dir path])]
(when (and format (contains? (common-config/text-formats) format))
(p/let [content (if (and (config/db-based-graph? repo)
;; not global
(not (string/starts-with? path "/")))
(p/let [content (if-not (string/starts-with? path "/")
(db/get-file path)
(fs/read-file dir path))]
(reset! *content (or content ""))))
@@ -104,17 +102,7 @@
rel-path (when (string/starts-with? path repo-dir)
(path/trim-dir-prefix repo-dir path))
title (db-model/get-file-page (or path rel-path))
in-db? (when-not (path/absolute? path)
(boolean (db/get-file (or path rel-path))))
file-path (cond
(config/db-based-graph? (state/get-current-repo))
path
in-db?
(path/path-join repo-dir path)
:else
path)
file-path path
random-id (str (common-uuid/gen-uuid))
content (rum/react (::file-content state))]
[:div.file {:id (str "file-edit-wrapper-" random-id)

View File

@@ -76,14 +76,9 @@
(defn get-node-icon-cp
[node-entity opts]
(let [opts' (merge {:size 14} opts)
node-icon* (if (:link? opts)
"arrow-narrow-right"
(get-node-icon node-entity opts))
node-icon (if (config/db-based-graph?)
node-icon*
(or (when-let [icon' (get-in node-entity [:block/properties :icon])]
[:span icon'])
node-icon*))]
node-icon (if (:link? opts)
"arrow-narrow-right"
(get-node-icon node-entity opts))]
(when-not (or (string/blank? node-icon) (and (contains? #{"point-filled" "letter-p" "hash" "file"} node-icon) (:not-text-or-page? opts)))
[:div.icon-cp-container.flex.items-center
(merge {:style {:color (or (:color node-icon) "inherit")}}

View File

@@ -47,7 +47,6 @@
(when-let [id (:db/id page)]
(let [page (db/sub-block id)
repo (state/get-current-repo)
db-based? (config/db-based-graph? repo)
icon (icon/get-node-icon-cp page {:size 16})
title (:block/title page)
untitled? (db-model/untitled-page? title)
@@ -65,7 +64,7 @@
(when-not recent?
(x-menu-item
{:key "unfavorite"
:on-click #(page-handler/<unfavorite-page! (if db-based? (str (:block/uuid page)) title))}
:on-click #(page-handler/<unfavorite-page! (str (:block/uuid page)))}
(ctx-icon "star-off")
(t :page/unfavorite)
(x-menu-shortcut (when-let [binding (shortcut-dh/shortcut-binding :command/toggle-favorite)]
@@ -200,7 +199,7 @@
(when child [:div.bd child])]]))
(rum/defc ^:large-vars/cleanup-todo sidebar-navigations
[{:keys [default-home route-match route-name srs-open? db-based?]}]
[{:keys [default-home route-match route-name srs-open?]}]
(let [navs [:flashcards :all-pages :graph-view :tag/tasks :tag/assets]
[checked-navs set-checked-navs!] (rum/use-state (or (storage/get :ls-sidebar-navigations)
[:flashcards :all-pages :graph-view]))]
@@ -286,17 +285,16 @@
:icon "files"})
(= (namespace nav) "tag")
(when db-based?
(let [name'' (name nav)
class-ident (get {"assets" :logseq.class/Asset "tasks" :logseq.class/Task} name'')]
(when-let [tag-uuid (and class-ident (:block/uuid (db/entity class-ident)))]
(sidebar-item
{:class (str "tag-view-nav " name'')
:title (tt (keyword "left-side-bar" name'')
(keyword "right-side-bar" name''))
:href (rfe/href :page {:name tag-uuid})
:active (= (str tag-uuid) (get-in route-match [:path-params :name]))
:icon "hash"}))))))])))
(let [name'' (name nav)
class-ident (get {"assets" :logseq.class/Asset "tasks" :logseq.class/Task} name'')]
(when-let [tag-uuid (and class-ident (:block/uuid (db/entity class-ident)))]
(sidebar-item
{:class (str "tag-view-nav " name'')
:title (tt (keyword "left-side-bar" name'')
(keyword "right-side-bar" name''))
:href (rfe/href :page {:name tag-uuid})
:active (= (str tag-uuid) (get-in route-match [:path-params :name]))
:icon "hash"})))))])))
(rum/defc sidebar-favorites < rum/reactive
[]
@@ -347,7 +345,6 @@
[el-rect set-el-rect!] (rum/use-state nil)
ref-el (rum/use-ref nil)
ref-open? (rum/use-ref left-sidebar-open?)
db-based? (config/db-based-graph? (state/get-current-repo))
default-home (get-default-home-if-valid)
route-name (get-in route-match [:data :name])
on-contents-scroll #(when-let [^js el (.-target %)]
@@ -424,7 +421,6 @@
(sidebar-navigations
{:default-home default-home
:route-match route-match
:db-based? db-based?
:route-name route-name
:srs-open? srs-open?})]

View File

@@ -7,7 +7,6 @@
[frontend.components.content :as content]
[frontend.components.db-based.page :as db-page]
[frontend.components.editor :as editor]
[frontend.components.icon :as icon-component]
[frontend.components.library :as library]
[frontend.components.objects :as objects]
[frontend.components.plugins :as plugins]
@@ -25,8 +24,6 @@
[frontend.db.model :as model]
[frontend.extensions.graph :as graph]
[frontend.extensions.graph.pixi :as pixi]
[frontend.extensions.pdf.utils :as pdf-utils]
[frontend.format.mldoc :as mldoc]
[frontend.handler.common :as common-handler]
[frontend.handler.config :as config-handler]
[frontend.handler.editor :as editor-handler]
@@ -44,10 +41,8 @@
[goog.object :as gobj]
[logseq.common.config :as common-config]
[logseq.common.util :as common-util]
[logseq.common.util.page-ref :as page-ref]
[logseq.db :as ldb]
[logseq.db.frontend.db :as db-db]
[logseq.graph-parser.mldoc :as gp-mldoc]
[logseq.shui.hooks :as hooks]
[logseq.shui.ui :as shui]
[promesa.core :as p]
@@ -162,16 +157,6 @@
(add-button-inner block (assoc config :editing? editing?))))
(rum/defcs page-blocks-cp < rum/reactive db-mixins/query
{:will-mount (fn [state]
(when-not (config/db-based-graph?)
(let [page-e (first (:rum/args state))
page-name (:block/name page-e)]
(when (and page-name
(db/journal-page? page-name)
(>= (date/journal-title->int page-name)
(date/journal-title->int (date/today))))
(state/pub-event! [:journal/insert-template page-name]))))
state)}
[state block* {:keys [sidebar? hide-add-button? journals?] :as config}]
(when-let [id (:db/id block*)]
(let [block (db/sub-block id)
@@ -235,9 +220,7 @@
(when (seq queries)
[:div#today-queries
(for [query queries]
(let [query' (if (config/db-based-graph?)
(assoc query :collapsed? true)
query)]
(let [query' (assoc query :collapsed? true)]
(rum/with-key
(ui/catch-error
(ui/component-error "Failed default query:" {:content (pr-str query')})
@@ -249,150 +232,6 @@
query'))
(str repo "-custom-query-" (:query query')))))]))))
(rum/defc tagged-pages
[repo tag tag-title]
(let [[pages set-pages!] (rum/use-state nil)]
(hooks/use-effect!
(fn []
(p/let [result (db-async/<get-tag-pages repo (:db/id tag))]
(set-pages! result)))
[tag])
(when (seq pages)
[:div.references.page-tags.flex-1.flex-row
[:div.content
(ui/foldable
[:h2.font-bold.opacity-50 (util/format "Pages tagged with \"%s\"" tag-title)]
[:ul.mt-2
(for [page (sort-by :block/title pages)]
[:li {:key (str "tagged-page-" (:db/id page))}
(component-block/page-cp {} page)])]
{:default-collapsed? false})]])))
(rum/defc page-title-editor < rum/reactive
[page {:keys [*input-value *title-value *edit? page-name old-name]}]
(let [input-ref (rum/create-ref)
tag-idents (map :db/ident (:block/tags page))
collide? #(and (not= (util/page-name-sanity-lc page-name)
(util/page-name-sanity-lc @*title-value))
(db/page-exists? page-name tag-idents)
(db/page-exists? @*title-value tag-idents))
rollback-fn #(let [old-name old-name]
(reset! *title-value old-name)
(gobj/set (rum/deref input-ref) "value" old-name)
(reset! *edit? true)
(.focus (rum/deref input-ref)))
blur-fn (fn [e]
(when (common-util/wrapped-by-quotes? @*title-value)
(swap! *title-value common-util/unquote-string)
(gobj/set (rum/deref input-ref) "value" @*title-value))
(cond
(string/blank? @*title-value)
(do (notification/show! (t :page/illegal-page-name) :warning)
(rollback-fn))
(collide?)
(do (notification/show! (t :page/page-already-exists @*title-value) :error)
(rollback-fn))
:else
(p/do!
(page-handler/rename! (:block/uuid page) @*title-value)
(js/setTimeout #(reset! *edit? false) 100)))
(util/stop e))]
[:input.edit-input.p-0.outline-none.focus:outline-none.no-ring
{:type "text"
:ref input-ref
:auto-focus true
:style {:width "100%"
:font-weight "inherit"}
:auto-complete (if (util/chrome?) "chrome-off" "off") ; off not working here
:value (rum/react *input-value)
:on-change (fn [^js e]
(let [value (util/evalue e)]
(reset! *title-value (string/trim value))
(reset! *input-value value)))
:on-blur blur-fn
:on-key-down (fn [^js e]
(when (= (gobj/get e "key") "Enter")
(blur-fn e)))
:on-key-up (fn [^js e]
;; Esc
(when (= 27 (.-keyCode e))
(reset! *title-value old-name)
(reset! *edit? false)))}]))
(rum/defcs ^:large-vars/cleanup-todo page-title-cp < rum/reactive db-mixins/query
(rum/local false ::edit?)
(rum/local "" ::input-value)
{:init (fn [state]
(let [page (first (:rum/args state))
title (:block/title page)
*title-value (atom title)]
(assoc state ::title-value *title-value)))}
[state page {:keys [fmt-journal? preview?]}]
(when page
(let [page (db/sub-block (:db/id page))
title (:block/title page)]
(when title
(let [repo (state/get-current-repo)
journal? (ldb/journal? page)
*title-value (get state ::title-value)
*edit? (get state ::edit?)
*input-value (get state ::input-value)
hls-page? (pdf-utils/hls-file? title)
;; normal page cannot be untitled right?
title (if hls-page?
[:a.asset-ref (pdf-utils/fix-local-asset-pagename title)]
(if fmt-journal?
(date/journal-title->custom-format title)
title))
old-name title]
[:div.ls-page-title.flex.flex-1.flex-row.flex-wrap.w-full.relative.items-center.gap-2
[:h1.page-title.flex-1.cursor-pointer.gap-1
{:class "title"
:on-pointer-down (fn [e]
(when (util/right-click? e)
(state/set-state! :page-title/context {:page (:block/title page)
:page-entity page})))
:on-click (fn [e]
(when-not (= (.-nodeName (.-target e)) "INPUT")
(.preventDefault e)
(if (gobj/get e "shiftKey")
(state/sidebar-add-block!
repo
(:db/id page)
:page)
(when (and (not hls-page?)
(not journal?)
(not config/publishing?)
(not (ldb/built-in? page)))
(reset! *input-value old-name)
(reset! *edit? true)))))}
(when-not (config/db-based-graph?)
(when (get-in page [:block/properties :icon])
(icon-component/get-node-icon-cp page {})))
(if @*edit?
(page-title-editor page {:*title-value *title-value
:*edit? *edit?
:*input-value *input-value
:page-name (:block/title page)
:old-name old-name
:preview? preview?})
[:span.title.block
{:on-click (fn []
(when (and (not preview?)
(contains? #{:home :all-journals} (get-in (state/get-route-match) [:data :name])))
(route-handler/redirect-to-page! (:block/uuid page))))
:data-value @*input-value
:data-ref (:block/title page)
:style {:opacity (when @*edit? 0)}}
(let [nested? (and (string/includes? title page-ref/left-brackets)
(string/includes? title page-ref/right-brackets))]
(cond nested? (component-block/map-inline {} (gp-mldoc/inline->edn title (mldoc/get-default-config
(get page :block/format :markdown))))
:else title))])]])))))
(rum/defc db-page-title-actions
[page]
[:div.ls-page-title-actions
@@ -612,7 +451,6 @@
property-page? (ldb/property? page)
title (:block/title page)
journal? (db/journal-page? title)
db-based? (config/db-based-graph? repo)
fmt-journal? (boolean (date/journal-title->int title))
today? (and
journal?
@@ -620,7 +458,7 @@
*control-show? (::control-show? state)
*all-collapsed? (::all-collapsed? state)
home? (= :home (state/get-current-route))
show-tabs? (and db-based? (or class-page? (ldb/property? page)) (not tag-dialog?))]
show-tabs? (and (or class-page? (ldb/property? page)) (not tag-dialog?))]
(if page
(when (or title block?)
[:div.flex-1.page.relative.cp__page-inner-wrap
@@ -637,7 +475,7 @@
[:div.relative.grid.gap-4.sm:gap-8.page-inner.mb-16
(when-not (or block? sidebar?)
[:div.flex.flex-row.space-between
(when (and (or (mobile-util/native-platform?) (util/mobile?)) (not db-based?))
(when (or (mobile-util/native-platform?) (util/mobile?))
[:div.flex.flex-row.pr-2
{:style {:margin-left -15}
:on-mouse-over (fn [e]
@@ -646,24 +484,20 @@
(page-mouse-leave e *control-show?))}
(page-blocks-collapse-control title *control-show? *all-collapsed?)])
(when (ldb/page? page)
(if db-based?
(db-page-title page
{:sidebar? sidebar?
:journals? journals?
:container-id (:container-id state)
:tag-dialog? tag-dialog?})
(page-title-cp page {:journal? journal?
:fmt-journal? fmt-journal?
:preview? preview?})))
(db-page-title page
{:sidebar? sidebar?
:journals? journals?
:container-id (:container-id state)
:tag-dialog? tag-dialog?}))
(lsp-pagebar-slot)])
(when (and block? (not sidebar?))
(component-block/breadcrumb {} repo (:block/uuid page) {}))
(when (and db-based? (ldb/library? page))
(when (ldb/library? page)
(library/add-pages page))
(when (and db-based? sidebar? (ldb/page? page))
(when (and sidebar? (ldb/page? page))
[:div.-mb-8
(sidebar-page-properties config page)])
@@ -687,14 +521,11 @@
(when today?
(scheduled/scheduled-and-deadlines title))
(when (and (not block?) (not db-based?))
(tagged-pages repo page title))
(when (and (ldb/page? page) (:logseq.property.class/_extends page))
(class-component/class-children page))
;; referenced blocks
(when-not (or tag-dialog? linked-refs? (and block? (not db-based?)))
(when-not (or tag-dialog? linked-refs?)
[:div.fade-in.delay {:key "page-references"}
(rum/with-key
(reference/references page {:sidebar? sidebar?
@@ -706,8 +537,7 @@
sidebar?
tag-dialog?
home?
(or class-page? property-page?)
(and block? (not db-based?)))
class-page? property-page?)
[:div.fade-in.delay {:key "page-unlinked-references"}
(reference/unlinked-references page {:sidebar? sidebar?})])])])
[:div.opacity-75 "Page not found"])))
@@ -921,23 +751,22 @@
(set-setting! :excluded-pages? value)))
true)]]
(when (config/db-based-graph? (state/get-current-repo))
[:div.flex.flex-col.mb-2
[:p "Created before"]
(when created-at-filter
[:div (.toDateString (js/Date. (+ created-at-filter (get-in graph [:all-pages :created-at-min]))))])
[:div.flex.flex-col.mb-2
[:p "Created before"]
(when created-at-filter
[:div (.toDateString (js/Date. (+ created-at-filter (get-in graph [:all-pages :created-at-min]))))])
(ui/tooltip
(ui/tooltip
;; Slider keeps track off the range from min created-at to max created-at
;; because there were bugs with setting min and max directly
(ui/slider created-at-filter
{:min 0
:max (- (get-in graph [:all-pages :created-at-max])
(get-in graph [:all-pages :created-at-min]))
:on-change #(do
(reset! *created-at-filter (int %))
(set-setting! :created-at-filter (int %)))})
[:div.px-1 (str (js/Date. (+ created-at-filter (get-in graph [:all-pages :created-at-min]))))])])
(ui/slider created-at-filter
{:min 0
:max (- (get-in graph [:all-pages :created-at-max])
(get-in graph [:all-pages :created-at-min]))
:on-change #(do
(reset! *created-at-filter (int %))
(set-setting! :created-at-filter (int %)))})
[:div.px-1 (str (js/Date. (+ created-at-filter (get-in graph [:all-pages :created-at-min]))))])]
(when (seq focus-nodes)
[:div.flex.flex-col.mb-2

View File

@@ -182,8 +182,7 @@
(rum/defc tags
[repo *tree opts loc]
(let [[values set-values!] (rum/use-state nil)
db-based? (config/db-based-graph? repo)]
(let [[values set-values!] (rum/use-state nil)]
(hooks/use-effect!
(fn []
(let [result (db-model/get-all-readable-classes repo {:except-root-class? true})]
@@ -194,9 +193,8 @@
{:label (:block/title block)
:value (:block/uuid block)})))]
(select items
(fn [{:keys [value label]}]
(append-tree! *tree opts loc [(if db-based? :tags :page-tags)
(if db-based? (str value) label)]))
(fn [{:keys [value _label]}]
(append-tree! *tree opts loc [:tags (str value)]))
{:extract-fn :label}))))
(rum/defc page-search
@@ -250,19 +248,18 @@
(append-tree! *tree opts loc (vec (cons :task choices)))))}))
"priority"
(select (if (config/db-based-graph? repo)
(let [values (:property/closed-values (db/entity :logseq.property/priority))]
(mapv db-property/property-value-content values))
gp-db/built-in-priorities)
(constantly nil)
{:multiple-choices? true
:selected-choices #{}
:extract-chosen-fn :value
:prompt-key :select/default-select-multiple
:close-modal? false
:on-apply (fn [choices]
(when (seq choices)
(append-tree! *tree opts loc (vec (cons :priority choices)))))})
(select
(let [values (:property/closed-values (db/entity :logseq.property/priority))]
(mapv db-property/property-value-content values))
(constantly nil)
{:multiple-choices? true
:selected-choices #{}
:extract-chosen-fn :value
:prompt-key :select/default-select-multiple
:close-modal? false
:on-apply (fn [choices]
(when (seq choices)
(append-tree! *tree opts loc (vec (cons :priority choices)))))})
"page"
(page-search (fn [{:keys [value]}]
@@ -363,8 +360,7 @@
(str "#" (uuid->page-title (second (second clause)))))
(contains? #{:property :private-property :page-property} (keyword f))
(str (if (and (config/db-based-graph? (state/get-current-repo))
(qualified-keyword? (second clause)))
(str (if (qualified-keyword? (second clause))
(:block/title (db/entity (second clause)))
(some-> (second clause) name))
": "
@@ -570,12 +566,7 @@
(str result))))
repo (state/get-current-repo)
block (db/entity [:block/uuid (:block/uuid block)])]
(if (config/db-based-graph? (state/get-current-repo))
(editor-handler/save-block! repo (:block/uuid block) q)
(let [content (string/replace (:block/title block)
#"\{\{query[^}]+\}\}"
(util/format "{{query %s}}" q))]
(editor-handler/save-block! repo (:block/uuid block) content)))))))
(editor-handler/save-block! repo (:block/uuid block) q)))))
(assoc state ::tree *tree)))
:will-mount (fn [state]
(let [q-str (get-q (first (:rum/args state)))

View File

@@ -2,7 +2,6 @@
(:require [frontend.common.missionary :as c.m]
[frontend.components.reference-filters :as filters]
[frontend.components.views :as views]
[frontend.config :as config]
[frontend.db :as db]
[frontend.db-mixins :as db-mixins]
[frontend.db.async :as db-async]
@@ -67,9 +66,8 @@
[])
(when (> refs-total-count 0)
(ui/catch-error
(ui/component-error (if (config/db-based-graph? (state/get-current-repo))
"Linked References: Unexpected error."
"Linked References: Unexpected error. Please re-index your graph first."))
(ui/component-error
"Linked References: Unexpected error.")
[:div.references
(references-cp entity (assoc config :refs-total-count refs-total-count))])))))

View File

@@ -2,13 +2,11 @@
"References filters"
(:require [clojure.string :as string]
[datascript.impl.entity :as de]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
[frontend.db-mixins :as db-mixins]
[frontend.handler.page :as page-handler]
[frontend.search :as search]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[logseq.db.common.reference :as db-reference]
@@ -28,22 +26,14 @@
ref-name
(when ref-count [:sup " " ref-count])]
:on-click (fn [e]
(let [db-based? (config/db-based-graph? (state/get-current-repo))
includes (set (map :block/name (:included filters)))
(let [includes (set (map :block/name (:included filters)))
excludes (set (map :block/name (:excluded filters)))
included? (includes lc-reference)
not-in-filters? (and (not included?) (not (excludes lc-reference)))
shift? (.-shiftKey e)]
(if db-based?
(page-handler/db-based-save-filter! page (:db/id (db/get-page lc-reference))
{:add? not-in-filters?
:include? (if not-in-filters? (not shift?) included?)})
(let [filters-m (->> (concat (map #(vector % true) includes) (map #(vector % false) excludes))
(into {}))
filters' (if not-in-filters?
(assoc filters-m lc-reference (not shift?))
(dissoc filters-m lc-reference))]
(page-handler/file-based-save-filter! page filters')))))
(page-handler/db-based-save-filter! page (:db/id (db/get-page lc-reference))
{:add? not-in-filters?
:include? (if not-in-filters? (not shift?) included?)})))
:small? true
:variant :outline)))

View File

@@ -175,6 +175,7 @@
(remove #(= (:url %) config/demo-repo) repos)
(util/mobile?)
(filter (fn [item]
;; use `config/db-based-graph?` to avoid loading old file graphs
(config/db-based-graph? (:url item)))))
{remote-graphs true local-graphs false} (group-by (comp boolean :remote?) repos)
{own-graphs true shared-graphs false}

View File

@@ -277,7 +277,7 @@
(->> (state/get-repos)
(remove (fn [{:keys [url]}]
;; Can't replace current graph as ui wouldn't reload properly
(or (= url current-repo) (not (config/db-based-graph? url)))))
(= url current-repo)))
(map (fn [{:keys [url] :as original-graph}]
{:value (text-util/get-graph-name-from-path url)
:id (config/get-repo-dir url)

View File

@@ -1,7 +1,6 @@
(ns frontend.components.selection
"Block selection"
(:require [frontend.config :as config]
[frontend.db :as db]
(:require [frontend.db :as db]
[frontend.handler.editor :as editor-handler]
[frontend.state :as state]
[frontend.ui :as ui]
@@ -22,22 +21,20 @@
:size :sm
:class (str "p-2 text-xs h-8"
(when-not button-border?
" !border-b-0"))}
db-graph? (config/db-based-graph?)]
" !border-b-0"))}]
[:div.selection-action-bar
(shui/button-group
;; set tag
(when db-graph?
(shui/button
(assoc button-opts
:on-pointer-down (fn [e]
(util/stop e)
(state/pub-event! [:editor/new-property {:target (.-target e)
:selected-blocks selected-blocks
:property-key "Tags"
:on-dialog-close #(state/pub-event! [:editor/hide-action-bar])}])))
(ui/tooltip (ui/icon "hash" {:size 13}) "Set tag"
{:trigger-props {:class "flex"}})))
(shui/button
(assoc button-opts
:on-pointer-down (fn [e]
(util/stop e)
(state/pub-event! [:editor/new-property {:target (.-target e)
:selected-blocks selected-blocks
:property-key "Tags"
:on-dialog-close #(state/pub-event! [:editor/hide-action-bar])}])))
(ui/tooltip (ui/icon "hash" {:size 13}) "Set tag"
{:trigger-props {:class "flex"}}))
(shui/button
(assoc button-opts
:on-pointer-down (fn [e]
@@ -46,26 +43,24 @@
(state/clear-selection!)
(state/pub-event! [:editor/hide-action-bar])))
"Copy")
(when db-graph?
(shui/button
(assoc button-opts
:on-pointer-down (fn [e]
(util/stop e)
(state/pub-event! [:editor/new-property {:target (.-target e)
:selected-blocks selected-blocks
:on-dialog-close #(state/pub-event! [:editor/hide-action-bar])}])))
"Set property"))
(when db-graph?
(shui/button
(assoc button-opts
:on-pointer-down (fn [e]
(util/stop e)
(state/pub-event! [:editor/new-property {:target (.-target e)
:selected-blocks selected-blocks
:remove-property? true
:select-opts {:show-new-when-not-exact-match? false}
:on-dialog-close #(state/pub-event! [:editor/hide-action-bar])}])))
"Unset property"))
(shui/button
(assoc button-opts
:on-pointer-down (fn [e]
(util/stop e)
(state/pub-event! [:editor/new-property {:target (.-target e)
:selected-blocks selected-blocks
:on-dialog-close #(state/pub-event! [:editor/hide-action-bar])}])))
"Set property")
(shui/button
(assoc button-opts
:on-pointer-down (fn [e]
(util/stop e)
(state/pub-event! [:editor/new-property {:target (.-target e)
:selected-blocks selected-blocks
:remove-property? true
:select-opts {:show-new-when-not-exact-match? false}
:on-dialog-close #(state/pub-event! [:editor/hide-action-bar])}])))
"Unset property")
(when-not (contains? #{:logseq.class/Page} (:db/ident view-parent))
(shui/button
(assoc button-opts

View File

@@ -32,7 +32,6 @@
[frontend.ui :as ui]
[frontend.util :refer [classnames web-platform?] :as util]
[frontend.version :as fv]
[goog.object :as gobj]
[goog.string :as gstring]
[lambdaisland.glogi :as log]
[logseq.db :as ldb]
@@ -282,63 +281,6 @@
(js/logseq.api.relaunch))))
true)]]]))
(rum/defcs switch-git-auto-commit-row < rum/reactive
[state t]
(let [enabled? (state/get-git-auto-commit-enabled?)]
[:div.it.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-center
[:label.block.text-sm.font-medium.leading-5.opacity-70
(t :settings-page/git-switcher-label)]
[:div
[:div.rounded-md.sm:max-w-xs
(ui/toggle
enabled?
(fn []
(state/set-state! [:electron/user-cfgs :git/disable-auto-commit?] enabled?)
(p/do!
(ipc/ipc :userAppCfgs :git/disable-auto-commit? enabled?)
(ipc/ipc :setGitAutoCommit)))
true)]]]))
(rum/defcs switch-git-commit-on-close-row < rum/reactive
[state t]
(let [enabled? (state/get-git-commit-on-close-enabled?)]
[:div.it.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-center
[:label.block.text-sm.font-medium.leading-5.opacity-70
(t :settings-page/git-commit-on-close)]
[:div
[:div.rounded-md.sm:max-w-xs
(ui/toggle
enabled?
(fn []
(state/set-state! [:electron/user-cfgs :git/commit-on-close?] (not enabled?))
(ipc/ipc :userAppCfgs :git/commit-on-close? (not enabled?)))
true)]]]))
(rum/defcs git-auto-commit-seconds < rum/reactive
[state t]
(let [secs (or (state/sub [:electron/user-cfgs :git/auto-commit-seconds]) 60)]
[:div.it.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-center
[:label.block.text-sm.font-medium.leading-5.opacity-70
(t :settings-page/git-commit-delay)]
[:div.mt-1.sm:mt-0.sm:col-span-2
[:div.max-w-lg.rounded-md.sm:max-w-xs
[:input#home-default-page.form-input.is-small.transition.duration-150.ease-in-out
{:default-value secs
:on-blur (fn [event]
(let [value (-> (util/evalue event)
util/safe-parse-int)]
(if (and (number? value)
(< 0 value (inc 86400)))
(p/do!
(state/set-state! [:electron/user-cfgs :git/auto-commit-seconds] value)
(ipc/ipc :userAppCfgs :git/auto-commit-seconds value)
(ipc/ipc :setGitAutoCommit))
(when-let [elem (gobj/get event "target")]
(notification/show!
[:div "Invalid value! Must be a number between 1 and 86400"]
:warning true)
(gobj/set elem "value" secs)))))}]]]]))
(rum/defc app-auto-update-row < rum/reactive [t]
(let [enabled? (state/sub [:electron/user-cfgs :auto-update])
enabled? (if (nil? enabled?) true enabled?)]
@@ -439,33 +381,22 @@
[:div.it.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-:div.it.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-center
[:label.block.text-sm.font-medium.leading-5.opacity-70
{:for "custom_date_format"}
(t :settings-page/custom-date-format)
(when-not (config/db-based-graph? (state/get-current-repo))
(ui/tooltip [:span.flex.px-2 (svg/info)]
[:span (t :settings-page/custom-date-format-warning)]))]
(t :settings-page/custom-date-format)]
[:div.mt-1.sm:mt-0.sm:col-span-2
[:div.max-w-lg.rounded-md
[:select.form-select.is-small
{:value preferred-date-format
:on-change (fn [e]
(let [repo (state/get-current-repo)
format (util/evalue e)
db-based? (config/db-based-graph? repo)]
format (util/evalue e)]
(when-not (string/blank? format)
(if db-based?
(p/do!
(property-handler/set-block-property! repo
:logseq.class/Journal
:logseq.property.journal/title-format
format)
(notification/show! "Please refresh the app for this change to take effect"))
(do
(config-handler/set-config! :journal/page-title-format format)
(notification/show!
[:div (t :settings-page/custom-date-format-notification)]
:warning false)))
(shui/dialog-close-all!)
(when-not db-based? (route-handler/redirect! {:to :graphs})))))}
(p/do!
(property-handler/set-block-property! repo
:logseq.class/Journal
:logseq.property.journal/title-format
format)
(notification/show! "Please refresh the app for this change to take effect"))
(shui/dialog-close-all!))))}
(for [format (sort (date/journal-title-formatters))]
[:option {:key format} format])]]]])
@@ -763,9 +694,7 @@
(rum/defcs settings-editor < rum/reactive
[_state current-repo]
(let [preferred-format (state/get-preferred-format)
preferred-date-format (state/get-date-formatter)
preferred-workflow (state/get-preferred-workflow)
(let [preferred-date-format (state/get-date-formatter)
enable-timetracking? (state/enable-timetracking?)
enable-all-pages-public? (state/all-pages-public?)
logical-outdenting? (state/logical-outdenting?)
@@ -775,16 +704,10 @@
enable-tooltip? (state/enable-tooltip?)
enable-shortcut-tooltip? (state/sub :ui/shortcut-tooltip?)
show-brackets? (state/show-brackets?)
wide-mode? (state/sub :ui/wide-mode?)
enable-git-auto-push? (state/enable-git-auto-push? current-repo)
db-graph? (config/db-based-graph? (state/get-current-repo))]
wide-mode? (state/sub :ui/wide-mode?)]
[:div.panel-wrap.is-editor
(when-not db-graph?
(file-format-row t preferred-format))
(date-format-row t preferred-date-format)
(when-not db-graph?
(workflow-row t preferred-workflow))
(show-brackets-row t show-brackets?)
(toggle-wide-mode-row t wide-mode?)
@@ -798,30 +721,7 @@
(when-not (or (util/mobile?) (mobile-util/native-platform?))
(tooltip-row t enable-tooltip?))
(timetracking-row t enable-timetracking?)
(enable-all-pages-public-row t enable-all-pages-public?)
(when-not db-graph?
(auto-push-row t current-repo enable-git-auto-push?))]))
(rum/defc settings-git
[]
[:div.panel-wrap
[:div.text-sm.my-4
(ui/admonition
:tip
[:p (t :settings-page/git-tip)])
[:span.text-sm.opacity-50.my-4
(t :settings-page/git-desc-1)]
[:br] [:br]
[:span.text-sm.opacity-50.my-4
(t :settings-page/git-desc-2)]
[:a {:href "https://git-scm.com/" :target "_blank"}
"Git"]
[:span.text-sm.opacity-50.my-4
(t :settings-page/git-desc-3)]]
[:br]
(switch-git-auto-commit-row t)
(switch-git-commit-on-close-row t)
(git-auto-commit-seconds t)])
(enable-all-pages-public-row t enable-all-pages-public?)]))
(rum/defc settings-advanced < rum/reactive
[]
@@ -1024,7 +924,6 @@
(let [current-repo (state/get-current-repo)
enable-journals? (state/enable-journals? current-repo)
enable-flashcards? (state/enable-flashcards? current-repo)
db-based? (config/db-based-graph? current-repo)
logged-in? (user-handler/logged-in?)]
[:div.panel-wrap.is-features.mb-8
(journal-row enable-journals?)
@@ -1046,7 +945,6 @@
(when (util/electron?)
(http-server-switcher-row))
(flashcards-switcher-row enable-flashcards?)
(when-not db-based? (zotero-settings-row))
(when-not web-platform?
[:div.mt-1.sm:mt-0.sm:col-span-2
[:hr]
@@ -1402,8 +1300,7 @@
_installed-plugins (state/sub :plugin/installed-plugins)
plugins-of-settings (and config/lsp-enabled? (seq (plugin-handler/get-enabled-plugins-if-setting-schema)))
*active (::active state)
logged-in? (user-handler/logged-in?)
db-based? (config/db-based-graph?)]
logged-in? (user-handler/logged-in?)]
[:div#settings.cp__settings-main
(settings-effect @*active)
@@ -1419,13 +1316,7 @@
[:editor "editor" (t :settings-page/tab-editor) (ui/icon "writing")]
[:keymap "keymap" (t :settings-page/tab-keymap) (ui/icon "keyboard")]
(when db-based?
[:ai (t :settings-page/tab-ai) (t :settings-page/ai) (ui/icon "wand")])
(when (and (util/electron?) (not db-based?))
[:version-control "git" (t :settings-page/tab-version-control) (ui/icon "history")])
;; (when (util/electron?)
;; [:assets "assets" (t :settings-page/tab-assets) (ui/icon "box")])
[:ai (t :settings-page/tab-ai) (t :settings-page/ai) (ui/icon "wand")]
[:advanced "advanced" (t :settings-page/tab-advanced) (ui/icon "bulb")]
[:features "features" (t :settings-page/tab-features) (ui/icon "app-feature")]
@@ -1474,9 +1365,6 @@
:keymap
(shortcut/shortcut-keymap-x)
:version-control
(settings-git)
:assets
(assets/settings-content)

View File

@@ -63,12 +63,12 @@
[accent-color])
(hooks/use-effect!
(fn []
(when-let [{:keys [type global]} editor-font]
(doto js/document.documentElement
(.setAttribute "data-font" (or type "default"))
(.setAttribute "data-font-global" (boolean global)))))
[editor-font])
(fn []
(when-let [{:keys [type global]} editor-font]
(doto js/document.documentElement
(.setAttribute "data-font" (or type "default"))
(.setAttribute "data-font-global" (boolean global)))))
[editor-font])
(hooks/use-effect!
#(let [doc js/document.documentElement]
@@ -101,7 +101,6 @@
(hooks/use-effect!
(fn []
(ui-handler/reset-custom-css!)
(ui-handler/set-file-graph-flag! (false? (config/db-based-graph? current-repo)))
(pdf/reset-current-pdf!)
(plugin-handler/hook-plugin-app :current-graph-changed {}))
[current-repo])

View File

@@ -36,22 +36,6 @@
}
}
html.is-file-graph {
#main-content-container {
@apply pt-2;
}
.page-inner {
@apply sm:gap-2;
}
.sidebar-item {
.ls-page-blocks {
@apply pt-4;
}
}
}
.hide-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none !important; /* Firefox */

View File

@@ -136,7 +136,6 @@
(defn header-cp
[{:keys [view-entity column-set-sorting! state]} column]
(let [sorting (:sorting state)
db-based? (config/db-based-graph?)
[asc?] (some (fn [item] (when (= (:id item) (:id column))
(when-some [asc? (:asc? item)]
[asc?]))) sorting)
@@ -157,7 +156,7 @@
[:div.flex.flex-row.items-center.gap-1
(ui/icon "arrow-down" {:size 15})
[:div "Sort descending"]])
(when (and db-based? property)
(when property
(shui/dropdown-menu-item
{:on-click (fn [_e]
(if pinned?
@@ -1546,19 +1545,18 @@
(defn- db-set-table-state!
[entity {:keys [set-sorting! set-filters! set-visible-columns!
set-ordered-columns! set-sized-columns!]}]
(let [repo (state/get-current-repo)
db-based? (config/db-based-graph?)]
(let [repo (state/get-current-repo)]
{:set-sorting!
(fn [sorting]
(p/do!
(when db-based? (property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/sorting sorting))
(property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/sorting sorting)
(set-sorting! sorting)))
:set-filters!
(fn [filters]
(let [filters (-> (update filters :filters table-filters->persist-state)
(update :or? boolean))]
(p/do!
(when db-based? (property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/filters filters))
(property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/filters filters)
(set-filters! filters))))
:set-visible-columns!
(fn [columns]
@@ -1566,18 +1564,18 @@
(when (false? visible?)
column)) columns))]
(p/do!
(when db-based? (property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/hidden-columns hidden-columns))
(property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/hidden-columns hidden-columns)
(set-visible-columns! columns))))
:set-ordered-columns!
(fn [ordered-columns]
(let [ids (vec (remove #{:select} ordered-columns))]
(p/do!
(when db-based? (property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/ordered-columns ids))
(property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/ordered-columns ids)
(set-ordered-columns! ordered-columns))))
:set-sized-columns!
(fn [sized-columns]
(p/do!
(when db-based? (property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/sized-columns sized-columns))
(property-handler/set-block-property! repo (:db/id entity) :logseq.property.table/sized-columns sized-columns)
(set-sized-columns! sized-columns)))}))
(rum/defc lazy-item
@@ -1949,7 +1947,6 @@
{:keys [view-feature-type title-key additional-actions]
:as option}]
(let [[hover? set-hover?] (hooks/use-state nil)
db-based? (config/db-based-graph? (state/get-current-repo))
references? (contains? #{:linked-references :unlinked-references} view-feature-type)
opacity (cond
(and references? (not hover?)) "opacity-0"
@@ -1961,23 +1958,14 @@
(ui/dropdown-exists?))
(set-hover? false))}
[:div.flex.flex-row.items-center.gap-2
(if db-based?
(if (= view-feature-type :query-result)
[:div.font-medium.opacity-50.text-sm
(t (or title-key :views.table/default-title)
(count (:rows table)))]
(views-tab view-parent view-entity (assoc option
:hover? hover?
:opacity opacity
:references? references?)))
[:div.font-medium.text-sm
[:span
(case view-feature-type
:all-pages "All pages"
:linked-references "Linked references"
:unlinked-references "Unlinked references"
"Nodes")]
[:span.ml-1 (count (:rows table))]])]
(if (= view-feature-type :query-result)
[:div.font-medium.opacity-50.text-sm
(t (or title-key :views.table/default-title)
(count (:rows table)))]
(views-tab view-parent view-entity (assoc option
:hover? hover?
:opacity opacity
:references? references?)))]
[:div.view-actions.flex.items-center.gap-1.transition-opacity.ease-in.duration-300
{:class opacity}
@@ -1987,22 +1975,21 @@
(action option)
action))])
(when (and db-based? (seq sorting))
(when (seq sorting)
(view-sorting table columns sorting))
(when db-based? (filter-properties view-entity columns table option))
(filter-properties view-entity columns table option)
[:div.view-action-search
(search input {:on-change set-input!
:set-input! set-input!})]
(when db-based?
[:div.view-action-type.text-muted-foreground.text-sm
(pv/property-value view-entity (db/entity :logseq.property.view/type) {:icon? true})])
[:div.view-action-type.text-muted-foreground.text-sm
(pv/property-value view-entity (db/entity :logseq.property.view/type) {:icon? true})]
(when db-based? (more-actions view-entity columns table option))
(more-actions view-entity columns table option)
(when (and db-based? add-new-object!) (new-record-button table view-entity))]]))
(when add-new-object! (new-record-button table view-entity))]]))
(rum/defc group-item
[view-entity table' group group-by-property value option view-opts {:keys [list-view? group-by-page? readable-property-value]}]
@@ -2040,8 +2027,7 @@
(rum/defc ^:large-vars/cleanup-todo view-inner < rum/static
[view-entity {:keys [view-parent data full-data set-data! columns add-new-object! foldable-options input set-input! sorting set-sorting! filters set-filters! display-type group-by-property-ident config] :as option*}
*scroller-ref]
(let [db-based? (config/db-based-graph?)
journals? (:journals? config)
(let [journals? (:journals? config)
option (assoc option* :properties
(-> (remove #{:id :select} (map :id columns))
(conj :block/uuid :block/name)
@@ -2155,8 +2141,7 @@
"Empty"
:else
(str %))
group-by-page? (or (= :block/page group-by-property-ident)
(and (not db-based?) (contains? #{:linked-references :unlinked-references} display-type)))
group-by-page? (= :block/page group-by-property-ident)
key (str (:db/id view-entity) "-group-idx-" idx)]
(rum/with-key
(group-item view-entity table' group group-by-property value option view-opts
@@ -2249,21 +2234,14 @@
[view-entity {:keys [config view-parent view-feature-type data query-entity-ids query set-view-entity!] :as option}]
(let [[input set-input!] (hooks/use-state "")
[properties set-properties!] (hooks/use-state nil)
db-based? (config/db-based-graph?)
group-by-property (:logseq.property.view/group-by-property view-entity)
display-type (if (config/db-based-graph?)
(or (:db/ident (get view-entity :logseq.property.view/type))
(when (= (:view-type option) :linked-references)
:logseq.property.view/type.list)
:logseq.property.view/type.table)
(if (= view-feature-type :all-pages)
:logseq.property.view/type.table
:logseq.property.view/type.list))
display-type (or (:db/ident (get view-entity :logseq.property.view/type))
(when (= (:view-type option) :linked-references)
:logseq.property.view/type.list)
:logseq.property.view/type.table)
list-view? (= display-type :logseq.property.view/type.list)
group-by-property-ident (or (:db/ident group-by-property)
(when (and list-view? (nil? group-by-property))
:block/page)
(when (and (not db-based?) (contains? #{:linked-references :unlinked-references} view-feature-type))
:block/page))
sorting* (:logseq.property.table/sorting view-entity)
sorting (if (or (= sorting* :logseq.property/empty-placeholder) (empty? sorting*))
@@ -2362,14 +2340,13 @@
[{:keys [view-parent view-feature-type view-entity] :as option}]
(let [[views set-views!] (hooks/use-state nil)
[view-entity set-view-entity!] (hooks/use-state view-entity)
query? (= view-feature-type :query-result)
db-based? (config/db-based-graph?)]
query? (= view-feature-type :query-result)]
(hooks/use-effect!
#(c.m/run-task*
(m/sp
(when-not query?
(let [repo (state/get-current-repo)]
(when (and db-based? (not view-entity))
(when-not view-entity
(c.m/<? (db-async/<get-views repo (:db/id view-parent) view-feature-type))
(let [views (get-views view-parent view-feature-type)]
(if-let [v (first views)]
@@ -2381,8 +2358,7 @@
(set-views! (concat views [new-view]))
(set-view-entity! new-view))))))))))
[])
(when (if db-based? view-entity (or view-entity view-parent
(= view-feature-type :all-pages)))
(when view-entity
(let [option' (assoc option
:view-feature-type (or view-feature-type
(:logseq.property.view/feature-type view-entity))

View File

@@ -4,7 +4,6 @@
[cljs-time.core :as t]
[cljs-time.format :as tf]
[datascript.core :as d]
[frontend.config :as config]
[frontend.date :as date]
[frontend.db :as db]
[frontend.db.async.util :as db-async-util]
@@ -215,16 +214,6 @@
db-model/sort-by-order-recursive
db-utils/group-by-page))))))
(defn <get-tag-pages
[graph tag-id]
(<q graph {:transact-db? false}
'[:find [(pull ?page [:db/id :block/uuid :block/name :block/title :block/created-at :block/updated-at]) ...]
:in $ ?tag-id
:where
[?page :block/tags ?tag-id]
[?page :block/name]]
tag-id))
(defn <get-tag-objects
[graph class-id]
(let [class-children (db-model/get-structured-children graph class-id)

View File

@@ -55,7 +55,9 @@
:else
repo-name)]
(string/replace-first repo-name' config/db-version-prefix "")))
(if (config/db-based-graph? repo-name')
(string/replace-first repo-name' config/db-version-prefix "")
repo-name')))
(defn remove-conn!
[repo]
@@ -82,7 +84,9 @@
(start! repo {}))
([repo {:keys [listen-handler]}]
(let [db-name (db-conn-state/get-repo-path repo)
db-conn (d/create-conn db-schema/schema)]
db-conn (if (config/db-based-graph? repo)
(d/create-conn db-schema/schema)
(gp-db/start-conn))]
(destroy-all!)
(swap! conns assoc db-name db-conn)
(when listen-handler

View File

@@ -24,6 +24,7 @@
input
(merge {:current-page-fn (fn []
(or (when-let [name-or-uuid (state/get-current-page)]
;; `ldb/db-based-graph?` left here for testing
(if (ldb/db-based-graph? db)
(:block/title (model/get-block-by-uuid name-or-uuid))
name-or-uuid))

View File

@@ -43,8 +43,7 @@
(state/set-edit-content! (state/get-edit-input-id) new-content)
(editor-handler/save-block-if-changed! block new-content))
(and (not-empty (:file-path config))
(config/db-based-graph? repo))
(not-empty (:file-path config))
(db-editor-handler/save-file! (:file-path config) value)
:else

View File

@@ -20,7 +20,7 @@
(let [result* (db/pull eid)
entity (db/entity eid)
result (cond-> result*
(and (seq (:block/properties entity)) (config/db-based-graph? (state/get-current-repo)))
(seq (:block/properties entity))
(assoc :block.debug/properties
(->> (:block/properties entity)
(map (fn [[k v]]
@@ -81,16 +81,6 @@
(show-entity-data page-id)
(notification/show! "No page found" :warning)))
(defn ^:export show-page-ast []
(if (config/db-based-graph? (state/get-current-repo))
(notification/show! "Command not available yet for DB graphs" :warning)
(let [page-data (db/pull '[:block/format {:block/file [:file/content]}]
(page-util/get-current-page-id))]
(if (get-in page-data [:block/file :file/content])
(show-content-ast (get-in page-data [:block/file :file/content])
(get page-data :block/format :markdown))
(notification/show! "No page found" :warning)))))
(defn ^:export validate-db []
(state/<invoke-db-worker :thread-api/validate-db (state/get-current-repo)))

View File

@@ -1018,21 +1018,6 @@
(string/join "\n\n"))]
(util/copy-to-clipboard! copy-str))))
(defn copy-block-embeds
[]
(when-let [blocks (seq (get-selected-blocks))]
(let [ids (->> (distinct (map #(when-let [id (dom/attr % "blockid")]
(uuid id)) blocks))
(remove nil?))
ids-str (if (config/db-based-graph? (state/get-current-repo))
(some->> ids
(map (fn [id] (ref/->block-ref id)))
(string/join "\n\n"))
(some->> ids
(map (fn [id] (util/format "{{embed ((%s))}}" id)))
(string/join "\n\n")))]
(util/copy-to-clipboard! ids-str))))
(defn get-selected-toplevel-block-uuids
[]
(when-let [blocks (seq (get-selected-blocks))]

View File

@@ -39,7 +39,7 @@
[:ui/theme
:ui/sidebar-collapsed-blocks])
:repo-config (get-in @state/state [:config repo])
:db-graph? (config/db-based-graph? repo)})
:db-graph? true})
html-str (str "data:text/html;charset=UTF-8,"
(js/encodeURIComponent html))]
(if (util/electron?)
@@ -67,24 +67,9 @@
(.setAttribute anchor "download" (.-name zipfile))
(.click anchor))))
(defn file-based-export-repo-as-zip!
[repo]
(p/let [files (export-common-handler/<get-file-contents repo "md")
[owner repo-name] (util/get-git-owner-and-repo repo)
repo-name (str owner "-" repo-name)
files (map (fn [{:keys [path content]}] [path content]) files)]
(when (seq files)
(p/let [zipfile (zip/make-zip repo-name files repo)]
(when-let [anchor (gdom/getElement "download-as-zip")]
(.setAttribute anchor "href" (js/window.URL.createObjectURL zipfile))
(.setAttribute anchor "download" (.-name zipfile))
(.click anchor))))))
(defn export-repo-as-zip!
[repo]
(if (config/db-based-graph? repo)
(db-based-export-repo-as-zip! repo)
(file-based-export-repo-as-zip! repo)))
(db-based-export-repo-as-zip! repo))
(defn- export-file-on-mobile [data path]
(p/catch
@@ -312,7 +297,7 @@
(defn backup-db-graph
[repo]
(when (and (config/db-based-graph? repo) (not (util/capacitor?)))
(when-not (util/capacitor?)
(web-backup-db-graph repo)))
(defonce *backup-interval (atom nil))
@@ -324,7 +309,6 @@
(defn auto-db-backup!
[repo]
(when (and
(config/db-based-graph? repo)
util/web-platform?
(not (util/capacitor?))
(ldb/get-key-value (db/get-db repo) :logseq.kv/graph-backup-folder))

View File

@@ -30,9 +30,8 @@
(mldoc/->edn text format)
text format
{:page-name (:block/name (db/entity page-id))})
db-based? (config/db-based-graph? (state/get-current-repo))
blocks' (cond->> (gp-block/with-parent-and-order page-id blocks)
db-based?
true
(map (fn [block]
(let [refs (:block/refs block)]
(-> block
@@ -199,9 +198,7 @@
;; Handle internal paste
(let [revert-cut-txs (get-revert-cut-txs blocks)
keep-uuid? (= (state/get-block-op-type) :cut)
blocks (if (config/db-based-graph? (state/get-current-repo))
(map (fn [b] (dissoc b :block/properties)) blocks)
blocks)]
blocks (map (fn [b] (dissoc b :block/properties)) blocks)]
(if embed-block?
(when-let [block-id (:block/uuid (first blocks))]
(when-let [current-block (state/get-edit-block)]

View File

@@ -35,33 +35,31 @@
(defn remove-repo!
[{:keys [url] :as repo} & {:keys [switch-graph?]
:or {switch-graph? true}}]
(let [current-repo (state/get-current-repo)
db-based? (config/db-based-graph? url)]
(when (or (config/local-file-based-graph? url) db-based?)
(p/do!
(idb/clear-local-db! url) ; clear file handles
(db/remove-conn! url)
(db-persist/delete-graph! url)
(search/remove-db! url)
(state/delete-repo! repo)
(when switch-graph?
(if (= current-repo url)
(do
(state/set-current-repo! nil)
(when-let [graph (:url (first (state/get-repos)))]
(notification/show! (str "Removed graph "
(pr-str (text-util/get-graph-name-from-path url))
". Redirecting to graph "
(pr-str (text-util/get-graph-name-from-path graph)))
:success)
(state/pub-event! [:graph/switch graph {:persist? false}])))
(notification/show! (str "Removed graph " (pr-str (text-util/get-graph-name-from-path url))) :success)))))))
(let [current-repo (state/get-current-repo)]
(p/do!
(idb/clear-local-db! url) ; clear file handles
(db/remove-conn! url)
(db-persist/delete-graph! url)
(search/remove-db! url)
(state/delete-repo! repo)
(when switch-graph?
(if (= current-repo url)
(do
(state/set-current-repo! nil)
(when-let [graph (:url (first (state/get-repos)))]
(notification/show! (str "Removed graph "
(pr-str (text-util/get-graph-name-from-path url))
". Redirecting to graph "
(pr-str (text-util/get-graph-name-from-path graph)))
:success)
(state/pub-event! [:graph/switch graph {:persist? false}])))
(notification/show! (str "Removed graph " (pr-str (text-util/get-graph-name-from-path url))) :success))))))
(defn start-repo-db-if-not-exists!
[repo & {:as opts}]
(state/set-current-repo! repo)
(db/start-db-conn! repo (assoc opts
:db-graph? (config/db-based-graph? repo)
:db-graph? true
:listen-handler (fn [conn]
(undo-redo/listen-db-changes! repo conn)))))

View File

@@ -124,11 +124,6 @@
(dom/remove! el-style))
(add-style-if-exists!))
(defn set-file-graph-flag!
[file-graph?]
(apply (if file-graph? dom/add-class! dom/remove-class!)
[js/document.documentElement "is-file-graph"]))
(def *js-execed (atom #{}))
(defn exec-js-if-exists-&-allowed!

View File

@@ -503,10 +503,6 @@
:inactive (not (state/developer-mode?))
:fn :frontend.handler.common.developer/show-page-data}
:dev/show-page-ast {:binding []
:inactive (not (state/developer-mode?))
:fn :frontend.handler.common.developer/show-page-ast}
:misc/export-block-data {:binding []
:fn :frontend.handler.db-based.export/export-block-data}
@@ -722,7 +718,6 @@
:dev/show-block-data
:dev/show-block-ast
:dev/show-page-data
:dev/show-page-ast
:dev/replace-graph-with-db-file
:dev/validate-db
:dev/gc-graph
@@ -886,7 +881,6 @@
:dev/show-block-data
:dev/show-block-ast
:dev/show-page-data
:dev/show-page-ast
:dev/replace-graph-with-db-file
:dev/validate-db
:dev/gc-graph

View File

@@ -1,20 +1,20 @@
(ns frontend.page
"Provides root component for both Logseq app and publishing build"
(:require [logseq.shui.ui :as shui]
[rum.core :as rum]
[frontend.state :as state]
[frontend.config :as config]
[frontend.ui :as ui]
[frontend.components.container :as container]
[frontend.handler.search :as search-handler]
[frontend.handler.notification :as notification]
(:require [frontend.components.container :as container]
[frontend.components.onboarding.quick-tour :as quick-tour]
[frontend.handler.plugin :as plugin-handler]
[frontend.components.plugins :as plugin]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.handler.export :as export]
[frontend.handler.notification :as notification]
[frontend.handler.plugin :as plugin-handler]
[frontend.handler.search :as search-handler]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[reitit.frontend.easy :as rfe]))
[logseq.shui.ui :as shui]
[reitit.frontend.easy :as rfe]
[rum.core :as rum]))
(defn- setup-fns!
[]
@@ -32,8 +32,7 @@
of broken conditions"
[]
;; This layout emulates most of container/sidebar
(let [current-repo (state/get-current-repo)
db-based? (config/db-based-graph? current-repo)]
(let [current-repo (state/get-current-repo)]
[:div#main-container.cp__sidebar-main-layout.flex-1.flex
[:div.#app-container
[:div#left-container
@@ -68,21 +67,20 @@
[:div.text-xs.toned-down "Quit the app and then reopen it."]]
[:div (ui/icon "command" {:class "rounded-md p-1 mr-2 bg-quaternary"})
(ui/icon (if (util/electron?) "letter-q" "letter-r") {:class "rounded-md p-1 bg-quaternary"})]]
(when db-based?
[:div.flex.flex-row.justify-between.align-items.mb-4.items-center.separator-top.py-4
[:div.flex.flex-col.items-start.mr-2
[:div.text-2xs.font-bold.uppercase.toned-down (t :page/step "3")]
[:div [:span.highlighted.font-bold "Export "] [:span.toned-down " current graph as SQLite db"]]
[:div.text-xs.toned-down "You can send it to help@logseq.com for debugging."]
[:a#download-as-sqlite-db.hidden]]
[:div
(ui/button "Export graph"
:small? true
:on-click #(export/export-repo-as-sqlite-db! current-repo))]])
[:div.flex.flex-row.justify-between.align-items.mb-4.items-center.separator-top.py-4
[:div.flex.flex-col.items-start.mr-2
[:div.text-2xs.font-bold.uppercase.toned-down (t :page/step "3")]
[:div [:span.highlighted.font-bold "Export "] [:span.toned-down " current graph as SQLite db"]]
[:div.text-xs.toned-down "You can send it to help@logseq.com for debugging."]
[:a#download-as-sqlite-db.hidden]]
[:div
(ui/button "Export graph"
:small? true
:on-click #(export/export-repo-as-sqlite-db! current-repo))]]
[:div.flex.flex-row.justify-between.align-items.mb-4.items-center.separator-top.py-4
[:div.flex.flex-col.items-start
[:div.text-2xs.font-bold.uppercase.toned-down (t :page/step (if db-based? "4" "3"))]
[:div.text-2xs.font-bold.uppercase.toned-down (t :page/step "4")]
[:div [:span.highlighted.font-bold "Clear"] [:span.toned-down " local storage"]]
[:div.text-xs.toned-down "This does delete minor preferences like dark/light theme preference."]]
[:div
@@ -92,17 +90,13 @@
(.clear js/localStorage)
(notification/show! "Cleared!" :success)))]]]
[:div
(when-not db-based?
[:p "If you think you have experienced data loss, check for backup files under
the folder logseq/bak/."])
(when db-based?
[:p "You can also go to "
[:a {:title "All graphs"
:on-click (fn []
(set! (.-href js/window.location) (rfe/href :graphs))
(.reload js/window.location))}
"All graphs"]
" to switch to another graph."])
[:p "You can also go to "
[:a {:title "All graphs"
:on-click (fn []
(set! (.-href js/window.location) (rfe/href :graphs))
(.reload js/window.location))}
"All graphs"]
" to switch to another graph."]
[:p "If these troubleshooting steps have not solved your problem, please "
[:a.underline
{:href "https://github.com/logseq/logseq/issues/new?labels=from:in-app&template=bug_report.yaml"}
@@ -117,7 +111,7 @@
[:p {:class "text-gray-500 mb-8"} "Oops! The page you're looking for doesn't exist."]
(shui/button {:on-click #(rfe/push-state :home)
:variant :outline}
(shui/tabler-icon "home") "Go back home")])
(shui/tabler-icon "home") "Go back home")])
(rum/defc current-page < rum/reactive
{:did-mount (fn [state]
@@ -137,13 +131,13 @@
(let [route-name (get-in route-match [:data :name])]
(when-let [view (:view (:data route-match))]
(ui/catch-error-and-notify
(helpful-default-error-screen)
[:<>
(if (= :draw route-name)
(view route-match)
(container/root-container
route-match
(view route-match)))
(when config/lsp-enabled?
(plugin/hook-daemon-renderers))])))
(helpful-default-error-screen)
[:<>
(if (= :draw route-name)
(view route-match)
(container/root-container
route-match
(view route-match)))
(when config/lsp-enabled?
(plugin/hook-daemon-renderers))])))
(not-found)))

View File

@@ -180,7 +180,6 @@
:dev/show-page-data "(Dev) Show page data"
:dev/show-block-data "(Dev) Show block data"
:dev/show-block-ast "(Dev) Show block AST"
:dev/show-page-ast "(Dev) Show page AST"
:content/copy-export-as "Copy / Export as.."
:content/copy-block-url "Copy block URL"
:content/copy-block-ref "Copy block ref"
@@ -651,7 +650,6 @@
:dev/show-block-data "(Dev) Show block data"
:dev/show-block-ast "(Dev) Show block AST"
:dev/show-page-data "(Dev) Show page data"
:dev/show-page-ast "(Dev) Show page AST"
:dev/replace-graph-with-db-file "(Dev) Replace graph with its db.sqlite file"
:dev/validate-db "(Dev) Validate current graph"
:dev/gc-graph "(Dev) Garbage collect graph (remove unused data in SQLite)"

View File

@@ -1,46 +0,0 @@
(ns frontend.components.block.macros-test
(:require [frontend.components.block.macros :as block-macros]
[frontend.db.utils :as db-utils]
[clojure.test :refer [deftest are testing is]]))
(deftest macro-function
(testing "Default functions as an argument"
(are [user-input result]
(= result
(block-macros/function-macro
(mapv #(hash-map :block/properties %) [{:total 10} {:total 20} {:total 30}])
[user-input]))
"(sum :total)" 60
"(average :total)" 20
"(max :total)" 30
"(min :total)" 10
"(count :total)" 3))
(testing "Custom clojure function as an argument"
(is (= 130
(block-macros/function-macro
(mapv #(hash-map :block/properties %)
[{:total 10 :qty 3} {:total 20 :qty 5}])
["(sum (map (fn [x] (* (:total x) (:qty x))) result))"]))))
(testing "When query results are in page view"
(is (= 60
(block-macros/function-macro
(db-utils/group-by-page
[{:block/properties {:total 10} :block/page 1}
{:block/properties {:total 20} :block/page 2}
{:block/properties {:total 30} :block/page 1}])
["(sum :total)"]))
"Default function works like in query table view"))
(testing "Edge cases"
(is (= 40
(block-macros/function-macro
(mapv #(hash-map :block/properties %) [{:total 10} {} {:total 30}])
["(sum :total)"]))
"Function still works when some results are missing property")
(is (= 0
(block-macros/function-macro
(mapv #(hash-map :block/properties %) [{:total 10} {} {:total 30}])
["(sum :totally)"]))
"Function gives back 0 when given wrong property")))