Merge branch 'master' into enhance/plugin-class-ident

This commit is contained in:
charlie
2025-11-14 10:15:35 +08:00
28 changed files with 387 additions and 456 deletions

View File

@@ -73,8 +73,7 @@ jobs:
run: clojure -A:cljs -P
- name: Fetch yarn deps
# run: yarn install --frozen-lockfile
run: yarn install
run: yarn install --frozen-lockfile
- name: Build test asset
run: clojure -M:test compile test

View File

@@ -47,8 +47,7 @@ jobs:
cli: ${{ env.CLOJURE_VERSION }}
- name: Fetch yarn deps
# run: yarn install --frozen-lockfile
run: yarn install
run: yarn install --frozen-lockfile
- name: Set Build Environment Variables
run: |

View File

@@ -74,6 +74,13 @@
(d/entity db eid)))
(d/entity db eid)))
(defn unsafe->Entity
"Faster version of d/entity without checking e exists.
Only use it in performance-critical areas and where the existence of 'e' is confirmed."
[db e]
{:pre [(pos-int? e)]}
(Entity. db e (volatile! false) (volatile! {})))
(defn db-based-graph?
"Whether the current graph is db-only"
[db]

View File

@@ -278,11 +278,8 @@
(let [block-datoms (d/datoms db :eavt (:e d))
properties-of-property-datoms
(when (= (:v d) class-property-id)
(concat
(when-let [desc (:logseq.property/description (d/entity db (:e d)))]
(d/datoms db :eavt (:db/id desc)))
(when-let [desc (:logseq.property/default-value (d/entity db (:e d)))]
(d/datoms db :eavt (:db/id desc)))))]
(when-let [desc (:logseq.property/default-value (d/entity db (:e d)))]
(d/datoms db :eavt (:db/id desc))))]
(if (seq properties-of-property-datoms)
(concat block-datoms properties-of-property-datoms)
block-datoms)))))))
@@ -302,16 +299,6 @@
(d/datoms db :eavt (:db/id child)))
children)))))
(defn- get-views-data
[db]
(let [page-id (get-first-page-by-name db common-config/views-page-name)
children (when page-id (:block/_parent (d/entity db page-id)))]
(when (seq children)
(into
(mapcat (fn [b] (d/datoms db :eavt (:db/id b)))
children)
(d/datoms db :eavt page-id)))))
(defn get-recent-updated-pages
[db]
(when db
@@ -319,12 +306,16 @@
(d/datoms db :avet :block/updated-at)
rseq
(keep (fn [datom]
(let [e (d/entity db (:e datom))]
(when (and (common-entity-util/page? e)
(not (entity-util/hidden? e))
(not (string/blank? (:block/title e))))
e))))
(take 30))))
(let [page (first (d/datoms db :eavt (:e datom) :block/page))]
(when-not (or page
(let [title (:v (first (d/datoms db :eavt (:e datom) :block/title)))]
(string/blank? title)))
(let [e (d/entity db (:e datom))]
(when (and
(common-entity-util/page? e)
(not (entity-util/hidden? e)))
e))))))
(take 15))))
(defn- get-all-user-datoms
[db]
@@ -353,12 +344,11 @@
:logseq.kv/graph-text-embedding-model-name
:logseq.property/empty-placeholder])
favorites (when db-graph? (get-favorites db))
views (when db-graph? (get-views-data db))
recent-updated-pages (let [pages (get-recent-updated-pages db)]
(mapcat (fn [p] (d/datoms db :eavt (:db/id p))) pages))
all-files (get-all-files db)
structured-datoms (when db-graph?
(get-structured-datoms db))
recent-updated-pages (let [pages (get-recent-updated-pages db)]
(mapcat (fn [p] (d/datoms db :eavt (:db/id p))) pages))
user-datoms (get-all-user-datoms db)
pages-datoms (if db-graph?
(let [contents-id (get-first-page-by-title db "Contents")
@@ -369,14 +359,17 @@
;; load all pages for file graphs
(->> (d/datoms db :avet :block/name)
(mapcat (fn [d] (d/datoms db :eavt (:e d))))))
data (distinct
(concat idents
structured-datoms
user-datoms
favorites
recent-updated-pages
views
all-files
pages-datoms))]
data (->> (concat idents
structured-datoms
user-datoms
favorites
recent-updated-pages
all-files
pages-datoms)
distinct
(remove (fn [d]
(contains? #{:block/created-at :block/updated-at
:block/tx-id :logseq.property/created-by-ref}
(:a d)))))]
{:schema schema
:initial-data data}))

View File

