mirror of https://github.com/logseq/logseq
fix: can't switch between modals by shortcuts
parent
b6abd05a97
commit
3a0fa79611
|
@ -36,9 +36,6 @@
|
|||
(rum/defcs command-palette <
|
||||
(shortcut/disable-all-shortcuts)
|
||||
(rum/local "" ::input)
|
||||
{:will-unmount (fn [state]
|
||||
(state/set-state! :ui/command-palette-open? false)
|
||||
state)}
|
||||
[state {:keys [commands limit]
|
||||
:or {limit 100}}]
|
||||
(let [input (::input state)]
|
||||
|
@ -59,13 +56,3 @@
|
|||
{:item-render render-command
|
||||
:class "cp__palette-results"
|
||||
:on-chosen (fn [cmd] (cp/invoke-command cmd))})]]))
|
||||
|
||||
(rum/defc command-palette-modal < rum/reactive
|
||||
[]
|
||||
(let [open? (state/sub :ui/command-palette-open?)]
|
||||
(when open?
|
||||
(state/set-modal!
|
||||
#(command-palette {:commands (cp/get-commands)})
|
||||
{:fullscreen? false
|
||||
:close-btn? false}))
|
||||
nil))
|
||||
|
|
|
@ -411,7 +411,7 @@
|
|||
:theme "monospace"}
|
||||
[:a.flex.fade-link.items-center
|
||||
{:style {:margin-left 12}
|
||||
:on-click #(state/toggle! :ui/command-palette-open?)}
|
||||
:on-click #(state/pub-event! :modal/command-palette)}
|
||||
(ui/icon "command" {:style {:font-size 20}})])])]]
|
||||
(let [recent-search (mapv (fn [q] {:type :search :data q}) (db/get-key-value :recent/search))
|
||||
pages (->> (db/get-key-value :recent/pages)
|
||||
|
|
|
@ -366,7 +366,7 @@
|
|||
(route-handler/sidebar-journals!)
|
||||
(route-handler/go-to-journals!)))
|
||||
:icon "calendar"})))
|
||||
|
||||
|
||||
(when enable-whiteboards?
|
||||
(sidebar-item
|
||||
{:class "whiteboard"
|
||||
|
@ -375,7 +375,7 @@
|
|||
:active (and (not srs-open?) (#{:whiteboard :whiteboards} route-name))
|
||||
:icon "whiteboard"
|
||||
:icon-extension? true}))
|
||||
|
||||
|
||||
(when (state/enable-flashcards? (state/get-current-repo))
|
||||
[:div.flashcards-nav
|
||||
(flashcards srs-open?)])
|
||||
|
@ -804,7 +804,6 @@
|
|||
(ui/notification)
|
||||
(ui/modal)
|
||||
(ui/sub-modal)
|
||||
(command-palette/command-palette-modal)
|
||||
(select/select-modal)
|
||||
(custom-context-menu)
|
||||
(plugins/custom-js-installer {:t t
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
|
||||
(defn invoke-command [{:keys [action] :as cmd}]
|
||||
(add-history cmd)
|
||||
(state/set-state! :ui/command-palette-open? false)
|
||||
(state/close-modal!)
|
||||
(action))
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
[frontend.components.plugins :as plugin]
|
||||
[frontend.components.search :as component-search]
|
||||
[frontend.components.shell :as shell]
|
||||
[frontend.components.command-palette :as command-palette]
|
||||
[frontend.config :as config]
|
||||
[frontend.context.i18n :refer [t]]
|
||||
[frontend.db :as db]
|
||||
|
@ -42,6 +43,7 @@
|
|||
[frontend.handler.user :as user-handler]
|
||||
[frontend.handler.shell :as shell-handler]
|
||||
[frontend.handler.web.nfs :as nfs-handler]
|
||||
[frontend.handler.command-palette :as cp]
|
||||
[frontend.mobile.core :as mobile]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.mobile.graph-picker :as graph-picker]
|
||||
|
@ -708,6 +710,12 @@
|
|||
opts))
|
||||
{:center? true :close-btn? false :close-backdrop? false}))
|
||||
|
||||
(defmethod handle :modal/command-palette [_]
|
||||
(state/set-modal!
|
||||
#(command-palette/command-palette {:commands (cp/get-commands)})
|
||||
{:fullscreen? false
|
||||
:close-btn? false}))
|
||||
|
||||
(defmethod handle :journal/insert-template [[_ page-name]]
|
||||
(let [page-name (util/page-name-sanity-lc page-name)]
|
||||
(when-let [page (db/pull [:block/name page-name])]
|
||||
|
|
|
@ -257,7 +257,7 @@
|
|||
|
||||
:go/search {:binding "mod+k"
|
||||
:fn #(do
|
||||
(editor-handler/escape-editing)
|
||||
(editor-handler/escape-editing false)
|
||||
(route-handler/go-to-search! :global))}
|
||||
|
||||
:go/electron-find-in-page {:binding "mod+f"
|
||||
|
@ -301,7 +301,7 @@
|
|||
:command-palette/toggle {:binding "mod+shift+p"
|
||||
:fn #(do
|
||||
(editor-handler/escape-editing)
|
||||
(state/toggle! :ui/command-palette-open?))}
|
||||
(state/pub-event! [:modal/command-palette]))}
|
||||
|
||||
:graph/export-as-html {:fn #(export-handler/export-repo-as-html!
|
||||
(state/get-current-repo))
|
||||
|
@ -499,8 +499,7 @@
|
|||
|
||||
:shortcut.handler/editor-global
|
||||
(->
|
||||
(build-category-map [:command/run
|
||||
:command-palette/toggle
|
||||
(build-category-map [
|
||||
:graph/export-as-html
|
||||
:graph/open
|
||||
:graph/remove
|
||||
|
@ -548,7 +547,9 @@
|
|||
:go/forward
|
||||
:search/re-index
|
||||
:sidebar/open-today-page
|
||||
:sidebar/clear])
|
||||
:sidebar/clear
|
||||
:command/run
|
||||
:command-palette/toggle])
|
||||
(with-meta {:before m/prevent-default-behavior}))
|
||||
|
||||
:shortcut.handler/misc
|
||||
|
|
|
@ -94,7 +94,6 @@
|
|||
:ui/file-component nil
|
||||
:ui/custom-query-components {}
|
||||
:ui/show-recent? false
|
||||
:ui/command-palette-open? false
|
||||
:ui/developer-mode? (or (= (storage/get "developer-mode") "true")
|
||||
false)
|
||||
;; remember scroll positions of visited paths
|
||||
|
@ -1338,16 +1337,24 @@ Similar to re-frame subscriptions"
|
|||
{:fullscreen? false
|
||||
:close-btn? true}))
|
||||
([modal-panel-content {:keys [id label fullscreen? close-btn? close-backdrop? center?]}]
|
||||
(when (seq (get-sub-modals))
|
||||
(close-sub-modal! true))
|
||||
(swap! state assoc
|
||||
:modal/id id
|
||||
:modal/label (or label (if center? "ls-modal-align-center" ""))
|
||||
:modal/show? (boolean modal-panel-content)
|
||||
:modal/panel-content modal-panel-content
|
||||
:modal/fullscreen? fullscreen?
|
||||
:modal/close-btn? close-btn?
|
||||
:modal/close-backdrop? (if (boolean? close-backdrop?) close-backdrop? true)) nil))
|
||||
(let [opened? (modal-opened?)]
|
||||
(when opened?
|
||||
(close-modal!))
|
||||
(when (seq (get-sub-modals))
|
||||
(close-sub-modal! true))
|
||||
|
||||
(async/go
|
||||
(when opened?
|
||||
(<! (async/timeout 100)))
|
||||
(swap! state assoc
|
||||
:modal/id id
|
||||
:modal/label (or label (if center? "ls-modal-align-center" ""))
|
||||
:modal/show? (boolean modal-panel-content)
|
||||
:modal/panel-content modal-panel-content
|
||||
:modal/fullscreen? fullscreen?
|
||||
:modal/close-btn? close-btn?
|
||||
:modal/close-backdrop? (if (boolean? close-backdrop?) close-backdrop? true))))
|
||||
nil))
|
||||
|
||||
(defn close-modal!
|
||||
[]
|
||||
|
|
Loading…
Reference in New Issue