mirror of
https://github.com/logseq/logseq.git
synced 2026-04-26 07:05:10 +00:00
Update codemirror
This commit is contained in:
@@ -387,7 +387,10 @@
|
||||
lisp-like? (contains? #{"scheme" "lisp" "clojure" "edn"} mode)
|
||||
config-edit? (and (:file? config) (string/ends-with? (:file-path config) "config.edn"))
|
||||
textarea (gdom/getElement id)
|
||||
default-cm-options {:theme (str "solarized " theme)
|
||||
radix-color (state/sub :ui/radix-color)
|
||||
default-cm-options {:theme (if radix-color
|
||||
(str "lsradix " theme)
|
||||
(str "solarized " theme))
|
||||
:autoCloseBrackets true
|
||||
:lineNumbers true
|
||||
:matchBrackets lisp-like?
|
||||
@@ -412,8 +415,12 @@
|
||||
(when config-edit?
|
||||
{:hintOptions {}})
|
||||
user-options)
|
||||
theme-mode (state/sub :ui/theme)
|
||||
system-theme-mode (state/sub :ui/system-theme)
|
||||
editor (when textarea
|
||||
(from-textarea textarea (clj->js cm-options)))]
|
||||
(from-textarea textarea (clj->js cm-options)))
|
||||
element-key (str "editor-" id "-" radix-color "-" theme-mode "-" system-theme-mode "-" theme)]
|
||||
(js/console.log "element-key: " element-key theme)
|
||||
(when editor
|
||||
(let [textarea-ref (rum/ref-node state textarea-ref-name)
|
||||
element (.getWrapperElement editor)]
|
||||
@@ -470,17 +477,29 @@
|
||||
(let [editor (render! state)]
|
||||
(reset! editor-atom editor)))))
|
||||
|
||||
(defn get-theme! []
|
||||
(if (state/sub :ui/radix-color)
|
||||
(str "lsradix " (state/sub :ui/theme))
|
||||
(str "solarized " (state/sub :ui/theme))))
|
||||
|
||||
(rum/defcs editor < rum/reactive
|
||||
{:init (fn [state]
|
||||
(let [[_ _ _ code _ options] (:rum/args state)]
|
||||
(assoc state
|
||||
:editor-atom (atom nil)
|
||||
:calc-atom (atom (calc/eval-lines code))
|
||||
:code-options (atom options))))
|
||||
:code-options (atom options)
|
||||
:last-theme (atom (get-theme!)))))
|
||||
:did-mount (fn [state]
|
||||
(load-and-render! state)
|
||||
state)
|
||||
:did-update (fn [state]
|
||||
(let [next-theme (get-theme!)
|
||||
last-theme @(:last-theme state)
|
||||
editor (some-> state :editor-atom deref)]
|
||||
(when (and editor (not= next-theme last-theme))
|
||||
(reset! (:last-theme state) next-theme)
|
||||
(.setOption editor "theme" next-theme)))
|
||||
(reset! (:code-options state) (last (:rum/args state)))
|
||||
(when-not (:file? (first (:rum/args state)))
|
||||
(let [code (nth (:rum/args state) 3)
|
||||
|
||||
Reference in New Issue
Block a user