enhance (wip): customizable shortcuts

This commit is contained in:
Konstantinos Kaloutas
2023-04-24 17:40:37 +03:00
committed by Gabriel Horner
parent 02e8dbabd2
commit 9a89def497
6 changed files with 40 additions and 71 deletions

View File

@@ -181,4 +181,5 @@
(shortcut-table :shortcut.category/block-selection true)
(shortcut-table :shortcut.category/formatting true)
(shortcut-table :shortcut.category/toggle true)
(shortcut-table :shortcut.category/whiteboard true)
(shortcut-table :shortcut.category/others true)])

View File

@@ -11,6 +11,7 @@
[frontend.handler.common :as common-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.whiteboard :as whiteboard-handler]
[frontend.modules.shortcut.core :as shortcut]
[frontend.rum :refer [use-bounding-client-rect use-breakpoint
use-click-outside]]
[frontend.state :as state]
@@ -290,7 +291,8 @@
{:extension? true})])})]]
(tldraw-app page-name block-id)]))
(rum/defc whiteboard-route
(rum/defc whiteboard-route <
(shortcut/mixin :shortcut.handler/whiteboard)
[route-match]
(let [name (get-in route-match [:parameters :path :name])
{:keys [block-id]} (get-in route-match [:parameters :query])]

View File

@@ -71,6 +71,21 @@
:pdf/find {:binding "alt+f"
:fn pdf-utils/open-finder}
:whiteboard/lock {:binding "mod+l"
:fn #(.setLocked (state/active-tldraw-app) true)}
:whiteboard/unlock {:binding "mod+shift+l"
:fn #(.setLocked (state/active-tldraw-app) false)}
:whiteboard/group {:binding "mod+g"
:fn #(.doGroup (.-api ^js (state/active-tldraw-app)))}
:whiteboard/ungroup {:binding "mod+shift+g"
:fn #(.unGroup (.-api ^js (state/active-tldraw-app)))}
:whiteboard/toggle-grid {:binding "mod+shift+g"
:fn #(.toggleGrid (.-api ^js (state/active-tldraw-app)))}
:auto-complete/complete {:binding "enter"
:fn ui-handler/auto-complete-complete}
@@ -338,7 +353,7 @@
:graph/re-index {:fn (fn []
(p/let [multiple-windows? (ipc/ipc "graphHasMultipleWindows" (state/get-current-repo))]
(state/pub-event! [:graph/ask-for-re-index (atom multiple-windows?) nil])))
(state/pub-event! [:graph/ask-for-re-index (atom multiple-windows?) nil])))
:binding false}
:command/run {:binding "mod+shift+1"
@@ -507,6 +522,13 @@
:pdf/find])
(with-meta {:before m/enable-when-not-editing-mode!}))
:shortcut.handler/whiteboard
(-> (build-category-map [:whiteboard/lock
:whiteboard/unlock
:whiteboard/group
:whiteboard/ungroup])
(with-meta {:before m/enable-when-not-editing-mode!}))
:shortcut.handler/auto-complete
(build-category-map [:auto-complete/complete
:auto-complete/prev
@@ -552,8 +574,7 @@
:shortcut.handler/editor-global
(->
(build-category-map [
:graph/export-as-html
(build-category-map [:graph/export-as-html
:graph/open
:graph/remove
:graph/add
@@ -759,6 +780,12 @@
:ui/toggle-settings
:ui/toggle-contents]
:shortcut.category/whiteboard
[:whiteboard/lock
:whiteboard/unlock
:whiteboard/group
:whiteboard/ungroup]
:shortcut.category/others
[:pdf/previous-page
:pdf/next-page

View File

@@ -79,6 +79,11 @@
:editor/zoom-in "Zoom in editing block / Forwards otherwise"
:editor/zoom-out "Zoom out editing block / Backwards otherwise"
:editor/toggle-undo-redo-mode "Toggle undo redo mode (global or page only)"
:whiteboard/lock "Lock selected elements"
:whiteboard/unlock "Unlock selected elements"
:whiteboard/group "Group selected elements"
:whiteboard/ungroup "Ungroup selected elements"
:whiteboard/toggle-grid "Toggle the canvas grid"
:ui/toggle-brackets "Toggle whether to display brackets"
:go/search-in-page "Search blocks in the current page"
:go/electron-find-in-page "Find text in page"
@@ -145,6 +150,7 @@
:shortcut.category/block-command-editing "Block command editing"
:shortcut.category/block-selection "Block selection (press Esc to quit selection)"
:shortcut.category/toggle "Toggle"
:shortcut.category/whiteboard "Whiteboard"
:shortcut.category/others "Others"})
(def ^:large-vars/data-var dicts