Skip to content

Commit

Permalink
Add option to hide codemirror results
Browse files Browse the repository at this point in the history
  • Loading branch information
kimo-k committed Oct 28, 2023
1 parent 4f1c487 commit 4f04542
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/src/re_frame/docs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"eval"]])

(defn editor
[{:keys [source-str eval-result !view validators evaluable? editable? eval-on-init? on-change hover? focus? result-format]}]
[{:keys [source-str eval-result !view validators evaluable? editable? eval-on-init? on-change hover? focus? result-format result?]}]
(r/with-let
[eval! (fn [] (p/let [[status return-val] (eval-str (cm-string @!view))]
(reset! eval-result {:status status
Expand Down Expand Up @@ -173,7 +173,8 @@
:width "100%"
:margin-top "0.5rem"}}
[:div {:style {:flex 1}}
[editor-result @eval-result {:format result-format}]]
(when result?
[editor-result @eval-result {:format result-format}])]
(when evaluable?
[eval-button {:on-eval eval! :hover? @hover? :focus? @focus?}])]
[validation validators @eval-result]
Expand All @@ -186,6 +187,7 @@
:let [editable? (not (.. el -dataset -cmDocNoEdit))
evaluable? (not (.. el -dataset -cmDocNoEval))
eval-on-init? (not (.. el -dataset -cmDocNoEvalOnInit))
result? (not (.. el -dataset -cmDocNoResult))
result-format (keyword (or (.. el -dataset -cmDocResultFormat) "full"))
validator-els (.getElementsByClassName el "cm-doc-validator")
validators (into [] (comp
Expand All @@ -198,6 +200,7 @@
:editable? editable?
:evaluable? evaluable?
:eval-on-init? eval-on-init?
:result? result?
:result-format result-format
:hover? (r/atom false)
:focus? (r/atom false)
Expand Down

0 comments on commit 4f04542

Please sign in to comment.