File tree Expand file tree Collapse file tree 4 files changed +18
-11
lines changed
apps/svelte.dev/src/routes/(authed)/playground/[id] Expand file tree Collapse file tree 4 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 7272 if (! hash && ! saved ) {
7373 repl ?.set ({
7474 // TODO make this munging unnecessary (using JSON instead of structuredClone for better browser compat)
75- files: JSON .parse (JSON .stringify (data .gist .components )).map (munge )
75+ files: JSON .parse (JSON .stringify (data .gist .components )).map (munge ),
76+ tailwind: false // TODO
7677 });
7778
7879 modified = false ;
9293 name = recovered .name ;
9394 }
9495
95- repl .set ({ files });
96+ repl .set ({ files , tailwind: recovered . tailwind ?? false });
9697 } catch {
9798 alert (` Couldn't load the code from the URL. Make sure you copied the link correctly. ` );
9899 }
155156 async function update_hash() {
156157 // Only change hash when necessary to avoid polluting everyone's browser history
157158 if (modified ) {
158- const json = JSON .stringify ({ name , files: repl .toJSON ().files });
159+ const { files, tailwind } = repl .toJSON ();
160+ const json = JSON .stringify ({ name , files , tailwind });
159161 await set_hash (json );
160162 }
161163 }
210212 if (modified ) {
211213 // we can't save to the hash because it's an async operation, so we use
212214 // a short-lived sessionStorage value instead
213- const json = JSON .stringify ({ name , files: repl .toJSON ().files });
215+ const { files, tailwind } = repl .toJSON ();
216+ const json = JSON .stringify ({ name , files , tailwind });
214217 sessionStorage .setItem (STORAGE_KEY , json );
215218 }
216219 }}
Original file line number Diff line number Diff line change 4545
4646 if (! hash ) {
4747 repl ?.set ({
48- files: data .gist .components .map (munge )
48+ files: data .gist .components .map (munge ),
49+ tailwind: false // TODO
4950 });
5051
5152 return ;
5253 }
5354
5455 try {
5556 const recovered = JSON .parse (await decode_and_decompress_text (hash ));
56- repl .set ({ files: recovered .files });
57+ repl .set ({ files: recovered .files , tailwind: recovered . tailwind ?? false });
5758 } catch {
5859 alert (` Couldn't load the code from the URL. Make sure you copied the link correctly. ` );
5960 }
Original file line number Diff line number Diff line change @@ -393,12 +393,14 @@ export class Workspace {
393393 this . #onreset?.( this . #files) ;
394394 }
395395
396- reset ( new_files : Item [ ] , selected ?: string ) {
396+ reset ( new_files : Item [ ] , options : { tailwind : boolean } , selected ?: string ) {
397397 this . states . clear ( ) ;
398398 this . set ( new_files , selected ) ;
399399
400400 this . mark_saved ( ) ;
401401
402+ this . #tailwind = options . tailwind ;
403+
402404 this . #onreset( new_files ) ;
403405 this . #reset_diagnostics( ) ;
404406 }
@@ -471,7 +473,7 @@ export class Workspace {
471473
472474 set tailwind ( value ) {
473475 this . #tailwind = value ;
474- this . #onreset ( this . #files ) ;
476+ this . #onupdate ( this . #current ) ;
475477 }
476478
477479 get vim ( ) {
Original file line number Diff line number Diff line change 6767 export function toJSON() {
6868 return {
6969 imports: $bundle ?.imports ?? [],
70- files: workspace .files
70+ files: workspace .files ,
71+ tailwind: workspace .tailwind
7172 };
7273 }
7374
7475 // TODO get rid
75- export async function set(data : { files: File []; css ? : string }) {
76- workspace .reset (data .files , ' App.svelte' );
76+ export async function set(data : { files: File []; tailwind ? : boolean }) {
77+ workspace .reset (data .files , { tailwind: data . tailwind ?? false }, ' App.svelte' );
7778 }
7879
7980 // TODO get rid
You can’t perform that action at this time.
0 commit comments