Browse Source

Merge branch 'feat/db' into refactor/narrow-gap-between-page-and-block

Tienson Qin 1 year ago
parent
commit
cc3c4ac5dc

+ 1 - 0
scripts/src/logseq/tasks/lang.clj

@@ -114,6 +114,7 @@
    "(t prompt-key" [:select/default-prompt :select/default-select-multiple :select.graph/prompt]
    ;; All args to ui/make-confirm-modal are not keywords
    "(t title" []
+   "(t (or title-key" [:views.table/default-title :all-pages/table-title]
    "(t subtitle" [:asset/physical-delete]})
 
 (defn- whiteboard-dicts

+ 1 - 2
src/main/frontend/components/all_pages.cljs

@@ -59,8 +59,7 @@
     [:div.ls-all-pages.w-full
      (views/view view-entity {:data data
                               :set-data! set-data!
-                              :title (let [data-count (count data)]
-                                       (str data-count (if (> data-count 1) " Pages" " Page")))
+                              :title-key :all-pages/table-title
                               :columns columns
                               :on-delete-rows (fn [table selected-rows]
                                                 (shui/dialog-open!

+ 3 - 1
src/main/frontend/components/objects.cljs

@@ -98,7 +98,9 @@
   (when class
     (let [class (db/sub-block (:db/id class))
           config {:container-id (:container-id state)}
-          properties (outliner-property/get-class-properties class)
+          properties (cond->> (outliner-property/get-class-properties class)
+                       (= :logseq.class/Root (:db/ident class))
+                       (concat [(db/entity :block/tags)]))
           repo (state/get-current-repo)
           objects (->> (db-model/sub-class-objects repo (:db/id class))
                        (map (fn [row] (assoc row :id (:db/id row)))))]

+ 11 - 11
src/main/frontend/components/repo.cljs

@@ -351,7 +351,7 @@
                    {:as-dropdown? true
                     :auto-focus? false
                     :align "start"
-                    :content-props {:class "repos-list"
+                    :content-props {:class (str "repos-list " (when (<= (count repos) 1) " no-repos"))
                                     :data-mode (when db-based? "db")}})))
              :title repo-name}                              ;; show full path on hover
             [:div.flex.relative.graph-icon.rounded
@@ -388,18 +388,18 @@
   "Returns boolean indicating if DB graph name is invalid. Must be kept in sync with invalid-graph-name-warning"
   [graph-name]
   (or (fs-util/include-reserved-chars? graph-name)
-      (string/includes? graph-name "+")))
+    (string/includes? graph-name "+")))
 
 (rum/defcs new-db-graph < rum/reactive
-  (rum/local "" ::graph-name)
-  (rum/local false ::cloud?)
-  (rum/local false ::creating-db?)
-  (rum/local (rum/create-ref) ::input-ref)
-  {:did-mount (fn [s]
-                (when-let [^js input (some-> @(::input-ref s)
-                                       (rum/deref))]
-                  (js/setTimeout #(.focus input) 32))
-                s)}
+                          (rum/local "" ::graph-name)
+                          (rum/local false ::cloud?)
+                          (rum/local false ::creating-db?)
+                          (rum/local (rum/create-ref) ::input-ref)
+                          {:did-mount (fn [s]
+                                        (when-let [^js input (some-> @(::input-ref s)
+                                                               (rum/deref))]
+                                          (js/setTimeout #(.focus input) 32))
+                                        s)}
   [state]
   (let [*creating-db? (::creating-db? state)
         *graph-name (::graph-name state)

+ 11 - 3
src/main/frontend/components/repo.css

@@ -16,11 +16,19 @@
 
 .ui__dropdown-menu-content {
   &.repos-list {
-    @apply px-2 pb-[210px] relative;
+    @apply px-2 pb-[210px] relative overflow-hidden;
     @apply min-w-[280px] sm:max-w-[320px] max-h-[66vh];
 
+    &.no-repos {
+      @apply pb-[180px];
+    }
+
     &[data-mode=db] {
-      @apply pb-[130px];
+      @apply pb-[114px];
+
+      &.no-repos {
+        @apply pb-[109px];
+      }
     }
 
     .ui__dropdown-menu-item {
@@ -28,7 +36,7 @@
     }
 
     .cp__repos-list-wrap {
-      @apply max-h-96 overflow-scroll m-[-8px] px-2 pb-2;
+      @apply max-h-96 overflow-scroll m-[-8px] px-2 pb-6;
     }
   }
 }

+ 4 - 5
src/main/frontend/components/views.cljs

@@ -894,7 +894,7 @@
            (property-handler/set-block-property! repo (:db/id entity) :logseq.property/table-ordered-columns ids))))}))
 
 (rum/defc view-inner < rum/static
-  [view-entity {:keys [data set-data! columns add-new-object! create-view! title] :as option}]
+  [view-entity {:keys [data set-data! columns add-new-object! create-view! title-key] :as option}]
   (let [[input set-input!] (rum/use-state "")
         sorting (:logseq.property/table-sorting view-entity)
         [sorting set-sorting!] (rum/use-state (or sorting [{:id :block/updated-at, :asc? false}]))
@@ -943,10 +943,9 @@
 
     [:div.flex.flex-col.gap-2.grid
      [:div.flex.items-center.justify-between
-      (let [data-count (count (:data table))]
-        [:div.flex.flex-row.items-center.gap-2
-         [:div.font-medium (or title
-                               (str data-count (if (> data-count 1) " Objects" " Object")))]])
+      [:div.flex.flex-row.items-center.gap-2
+       [:div.font-medium (t (or title-key :views.table/default-title)
+                            (count (:rows table)))]]
       [:div.flex.items-center.gap-1
 
        (filter-properties columns table)

+ 2 - 1
src/main/frontend/config.cljs

@@ -344,7 +344,8 @@
   ([]
    (demo-graph? (state/get-current-repo)))
   ([repo-url]
-   (or (nil? repo-url) (= repo-url demo-repo))))
+   (or (nil? repo-url) (= repo-url demo-repo)
+     (string/ends-with? repo-url demo-repo))))
 
 (defonce recycle-dir ".recycle")
 (def config-file "config.edn")

+ 9 - 7
src/main/frontend/extensions/pdf/core.cljs

@@ -125,6 +125,8 @@
 
   (let [*el (rum/use-ref nil)
         ^js cnt (.-container viewer)
+        ^js body (some-> (.-ownerDocument cnt) (.-body))
+        key-alt? (= (some-> body (.-dataset) (.-activeKeystroke)) "Alt")
         head-height 0                                       ;; 48 temp
         top (- (+ (:y point) (.-scrollTop cnt)) head-height)
         left (+ (:x point) (.-scrollLeft cnt))
@@ -132,7 +134,7 @@
         new? (nil? id)
         new-&-highlight-mode? (and @*highlight-mode? new?)
         show-ctx-menu? (and (not new-&-highlight-mode?)
-                            (or (not selection) (and selection (state/sub :pdf/auto-open-ctx-menu?))))
+                            (or (not selection) (and selection (or (state/sub :pdf/auto-open-ctx-menu?) key-alt?))))
         content (:content highlight)
         area? (not (string/blank? (:image content)))
         action-fn! (fn [action clear?]
@@ -692,13 +694,13 @@
      ;; hl context tip menu
      (when-let [_hl (:highlight ctx-menu-state)]
        (js/ReactDOM.createPortal
-        (pdf-highlights-ctx-menu viewer ctx-menu-state
-                                 {:clear-ctx-menu! clear-ctx-menu!
-                                  :add-hl!         add-hl!
-                                  :del-hl!         del-hl!
-                                  :upd-hl!         upd-hl!})
+         (pdf-highlights-ctx-menu viewer ctx-menu-state
+           {:clear-ctx-menu! clear-ctx-menu!
+            :add-hl! add-hl!
+            :del-hl! del-hl!
+            :upd-hl! upd-hl!})
 
-        (.querySelector el ".pp-holder")))
+         (.querySelector el ".pp-holder")))
 
      ;; debug highlights anchor
      ;;(if (seq highlights)

+ 6 - 1
src/resources/dicts/en.edn

@@ -207,7 +207,7 @@
                                         ;; 1 Unlinked Reference
                                         ;; 5 Unlinked References
                                         (str total
-                                         (if (= total 1) " Unlinked Reference" " Unlinked References")))
+                                             (if (= total 1) " Unlinked Reference" " Unlinked References")))
  :editor/block-search "Search for a block"
  :text/image "Image"
  :asset/show-in-folder "Show image in folder"
@@ -491,6 +491,8 @@
  :export-save-to-file "Save to file"
  :all-graphs "All graphs"
  :all-pages "All pages"
+ ;; E.g. 1 Page or 2 Pages
+ :all-pages/table-title (fn [total] (str total (if (= total 1) " Page" " Pages")))
  :all-pages/failed-to-delete-pages "These pages had their content deleted but were unable to be deleted: {1}. See javascript console for more details."
  :all-whiteboards "All whiteboards"
  :all-files "All files"
@@ -636,6 +638,9 @@
  :header/go-back                     "Go back"
  :header/go-forward                  "Go forward"
 
+ ;; E.g. 1 Object or 2 Objects
+ :views.table/default-title (fn [total] (str total (if (= total 1) " Object" " Objects")))
+
  ;; Commands are nested for now to stay in sync with the shortcuts system.
  ;; Other languages should not nest keys under :commands
  :commands