From c9741b235ee1e6127fe5a1a84de006f838ba300d Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 10 Oct 2022 15:28:42 +0200 Subject: [PATCH] fix codemirror --- resources/public/codemirror.cljs | 54 -------------------------------- resources/public/codemirror.html | 14 ++++++--- 2 files changed, 9 insertions(+), 59 deletions(-) delete mode 100644 resources/public/codemirror.cljs diff --git a/resources/public/codemirror.cljs b/resources/public/codemirror.cljs deleted file mode 100644 index 57a0a0e..0000000 --- a/resources/public/codemirror.cljs +++ /dev/null @@ -1,54 +0,0 @@ -(require '[clojure.string :as str]) -(declare cm) - -(defn eval-me [] - (js/scittle.core.eval_string (-> cm .-state .-doc .toString))) - -(def extension - (.of js/cv.keymap - (clj->js [{:key "Mod-Enter" - :run (fn [] - (prn :hoeooo) - (eval-me))} - #_{:key (str modifier "-Enter") - :shift (partial eval-top-level on-result) - :run (partial eval-at-cursor on-result)}]))) -(def cm - (let [doc (str/trim " -(require '[reagent.core :as r] - '[reagent.dom :as rdom]) - -(defonce state (r/atom {:clicks 0})) - -(defn my-component [] - [:div - [:p \"Clicks: \" (:clicks @state)] - [:p [:button {:on-click #(swap! state update :clicks inc)} - \"Click me!\"]]]) - -(rdom/render [my-component] (.getElementById js/document \"reagent\")) -")] - (js/cm.EditorView. #js {:doc doc - :extensions #js [js/cm.basicSetup, (js/lc.clojure), (.highest js/cs.Prec extension)] - :parent (js/document.querySelector "#app") - #_#_:dispatch (fn [tr] (-> cm (.update #js [tr])) (eval-me)) - }))) -(set! (.-eval_me js/globalThis) eval-me) -(set! (.-cm_instance js/globalThis) cm) - -(defn linux? [] - (some? (re-find #"(Linux)|(X11)" js/navigator.userAgent))) - -(defn mac? [] - (and (not (linux?)) - (some? (re-find #"(Mac)|(iPhone)|(iPad)|(iPod)" js/navigator.platform)))) - -(let [elt (js/document.getElementById "evalMe") - txt (.-innerText elt) - mod-symbol (if (mac?) - "⌘" - "⌃") - txt (str txt " " mod-symbol"-⏎")] - (set! (.-innerHTML elt) txt)) - -(eval-me) diff --git a/resources/public/codemirror.html b/resources/public/codemirror.html index c247c4d..371548e 100644 --- a/resources/public/codemirror.html +++ b/resources/public/codemirror.html @@ -29,14 +29,18 @@ } - +

Using @nextjournal/lang-clojure directly from npm in HTML!