@@ -294,7 +294,7 @@
(let [refs-count? (and (coll? sorting) (some (fn [m] (= (:id m) :block.temp/refs-count)) sorting))
exclude-ids (when db-based? (get-exclude-page-ids db))]
(keep (fn [d]
(let [e (d/entity db (:e d))]
(let [e (entity-plus/unsafe->Entity db (:e d))]
(when-not (if db-based?
(exclude-ids (:db/id e))
(or (ldb/hidden-or-internal-tag? e)

View File

@@ -50,10 +50,10 @@
(defn page?
[entity]
(or (internal-page? entity)
(journal? entity)
(class? entity)
(property? entity)
(whiteboard? entity)
(journal? entity)))
(whiteboard? entity)))
(defn asset?
"Given an entity or map, check if it is an asset block"

View File

@@ -4,6 +4,7 @@
[electron.ipc :as ipc]
[frontend.components.block :as block]
[frontend.components.cmdk.list-item :as list-item]
[frontend.components.icon :as icon-component]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
@@ -62,7 +63,7 @@
(->>
[(when current-page
{:filter {:group :current-page} :text "Search only current page" :info "Add filter to search" :icon-theme :gray :icon "file"})
{:filter {:group :nodes} :text "Search only nodes" :info "Add filter to search" :icon-theme :gray :icon "letter-n"}
{:filter {:group :nodes} :text "Search only nodes" :info "Add filter to search" :icon-theme :gray :icon "point-filled"}
{:filter {:group :commands} :text "Search only commands" :info "Add filter to search" :icon-theme :gray :icon "command"}
{:filter {:group :files} :text "Search only files" :info "Add filter to search" :icon-theme :gray :icon "file"}
{:filter {:group :themes} :text "Search only themes" :info "Add filter to search" :icon-theme :gray :icon "palette"}]
@@ -89,21 +90,24 @@
(not config/publishing?))
(let [class? (string/starts-with? q "#")
class-name (get-class-from-input q)
class (ldb/class? (db/get-case-page class-name))]
class (let [class (db/get-case-page class-name)]
(when (ldb/class? class)
class))]
(->> [{:text (cond
class "Configure tag"
class? "Create tag"
:else "Create page")
:icon "new-page"
:icon (if class "settings" "new-page")
:icon-theme :gray
:info (if class?
(let [class-name (get-class-from-input q)
class (db/get-case-page class-name)]
(if class
(str "Configure #" class-name)
(str "Create tag called '" class-name "'")))
:info (cond
class
(str "Configure #" class-name)
class?
(str "Create tag called '" class-name "'")
:else
(str "Create page called '" q "'"))
:source-create :page}]
:source-create :page
:class class}]
(remove nil?)))))
;; Take the results, decide how many items to show, and order the results appropriately
@@ -203,24 +207,12 @@
;; Each result group has it's own load-results function
(defmulti load-results (fn [group _state] group))
(defn get-page-icon
[entity]
(cond
(ldb/class? entity)
"hash"
(ldb/property? entity)
"letter-p"
(ldb/whiteboard? entity)
"writing"
:else
"file"))
(defmethod load-results :initial [_ state]
(when-let [db (db/get-db)]
(let [!results (::results state)
recent-pages (map (fn [block]
(let [text (block-handler/block-unique-title block)
icon (get-page-icon block)]
icon (icon-component/get-node-icon-cp block {:ignore-current-icon? true})]
{:icon icon
:icon-theme :gray
:text text
@@ -258,7 +250,7 @@
(->> search-results
(map (fn [block]
(let [text (block-handler/block-unique-title block)
icon (get-page-icon block)]
icon (icon-component/get-node-icon-cp block {:ignore-current-icon? true})]
{:icon icon
:icon-theme :gray
:text text
@@ -286,15 +278,16 @@
(let [entity (db/entity [:block/uuid (:block/uuid page)])
source-page (or (model/get-alias-source-page repo (:db/id entity))
(:alias page))
icon (get-page-icon entity)
title (block-handler/block-unique-title (or entity page))
title' (if source-page (str title " -> alias: " (:block/title source-page)) title)]
icon (icon-component/get-node-icon-cp entity {:ignore-current-icon? true})
title (block-handler/block-unique-title (or entity page)
{:alias (:block/title source-page)})]
(hash-map :icon icon
:icon-theme :gray
:text title'
:text title
:header (when (:block/parent entity)
(block/breadcrumb {:disable-preview? true
:search? true} repo (:block/uuid page) {}))
:search? true} repo (:block/uuid page)
{:disabled? true}))
:alias (:alias page)
:source-block (or source-page page))))
@@ -302,12 +295,13 @@
[repo block current-page input]
(let [id (:block/uuid block)
text (block-handler/block-unique-title block)
icon "letter-n"]
icon (icon-component/get-node-icon-cp block {:ignore-current-icon? true})]
{:icon icon
:icon-theme :gray
:text (highlight-content-query text input)
:header (block/breadcrumb {:disable-preview? true
:search? true} repo id {})
:search? true} repo id
{:disabled? true})
:current-page? (when-let [page-id (:block/page block)]
(= page-id (:block/uuid current-page)))
:source-block block}))
@@ -412,7 +406,7 @@
{:icon "node"
:icon-theme :gray
:text (highlight-content-query (:block/title block) @!input)
:header (block/breadcrumb {:search? true} repo id {})
:header (block/breadcrumb {:search? true} repo id {:disabled? true})
:current-page? true
:source-block block})) blocks)]
(swap! !results update :current-page merge {:status :success :items items})))
@@ -564,15 +558,17 @@
create-whiteboard? (= :whiteboard (:source-create item))
create-page? (= :page (:source-create item))
class (when create-class? (get-class-from-input @!input))]
(p/let [result (cond
create-class?
(db-page-handler/<create-class! class
{:redirect? false})
create-whiteboard? (whiteboard-handler/<create-new-whiteboard-and-redirect! @!input)
create-page? (page-handler/<create! @!input {:redirect? true}))]
(shui/dialog-close! :ls-dialog-cmdk)
(when (and create-class? result)
(state/pub-event! [:dialog/show-block result {:tag-dialog? true}])))))
(if (and (= (:text item) "Configure tag") (:class item))
(state/pub-event! [:dialog/show-block (:class item) {:tag-dialog? true}])
(p/let [result (cond
create-class?
(db-page-handler/<create-class! class
{:redirect? false})
create-whiteboard? (whiteboard-handler/<create-new-whiteboard-and-redirect! @!input)
create-page? (page-handler/<create! @!input {:redirect? true}))]
(shui/dialog-close! :ls-dialog-cmdk)
(when (and create-class? result)
(state/pub-event! [:dialog/show-block result {:tag-dialog? true}]))))))
(defn- get-filter-user-input
[input]

View File

@@ -2,6 +2,8 @@
(:require
["remove-accents" :as remove-accents]
[clojure.string :as string]
[frontend.components.icon :as icon-component]
[frontend.handler.block :as block-handler]
[goog.string :as gstring]
[logseq.shui.hooks :as hooks]
[logseq.shui.ui :as shui]
@@ -48,9 +50,9 @@
segs))
[:span normal-text])))))
(rum/defc root [{:keys [group icon icon-theme query text info shortcut value-label value
title highlighted on-highlight on-highlight-dep header on-click hls-page?
hoverable compact rounded on-mouse-enter component-opts source-page] :as _props
(rum/defc root [{:keys [icon icon-theme query text info shortcut value-label value
title highlighted on-highlight on-highlight-dep header on-click
hoverable compact rounded on-mouse-enter component-opts source-block] :as _props
:or {hoverable true rounded true}}
{:keys [app-config]}]
(let [ref (hooks/create-ref)
@@ -92,18 +94,16 @@
(if highlighted "bg-accent-07-alpha" "bg-gray-05")
" dark:text-white")
(= icon-theme :gray) (str " bg-gray-05 dark:text-white"))}
(shui/tabler-icon icon {:size "14" :class ""})]
(if (string? icon)
(shui/tabler-icon icon {:size "14" :class ""})
icon)]
[:div.flex.flex-1.flex-col
(when title
[:div.text-sm.pb-2.font-bold.text-gray-11 (highlight-query title)])
[:div {:class "text-sm font-medium text-gray-12"}
(if (and (= group :pages) (not= text source-page)) ;; alias
[:div.flex.flex-row.items-center.gap-2
(highlight-query text)
(if-not hls-page?
[:<> [:div.opacity-50.font-normal "alias of"] source-page]
[:div.opacity-50.font-normal.text-xs " — Highlights page"])]
(highlight-query text))
(block-handler/block-title-with-icon source-block
(highlight-query text)
icon-component/icon)
(when info
[:span.text-xs.text-gray-11 " — " (highlight-query info)])]]
(when (or value-label value)

View File

@@ -62,7 +62,7 @@
(when-let [el (gdom/getElement "main-content-container")]
(dnd/unsubscribe! el :upload-files))
state)}
[{:keys [route-match margin-less-pages? route-name indexeddb-support? db-restoring? main-content]}]
[{:keys [route-match margin-less-pages? route-name db-restoring? main-content]}]
(let [left-sidebar-open? (state/sub :ui/left-sidebar-open?)
onboarding-and-home? (and (or (nil? (state/get-current-repo)) (config/demo-graph?))
(not config/publishing?)
@@ -89,9 +89,6 @@
(footer/footer)
(cond
(not indexeddb-support?)
nil
db-restoring?
(if config/publishing?
[:div.space-y-2
@@ -423,7 +420,6 @@
margin-less-pages? (or (boolean (#{:graph} route-name))
(db-model/whiteboard-page? (state/get-current-page)))
db-restoring? (state/sub :db/restoring?)
indexeddb-support? (state/sub :indexeddb/support?)
page? (= :page route-name)
home? (= :home route-name)
native-titlebar? (state/sub [:electron/user-cfgs :window/native-titlebar?])
@@ -497,7 +493,6 @@
:logged? logged?
:home? home?
:route-name route-name
:indexeddb-support? indexeddb-support?
:light? light?
:db-restoring? db-restoring?
:main-content main-content'

View File

@@ -3,7 +3,7 @@
[dommy.core :as dom]
[frontend.commands :as commands :refer [*matched-commands]]
[frontend.components.file-based.datetime :as datetime-comp]
[frontend.components.search :as search]
[frontend.components.icon :as icon-component]
[frontend.components.svg :as svg]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
@@ -51,6 +51,45 @@
(contains? #{"TASK STATUS" "TASK DATE" "PRIORITY"} (last item))))) commands)
commands))
(defn node-render
[block q {:keys [db-tag? db-based?]}]
(let [block' (if-let [id (:block/uuid block)]
(if-let [e (db/entity [:block/uuid id])]
(assoc e
:block/title (or (:friendly-title block) (:block/title block) (:block/title e))
:alias (:alias block))
block)
block)]
(when-not (string/blank? (:block/title block'))
[:div.flex.flex-col
(when (and (:block/uuid block') (or (:block/parent block') (not (:page? block))))
(when-let [breadcrumb (state/get-component :block/breadcrumb)]
[:div.text-xs.opacity-70.mb-1 {:style {:margin-left 3}}
(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?))
[:div.flex.items-center.h-5.mr-1.opacity-50
(cond
(:nlp-date? block')
(ui/icon "calendar" {:size 14})
(or (string/starts-with? (str (:block/title block')) (t :new-tag))
(string/starts-with? (str (:block/title block')) (t :new-page)))
(ui/icon "plus" {:size 14})
:else
(icon-component/get-node-icon-cp block' {:ignore-current-icon? true}))])
(let [title (let [alias (get-in block' [:alias :block/title])]
(block-handler/block-unique-title block' {:alias alias}))]
(if (or (string/starts-with? title (t :new-tag))
(string/starts-with? title (t :new-page)))
title
(block-handler/block-title-with-icon block'
(search-handler/highlight-exact-query title q)
icon-component/icon)))]])))
(rum/defcs commands < rum/reactive
(rum/local [] ::matched-commands)
[s id format]
@@ -202,56 +241,8 @@
:on-enter (fn []
(page-handler/page-not-exists-handler input id q current-pos))
:item-render (fn [block _chosen?]
(let [block' (if-let [id (:block/uuid block)]
(if-let [e (db/entity [:block/uuid id])]
(assoc e
:block/title (or (:friendly-title block) (:block/title e) (:block/title block))
:alias (:alias block))
block)
block)]
[:div.flex.flex-col
(when (and (:block/uuid block') (or (:block/parent block') (not (:page? block))))
(when-let [breadcrumb (state/get-component :block/breadcrumb)]
[:div.text-xs.opacity-70.mb-1 {:style {:margin-left 3}}
(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?))
[:div.flex.items-center.h-5.mr-1.opacity-50
(cond
(:nlp-date? block')
(ui/icon "calendar" {:size 14})
(ldb/class? block')
(ui/icon "hash" {:size 14})
(ldb/property? block')
(ui/icon "letter-p" {:size 14})
(db-model/whiteboard-page? block')
(ui/icon "writing" {:size 14})
(or (ldb/page? block') (:page? block))
(ui/icon "file" {:size 14})
(or (string/starts-with? (str (:block/title block')) (t :new-tag))
(string/starts-with? (str (:block/title block')) (t :new-page)))
(ui/icon "plus" {:size 14})
:else
(ui/icon "letter-n" {:size 14}))])
(let [title (let [alias (get-in block' [:alias :block/title])
title (if (and db-based? (not (ldb/built-in? block')))
(block-handler/block-unique-title block')
(:block/title block'))]
(if alias
(str title " -> alias: " alias)
title))]
(if (or (string/starts-with? title (t :new-tag))
(string/starts-with? title (t :new-page)))
title
(search-handler/highlight-exact-query title q)))]]))
(node-render block q {:db-tag? db-tag?
:db-based? db-based?}))
:empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 (if db-tag?
"Search for a tag"
"Search for a node")]
@@ -339,12 +330,9 @@
{:on-chosen chosen-handler
: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/keys [page uuid title]}]
(let [page-entity (db/entity [:block/uuid page])
repo (state/sub :git/current-repo)
format (get page-entity :block/format :markdown)]
(when-not (string/blank? title)
[:.py-2 (search/block-search-result-item repo uuid format title q :block)])))
:item-render (fn [block]
(node-render block q {:db-tag? false
:db-based? db?}))
:class "ac-block-search"})))
(rum/defcs block-search < rum/reactive

View File

@@ -45,13 +45,13 @@
item)))
(defn get-node-icon
[node-entity]
(or (get node-entity (pu/get-pid :logseq.property/icon))
[node-entity {:keys [ignore-current-icon?]
:or {ignore-current-icon? false}}]
(or (when-not ignore-current-icon?
(get node-entity (pu/get-pid :logseq.property/icon)))
(let [asset-type (:logseq.property.asset/type node-entity)
first-tag-icon (some :logseq.property/icon (sort-by :db/id (:block/tags node-entity)))]
(cond
(some? first-tag-icon)
first-tag-icon
(ldb/class? node-entity)
"hash"
(ldb/property? node-entity)
@@ -62,21 +62,23 @@
"file"
(= asset-type "pdf")
"book"
(some? first-tag-icon)
first-tag-icon
:else
"letter-n"))))
"point-filled"))))
(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))
(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*))]
(when-not (or (string/blank? node-icon) (and (contains? #{"letter-n" "letter-p" "hash" "file"} node-icon) (:not-text-or-page? 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")}}
(select-keys opts [:class]))

View File

@@ -615,21 +615,15 @@
(rum/local false ::all-collapsed?)
(rum/local false ::control-show?)
(rum/local nil ::current-page)
(rum/local false ::objects-ready?)
[state {:keys [repo page preview? sidebar? tag-dialog? linked-refs? unlinked-refs? config] :as option}]
[state {:keys [repo page preview? sidebar? tag-dialog? linked-refs? unlinked-refs? config journals?] :as option}]
(let [current-repo (state/sub :git/current-repo)
*objects-ready? (::objects-ready? state)
page (or page (some-> (:db/id option) db/entity))
config (assoc config
:*objects-ready? *objects-ready?
:id (str (:block/uuid page)))
repo (or repo current-repo)
block? (some? (:block/page page))
class-page? (ldb/class? page)
property-page? (ldb/property? page)
objects-ready? (if (or class-page? property-page?)
(rum/react *objects-ready?)
true)
title (:block/title page)
journal? (db/journal-page? title)
db-based? (config/db-based-graph? repo)
@@ -693,7 +687,7 @@
(sidebar-page-properties config page)])
(when show-tabs?
(tabs page {:current-page? option :sidebar? sidebar? :*objects-ready? *objects-ready?}))
(tabs page {:current-page? option :sidebar? sidebar?}))
(when (not tag-dialog?)
[:div.ls-page-blocks
@@ -704,7 +698,7 @@
:container-id (:container-id state)
:whiteboard? whiteboard?}))])])
(when (and (not preview?) (or (not show-tabs?) objects-ready?))
(when (and (not preview?) (not show-tabs?))
[:div.ml-1.flex.flex-col.gap-8
(when today?
(today-queries repo today? sidebar?))
@@ -722,7 +716,9 @@
(when-not (or whiteboard? tag-dialog? linked-refs? (and block? (not db-based?)))
[:div.fade-in.delay {:key "page-references"}
(rum/with-key
(reference/references page {:sidebar? sidebar?})
(reference/references page {:sidebar? sidebar?
:journals? journals?
:refs-count (:refs-count option)})
(str title "-refs"))])
(when-not block-or-whiteboard?
@@ -750,11 +746,17 @@
page-uuid? (when page-name (util/uuid-string? page-name))
*loading? (atom true)
page (db/get-page page-id-uuid-or-name)
*page (atom page)]
*page (atom page)
*refs-count (atom nil)
repo (state/get-current-repo)]
(when (:block.temp/load-status page) (reset! *loading? false))
(p/let [page-block (db-async/<get-block (state/get-current-repo) page-id-uuid-or-name)]
(p/let [page-block (db-async/<get-block repo page-id-uuid-or-name)
page-id (:db/id page-block)
refs-count (when-not (or (ldb/class? page-block) (ldb/property? page-block))
(db-async/<get-block-refs-count repo page-id))]
(reset! *loading? false)
(reset! *page (db/entity (:db/id page-block)))
(reset! *refs-count refs-count)
(when page-block
(when-not (or preview-or-sidebar? (:tag-dialog? option))
(if-let [page-uuid (and (not (:db/id page*))
@@ -764,15 +766,19 @@
(route-handler/update-page-title-and-label! (state/get-route-match))))))
(assoc state
::loading? *loading?
::*page *page)))
::*page *page
::*refs-count *refs-count)))
:will-unmount (fn [state]
(state/set-state! :editor/virtualized-scroll-fn nil)
state)}
[state option]
(let [loading? (rum/react (::loading? state))
page (rum/react (::*page state))]
page (rum/react (::*page state))
refs-count (rum/react (::*refs-count state))]
(when (and page (not loading?))
(page-inner (assoc option :page page)))))
(page-inner (assoc option
:page page
:refs-count refs-count)))))
(rum/defcs page-cp
[state option]

View File

@@ -210,7 +210,7 @@
:url "link"
:property "letter-p"
:page "page"
:node "letter-n"
:node "point-filled"
"letter-t"))]
(ui/icon icon {:class "opacity-50"
:size 15})))

View File

@@ -653,18 +653,6 @@
:close-modal? false
k f'))))
(defn- get-node-icon
[node]
(cond
(ldb/class? node)
"hash"
(ldb/property? node)
"letter-p"
(entity-util/page? node)
"page"
:else
"letter-n"))
(rum/defc ^:large-vars/cleanup-todo select-node < rum/static
[property
{:keys [block multiple-choices? dropdown? input-opts on-input add-new-choice! target] :as opts}
@@ -755,12 +743,11 @@
node)
id (:db/id node)
[header label] (if (integer? id)
(when-let [node-title (if (seq (:logseq.property/classes property))
(db-content/recur-replace-uuid-in-block-title node)
(block-handler/block-unique-title node))]
(let [title (subs node-title 0 256)
node (or (db/entity id) node)
icon (get-node-icon node)
(when-let [title (if (seq (:logseq.property/classes property))
(some-> (db-content/recur-replace-uuid-in-block-title node)
(subs 0 256))
(block-handler/block-unique-title node))]
(let [node (or (db/entity id) node)
header (when-not (db/page? node)
(when-let [breadcrumb (state/get-component :block/breadcrumb)]
[:div.text-xs.opacity-70
@@ -768,9 +755,11 @@
{:disabled? true})]))
label [:div.flex.flex-row.items-center.gap-1
(when-not (or (:logseq.property/classes property)
(contains? #{:class :property} (:logseq.property/type property)))
(ui/icon icon {:size 14}))
[:div title]]]
(contains? #{:class :property} property-type))
(icon-component/get-node-icon-cp node {:ignore-current-icon? true}))
[:div (if (contains? #{:class :property :page} property-type)
title
(block-handler/block-title-with-icon node title icon-component/icon))]]]
[header label]))
[nil (:block/title node)])]
(assoc node

View File

@@ -57,12 +57,13 @@
(rum/defc references
[entity config]
(when-let [id (:db/id entity)]
(let [[refs-total-count set-refs-total-count!] (hooks/use-state nil)]
(let [[refs-total-count set-refs-total-count!] (hooks/use-state (:refs-count config))]
(hooks/use-effect!
#(c.m/run-task*
(m/sp
(let [result (c.m/<? (db-async/<get-block-refs-count (state/get-current-repo) id))]
(set-refs-total-count! result))))
(when-not (:refs-count config)
(let [result (c.m/<? (db-async/<get-block-refs-count (state/get-current-repo) id))]
(set-refs-total-count! result)))))
[])
(when (> refs-total-count 0)
(ui/catch-error

View File

@@ -1,19 +0,0 @@
(ns frontend.components.search
(:require [rum.core :as rum]
[frontend.handler.search :as search-handler]
[frontend.components.block :as block]))
(rum/defc block-search-result-item
[repo uuid format content q search-mode]
(let [content (search-handler/sanity-search-content format content)]
[:div
(when (not= search-mode :page)
[:div {:class "mb-1" :key "parents"}
(block/breadcrumb {:id "block-search-block-parent"
:block? true
:search? true}
repo
uuid
{:indent? false})])
[:div {:class "font-medium" :key "content"}
(search-handler/highlight-exact-query content q)]]))

View File

@@ -49,6 +49,16 @@
(def ^:private yyyy-MM-dd-formatter (tf/formatter "yyyy-MM-dd"))
(defn- virtualized-list
[{:keys [total-count item-content compute-item-key] :as option}
disable-virtualized?]
(if disable-virtualized?
[:div.content
(for [i (range 0 total-count)]
(rum/with-key (item-content i)
(compute-item-key i)))]
(ui/virtualized-list option)))
(defn- get-scroll-parent
[config]
(if (:sidebar? config)
@@ -1573,7 +1583,11 @@
db-id (cond (map? item) (:db/id item)
(number? item) item
:else nil)
[item set-item!] (hooks/use-state nil)
entity (when db-id
(let [e (db/entity db-id)]
(when (= :full (:block.temp/load-status e))
e)))
[item set-item!] (hooks/use-state entity)
opts (if list-view?
{:skip-refresh? true
:children? false}
@@ -1594,15 +1608,9 @@
(rum/defc table-body < rum/static
[table option rows *scroller-ref set-items-rendered!]
(let [[scrolling? set-scrolling!] (hooks/use-state false)
[ready? set-ready!] (hooks/use-state false)]
(hooks/use-effect!
(fn [] (util/schedule #(set-ready! true)))
[])
(when (and ready? (seq rows))
(ui/virtualized-list
(let [[scrolling? set-scrolling!] (hooks/use-state false)]
(when (seq rows)
(virtualized-list
{:ref #(reset! *scroller-ref %)
:increase-viewport-by {:top 300 :bottom 300}
:custom-scroll-parent (get-scroll-parent
@@ -1617,14 +1625,15 @@
:is-scrolling set-scrolling!
:item-content (fn [idx _user ^js context]
(let [option (assoc option
:scrolling? (.-scrolling context)
:scrolling? (when context (.-scrolling context))
:table-view? true)]
(lazy-item (:data table) idx option
(fn [row]
(table-row table row {} option)))))
:items-rendered (fn [props]
(when (seq props)
(set-items-rendered! true)))}))))
(set-items-rendered! true)))}
(:disable-virtualized? option)))))
(rum/defc table-view < rum/static
[table option row-selection *scroller-ref]
@@ -1642,9 +1651,8 @@
(shui/table-footer (add-new-row (:view-entity option) table)))]]))))
(rum/defc list-view < rum/static
[{:keys [config ref-matched-children-ids view-feature-type] :as option} view-entity {:keys [rows]} *scroller-ref]
(let [references-view? (contains? #{:linked-references :unlinked-references} view-feature-type)
lazy-item-render (fn [rows idx]
[{:keys [config ref-matched-children-ids disable-virtualized?] :as option} view-entity {:keys [rows]} *scroller-ref]
(let [lazy-item-render (fn [rows idx]
(lazy-item rows idx (assoc option :list-view? true)
(fn [block]
(let [config' (cond->
@@ -1656,21 +1664,18 @@
(block-container config' block)))))
list-cp (fn [rows]
(when (seq rows)
(if references-view?
[:div.content
(for [[idx _row] (medley/indexed rows)]
(lazy-item-render rows idx))]
(ui/virtualized-list
{:ref #(reset! *scroller-ref %)
:class "content"
:custom-scroll-parent (get-scroll-parent config)
:increase-viewport-by {:top 64 :bottom 64}
:compute-item-key (fn [idx]
(let [block-id (util/nth-safe rows idx)]
(str "list-row-" block-id)))
:total-count (count rows)
:skipAnimationFrameInResizeObserver true
:item-content (fn [idx] (lazy-item-render rows idx))}))))
(virtualized-list
{:ref #(reset! *scroller-ref %)
:class "content"
:custom-scroll-parent (get-scroll-parent config)
:increase-viewport-by {:top 64 :bottom 64}
:compute-item-key (fn [idx]
(let [block-id (util/nth-safe rows idx)]
(str "list-row-" block-id)))
:total-count (count rows)
:skipAnimationFrameInResizeObserver true
:item-content (fn [idx] (lazy-item-render rows idx))}
disable-virtualized?)))
breadcrumb (state/get-component :block/breadcrumb)
all-numbers? (every? number? rows)]
(if all-numbers?
@@ -1996,9 +2001,10 @@
(when (and db-based? add-new-object!) (new-record-button table view-entity))]]))
(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] :as option*}
[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)
option (assoc option* :properties
(-> (remove #{:id :select} (map :id columns))
(conj :block/uuid :block/name)
@@ -2068,6 +2074,7 @@
*view-ref (rum/use-ref nil)
gallery? (= display-type :logseq.property.view/type.gallery)
list-view? (= display-type :logseq.property.view/type.list)
disable-virtualized? journals?
[ready? set-ready?] (hooks/use-state false)]
(run-effects! option table-map *scroller-ref gallery? set-ready?)
@@ -2087,7 +2094,7 @@
(if (and group-by-property-ident (not (number? (first (:rows table)))))
(when (and ready? (seq (:rows table)))
[:div.flex.flex-col.border-t.pt-2.gap-2
(ui/virtualized-list
(virtualized-list
{:class (when list-view? "group-list-view")
:custom-scroll-parent (util/app-scroll-container-node (rum/deref *view-ref))
:increase-viewport-by {:top 300 :bottom 300}
@@ -2096,48 +2103,57 @@
:skipAnimationFrameInResizeObserver true
:total-count (count (:rows table))
:item-content (fn [idx]
(let [[value group] (nth (:rows table) idx)]
(let [add-new-object! (when (fn? add-new-object!)
(fn [_]
(add-new-object! view-entity table
{:properties {(:db/ident group-by-property) (or (and (map? value) (:db/id value)) value)}})))
table' (shui/table-option (-> table-map
(assoc-in [:data-fns :add-new-object!] add-new-object!)
(assoc :data group ; data for this group
)))
readable-property-value #(cond (and (map? %) (or (:block/title %) (:logseq.property/value %)))
(db-property/property-value-content %)
(= (:db/ident %) :logseq.property/empty-placeholder)
"Empty"
:else
(str %))
group-by-page? (or (= :block/page group-by-property-ident)
(and (not db-based?) (contains? #{:linked-references :unlinked-references} display-type)))]
(rum/with-key
(ui/foldable
[:div
{:class (when-not list-view? "my-2")}
(cond
group-by-page?
(if value
(let [c (state/get-component :block/page-cp)]
(c {:disable-preview? true} value))
[:div.text-muted-foreground.text-sm
"Pages"])
(let [[value group] (nth (:rows table) idx)
add-new-object! (when (fn? add-new-object!)
(fn [_]
(add-new-object! view-entity table
{:properties {(:db/ident group-by-property) (or (and (map? value) (:db/id value)) value)}})))
table' (shui/table-option (-> table-map
(assoc-in [:data-fns :add-new-object!] add-new-object!)
(assoc :data group ; data for this group
)))
readable-property-value #(cond (and (map? %) (or (:block/title %) (:logseq.property/value %)))
(db-property/property-value-content %)
(= (:db/ident %) :logseq.property/empty-placeholder)
"Empty"
:else
(str %))
group-by-page? (or (= :block/page group-by-property-ident)
(and (not db-based?) (contains? #{:linked-references :unlinked-references} display-type)))]
(rum/with-key
(ui/foldable
[:div
{:class (when-not list-view? "my-2")}
(cond
group-by-page?
(if value
(let [c (state/get-component :block/page-cp)]
(c {:disable-preview? true} value))
[:div.text-muted-foreground.text-sm
"Pages"])
(some? value)
(let [icon (pu/get-block-property-value value :logseq.property/icon)]
[:div.flex.flex-row.gap-1.items-center
(when icon (icon-component/icon icon {:color? true}))
(readable-property-value value)])
:else
(str "No " (:block/title group-by-property)))]
(let [render (view-cp view-entity (assoc table' :rows group) option view-opts)]
(if list-view? [:div.-ml-2 render] render))
{:title-trigger? false})
(str (:db/id view-entity) "-group-idx-" idx)))))})])
(some? value)
(let [icon (pu/get-block-property-value value :logseq.property/icon)]
[:div.flex.flex-row.gap-1.items-center
(when icon (icon-component/icon icon {:color? true}))
(readable-property-value value)])
:else
(str "No " (:block/title group-by-property)))]
(fn []
(let [render (view-cp view-entity
(assoc table' :rows group)
(assoc option
;; disabled virtualization for nested view
:disable-virtualized? true)
view-opts)]
(if list-view? [:div.-ml-2 render] render)))
{:title-trigger? false})
(str (:db/id view-entity) "-group-idx-" idx))))}
disable-virtualized?)])
(view-cp view-entity table
(assoc option :group-by-property-ident group-by-property-ident)
(assoc option
:group-by-property-ident group-by-property-ident
:disable-virtualized? disable-virtualized?)
view-opts)))])
(merge {:title-trigger? false} foldable-options))]))
@@ -2179,9 +2195,9 @@
:advanced-query? advanced-query?}))))))
(defn- load-view-data-aux
[config view-entity view-parent {:keys [query? query query-entity-ids sorting filters input
view-feature-type group-by-property-ident
set-data! set-ref-pages-count! set-ref-matched-children-ids! set-properties! set-loading!]}]
[view-entity view-parent {:keys [query? query query-entity-ids sorting filters input
view-feature-type group-by-property-ident
set-data! set-ref-pages-count! set-ref-matched-children-ids! set-properties! set-loading!]}]
(c.m/run-task*
(m/sp
(let [need-query? (and query? (seq query-entity-ids) (or sorting filters (not (string/blank? input))))]
@@ -2212,10 +2228,7 @@
(set-ref-matched-children-ids! ref-matched-children-ids))
(set-properties! properties))
(finally
(set-loading! false)
(when (contains? #{:class-objects :property-objects} view-feature-type)
(when-let [*objects-ready? (:*objects-ready? config)]
(reset! *objects-ready? true)))))))))))
(set-loading! false)))))))))
(rum/defc view-aux
[view-entity {:keys [config view-parent view-feature-type data query-entity-ids query set-view-entity!] :as option}]
@@ -2251,7 +2264,7 @@
[ref-pages-count set-ref-pages-count!] (hooks/use-state nil)
[ref-matched-children-ids set-ref-matched-children-ids!] (hooks/use-state nil)
load-view-data (fn load-view-data []
(load-view-data-aux config view-entity view-parent
(load-view-data-aux view-entity view-parent
{:query? query?
:query query
:query-entity-ids query-entity-ids
@@ -2298,8 +2311,8 @@
(+ total 1)
(let [[_k col] item]
(if (and (vector? (first col))
(and (not (map? col))
(uuid? (ffirst col))))
(not (map? col))
(uuid? (ffirst col)))
(+ total (count-col col))
(+ total (count col)))))) 0 data))]
(f data)))

