Sfoglia il codice sorgente

Merge branch 'master' into feat/custom-children-list-style

charlie 2 anni fa
parent
commit
90f4bff1d5

+ 2 - 2
android/app/build.gradle

@@ -6,8 +6,8 @@ android {
         applicationId "com.logseq.app"
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 56
-        versionName "0.9.3"
+        versionCode 57
+        versionName "0.9.4"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         aaptOptions {
              // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

+ 4 - 4
ios/App/App.xcodeproj/project.pbxproj

@@ -515,7 +515,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.9.3;
+				MARKETING_VERSION = 0.9.4;
 				OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -542,7 +542,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.9.3;
+				MARKETING_VERSION = 0.9.4;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
@@ -567,7 +567,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.9.3;
+				MARKETING_VERSION = 0.9.4;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
@@ -594,7 +594,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.9.3;
+				MARKETING_VERSION = 0.9.4;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 1 - 1
resources/package.json

@@ -1,7 +1,7 @@
 {
   "name": "Logseq",
   "productName": "Logseq",
-  "version": "0.9.3",
+  "version": "0.9.4",
   "main": "electron.js",
   "author": "Logseq",
   "license": "AGPL-3.0",

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

@@ -1727,7 +1727,7 @@
    (every? #(= % ["Horizontal_Rule"]) body)))
 
 (rum/defcs block-control < rum/reactive
-  [state config block uuid block-id collapsed? *control-show? edit? has-child?]
+  [state config block uuid block-id collapsed? *control-show? edit?]
   (let [doc-mode?          (state/sub :document/mode?)
         control-show?      (util/react *control-show?)
         ref?               (:ref? config)
@@ -1735,11 +1735,12 @@
         fold-button-right? (state/enable-fold-button-right?)
         own-number-list?   (:own-order-number-list? config)
         order-list?        (boolean own-number-list?)
-        order-list-idx     (:own-order-list-index config)]
+        order-list-idx     (:own-order-list-index config)
+        collapsable?       (editor-handler/collapsable? uuid {:semantic? true})]
     [:div.block-control-wrap.mr-1.flex.flex-row.items-center.sm:mr-2
      {:class (util/classnames [{:is-order-list order-list?
                                 :bullet-closed collapsed?}])}
-     (when (or (not fold-button-right?) has-child?)
+     (when (or (not fold-button-right?) collapsable?)
        [:a.block-control
         {:id       (str "control-" uuid)
          :on-click (fn [event]
@@ -2857,7 +2858,7 @@
        :on-mouse-leave (fn [e]
                          (block-mouse-leave e *control-show? block-id doc-mode?))}
       (when (not slide?)
-        (block-control config block uuid block-id collapsed? *control-show? edit? has-child?))
+        (block-control config block uuid block-id collapsed? *control-show? edit?))
 
       (when @*show-left-menu?
         (block-left-menu config block))

+ 3 - 3
src/main/frontend/components/container.cljs

@@ -511,9 +511,6 @@
       {:tabIndex "-1"
        :data-is-margin-less-pages margin-less-pages?}
 
-      (when (util/electron?)
-        (find-in-page/search))
-
       (when show-action-bar?
         (action-bar/action-bar))
 
@@ -783,6 +780,9 @@
                         :default-home   default-home
                         :new-block-mode new-block-mode})
 
+        (when (util/electron?)
+          (find-in-page/search))
+
         (main {:route-match         route-match
                :margin-less-pages?  margin-less-pages?
                :logged?             logged?

+ 1 - 1
src/main/frontend/components/find_in_page.cljs

@@ -50,7 +50,7 @@
       :on-hide (fn []
                  (search-handler/electron-exit-find-in-page!)))))
   [{:keys [matches match-case? q]}]
-  [:div#search-in-page.flex.flex-row.absolute.top-2.right-4.shadow-lg.px-2.py-1.faster-fade-in.items-center
+  [:div#search-in-page.flex.flex-row.absolute.top-10.right-4.shadow-lg.px-2.py-1.faster-fade-in.items-center
 
    (search-input q matches)
 

+ 8 - 2
src/main/frontend/components/query/result.cljs

@@ -9,7 +9,8 @@
             [frontend.util :as util]
             [clojure.string :as string]
             [promesa.core :as p]
-            [rum.core :as rum]))
+            [rum.core :as rum]
+            [frontend.modules.outliner.tree :as tree]))
 
 (defn trigger-custom-query!
   [state *query-error *query-triggered?]
@@ -66,7 +67,12 @@
             ;; exclude the current one, otherwise it'll loop forever
             remove-blocks (if current-block-uuid [current-block-uuid] nil)
             transformed-query-result (when query-result
-                                       (db/custom-query-result-transform query-result remove-blocks q))
+                                       (let [result (db/custom-query-result-transform query-result remove-blocks q)]
+                                         (if (and query-result (coll? result) (:block/uuid (first result)))
+                                           (cond-> result
+                                            (get q :remove-block-children? true)
+                                            tree/filter-top-level-blocks)
+                                           result)))
             group-by-page? (get-group-by-page q options)
             result (if (and group-by-page? (:block/uuid (first transformed-query-result)))
                      (let [result (db-utils/group-by-page transformed-query-result)]

+ 7 - 11
src/main/frontend/components/query_table.cljs

@@ -12,8 +12,7 @@
             [frontend.format.block :as block]
             [medley.core :as medley]
             [rum.core :as rum]
-            [logseq.graph-parser.text :as text]
-            [frontend.modules.outliner.tree :as tree]))
+            [logseq.graph-parser.text :as text]))
 
 ;; Util fns
 ;; ========
@@ -158,20 +157,17 @@
   (rum/local false ::mouse-down?)
   [state config current-block result {:keys [page?]} map-inline page-cp ->elem inline-text]
   (when current-block
-    (let [result (tree/filter-top-level-blocks result)
-          select? (get state ::select?)
+    (let [select? (get state ::select?)
           *mouse-down? (::mouse-down? state)
-          ;; remove templates
-          result (remove (fn [b] (some? (get-in b [:block/properties :template]))) result)
-          result (if page? result (attach-clock-property result))
+          result' (if page? result (attach-clock-property result))
           clock-time-total (when-not page?
-                             (->> (map #(get-in % [:block/properties :clock-time] 0) result)
+                             (->> (map #(get-in % [:block/properties :clock-time] 0) result')
                                   (apply +)))
-          columns (get-columns current-block result {:page? page?})
+          columns (get-columns current-block result' {:page? page?})
           ;; Sort state needs to be in sync between final result and sortable title
           ;; as user needs to know if there result is sorted
           sort-state (get-sort-state current-block)
-          result' (sort-result result (assoc sort-state :page? page?))
+          sort-result (sort-result result (assoc sort-state :page? page?))
           property-separated-by-commas? (partial text/separated-by-commas? (state/get-config))]
       [:div.overflow-x-auto {:on-mouse-down (fn [e] (.stopPropagation e))
                              :style {:width "100%"}
@@ -186,7 +182,7 @@
                              (name column))]
               (sortable-title title column sort-state (:block/uuid current-block))))]]
         [:tbody
-         (for [row result']
+         (for [row sort-result]
            (let [format (:block/format row)]
              [:tr.cursor
               (for [column columns]

+ 2 - 2
src/main/frontend/ui.cljs

@@ -69,11 +69,11 @@
   [:div.flex.flex-row.justify-between.py-1.px-2.items-center
    [:div.flex.flex-row.justify-between.flex-1.mx-2.mt-2
     (for [color block-background-colors]
-      [:a.shadow-sm
+      [:a
        {:title (t (keyword "color" color))
         :on-click #(add-bgcolor-fn color)}
        [:div.heading-bg {:style {:background-color (str "var(--color-" color "-500)")}}]])
-    [:a.shadow-sm
+    [:a
      {:title (t :remove-background)
       :on-click rm-bgcolor-fn}
      [:div.heading-bg.remove "-"]]]])

+ 1 - 1
src/main/frontend/version.cljs

@@ -1,3 +1,3 @@
 (ns ^:no-doc frontend.version)
 
-(defonce version "0.9.3")
+(defonce version "0.9.4")

+ 17 - 5
src/test/frontend/components/query/result_test.cljs

@@ -14,10 +14,12 @@
     (binding [rum/*reactions* (volatile! #{})]
       (#'query-result/get-query-result {} {} (atom nil) (atom nil) current-block-uuid query {:table? table?}))))
 
-(deftest get-query-result
-  (let [result [{:block/uuid (random-uuid) :block/scheduled 20230418 :block/page {:db/id 1}}
-                {:block/uuid (random-uuid) :block/scheduled 20230415 :block/page {:db/id 1}}
-                {:block/uuid (random-uuid) :block/scheduled 20230417 :block/page {:db/id 1}}]
+(deftest get-query-result-with-transforms-and-grouping
+  (let [result (mapv
+                #(assoc % :block/page {:db/id 1} :block/parent {:db/id 2})
+                [{:block/uuid (random-uuid) :block/scheduled 20230418}
+                 {:block/uuid (random-uuid) :block/scheduled 20230415}
+                 {:block/uuid (random-uuid) :block/scheduled 20230417}])
         sorted-result (sort-by :block/scheduled result)]
     (testing "For list view"
       (are [query expected]
@@ -38,7 +40,7 @@
            ; User overrides transform to return grouped result
            {:result-transform '(partial sort-by :block/scheduled) :group-by-page? true}
            {{:db/id 1} sorted-result})
-      
+
       (testing "For table view"
         (are [query expected]
              (= expected (mock-get-query-result result query {:table? true}))
@@ -63,3 +65,13 @@
                                         {:table? false
                                          :current-block-uuid (:block/uuid current-block)})))
             "Current block is not included in results")))))
+
+(deftest get-query-result-with-remove-block-children-option
+  (let [result [{:db/id 1 :block/content "parent" :block/uuid 1}
+                {:db/id 2 :block/content "child" :block/uuid 2 :block/parent {:db/id 1}}]]
+    (is (= [{:db/id 1 :block/content "parent" :block/uuid 1}]
+           (mock-get-query-result result {:remove-block-children? true} {:table? true}))
+        "Removes children when :remove-block-children? is true")
+    (is (= result
+           (mock-get-query-result result {:remove-block-children? false} {:table? true}))
+        "Doesn't remove children when :remove-block-children? is false")))