Merge branch 'feat/db' into feat/capacitor-new

This commit is contained in:
charlie
2025-05-20 19:53:42 +08:00
15 changed files with 117 additions and 59 deletions

View File

@@ -439,11 +439,10 @@
(println "draw file created, " path))
text)) "Draw a graph with Excalidraw"])
(when (util/electron?)
["Upload an asset"
[[:editor/click-hidden-file-input :id]]
"Upload file types like image, pdf, docx, etc.)"
:icon/upload])
["Upload an asset"
[[:editor/click-hidden-file-input :id]]
"Upload file types like image, pdf, docx, etc.)"
:icon/upload]
["Template" [[:editor/input command-trigger nil]
[:editor/search-template]] "Insert a created template here"

View File

@@ -3047,7 +3047,6 @@
(block-content config block edit-input-id block-id *show-query?))))
(rum/defcs ^:large-vars/cleanup-todo block-content-or-editor < rum/reactive
(rum/local false ::hover?)
[state config {:block/keys [uuid] :as block} {:keys [edit-input-id block-id edit? hide-block-refs-count? refs-count *hide-block-refs? *show-query?]}]
(let [format (if (config/db-based-graph? (state/get-current-repo))
:markdown
@@ -3084,7 +3083,10 @@
:format format}
edit-input-id
config))]
[:div.flex.flex-1.w-full.block-content-wrapper {:style {:display "flex"}}
[:div.flex.flex-1.w-full.block-content-wrapper
{:style {:display "flex"}}
(when-let [actions-cp (:page-title-actions-cp config)]
(actions-cp block))
(block-content-with-error config block edit-input-id block-id *show-query? editor-box)
(when (and (not hide-block-refs-count?)
@@ -3639,8 +3641,6 @@
[:div.flex.flex-col.w-full
[:div.block-main-content.flex.flex-row.gap-2
(when-let [actions-cp (:page-title-actions-cp config)]
(actions-cp block))
(when page-icon
page-icon)

View File

@@ -524,10 +524,16 @@
}
}
.block-main-content {
.ls-page-title-container .block-content-wrapper {
.ls-page-title-actions {
@apply absolute -top-4 opacity-0;
left: -2px;
}
&:hover {
& > .db-page-title-actions {
& > .ls-page-title-actions {
@apply delay-300 transition-opacity opacity-100;
}
}
}

View File

@@ -931,7 +931,11 @@
(defn- on-mouse-up
[e]
(when-not (.closest (.-target e) ".block-control-wrap")
(when-not (or (.closest (.-target e) ".block-control-wrap")
(.closest (.-target e) "button")
(.closest (.-target e) "input")
(.closest (.-target e) "textarea")
(.closest (.-target e) "a"))
(editor-handler/show-action-bar!)))
(rum/defcs ^:large-vars/cleanup-todo root-container < rum/reactive

View File

@@ -192,13 +192,13 @@
(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]))))
(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? whiteboard?] :as config}]
(when-let [id (:db/id block*)]
@@ -420,11 +420,11 @@
(rum/defc db-page-title-actions
[page]
[:div.absolute.-top-4.left-0.opacity-0.db-page-title-actions
[:div.ls-page-title-actions
[:div.flex.flex-row.items-center.gap-2
(when-not (:logseq.property/icon (db/entity (:db/id page)))
(shui/button
{:variant :outline
{:variant :ghost
:size :sm
:class "px-2 py-0 h-6 text-xs text-muted-foreground"
:on-click (fn [e]
@@ -434,7 +434,7 @@
"Add icon"))
(shui/button
{:variant :outline
{:variant :ghost
:size :sm
:class "px-2 py-0 h-6 text-xs text-muted-foreground"
:on-click (fn [e]

View File

@@ -92,7 +92,7 @@
}
}
.db-page-title-actions {
.ls-page-title-actions {
&:has(button[data-popup-active]) {
@apply opacity-100;
}

View File

@@ -1156,7 +1156,7 @@
(if editing?
(popup-content nil)
(let [show! (fn [e]
(util/stop e)
(state/clear-selection!)
(let [target (when e (.-target e))]
(when-not (or config/publishing?
(util/shift-key? e)
@@ -1171,7 +1171,7 @@
{:ref *el
:id trigger-id
:tabIndex 0
:on-click show!
:on-pointer-down show!
:on-key-down (fn [e]
(case (util/ekey e)
("Backspace" "Delete")

View File

@@ -2,6 +2,7 @@
(:require [clojure.set :as set]
[clojure.string :as string]
[clojure.walk :as w]
[dommy.core :as d]
[dommy.core :as dom]
[electron.ipc :as ipc]
[frontend.commands :as commands]
@@ -1242,15 +1243,20 @@
(defonce *action-bar-timeout (atom nil))
(defn popup-exists?
[id]
(some->> (shui-popup/get-popups)
(some #(some-> % (:id) (str) (string/includes? (str id))))))
(defn show-action-bar!
[& {:keys [delay]
:or {delay 200}}]
(when (config/db-based-graph?)
(when (and (config/db-based-graph?) (not (popup-exists? :selection-action-bar)))
(when-let [timeout @*action-bar-timeout]
(js/clearTimeout timeout))
(state/pub-event! [:editor/hide-action-bar])
(when (seq (state/get-selection-blocks))
(when (seq (remove (fn [b] (d/has-class? b "ls-table-cell"))
(state/get-selection-blocks)))
(let [timeout (js/setTimeout #(state/pub-event! [:editor/show-action-bar]) delay)]
(reset! *action-bar-timeout timeout)))))
@@ -3325,11 +3331,6 @@
(cursor/select-up-down input direction anchor cursor-rect)))
(select-block-up-down direction))))
(defn popup-exists?
[id]
(some->> (shui-popup/get-popups)
(some #(some-> % (:id) (str) (string/includes? (str id))))))
(defn editor-commands-popup-exists?
[]
(popup-exists? "editor.commands"))

View File

@@ -790,6 +790,11 @@
(->> blocks
(remove (fn [b] (= "true" (d/attr b "data-embed")))))))
#?(:cljs
(defn remove-property-value-blocks [blocks]
(->> blocks
(remove (fn [b] (d/has-class? b "property-value-container"))))))
#?(:cljs
(defn get-selected-text
[]
@@ -898,7 +903,8 @@
(defn get-prev-block-non-collapsed-non-embed
[block]
(when-let [blocks (->> (get-blocks-noncollapse)
remove-embedded-blocks)]
remove-embedded-blocks
remove-property-value-blocks)]
(when-let [index (.indexOf blocks block)]
(let [idx (dec index)]
(when (>= idx 0)

View File

@@ -859,6 +859,12 @@
:logseq.task/scheduled :logseq.property/scheduled})
conn search-db))
(defn- empty-placeholder-add-block-uuid
[_conn _search-db]
[{:db/ident :logseq.property/empty-placeholder
:block/uuid (common-uuid/gen-uuid :builtin-block-uuid :logseq.property/empty-placeholder)}])
(def ^:large-vars/cleanup-todo schema-version->updates
"A vec of tuples defining datascript migrations. Each tuple consists of the
schema version integer and a migration map. A migration map can have keys of :properties, :classes
@@ -958,8 +964,8 @@
[62 {:fix remove-block-schema}]
[63 {:properties [:logseq.property.table/pinned-columns]}]
[64 {:fix update-view-filter}]
;;;; schema-version format: "<major>.<minor>"
;;;; int number equals to "<major>" (without <minor>)
;;;; schema-version format: "<major>.<minor>"
;;;; int number equals to "<major>" (without <minor>)
["64.1" {:properties [:logseq.property.view/group-by-property]
:fix add-view-icons}]
["64.2" {:properties [:logseq.property.view/feature-type]
@@ -970,7 +976,8 @@
["64.5" {:fix add-group-by-property-for-list-views}]
["64.6" {:fix cardinality-one-multiple-values}]
["64.7" {:fix rename-repeated-properties}]
["64.8" {:fix rename-task-properties}]])
["64.8" {:fix rename-task-properties}]
["64.9" {:fix empty-placeholder-add-block-uuid}]])
(let [[major minor] (last (sort (map (comp (juxt :major :minor) db-schema/parse-schema-version first)
schema-version->updates)))