Custom shortcut for inserting new heading

pull/645/head
Tienson Qin 2020-06-26 10:00:18 +08:00
parent 111c9de36c
commit 8e245296a3
2 changed files with 21 additions and 3 deletions

View File

@ -563,9 +563,23 @@
13 (fn [state e]
(let [{:keys [heading]} (get-state state)]
(when heading
(if (gobj/get e "shiftKey")
nil
(when-not (in-auto-complete? input)
(let [shortcut (when-let [v (state/get-shortcut repo :editor/new-heading)]
(string/lower-case (string/trim v)))
insert? (cond
config/mobile?
false
(and (= shortcut "alt+enter") (not (gobj/get e "altKey")))
false
(gobj/get e "shiftKey")
false
:else
true)]
(when (and
insert?
(not (in-auto-complete? input)))
(insert-new-heading! state))))))
;; up
38 (fn [state e]

View File

@ -380,3 +380,7 @@
(defn set-git-status!
[repo-url value]
(swap! state assoc-in [:git/status repo-url] value))
(defn get-shortcut
[repo key]
(get-in @state [:config repo :shortcuts key]))