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

fix: set edit-block-fn when inserting new block

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

+ 0 - 6
src/main/capacitor/components/app.cljs

@@ -83,11 +83,6 @@
     {:tab "settings"}
     (ion/tabler-icon "settings" {:size 22}) "Settings")))
 
-(rum/defc keep-keyboard-open
-  []
-  [:input.absolute.top-4.left-0.w-1.h-1.opacity-0
-   {:id "app-keep-keyboard-open-input"}])
-
 (rum/defc journals < rum/reactive
   []
   (let [show-action-bar? (fstate/sub :mobile/show-action-bar?)]
@@ -200,7 +195,6 @@
        (settings/page)))
      (bottom-tabs)
 
-     (keep-keyboard-open)
      (ui-component/install-notifications)
      (ui-component/install-modals)
 

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

@@ -2620,7 +2620,6 @@
 
             :else
             (let [block (or (db/entity [:block/uuid (:block/uuid block)]) block)]
-              (util/mobile-keep-keyboard-open)
               (editor-handler/clear-selection!)
               (editor-handler/unhighlight-blocks!)
               (let [f #(p/do!

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

@@ -174,7 +174,6 @@
                      save-code-editor? true}
                 :as opts}]
   (when (and (not config/publishing?) (:block/uuid block))
-    (util/mobile-keep-keyboard-open)
     (let [repo (state/get-current-repo)]
       (p/do!
        (when-not (:block.temp/fully-loaded? (db/entity (:db/id block)))

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

@@ -67,7 +67,6 @@
             [logseq.outliner.core :as outliner-core]
             [logseq.outliner.property :as outliner-property]
             [logseq.shui.popup.core :as shui-popup]
-            ;; [capacitor.components.common :as cc-common]
             [promesa.core :as p]
             [rum.core :as rum]))
 
@@ -508,18 +507,19 @@
 
                           :else
                           insert-new-block-aux!)
-              [result-promise sibling? next-block] (insert-fn config block'' value)]
+              [result-promise sibling? next-block] (insert-fn config block'' value)
+              edit-block-f (fn []
+                             (let [next-block' (db/entity [:block/uuid (:block/uuid next-block)])
+                                   pos 0
+                                   unsaved-chars @(:editor/async-unsaved-chars @state/state)
+                                   container-id (get-new-container-id :insert {:sibling? sibling?})]
+                               (edit-block! next-block' (+ pos (count unsaved-chars))
+                                            {:container-id container-id
+                                             :custom-content (str unsaved-chars (:block/title next-block'))})))]
           (p/do!
+           (state/set-state! :editor/edit-block-fn edit-block-f)
            result-promise
-           (clear-when-saved!)
-           (let [next-block' (db/entity [:block/uuid (:block/uuid next-block)])
-                 pos 0
-                 unsaved-chars @(:editor/async-unsaved-chars @state/state)
-                 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))
-                          {:container-id container-id
-                           :custom-content (str unsaved-chars (:block/title next-block'))}))))))
+           (clear-when-saved!)))))
     (p/finally (fn []
                  (state/set-state! :editor/async-unsaved-chars nil))))))
 

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

@@ -1540,10 +1540,3 @@ Arg *stop: atom, reset to true to stop the loop"
      [^js target]
      (when target
        (some-> target (.querySelector ".CodeMirror") (.-CodeMirror)))))
-
-#?(:cljs
-   (defn mobile-keep-keyboard-open
-     []
-     (when mobile?
-       (when-let [node (gdom/getElement "app-keep-keyboard-open-input")]
-         (.focus node)))))