mirror of
https://github.com/logseq/logseq.git
synced 2026-05-23 12:14:06 +00:00
fix: open editor in quick add
This commit is contained in:
@@ -3938,9 +3938,7 @@
|
||||
(p/do!
|
||||
(db-async/<get-block graph (date/today))
|
||||
(p/let [add-page (db-async/<get-block graph (:db/id (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)))]
|
||||
(if (:block/_parent add-page)
|
||||
(let [block (last (ldb/sort-by-order (:block/_parent add-page)))]
|
||||
(edit-block! block :max {:container-id :unknown-container}))
|
||||
(when-not (:block/_parent add-page)
|
||||
(api-insert-new-block! "" {:page (:block/uuid add-page)
|
||||
:container-id :unknown-container})))
|
||||
(state/pub-event! [(if (util/mobile?)
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
(ns mobile.components.popup
|
||||
"Mobile popup"
|
||||
(:require [dommy.core :as dom]
|
||||
[frontend.db :as db]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.state :as state]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.shui.popup.core :as shui-popup]
|
||||
[logseq.shui.ui :as shui]
|
||||
[mobile.components.ui :as mobile-ui]
|
||||
[mobile.init :as init]
|
||||
[mobile.ionic :as ion]
|
||||
[mobile.state :as mobile-state]
|
||||
@@ -11,7 +16,7 @@
|
||||
|
||||
(defonce *last-popup-modal? (atom nil))
|
||||
|
||||
(defn warp-calc-commands-popup-side
|
||||
(defn wrap-calc-commands-popup-side
|
||||
[pos opts]
|
||||
(let [[side mh] (let [[_x y _ height] pos
|
||||
vh js/window.innerHeight
|
||||
@@ -29,7 +34,7 @@
|
||||
[event content-fn {:keys [id dropdown-menu?] :as opts}]
|
||||
(cond
|
||||
(and (keyword? id) (= "editor.commands" (namespace id)))
|
||||
(let [opts (warp-calc-commands-popup-side event opts)
|
||||
(let [opts (wrap-calc-commands-popup-side event opts)
|
||||
side (some-> 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)))]))))
|
||||
|
||||
@@ -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}}))
|
||||
|
||||
Reference in New Issue
Block a user