View File

@@ -16,6 +16,7 @@
[frontend.page :as page]
[frontend.routes :as routes]
[frontend.spec]
[lambdaisland.glogi :as log]
[logseq.api]
[logseq.db.frontend.kv-entity]
[malli.dev.cljs :as md]
@@ -86,8 +87,8 @@
;; so it is available even in :advanced release builds
;; (setup-entity-profile!)
(plugin-handler/setup!
#(handler/start! start)))
(log/info ::init "App started")
(handler/start! start))
(defn ^:export stop []
;; stop is called before any code is reloaded

View File

@@ -6,6 +6,7 @@
[frontend.persist-db :as persist-db]
[frontend.state :as state]
[frontend.undo-redo :as undo-redo]
[lambdaisland.glogi :as log]
[logseq.db :as ldb]
[promesa.core :as p]))
@@ -32,7 +33,7 @@
_ (swap! db-conn/conns assoc db-name conn)
end-time (t/now)]
(println ::restore-graph! "loads" (count initial-data) "datoms in" (t/in-millis (t/interval start-time end-time)) "ms")
(log/info ::restore-graph! (str "loads " (count initial-data) " datoms in " (t/in-millis (t/interval start-time end-time)) " ms"))
(state/pub-event! [:graph/restored repo])
(state/set-state! :graph/loading? false)

