Skip to content

Commit 20cf767

Browse files
committed
visual-syntax option should work outside of embedded mode
1 parent bb40067 commit 20cf767

File tree

1 file changed

+43
-28
lines changed

1 file changed

+43
-28
lines changed

src/interactive_syntax/core.cljs

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,8 @@
12101210
{:keys [hider-bars]
12111211
:as print-options} :print-options
12121212
editor-reset-ref :editor-reset
1213-
visr-run-ref :visr-run}]]
1213+
visr-run-ref :visr-run
1214+
visual-syntax :visual-syntax}]]
12141215
(let [edit (atom nil)
12151216
visrs (atom {})
12161217
key (random-uuid)
@@ -1253,11 +1254,12 @@
12531254
(reset! visrs {})
12541255
(when editor-reset-ref
12551256
(reset! editor-reset-ref true))
1256-
(env/reset-editors! @input set-text edit visrs cache
1257-
(codemirror-options) db #()
1258-
{:for-print for-print
1259-
:hider-bars hider-bars
1260-
:visr-run visr-run-ref}))))
1257+
(when visual-syntax
1258+
(env/reset-editors! @input set-text edit visrs cache
1259+
(codemirror-options) db #()
1260+
{:for-print for-print
1261+
:hider-bars hider-bars
1262+
:visr-run visr-run-ref})))))
12611263
(add-watch cache ::set-running?
12621264
(fn [k r o n]
12631265
(when (and editor-reset-ref (empty? (:queue n)))
@@ -1280,6 +1282,7 @@
12801282
hider-bars :hider-bars
12811283
:theme "neat"
12821284
:as print-options} :print-options
1285+
visual-syntax :visual-syntax
12831286
editor-reset-ref :editor-reset
12841287
visr-run-ref :visr-run}]]
12851288
@current-file
@@ -1299,11 +1302,12 @@
12991302
(reset! input value)
13001303
(when editor-reset-ref
13011304
(reset! editor-reset-ref true))
1302-
(env/reset-editors! @input set-text edit visrs
1303-
cache (codemirror-options) db
1304-
#() {:for-print for-print
1305-
:hider-bars hider-bars
1306-
:visr-run visr-run-ref}))
1305+
(when visual-syntax
1306+
(env/reset-editors! @input set-text edit visrs
1307+
cache (codemirror-options) db
1308+
#() {:for-print for-print
1309+
:hider-bars hider-bars
1310+
:visr-run visr-run-ref})))
13071311
:onCursor (fn [editor data]
13081312
(reset! cursor data))
13091313
:onScroll (fn [editor data]
@@ -1337,12 +1341,13 @@
13371341
(reset! editor-ref e))
13381342
(when editor-reset-ref
13391343
(reset! editor-reset-ref true))
1340-
(env/reset-editors! @input set-text edit visrs
1341-
cache (codemirror-options) db
1342-
#(reset! mounted? true)
1343-
{:for-print for-print
1344-
:hider-bars hider-bars
1345-
:visr-run visr-run-ref}))}]
1344+
(when visual-syntax
1345+
(env/reset-editors! @input set-text edit visrs
1346+
cache (codemirror-options) db
1347+
#(reset! mounted? true)
1348+
{:for-print for-print
1349+
:hider-bars hider-bars
1350+
:visr-run visr-run-ref})))}]
13461351
(when for-print
13471352
[:style {:type "text/css" :media "print"}
13481353
(css [:.CodeMirror-linenumber
@@ -1354,7 +1359,8 @@
13541359

13551360
(defn result-view [{:keys [output options]
13561361
:as db}
1357-
& [repl-ref]]
1362+
& [{repl-ref :editor
1363+
visual-syntax :visual-syntax}]]
13581364
(let [edit (atom nil)
13591365
cache (env/make-reset-editors-cache)
13601366
instances (atom [])
@@ -1397,7 +1403,8 @@
13971403
(add-watch output ::result-view watch-updater)
13981404
(fn [{:keys [output options]
13991405
:as db}
1400-
& [repl-ref]]
1406+
& [{repl-ref :editor
1407+
visual-syntax :visual-syntax}]]
14011408
[:> cm/UnControlled
14021409
{:value (string/join "\n" (filter string? @output))
14031410
:options (conj (env/codemirror-options db)
@@ -1467,6 +1474,7 @@
14671474
editor-reset-ref :editor-reset
14681475
repl-ref :repl
14691476
visr-run-ref :visr-run
1477+
visual-syntax :visual-syntax
14701478
:as opts}]]
14711479
(let [search (js/URLSearchParams. js/window.location.search)]
14721480
(chonky/setChonkyDefaults
@@ -1537,13 +1545,16 @@
15371545
:style {:height "100%"}}
15381546
[editor-view db {:editor-reset editor-reset-ref
15391547
:editor editor-ref
1540-
:visr-run visr-run-ref}]]
1548+
:visr-run visr-run-ref
1549+
:visual-syntax visual-syntax}]]
15411550
(if @app-pane
15421551
[:> SplitPane {:split (utils/swap-orientation @orientation)}
15431552
[:> Pane {:initialSize 1}
1544-
[result-view db repl-ref]]
1553+
[result-view db {:editor repl-ref
1554+
:visual-syntax visual-syntax}]]
15451555
@app-pane]
1546-
[result-view db repl-ref])]]
1556+
[result-view db {:editor repl-ref
1557+
:visual-syntax visual-syntax}])]]
15471558
[:div {:style {:flex "1 1 auto"
15481559
:overflow "auto"
15491560
:height "100%"
@@ -1555,7 +1566,8 @@
15551566
[:> SplitPane {:split @orientation}
15561567
[editor-view db {:editor-reset editor-reset-ref
15571568
:editor editor-ref
1558-
:visr-run visr-run-ref}]
1569+
:visr-run visr-run-ref
1570+
:visual-syntax visual-syntax}]
15591571
[result-view db repl-ref]]]]])]))
15601572

15611573
;; -------------------------
@@ -1718,12 +1730,15 @@
17181730
:gutters
17191731
#js ["CodeMirror-linenumbers"]
17201732
:foldGutter false}}]
1721-
(.getElementById js/document "app")),
1733+
(.getElementById js/document "app")),
17221734
fullscreen? (utils/render [editor-view db]
1723-
(.getElementById js/document "app")),
1724-
:else (utils/render [home-page db (when embedded?
1725-
{:editor-reset editor-reset-ref})]
1726-
(.getElementById js/document "app")))))))
1735+
(.getElementById js/document "app")),
1736+
:else (utils/render
1737+
[home-page db
1738+
(if embedded?
1739+
{:editor-reset editor-reset-ref}
1740+
{:visual-syntax (not= visual-syntax "false")})]
1741+
(.getElementById js/document "app")))))))
17271742

17281743
(defn init! [& [opts]]
17291744
(mount-root opts))

0 commit comments

Comments
 (0)