@@ -2,9 +2,9 @@ use std::sync::Arc;
22
33use itertools:: Itertools ;
44use leptos:: {
5- component, create_effect, create_node_ref, create_rw_signal, ev, event_target_value, html, spawn_local ,
6- use_context, view, IntoView , RwSignal , Signal , SignalGetUntracked , SignalSet , SignalUpdate ,
7- SignalWith , SignalWithUntracked ,
5+ component, create_effect, create_node_ref, create_rw_signal, ev, event_target_value, html,
6+ spawn_local , use_context, view, IntoView , RwSignal , Signal , SignalGetUntracked , SignalSet ,
7+ SignalUpdate , SignalWith , SignalWithUntracked ,
88} ;
99use simplicityhl:: parse:: ParseFromStr ;
1010use simplicityhl:: simplicity:: jet:: elements:: ElementsEnv ;
@@ -176,30 +176,35 @@ pub fn ProgramTab() -> impl IntoView {
176176 let update_program_text = move |event : ev:: Event | {
177177 program. text . set ( event_target_value ( & event) ) ;
178178 } ;
179-
179+
180180 // Initialize CodeMirror when textarea is mounted (optional enhancement)
181181 create_effect ( move |_prev_value| {
182182 if let Some ( textarea) = textarea_ref. get ( ) {
183183 // Only initialize once
184184 spawn_local ( async move {
185185 // Small delay to ensure CodeMirror is loaded
186186 gloo_timers:: future:: TimeoutFuture :: new ( 50 ) . await ;
187-
187+
188188 if let Some ( window) = web_sys:: window ( ) {
189189 // Check if CodeMirror and our init function exist
190- let has_codemirror = js_sys:: Reflect :: has ( & window, & "CodeMirror" . into ( ) ) . unwrap_or ( false ) ;
191-
190+ let has_codemirror =
191+ js_sys:: Reflect :: has ( & window, & "CodeMirror" . into ( ) ) . unwrap_or ( false ) ;
192+
192193 if has_codemirror {
193- if let Ok ( simplicity_editor) = js_sys:: Reflect :: get ( & window, & "SimplicityEditor" . into ( ) ) {
194+ if let Ok ( simplicity_editor) =
195+ js_sys:: Reflect :: get ( & window, & "SimplicityEditor" . into ( ) )
196+ {
194197 // Call SimplicityEditor.init() if it exists
195- if let Ok ( init_fn) = js_sys:: Reflect :: get ( & simplicity_editor, & "init" . into ( ) ) {
198+ if let Ok ( init_fn) =
199+ js_sys:: Reflect :: get ( & simplicity_editor, & "init" . into ( ) )
200+ {
196201 if let Some ( init_fn) = init_fn. dyn_ref :: < js_sys:: Function > ( ) {
197202 let textarea_id = "program-input" ;
198203 let initial_value = textarea. value ( ) ;
199204 let _ = init_fn. call2 (
200205 & simplicity_editor,
201206 & textarea_id. into ( ) ,
202- & initial_value. into ( )
207+ & initial_value. into ( ) ,
203208 ) ;
204209 }
205210 }
@@ -209,7 +214,7 @@ pub fn ProgramTab() -> impl IntoView {
209214 } ) ;
210215 }
211216 } ) ;
212-
217+
213218 let insert_4_spaces = move || {
214219 let element = textarea_ref. get ( ) . expect ( "<textarea> should be mounted" ) ;
215220 if let Ok ( Some ( start) ) = element. selection_start ( ) {
0 commit comments