View File

@@ -8,8 +8,8 @@
[frontend.components.content :as cp-content]
[frontend.components.editor :as editor]
[frontend.components.page :as page]
[frontend.components.user.login :as user.login]
[frontend.components.reference :as reference]
[frontend.components.user.login :as user.login]
[frontend.components.whiteboard :as whiteboard]
[frontend.config :as config]
[frontend.context.i18n :as i18n]
@@ -23,8 +23,8 @@
[frontend.handler.file-based.events]
[frontend.handler.file-based.file :as file-handler]
[frontend.handler.global-config :as global-config-handler]
[frontend.handler.notification :as notification]
[frontend.handler.page :as page-handler]
[frontend.handler.plugin :as plugin-handler]
[frontend.handler.plugin-config :as plugin-config-handler]
[frontend.handler.repo :as repo-handler]
[frontend.handler.repo-config :as repo-config-handler]
@@ -137,64 +137,67 @@
(defn start!
[render]
(let [t1 (util/time-ms)]
(p/do!
(idb/start)
(plugin-handler/setup!)
(render))
(idb/start)
(get-system-info)
(set-global-error-notification!)
(get-system-info)
(set-global-error-notification!)
(register-components-fns!)
(user-handler/restore-tokens-from-localstorage)
(user.login/setup-configure!)
(state/set-db-restoring! true)
(when (util/electron?)
(el/listen!))
(render)
(i18n/start)
(instrument/init)
(register-components-fns!)
(user-handler/restore-tokens-from-localstorage)
(user.login/setup-configure!)
(state/set-db-restoring! true)
(when (util/electron?)
(el/listen!))
(-> (util/indexeddb-check?)
(p/catch (fn [_e]
(notification/show! "Sorry, it seems that your browser doesn't support IndexedDB, we recommend to use latest Chrome(Chromium) or Firefox(Non-private mode)." :error false)
(state/set-indexedb-support! false))))
(i18n/start)
(instrument/init)
(react/run-custom-queries-when-idle!)
(react/run-custom-queries-when-idle!)
(events/run!)
(events/run!)
(log/info ::start-web-worker {})
(log/info ::start-web-worker {})
(p/do!
(-> (p/let [_ (db-browser/start-db-worker!)
repos (repo-handler/get-repos)
_ (state/set-repos! repos)
_ (mobile-util/hide-splash) ;; hide splash as early as ui is stable
repo (or (state/get-current-repo) (:url (first repos)))
_ (if (empty? repos)
(repo-handler/new-db! config/demo-repo)
(restore-and-setup! repo))]
(set-network-watcher!)
(p/do!
(-> (p/let [t2 (util/time-ms)
_ (db-browser/start-db-worker!)
_ (log/info ::db-worker-spent-time (- (util/time-ms) t2))
repos (repo-handler/get-repos)
_ (state/set-repos! repos)
_ (mobile-util/hide-splash) ;; hide splash as early as ui is stable
repo (or (state/get-current-repo) (:url (first repos)))
_ (if (empty? repos)
(repo-handler/new-db! config/demo-repo)
(restore-and-setup! repo))]
(set-network-watcher!)
(when (util/electron?)
(persist-db/run-export-periodically!))
(when (mobile-util/native-platform?)
(state/restore-mobile-theme!)))
(p/catch (fn [e]
(js/console.error "Error while restoring repos: " e)))
(p/finally (fn []
(state/set-db-restoring! false)
(p/resolve! state/app-ready-promise true)
(when-not (util/mobile?)
(p/let [webgpu-available? (db-browser/<check-webgpu-available?)]
(log/info :webgpu-available? webgpu-available?)
(when webgpu-available?
(p/do! (db-browser/start-inference-worker!)
(db-browser/<connect-db-worker-and-infer-worker!)
(reset! vector-search-flows/*infer-worker-ready true))))))))
(when (util/electron?)
(persist-db/run-export-periodically!))
(when (mobile-util/native-platform?)
(state/restore-mobile-theme!)))
(p/catch (fn [e]
(js/console.error "Error while restoring repos: " e)))
(p/finally (fn []
(state/set-db-restoring! false)
(p/resolve! state/app-ready-promise true)
(log/info ::app-init-spent-time (- (util/time-ms) t1))
(when-not (util/mobile?)
(p/let [webgpu-available? (db-browser/<check-webgpu-available?)]
(log/info :webgpu-available? webgpu-available?)
(when webgpu-available?
(p/do! (db-browser/start-inference-worker!)
(db-browser/<connect-db-worker-and-infer-worker!)
(reset! vector-search-flows/*infer-worker-ready true))))
nil))))
(util/<app-wake-up-from-sleep-loop (atom false))
(util/<app-wake-up-from-sleep-loop (atom false))
(when-not (util/mobile?)
(persist-var/load-vars))))
(when-not (util/mobile?)
(persist-var/load-vars)))))
(defn stop! []
(prn "stop!"))

View File

@@ -134,34 +134,49 @@
(defn block-unique-title
"Multiple pages/objects may have the same `:block/title`.
Notice: this doesn't prevent for pages/objects that have the same tag or created by different clients."
[block & {:keys [with-tags?]
[block & {:keys [with-tags? alias]
:or {with-tags? true}}]
(let [block-e (cond
(de/entity? block)
block
(uuid? (:block/uuid block))
(db/entity [:block/uuid (:block/uuid block)])
:else
block)
tags (remove (fn [t]
(or (some-> (:block/raw-title block-e) (ldb/inline-tag? t))
(ldb/private-tags (:db/ident t))))
(map (fn [tag] (if (number? tag) (db/entity tag) tag)) (:block/tags block)))]
(cond
(ldb/class? block)
(ldb/get-class-title-with-extends block)
(if (ldb/built-in? block)
(:block/title block)
(let [block-e (cond
(de/entity? block)
block
(uuid? (:block/uuid block))
(db/entity [:block/uuid (:block/uuid block)])
:else
block)
tags (remove (fn [t]
(or (some-> (:block/raw-title block-e) (ldb/inline-tag? t))
(ldb/private-tags (:db/ident t))))
(map (fn [tag] (if (number? tag) (db/entity tag) tag)) (:block/tags block)))
title (cond
(ldb/class? block)
(ldb/get-class-title-with-extends block)
(and with-tags? (seq tags))
(str (:block/title block)
" "
(string/join
", "
(keep (fn [tag]
(when-let [title (:block/title tag)]
(str "#" title)))
tags)))
:else
(:block/title block))))
(and with-tags? (seq tags))
(str (:block/title block)
" "
(string/join
", "
(keep (fn [tag]
(when-let [title (:block/title tag)]
(str "#" title)))
tags)))
:else
(:block/title block))]
(when title
(str (subs title 0 256)
(when alias
(str " -> alias: " alias)))))))
(defn block-title-with-icon
"Used for select item"
[block title icon-cp]
(if-let [icon (:logseq.property/icon block)]
[:div.flex.flex-row.items-center.gap-1
(icon-cp icon {:size 14})
title]
(or title (:block/title block))))
(defn edit-block!
[block pos & {:keys [_container-id custom-content tail-len save-code-editor?]

View File

@@ -829,7 +829,7 @@
(str text)]]])))
(defn ^:large-vars/cleanup-todo init-plugins!
[callback]
[]
(let [el (js/document.createElement "div")]
(.appendChild js/document.body el)
@@ -951,7 +951,7 @@
(state/set-state! :plugin/indicator-text true)
;; wait for the plugin register async messages
(js/setTimeout
(fn [] (callback)
(fn []
(some-> (seq plugins-async)
(p/delay 16)
(p/then #(.register js/LSPluginCore (bean/->js plugins-async) true))))
@@ -963,13 +963,10 @@
(defn setup!
"setup plugin core handler"
[callback]
(if (not config/lsp-enabled?)
(callback)
(do
(idb/start)
(setup-global-apis-for-web!)
(init-plugins! callback))))
[]
(when (and config/lsp-enabled? (not (util/mobile?)))
(setup-global-apis-for-web!)
(init-plugins!)))
(comment
{:pending (count (:plugin/updates-pending @state/state))

View File

@@ -13,15 +13,9 @@
[frontend.storage :as storage]
[frontend.util :as util]
[logseq.db :as ldb]
[logseq.graph-parser.text :as text]
[missionary.core :as m]
[promesa.core :as p]))
(defn sanity-search-content
"Convert a block to the display contents for searching"
[format content]
(text/remove-level-spaces content format (config/get-block-pattern format)))
(defn search
"The aggretation of search results"
([q]
@@ -147,7 +141,7 @@
(not (util/safe-re-find #" " q)))
(let [i (string/index-of lc-content lc-q)
[before after] [(subs content 0 i) (subs content (+ i (count q)))]]
[:div
[:span
(when-not (string/blank? before)
[:span before])
[:mark.p-0.rounded-none (subs content i (+ i (count q)))]
@@ -171,7 +165,7 @@
content
result)))
(conj result [:span content])))]
[:p {:class "m-0"} elements]))))))
[:span {:class "m-0"} elements]))))))
(defn get-recents
[]

View File

@@ -142,7 +142,7 @@
(reset! state/*db-worker wrapped-worker)
(-> (p/let [_ (state/<invoke-db-worker :thread-api/init config/RTC-WS-URL)
_ (sync-app-state!)
_ (log/debug "init worker spent" (str (- (util/time-ms) t1) "ms"))
_ (log/info "init worker spent" (str (- (util/time-ms) t1) "ms"))
_ (sync-ui-state!)
_ (ask-persist-permission!)
_ (state/pub-event! [:graph/sync-context])]

View File

@@ -85,7 +85,6 @@
;; TODO: how to detect the network reliably?
;; NOTE: prefer to use flows/network-online-event-flow
:network/online? true
:indexeddb/support? true
:me nil
:git/current-repo current-graph
:draw? false
@@ -1541,10 +1540,6 @@ Similar to re-frame subscriptions"
[value]
(set-state! :db/restoring? value))
(defn set-indexedb-support!
[value]
(set-state! :indexeddb/support? value))
(defn modal-opened?
[]
(shui-dialog/has-modal?))

View File

@@ -949,24 +949,6 @@
(boolean (and (safe-re-find #"Chrome" user-agent)
(safe-re-find #"Google Inc" vendor))))))
#?(:cljs
(defn indexeddb-check?
"Check if indexedDB support is available, reject if not"
[]
(let [db-name "logseq-indexeddb-check"]
(if js/window.indexedDB
(js/Promise. (fn [resolve reject]
(let [req (js/window.indexedDB.open db-name)]
(set! (.-onerror req) reject)
(set! (.-onsuccess req)
(fn [_event]
(.close (.-result req))
(let [req (js/window.indexedDB.deleteDatabase db-name)]
(set! (.-onerror req) reject)
(set! (.-onsuccess req) (fn [_event]
(resolve true)))))))))
(p/rejected "no indexeddb defined")))))
(defonce mac? #?(:cljs goog.userAgent/MAC
:clj nil))

View File

@@ -423,9 +423,7 @@ DROP TRIGGER IF EXISTS blocks_au;
(ldb/class? block))))
{:db/id (:db/id block)
:block/uuid (:block/uuid block)
:block/title (if (ldb/page? block)
(ldb/get-title-with-parents block)
(or snippet title))
:block/title (or snippet title)
:block.temp/original-title (:block/title block)
:block/page (or
(:block/uuid (:block/page block))
@@ -435,6 +433,7 @@ DROP TRIGGER IF EXISTS blocks_au;
nil)))
:block/parent (:db/id (:block/parent block))
:block/tags (seq (map :db/id (:block/tags block)))
:logseq.property/icon (:logseq.property/icon block)
:page? (ldb/page? block)
:alias (some-> (first (:block/_alias block))
(select-keys [:block/uuid :block/title]))})))))))]

View File

@@ -9546,9 +9546,9 @@ statuses@~1.5.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
"stay-liquid@https://github.com/logseq/stay-liquid":
"stay-liquid@https://github.com/logseq/stay-liquid.git#b2fde7447e2fff96f16b7715c6857d91c992359d":
version "0.1.0"
resolved "https://github.com/logseq/stay-liquid#b2fde7447e2fff96f16b7715c6857d91c992359d"
resolved "https://github.com/logseq/stay-liquid.git#b2fde7447e2fff96f16b7715c6857d91c992359d"
dependencies:
"@capacitor/core" "^7.4.4"
@@ -9613,7 +9613,7 @@ streamx@^2.15.0, streamx@^2.21.0:
optionalDependencies:
bare-events "^2.2.0"
"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -9631,15 +9631,6 @@ string-width@^1.0.1, string-width@^1.0.2:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
string-width@^2.0.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
@@ -9713,7 +9704,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -9734,13 +9725,6 @@ strip-ansi@^4.0.0:
dependencies:
ansi-regex "^3.0.0"
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -10978,7 +10962,7 @@ wordwrap@^1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -11004,15 +10988,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"