fix: keep keyboard open when editing another block

This commit is contained in:
Tienson Qin
2025-08-06 16:50:22 +08:00
parent 2c0affde1b
commit 66f381a331
2 changed files with 60 additions and 58 deletions

View File

@@ -8,11 +8,11 @@
[frontend.state :as state]
[frontend.ui :as ui]
[logseq.db.frontend.entity-util :as entity-util]
[logseq.shui.silkhq :as silkhq]
[logseq.shui.ui :as shui]
[mobile.components.ui :as mobile-ui]
[mobile.init :as init]
[mobile.state :as mobile-state]
[logseq.shui.silkhq :as silkhq]
[promesa.core :as p]
[rum.core :as rum]))
@@ -28,63 +28,64 @@
(init/keyboard-hide))
(silkhq/bottom-sheet
{:presented (boolean open?)
:onPresentedChange (fn [v?]
(when (false? v?)
(mobile-state/set-singleton-modal! nil)
(state/clear-edit!)
(state/pub-event! [:mobile/keyboard-will-hide])))}
(silkhq/bottom-sheet-portal
(silkhq/bottom-sheet-view
{:class "block-modal-page"}
(silkhq/bottom-sheet-backdrop)
(silkhq/bottom-sheet-content
{:class "app-silk-sheet-scroll-content"}
(silkhq/scroll {:as-child true}
(silkhq/scroll-view
{:class "app-silk-scroll-view"}
(silkhq/scroll-content
{:class "app-silk-scroll-content"}
[:div.app-silk-scroll-content-inner
[:div.flex.justify-between.items-center.block-modal-page-header
[:a.opacity-40.active:opacity-60.px-2
{:on-pointer-down close!}
(shui/tabler-icon "chevron-down" {:size 18 :stroke 3})]
[:a.opacity-40.active:opacity-60.pr-1
{:on-pointer-down (fn []
(mobile-ui/open-popup!
(fn []
[:div.-mx-2
(ui/menu-link
{:on-click #(mobile-ui/close-popup!)}
[:span.text-lg.flex.gap-2.items-center
(shui/tabler-icon "copy" {:class "opacity-80" :size 22})
"Copy"])
{:presented (boolean open?)
:onPresentedChange (fn [v?]
(when (false? v?)
(mobile-state/set-singleton-modal! nil)
(state/clear-edit!)
(state/pub-event! [:mobile/keyboard-will-hide])))}
(silkhq/bottom-sheet-portal
(silkhq/bottom-sheet-view
{:class "block-modal-page"
:inertOutside false}
(silkhq/bottom-sheet-backdrop)
(silkhq/bottom-sheet-content
{:class "app-silk-sheet-scroll-content"}
(silkhq/scroll {:as-child true}
(silkhq/scroll-view
{:class "app-silk-scroll-view"}
(silkhq/scroll-content
{:class "app-silk-scroll-content"}
[:div.app-silk-scroll-content-inner
[:div.flex.justify-between.items-center.block-modal-page-header
[:a.opacity-40.active:opacity-60.px-2
{:on-pointer-down close!}
(shui/tabler-icon "chevron-down" {:size 18 :stroke 3})]
[:a.opacity-40.active:opacity-60.pr-1
{:on-pointer-down (fn []
(mobile-ui/open-popup!
(fn []
[:div.-mx-2
(ui/menu-link
{:on-click #(mobile-ui/close-popup!)}
[:span.text-lg.flex.gap-2.items-center
(shui/tabler-icon "copy" {:class "opacity-80" :size 22})
"Copy"])
(ui/menu-link
{:on-click #(-> (shui/dialog-confirm!
(str "⚠️ Are you sure you want to delete this "
(if (entity-util/page? block) "page" "block")
"?"))
(p/then
(fn []
(mobile-ui/close-popup!)
(some->
(:block/uuid block)
(page-handler/<delete!
(fn [] (close!))
{:error-handler
(fn [{:keys [msg]}]
(notification/show! msg :warning))})))))}
[:span.text-lg.flex.gap-2.items-center.text-red-700
(shui/tabler-icon "trash" {:class "opacity-80" :size 22})
"Delete"])])
{:title "Actions"
:type :action-sheet}))}
(shui/tabler-icon "dots-vertical" {:size 18 :stroke 2})]]
(ui/menu-link
{:on-click #(-> (shui/dialog-confirm!
(str "⚠️ Are you sure you want to delete this "
(if (entity-util/page? block) "page" "block")
"?"))
(p/then
(fn []
(mobile-ui/close-popup!)
(some->
(:block/uuid block)
(page-handler/<delete!
(fn [] (close!))
{:error-handler
(fn [{:keys [msg]}]
(notification/show! msg :warning))})))))}
[:span.text-lg.flex.gap-2.items-center.text-red-700
(shui/tabler-icon "trash" {:class "opacity-80" :size 22})
"Delete"])])
{:title "Actions"
:type :action-sheet}))}
(shui/tabler-icon "dots-vertical" {:size 18 :stroke 2})]]
;; block page content
[:div.block-modal-page-content
(when open?
(mobile-ui/classic-app-container-wrap
(page/page-cp (db/entity [:block/uuid (:block/uuid block)]))))]])))))))))
[:div.block-modal-page-content
(when open?
(mobile-ui/classic-app-container-wrap
(page/page-cp (db/entity [:block/uuid (:block/uuid block)]))))]])))))))))

View File

@@ -87,6 +87,7 @@
(silkhq/bottom-sheet-portal
(silkhq/bottom-sheet-view
{:class (str "app-silk-popup-sheet-view as-" (name (or (:type opts) "default")))
:inertOutside false
:onTravelEnd (fn []
(when quick-add?
(js/setTimeout #(editor-handler/quick-add-open-last-block!) 50)))}