fix(ui): code block theme when toggling theme

This commit is contained in:
charlie
2021-06-01 14:07:01 +08:00
committed by Tienson Qin
parent bef8d0da68
commit 81ae683689
3 changed files with 12 additions and 15 deletions

View File

@@ -113,8 +113,9 @@
(let [editor @editor-atom
doc (.getDoc editor)
code (nth (:rum/args state) 3)]
(.setValue doc code))
(let [[config id attr code] (:rum/args state)
(.setValue doc code)
@editor-atom)
(let [[config id attr code theme] (:rum/args state)
original-mode (get attr :data-lang)
mode (or original-mode "javascript")
clojure? (contains? #{"clojure" "clj" "text/x-clojure" "cljs" "cljc"} mode)
@@ -127,7 +128,7 @@
(when textarea
(from-textarea textarea
#js {:mode mode
:theme (if dark? "solarized dark" "solarized")
:theme (str "solarized " theme)
:matchBrackets lisp?
:autoCloseBrackets true
:lineNumbers true
@@ -171,9 +172,11 @@
(load-and-render! state)
state)
:did-update (fn [state]
(when-let [editor @(:editor-atom state)]
(.setOption editor "theme" (str "solarized " (nth (state :rum/args) 4))))
(load-and-render! state)
state)}
[state config id attr code options]
[state config id attr code theme options]
[:div.extensions__code
[:div.extensions__code-lang
(let [mode (string/lower-case (get attr :data-lang "javascript"))]