mirror of https://github.com/logseq/logseq
parent
0de5ef64ff
commit
8583770dfc
|
@ -394,7 +394,7 @@
|
|||
:text-align "left"
|
||||
:font-weight 500
|
||||
:max-height 600
|
||||
:padding-bottom 200}}
|
||||
:padding-bottom 64}}
|
||||
[:h2.font-bold.text-lg page-name]
|
||||
(let [page (db/entity [:block/name (string/lower-case page-name)])]
|
||||
((state/get-page-blocks-cp) (state/get-current-repo) page (:sidebar? config)))]
|
||||
|
|
|
@ -81,27 +81,42 @@
|
|||
(swap! *installed dissoc install-id)))
|
||||
|
||||
|
||||
;; Sometimes backspace removes two chars instead of one
|
||||
;; https://github.com/logseq/logseq/issues/1965
|
||||
;; A workaround to ensure each shortcut group is only registered once
|
||||
|
||||
(defonce *registered-shortcuts-state (atom nil))
|
||||
|
||||
(defn- uninstall-shortcut-aux!
|
||||
[state handler-id]
|
||||
(some-> (get state :shortcut-key)
|
||||
uninstall-shortcut!)
|
||||
(swap! *registered-shortcuts-state dissoc handler-id))
|
||||
|
||||
(defn- install-shortcut-aux!
|
||||
[state handler-id]
|
||||
(if (get @*registered-shortcuts-state handler-id)
|
||||
state
|
||||
(let [install-id (-> handler-id
|
||||
(install-shortcut! {:state state}))]
|
||||
(swap! *registered-shortcuts-state assoc handler-id install-id)
|
||||
(assoc state :shortcut-key install-id))))
|
||||
|
||||
(defn mixin [handler-id]
|
||||
{:did-mount
|
||||
(fn [state]
|
||||
(let [install-id (-> handler-id
|
||||
(install-shortcut! {:state state}))]
|
||||
(assoc state :shortcut-key install-id)))
|
||||
(install-shortcut-aux! state handler-id))
|
||||
|
||||
:did-remount (fn [old-state new-state]
|
||||
|
||||
;; uninstall
|
||||
(-> (get old-state :shortcut-key)
|
||||
uninstall-shortcut!)
|
||||
(uninstall-shortcut-aux! old-state handler-id)
|
||||
|
||||
;; update new states
|
||||
(let [install-id (-> handler-id
|
||||
(install-shortcut! {:state new-state}))]
|
||||
(assoc new-state :shortcut-key install-id)))
|
||||
(install-shortcut-aux! new-state handler-id))
|
||||
:will-unmount
|
||||
(fn [state]
|
||||
(-> (get state :shortcut-key)
|
||||
uninstall-shortcut!)
|
||||
(uninstall-shortcut-aux! state handler-id)
|
||||
(dissoc state :shortcut-key))})
|
||||
|
||||
(defn unlisten-all []
|
||||
|
|
Loading…
Reference in New Issue