Просмотр исходного кода

enhance(ux): mod+j support sidebar

Tienson Qin 9 месяцев назад
Родитель
Сommit
ff8a7c0df0

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

@@ -602,7 +602,7 @@
 
 (rum/defc sidebar-page-properties
   [config page]
-  (let [[collapsed? set-collapsed!] (rum/use-state true)]
+  (let [[collapsed? set-collapsed!] (rum/use-state (not (ldb/class? page)))]
     [:div.ls-sidebar-page-properties.flex.flex-col.gap-2.mt-2
      [:div
       (shui/button

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

@@ -423,7 +423,7 @@
 (rum/defcs new-property < rum/reactive
   [state block opts]
   (when-not config/publishing?
-    [:div.ls-new-property {:style {:margin-left 6 :margin-top 1}}
+    [:div.ls-new-property {:style {:margin-left 7 :margin-top 1}}
      [:a.fade-link.flex.jtrigger
       {:tab-index 0
        :on-click (fn [e]

+ 16 - 10
src/main/frontend/components/property.css

@@ -45,23 +45,29 @@
   @apply focus-visible:outline-none focus-visible:bg-gray-03 focus-visible:rounded;
 }
 
-.ls-properties-area {
-  .property-pair {
-    @apply flex flex-row flex-wrap space-x-1;
-
-    .jtrigger {
-      @apply relative;
+.jtrigger {
+    @apply relative;
 
-      &-id {
-        @apply absolute left-[-22px] top-[2px] rounded-full leading-none
+    &-id {
+        @apply absolute left-[-19px] top-[3px] rounded-full leading-none
         flex items-center justify-center bg-primary text-primary-foreground border-none
         text-xs min-w-[20px] min-h-[20px] scale-95;
-      }
     }
+}
+
+.ls-new-property .jtrigger {
+    &-id {
+      @apply left-[-11px] top-[2px];
+    }
+}
+
+.ls-properties-area {
+  .property-pair {
+    @apply flex flex-row flex-wrap space-x-1;
 
     .jtrigger-view {
       > .jtrigger-id {
-        @apply left-[-14px];
+        @apply left-[-11px];
       }
 
       &:has(> .jtrigger-id) {

+ 1 - 1
src/main/frontend/components/property/value.cljs

@@ -1189,7 +1189,7 @@
          {:ref *el
           :id trigger-id
           :tabIndex 0
-          :on-pointer-down show!
+          :on-click show!
           :on-key-down (fn [e]
                          (case (util/ekey e)
                            ("Backspace" "Delete")

+ 9 - 13
src/main/frontend/handler/jump.cljs

@@ -1,12 +1,12 @@
 (ns frontend.handler.jump
   "Jump to property key/value"
-  (:require [frontend.state :as state]
+  (:require [clojure.string :as string]
             [dommy.core :as d]
-            [clojure.string :as string]
-            [frontend.util :as util]
-            [frontend.handler.notification :as notification]
+            [frontend.db :as db]
             [frontend.handler.editor :as editor-handler]
-            [frontend.db :as db]))
+            [frontend.handler.notification :as notification]
+            [frontend.state :as state]
+            [frontend.util :as util]))
 
 (defonce *current-keys (atom nil))
 (defonce *jump-data (atom {}))
@@ -92,20 +92,16 @@
                              (first (state/get-selection-block-ids))
                              (:block/uuid (db/get-page (state/get-current-page))))]
     (cond
-      current-block-id
+      (or current-block-id (:ui/sidebar-open? @state/state))
       (when (empty? (d/sel js/document ".jtrigger-id"))
         (let [current-block (when (uuid? current-block-id)
                               (db/entity [:block/uuid current-block-id]))
               collapsed? (or (state/get-block-collapsed current-block-id) (:block/collapsed? current-block))]
           (when collapsed?
             (editor-handler/expand-block! current-block-id))
-          (let [f #(let [selected-block-or-page (or (first (state/get-selection-blocks))
-                                   ;; current edited block
-                                                    (some-> (:block-parent-id (first (state/get-editor-args)))
-                                                            js/document.getElementById)
-                                   ;; current page
-                                                    (d/sel1 js/document "#main-content-container .ls-properties-area"))
-                         triggers (d/sel selected-block-or-page ".jtrigger")]
+          (let [f #(let [triggers (->> (d/sel ".jtrigger")
+                                       (remove (fn [^js n] (or (.closest n ".positioned-properties")
+                                                               (.closest n ".view-actions")))))]
                      (when (seq triggers)
                        (reset! *jump-data {:mode :property
                                            :triggers triggers})