diff --git a/web/src/main/frontend/components/editor.cljs b/web/src/main/frontend/components/editor.cljs index 040d1c6d6..caad2a67c 100644 --- a/web/src/main/frontend/components/editor.cljs +++ b/web/src/main/frontend/components/editor.cljs @@ -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] diff --git a/web/src/main/frontend/state.cljs b/web/src/main/frontend/state.cljs index 426964a84..d5441bf6f 100644 --- a/web/src/main/frontend/state.cljs +++ b/web/src/main/frontend/state.cljs @@ -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]))