Browse Source

enhance(capacitor): improve classic block editor

charlie 7 months ago
parent
commit
0c8e66bda7

+ 15 - 0
src/main/capacitor/app.css

@@ -1,3 +1,6 @@
+html, body {
+  @apply text-[18px] leading-6;
+}
 #root {
 #root {
   @apply p-4;
   @apply p-4;
 }
 }
@@ -86,6 +89,18 @@ ion-textarea {
 .editor-aux-input {
 .editor-aux-input {
 }
 }
 
 
+.app-page-blocks {
+  &.as-classic {
+    @apply -ml-2.5 py-2 pr-1;
+
+    .editor-inner {
+      > textarea {
+        @apply w-full;
+      }
+    }
+  }
+}
+
 .app-blocks-list {
 .app-blocks-list {
   .normalize-text-style {
   .normalize-text-style {
     @apply text-[20px] leading-[28px];
     @apply text-[20px] leading-[28px];

+ 6 - 1
src/main/capacitor/components/blocks.cljs

@@ -291,6 +291,11 @@
       [:div.app-page-blocks.mb-4
       [:div.app-page-blocks.mb-4
        (blocks-container page)])))
        (blocks-container page)])))
 
 
+(rum/defc page-blocks-classic
+  [page]
+  [:div.app-page-blocks.as-classic
+   (cp-page/page-blocks-cp page {})])
+
 (rum/defc page [block {:keys [reload-pages!]}]
 (rum/defc page [block {:keys [reload-pages!]}]
   (let [[^js nav] (state/use-nav-root)
   (let [[^js nav] (state/use-nav-root)
         [page set-page!] (rum/use-state (db-utils/entity (:db/id block)))
         [page set-page!] (rum/use-state (db-utils/entity (:db/id block)))
@@ -338,7 +343,7 @@
       (ionic/ion-content {:class "ion-padding"}
       (ionic/ion-content {:class "ion-padding"}
         (if loading?
         (if loading?
           [:p.text-xl.text-center "Loading ..."]
           [:p.text-xl.text-center "Loading ..."]
-          (cp-page/page-blocks-cp page {})
+          (page-blocks-classic page)
           ;(let [edit-opts {:reload-page! rerender!}]
           ;(let [edit-opts {:reload-page! rerender!}]
           ;  [:<>
           ;  [:<>
           ;   (when-let [children (:block/_parent page)]
           ;   (when-let [children (:block/_parent page)]

+ 2 - 3
src/main/frontend/components/block.cljs

@@ -2148,8 +2148,7 @@
                                 :is-with-icon  with-icon?
                                 :is-with-icon  with-icon?
                                 :bullet-closed collapsed?
                                 :bullet-closed collapsed?
                                 :bullet-hidden (:hide-bullet? config)}])}
                                 :bullet-hidden (:hide-bullet? config)}])}
-     (when (and (or (not fold-button-right?) collapsable?)
-                (not (:table? config)))
+     (when (not (:table? config))
        [:a.block-control
        [:a.block-control
         {:id       (str "control-" uuid)
         {:id       (str "control-" uuid)
          :on-click (fn [event]
          :on-click (fn [event]
@@ -2896,7 +2895,7 @@
         block-type (or
         block-type (or
                     (pu/lookup block :logseq.property/ls-type)
                     (pu/lookup block :logseq.property/ls-type)
                     :default)
                     :default)
-        mouse-down-key (if (util/ios?)
+        mouse-down-key (if (util/mobile?)
                          :on-click
                          :on-click
                          :on-pointer-down) ; TODO: it seems that Safari doesn't work well with on-pointer-down
                          :on-pointer-down) ; TODO: it seems that Safari doesn't work well with on-pointer-down
         attrs (cond->
         attrs (cond->

+ 2 - 0
src/main/frontend/handler/editor.cljs

@@ -67,6 +67,7 @@
             [logseq.outliner.core :as outliner-core]
             [logseq.outliner.core :as outliner-core]
             [logseq.outliner.property :as outliner-property]
             [logseq.outliner.property :as outliner-property]
             [logseq.shui.popup.core :as shui-popup]
             [logseq.shui.popup.core :as shui-popup]
+            [capacitor.components.common :as cc-common]
             [promesa.core :as p]
             [promesa.core :as p]
             [rum.core :as rum]))
             [rum.core :as rum]))
 
 
@@ -515,6 +516,7 @@
                  pos 0
                  pos 0
                  unsaved-chars @(:editor/async-unsaved-chars @state/state)
                  unsaved-chars @(:editor/async-unsaved-chars @state/state)
                  container-id (get-new-container-id :insert {:sibling? sibling?})]
                  container-id (get-new-container-id :insert {:sibling? sibling?})]
+             (when (util/mobile?) (cc-common/keep-keyboard-open nil))
              (edit-block! next-block' (+ pos (count unsaved-chars))
              (edit-block! next-block' (+ pos (count unsaved-chars))
                           {:container-id container-id
                           {:container-id container-id
                            :custom-content (str unsaved-chars (:block/title next-block'))}))))))
                            :custom-content (str unsaved-chars (:block/title next-block'))}))))))

+ 0 - 1
src/main/frontend/handler/events.cljs

@@ -282,7 +282,6 @@
 
 
 (defmethod handle :graph/restored [[_ graph]]
 (defmethod handle :graph/restored [[_ graph]]
   (when graph (assets-handler/ensure-assets-dir! graph))
   (when graph (assets-handler/ensure-assets-dir! graph))
-  (mobile/init!)
   (rtc-flows/trigger-rtc-start graph)
   (rtc-flows/trigger-rtc-start graph)
   (fsrs/update-due-cards-count)
   (fsrs/update-due-cards-count)
   (when-not (mobile-util/native-ios?)
   (when-not (mobile-util/native-ios?)

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

@@ -2304,8 +2304,7 @@ Similar to re-frame subscriptions"
 
 
 (defn set-color-accent! [color]
 (defn set-color-accent! [color]
   (swap! state assoc :ui/radix-color color)
   (swap! state assoc :ui/radix-color color)
-  (storage/set :ui/radix-color color)
-  (util/set-android-theme))
+  (storage/set :ui/radix-color color))
 
 
 (defn set-editor-font! [font]
 (defn set-editor-font! [font]
   (let [font (if (keyword? font) (name font) (str font))]
   (let [font (if (keyword? font) (name font) (str font))]

+ 3 - 17
src/main/frontend/util.cljc

@@ -229,30 +229,17 @@
                rgb (take 3 rgb)]
                rgb (take 3 rgb)]
            (rgb2hex rgb))))))
            (rgb2hex rgb))))))
 
 
-#?(:cljs
-   (defn set-android-theme
-     []
-     (let [f #(when (mobile-util/native-android?)
-                (when-let [bg-color (try (get-computed-bg-color)
-                                         (catch :default _
-                                           nil))]
-                  (.setNavigationBarColor NavigationBar (clj->js {:color bg-color}))
-                  (.setBackgroundColor StatusBar (clj->js {:color bg-color}))))]
-       (js/setTimeout f 32))))
-
 #?(:cljs
 #?(:cljs
    (defn set-theme-light
    (defn set-theme-light
      []
      []
      (p/do!
      (p/do!
-      (.setStyle StatusBar (clj->js {:style (.-Light Style)}))
-      (set-android-theme))))
+      (.setStyle StatusBar (clj->js {:style (.-Light Style)})))))
 
 
 #?(:cljs
 #?(:cljs
    (defn set-theme-dark
    (defn set-theme-dark
      []
      []
      (p/do!
      (p/do!
-      (.setStyle StatusBar (clj->js {:style (.-Dark Style)}))
-      (set-android-theme))))
+      (.setStyle StatusBar (clj->js {:style (.-Dark Style)})))))
 
 
 (defn find-first
 (defn find-first
   [pred coll]
   [pred coll]
@@ -1049,8 +1036,7 @@
                      (d/set-attr! :type "text/css")
                      (d/set-attr! :type "text/css")
                      (d/set-attr! :href style)
                      (d/set-attr! :href style)
                      (d/set-attr! :media "all"))]
                      (d/set-attr! :media "all"))]
-           (d/append! parent-node link))
-         (set-android-theme)))))
+           (d/append! parent-node link))))))
 
 
 (defn remove-common-preceding
 (defn remove-common-preceding
   [col1 col2]
   [col1 col2]