Skip to content

Commit

Permalink
fix: search bar cannot copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Weihua Lu committed May 19, 2021
1 parent 543904a commit 57d0436
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/main/frontend/modules/shortcut/config.cljs
Original file line number Diff line number Diff line change
@@ -256,6 +256,12 @@
:binding "mod+c mod+r"
:fn #(repo-handler/re-index! nfs-handler/rebuild-index!)}}

:shortcut.handler/misc
;; always overrides the copy due to "mod+c mod+s"
{:misc/copy
{:binding "mod+c"
:fn (fn [] (js/document.execCommand "copy"))}}

:shortcut.handler/global-non-editing-only
^{:before m/enable-when-not-editing-mode!}
{:ui/toggle-document-mode
12 changes: 9 additions & 3 deletions src/main/frontend/modules/shortcut/core.cljs
Original file line number Diff line number Diff line change
@@ -19,9 +19,13 @@
KeyCodes/UP KeyCodes/LEFT KeyCodes/DOWN KeyCodes/RIGHT])

(defn install-shortcut!
[handler-id {:keys [set-global-keys? prevent-default? state]
[handler-id {:keys [set-global-keys?
prevent-default?
skip-installed?
state]
:or {set-global-keys? true
prevent-default? false}}]
prevent-default? false
skip-installed? false}}]
(let [shortcut-map (dh/shortcut-map handler-id state)
handler (new KeyboardShortcutHandler js/window)]
;; set arrows enter, tab to global
@@ -55,12 +59,14 @@

(events/listen handler EventType/SHORTCUT_TRIGGERED f)

(swap! *installed merge data)
(when-not skip-installed?
(swap! *installed merge data))

install-id)))

(defn install-shortcuts!
[]
(install-shortcut! :shortcut.handler/misc {:skip-installed? true})
(->> [:shortcut.handler/editor-global
:shortcut.handler/global-non-editing-only
:shortcut.handler/global-prevent-default]

0 comments on commit 57d0436

Please sign in to comment.