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

fix: cut selections on mobile shouldn't keep keyboard open

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

+ 5 - 4
src/main/frontend/handler/editor.cljs

@@ -857,7 +857,7 @@
   (delete-block-inner! repo (get-state)))
 
 (defn delete-blocks!
-  [repo block-uuids blocks dom-blocks]
+  [repo block-uuids blocks dom-blocks mobile-action-bar?]
   (when (seq block-uuids)
     (let [uuid->dom-block (zipmap block-uuids dom-blocks)
           block (first blocks)
@@ -871,7 +871,8 @@
                                                           "")]
            (state/set-state! :editor/edit-block-fn edit-block-f)))
        (ui-outliner-tx/transact!
-        {:outliner-op :delete-blocks}
+        {:outliner-op :delete-blocks
+         :mobile-action-bar? mobile-action-bar?}
         (outliner-op/delete-blocks! blocks' nil))))))
 
 (defn set-block-timestamp!
@@ -1052,7 +1053,7 @@
            (map :block/uuid)))))
 
 (defn cut-selection-blocks
-  [copy?]
+  [copy? & {:keys [mobile-action-bar?]}]
   (when copy? (copy-selection-blocks true))
   (state/set-block-op-type! :cut)
   (when-let [blocks (->> (get-selected-blocks)
@@ -1073,7 +1074,7 @@
                                       (tree/get-sorted-block-and-children repo (:db/id block)))
                                     top-level-blocks)]
           (when (seq sorted-blocks)
-            (delete-blocks! repo (map :block/uuid sorted-blocks) sorted-blocks dom-blocks)))))))
+            (delete-blocks! repo (map :block/uuid sorted-blocks) sorted-blocks dom-blocks mobile-action-bar?)))))))
 
 (def url-regex
   "Didn't use link/plain-link as it is incorrectly detects words as urls."

+ 1 - 1
src/main/frontend/mobile/action_bar.cljs

@@ -29,7 +29,7 @@
     [:div.action-bar
      [:div.action-bar-commands
       (action-command "copy" "Copy" #(editor-handler/copy-selection-blocks false))
-      (action-command "cut" "Cut" #(editor-handler/cut-selection-blocks true))
+      (action-command "cut" "Cut" #(editor-handler/cut-selection-blocks true {:mobile-action-bar? true}))
       (action-command "registered" "Copy ref"
                       (fn [_event] (editor-handler/copy-block-refs)))
       (action-command "link" "Copy url"

+ 1 - 1
src/main/frontend/mobile/mobile_bar.cljs

@@ -89,7 +89,7 @@
 
 (rum/defc mobile-bar < rum/reactive
   []
-  (when (util/capacitor-new?)
+  (when (util/mobile?)
     (let [commands' (commands)]
       [:div#mobile-editor-toolbar
        [:div.toolbar-commands

+ 3 - 1
src/main/frontend/modules/outliner/pipeline.cljs

@@ -80,7 +80,9 @@
             (when-not (:graph/importing @state/state)
 
               (let [edit-block-f @(:editor/edit-block-fn @state/state)
-                    delete-blocks? (= (:outliner-op tx-meta) :delete-blocks)]
+                    delete-blocks? (and (= (:outliner-op tx-meta) :delete-blocks)
+                                        (:local-tx? tx-meta)
+                                        (not (:mobile-action-bar? tx-meta)))]
                 (state/set-state! :editor/edit-block-fn nil)
                 (when delete-blocks?
                   (util/mobile-keep-keyboard-open))