Web ページに CodeMirror を埋め込んで、複数のコード スニペットを 1 つずつ編集しようとしています。
これを行うには:
node-defs-atom
コード スニペットのマップを含む1 つの Reagent アトムを用意します。node-history-atom
見ているスニペットのキーを含む別の原子を持っています- CodeMirror の値をキーのコード マップの値に設定します。
機能しないものは次のとおりです。
(defn editor [node-defs-atom node-history-atom]
(reagent/create-class
{:reagent-render (fn [] (do [:textarea
{ :value (@node-defs-atom (last @node-history-atom))
:auto-complete "off"}]))
:component-did-mount (editor-did-mount node-defs-atom node-history-atom)
}))
(defn editor-did-mount [node-defs-atom node-history-atom]
(fn [this]
(let [codemirror (.fromTextArea js/CodeMirror
(reagent/dom-node this)
#js {:mode "clojure"
:lineNumbers true})]
...... )))
で変更node-history-atom
しreset!
ても、CodeMirror 内のテキストには何も影響しません。何がうまくいかないのか本当にわかりません。
参照先をどこに置くべきか誰かが教えてくれたら、(@node-defs-atom (last @node-history-atom))
とても感謝しています。
前もって感謝します!