diff --git a/README.md b/README.md index 15cecc19..0fd71f1e 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ Enabling a decent Clojure/Script editor experience in the browser. Built for and * Expand/Contract: Alt + β / β or Mod + 1 / 2 π§ **Prepared for evaluation** -* At Cursor: Alt + β -* Top-level form: Alt + β§ + β -* Cell: Mod + β +* At Cursor: Mod + β +* Top-level form: Mod + β§ + β +* Cell: Alt + β **π§Ή Autoformatting** following [Tonskyβs Better Clojure Formatting](https://tonsky.me/blog/clojurefmt/) diff --git a/demo/src/nextjournal/clojure_mode/demo.cljs b/demo/src/nextjournal/clojure_mode/demo.cljs index 70269479..c8b9bcca 100644 --- a/demo/src/nextjournal/clojure_mode/demo.cljs +++ b/demo/src/nextjournal/clojure_mode/demo.cljs @@ -64,8 +64,8 @@ (j/obj :state (test-utils/make-state (cond-> #js [extensions] - eval? (.concat #js [(eval-region/extension {:modifier "Alt"}) - (demo.sci/extension {:modifier "Alt" + eval? (.concat #js [(eval-region/extension {:modifier "Meta"}) + (demo.sci/extension {:modifier "Meta" :on-result (partial reset! last-result)})])) source) :parent el)))))] @@ -211,7 +211,7 @@ (j/assoc! (js/document.getElementById "viewer-stylesheet") :innerHTML (rc/inline "stylesheets/viewer.css")) - (rdom/render [key-bindings-table (merge keymap/paredit-keymap* (demo.sci/keymap* "Alt"))] (js/document.getElementById "docs")) + (rdom/render [key-bindings-table (merge keymap/paredit-keymap* (demo.sci/keymap* "Mod"))] (js/document.getElementById "docs")) (rdom/render [:div.rounded-md.mb-0.text-sm.monospace.overflow-auto.relative.border.shadow-lg.bg-white [markdown-editor {:doc "# Hello Markdown diff --git a/demo/src/nextjournal/clojure_mode/demo/sci.cljs b/demo/src/nextjournal/clojure_mode/demo/sci.cljs index aa783a20..82546e40 100644 --- a/demo/src/nextjournal/clojure_mode/demo/sci.cljs +++ b/demo/src/nextjournal/clojure_mode/demo/sci.cljs @@ -14,13 +14,13 @@ (catch js/Error e {:error (str (.-message e))}))))) -(j/defn eval-at-cursor [on-result ^:js {:keys [state]}] +(j/defn eval-at-cursor* [on-result ^:js {:keys [state]}] (some->> (eval-region/cursor-node-string state) (eval-string) (on-result)) true) -(j/defn eval-top-level [on-result ^:js {:keys [state]}] +(j/defn eval-top-level* [on-result ^:js {:keys [state]}] (some->> (eval-region/top-level-string state) (eval-string) (on-result)) @@ -35,7 +35,7 @@ (defn keymap* [modifier] {:eval-cell - [{:key "Mod-Enter" + [{:key "Alt-Enter" :doc "Evaluate cell"}] :eval-at-cursor [{:key (str modifier "-Enter") @@ -48,8 +48,10 @@ on-result]}] (.of view/keymap (j/lit - [{:key "Mod-Enter" + [{:key "Alt-Enter" :run (partial eval-cell on-result)} {:key (str modifier "-Enter") - :shift (partial eval-top-level on-result) - :run (partial eval-at-cursor on-result)}]))) + :shift (j/fn eval-top-level [result] + (eval-top-level* on-result result)) + :run (j/fn eval-at-cursor [result] + (eval-at-cursor* on-result result))}]))) diff --git a/public/index.html b/public/index.html index 77e11d95..bafb199f 100644 --- a/public/index.html +++ b/public/index.html @@ -166,7 +166,7 @@