mirror of https://github.com/logseq/logseq
parent
0de5ef64ff
commit
8583770dfc
|
@ -394,7 +394,7 @@
|
||||||
:text-align "left"
|
:text-align "left"
|
||||||
:font-weight 500
|
:font-weight 500
|
||||||
:max-height 600
|
:max-height 600
|
||||||
:padding-bottom 200}}
|
:padding-bottom 64}}
|
||||||
[:h2.font-bold.text-lg page-name]
|
[:h2.font-bold.text-lg page-name]
|
||||||
(let [page (db/entity [:block/name (string/lower-case 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)))]
|
((state/get-page-blocks-cp) (state/get-current-repo) page (:sidebar? config)))]
|
||||||
|
|
|
@ -81,27 +81,42 @@
|
||||||
(swap! *installed dissoc install-id)))
|
(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]
|
(defn mixin [handler-id]
|
||||||
{:did-mount
|
{:did-mount
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(let [install-id (-> handler-id
|
(install-shortcut-aux! state handler-id))
|
||||||
(install-shortcut! {:state state}))]
|
|
||||||
(assoc state :shortcut-key install-id)))
|
|
||||||
|
|
||||||
:did-remount (fn [old-state new-state]
|
:did-remount (fn [old-state new-state]
|
||||||
|
|
||||||
;; uninstall
|
;; uninstall
|
||||||
(-> (get old-state :shortcut-key)
|
(uninstall-shortcut-aux! old-state handler-id)
|
||||||
uninstall-shortcut!)
|
|
||||||
|
|
||||||
;; update new states
|
;; update new states
|
||||||
(let [install-id (-> handler-id
|
(install-shortcut-aux! new-state handler-id))
|
||||||
(install-shortcut! {:state new-state}))]
|
|
||||||
(assoc new-state :shortcut-key install-id)))
|
|
||||||
:will-unmount
|
:will-unmount
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(-> (get state :shortcut-key)
|
(uninstall-shortcut-aux! state handler-id)
|
||||||
uninstall-shortcut!)
|
|
||||||
(dissoc state :shortcut-key))})
|
(dissoc state :shortcut-key))})
|
||||||
|
|
||||||
(defn unlisten-all []
|
(defn unlisten-all []
|
||||||
|
|
Loading…
Reference in New Issue