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

chore: remove keep-keyboard-open

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

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

@@ -2680,8 +2680,6 @@
                                           first
                                           util/caret-range)
                 mobile-range (when mobile? (get-cursor-range))]
-            (when-not forbidden-edit?
-              (util/mobile-keep-keyboard-open false))
             (when (and (not forbidden-edit?) (contains? #{1 0} button))
               (cond
                 (and meta? shift?)

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

@@ -768,8 +768,6 @@
       ;; exit editing mode
       :else
       (let [select? (= type :esc)]
-        (when (.closest (.-target e) ".block-content")
-          (util/mobile-keep-keyboard-open))
         (when-let [container (gdom/getElement "app-container")]
           (dom/remove-class! container "blocks-selection-mode"))
         (p/do!

+ 13 - 11
src/main/frontend/handler/editor.cljs

@@ -4070,17 +4070,19 @@
   []
   (let [today (db/get-page (date/today))
         add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)]
-    (when (and today add-page)
-      (let [children (:block/_parent (db/entity (:db/id add-page)))]
-        (p/do!
-         (when (seq children)
-           (if-let [today-last-child (last (ldb/sort-by-order (:block/_parent today)))]
-             (move-blocks! children today-last-child {:sibling? true})
-             (move-blocks! children today {:sibling? false})))
-         (state/close-modal!)
-         (shui/popup-hide!)
-         (when (seq children)
-           (notification/show! "Blocks added to today!" :success)))))))
+    (p/do!
+     (save-current-block!)
+     (when (and today add-page)
+       (let [children (:block/_parent (db/entity (:db/id add-page)))]
+         (p/do!
+          (when (seq children)
+            (if-let [today-last-child (last (ldb/sort-by-order (:block/_parent today)))]
+              (move-blocks! children today-last-child {:sibling? true})
+              (move-blocks! children today {:sibling? false})))
+          (state/close-modal!)
+          (shui/popup-hide!)
+          (when (seq children)
+            (notification/show! "Blocks added to today!" :success))))))))
 
 (defn quick-add
   []

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

@@ -1484,23 +1484,6 @@ Arg *stop: atom, reset to true to stop the loop"
      (when target
        (some-> target (.querySelector ".CodeMirror") (.-CodeMirror)))))
 
-#?(:cljs
-   (defn get-keep-keyboard-input-el
-     ([] (get-keep-keyboard-input-el ""))
-     ([t]
-      (js/document.getElementById (str "keep-keyboard-open-input" t)))))
-
-#?(:cljs
-   (defn mobile-keep-keyboard-open
-     ([]
-      (mobile-keep-keyboard-open true))
-     ([schedule?]
-      (when (mobile?)
-        (let [f #(when-let [node (or (get-keep-keyboard-input-el "in-modal")
-                                     (get-keep-keyboard-input-el))]
-                   (.focus node))]
-          (if schedule? (schedule f) (f)))))))
-
 #?(:cljs
    (defn rtc-test?
      []

+ 1 - 1
src/main/mobile/components/app.cljs

@@ -156,7 +156,7 @@
      (when show-action-bar?
        (selection-toolbar/action-bar))
      (shui-popup/install-popups)
-     (ui-component/keep-keyboard-virtual-input)
+     ;; (ui-component/keep-keyboard-virtual-input)
      (ui-component/install-notifications)
      (shui-toaster/install-toaster)
      (shui-dialog/install-modals)]))

+ 2 - 6
src/main/mobile/components/editor_toolbar.cljs

@@ -8,7 +8,6 @@
             [frontend.mobile.haptics :as haptics]
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
-            [frontend.util :as util]
             [frontend.util.cursor :as cursor]
             [goog.dom :as gdom]
             [logseq.common.util.page-ref :as page-ref]
@@ -239,11 +238,8 @@
   (let [editing? (state/sub :editor/editing?)
         code-block? (state/sub :editor/code-block-context)
         quick-add? (mobile-state/quick-add-open?)
-        keep-open? (= "app-keep-keyboard-open-input"
-                      (some-> js/document.activeElement (.-id)))
-        show? (and (util/mobile?)
-                   (not code-block?)
-                   (or editing? keep-open?))
+        show? (and (not code-block?)
+                   editing?)
         actions (toolbar-actions quick-add?)]
     (when (mobile-util/native-ios?)
       (native-toolbar show? actions))))

+ 8 - 9
src/main/mobile/components/popup.cljs

@@ -4,10 +4,10 @@
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.ui :as ui]
-            [frontend.util :as util]
             [logseq.shui.popup.core :as shui-popup]
             [logseq.shui.ui :as shui]
             [mobile.state :as mobile-state]
+            [promesa.core :as p]
             [rum.core :as rum]))
 
 (defonce *last-popup? (atom nil))
@@ -43,22 +43,21 @@
 (defn- handle-native-sheet-state!
   [^js data]
   (let [presenting? (.-presenting data)
-        presented? (.-presented data)
         dismissing? (.-dismissing data)]
     (cond
       presenting?
-      (when (mobile-state/quick-add-open?)
-        (util/mobile-keep-keyboard-open false))
-
-      presented?
       (when (mobile-state/quick-add-open?)
         (editor-handler/quick-add-open-last-block!))
 
       dismissing?
       (when (some? @mobile-state/*popup-data)
-        (state/pub-event! [:mobile/clear-edit])
-        (mobile-state/set-popup! nil)
-        (reset! *last-popup-data nil))
+        (p/do!
+         (state/pub-event! [:mobile/clear-edit])
+         (mobile-state/set-popup! nil)
+         (reset! *last-popup-data nil)
+         (when (mobile-util/native-ios?)
+           (let [plugin ^js mobile-util/native-editor-toolbar]
+             (.dismiss plugin)))))
 
       :else
       nil)))

+ 0 - 8
src/main/mobile/components/ui.cljs

@@ -18,14 +18,6 @@
     [:div#main-container.flex.flex-1
      [:div.w-full content]]]])
 
-(rum/defc keep-keyboard-virtual-input
-  ([] (keep-keyboard-virtual-input ""))
-  ([t]
-   [:input.absolute.top-4.left-0.w-1.h-1.opacity-0
-    {:id (str "keep-keyboard-open-input" t)
-     :auto-capitalize "sentences"
-     :auto-correct "true"}]))
-
 (rum/defc notification-clear-all
   []
   [:div.ui__notifications-content

+ 2 - 1
src/main/mobile/events.cljs

@@ -18,7 +18,8 @@
                     (fn []
                       (quick-add/quick-add))
                     {:id :ls-quick-add
-                     :default-height 600}))
+                     ;; large height to avoid layout shift
+                     :default-height 1200}))
 
 (defmethod events/handle :mobile/start-audio-record [_]
   (recorder/record! {:save-to-today? true}))

+ 1 - 0
src/main/mobile/init.cljs

@@ -130,5 +130,6 @@
 
 (comment
   (defn keyboard-show
+    "Notice, iOS is not supported"
     []
     (.show Keyboard)))