diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index 767a5d09c..512d0fd5b 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -491,8 +491,13 @@ (fn [e key-code] (let [key (gobj/get e "key") value (gobj/get input "value") + ctrlKey (gobj/get e "ctrlKey") + metaKey (gobj/get e "metaKey") pos (:pos (util/get-caret-pos input))] (cond + (or ctrlKey metaKey) + nil + (or (and (= key "#") (and diff --git a/src/main/frontend/db.cljs b/src/main/frontend/db.cljs index 25cc5536b..c1c808846 100644 --- a/src/main/frontend/db.cljs +++ b/src/main/frontend/db.cljs @@ -1180,8 +1180,15 @@ (string/join "\n")) :markdown - (str (subs content 0 (string/last-index-of content "---\n\n")) - "---\n\n") + (let [[m leading-spaces first-dashes] (re-find #"(\s*)(---\n)" content)] + (if m + (let [begin (count leading-spaces) + begin-inner (+ begin (count first-dashes)) + second-dashes "\n---\n" + end-inner (string/index-of content second-dashes begin-inner) + end (if end-inner (+ end-inner (count second-dashes)) begin)] + (subs content begin end)) + "")) content)))) diff --git a/src/main/frontend/keyboards.cljs b/src/main/frontend/keyboards.cljs index 00f81dba1..d711992fb 100644 --- a/src/main/frontend/keyboards.cljs +++ b/src/main/frontend/keyboards.cljs @@ -72,8 +72,7 @@ "ctrl+h" editor-handler/highlight-format! "ctrl+shift+a" editor-handler/select-all-blocks! "alt+shift+up" (fn [state e] (editor-handler/move-up-down e true)) - "alt+shift+down" (fn [state e] (editor-handler/move-up-down e false)) - "ctrl+c ctrl+s" (fn [state e] (search-handler/rebuild-indices!))} + "alt+shift+down" (fn [state e] (editor-handler/move-up-down e false))} (medley/map-keys util/->system-modifier))) (defonce chords @@ -83,7 +82,11 @@ "t r" ui-handler/toggle-right-sidebar! "t e" state/toggle-new-block-shortcut! "s" route-handler/toggle-between-page-and-file! - }) + "ctrl+c ctrl+s" (fn [state e] + (search-handler/rebuild-indices!) + ;; return false to prevent default browser behavior + ;; and stop event from bubbling + false)}) (defonce bind! (gobj/get mousetrap "bind"))