From e812f46f3692e879e6a1be2db42c8a42bf890b87 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 7 Jul 2025 22:01:36 +0800 Subject: [PATCH] fix: open editor in quick add --- src/main/frontend/handler/editor.cljs | 4 +--- src/main/mobile/components/popup.cljs | 33 +++++++++++++++++++++++---- src/main/mobile/events.cljs | 4 +--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index ea392cee73..e136cf42af 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -3938,9 +3938,7 @@ (p/do! (db-async/ opts :content-props :side) max-h (some-> opts :max-popup-height (js/parseInt) (- 48)) _ (when max-h (js/document.documentElement.style.setProperty @@ -65,13 +70,30 @@ (set! shui/popup-show! popup-show!) (set! shui/popup-hide! popup-hide!) +(rum/defc inner-content < + {:will-unmount (fn [state] + (state/clear-edit!) + (init/keyboard-hide) + state)} + [content-fn] + (content-fn)) + (rum/defc popup < rum/reactive [] (let [{:keys [open? content-fn opts]} (rum/react mobile-state/*popup-data) initial-breakpoint (if (= (:id opts) :ls-quick-add) 1 0.75)] (when open? - (state/clear-edit!) - (init/keyboard-hide)) + (if (= :ls-quick-add (:id opts)) + (when-let [add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)] + (when (:block/_parent add-page) + (js/setTimeout + (fn [] + (let [block (last (ldb/sort-by-order (:block/_parent add-page)))] + (editor-handler/edit-block! block :max {:container-id :unknown-container}))) + 500))) + (do + (state/clear-edit!) + (init/keyboard-hide)))) (ion/modal (merge {:isOpen (boolean open?) @@ -86,4 +108,5 @@ (when-let [title (:title opts)] [:h2.py-2.opacity-40 title]) (when content-fn - (content-fn))])))) + (mobile-ui/classic-app-container-wrap + (inner-content content-fn)))])))) diff --git a/src/main/mobile/events.cljs b/src/main/mobile/events.cljs index 5ecf36fb28..e1b3bbcc4b 100644 --- a/src/main/mobile/events.cljs +++ b/src/main/mobile/events.cljs @@ -2,7 +2,6 @@ "Mobile events" (:require [frontend.components.quick-add :as quick-add] [frontend.handler.events :as events] - [mobile.components.ui :as mobile-ui] [mobile.init :as init] [mobile.state :as mobile-state] [promesa.core :as p])) @@ -16,6 +15,5 @@ (defmethod events/handle :dialog/mobile-quick-add [_] (mobile-state/set-popup! {:open? true :content-fn (fn [] - (mobile-ui/classic-app-container-wrap - (quick-add/quick-add))) + (quick-add/quick-add)) :opts {:id :ls-quick-add}}))