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 72
72
if (! hash && ! saved ) {
73
73
repl ?.set ({
74
74
// 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
76
77
});
77
78
78
79
modified = false ;
92
93
name = recovered .name ;
93
94
}
94
95
95
- repl .set ({ files });
96
+ repl .set ({ files , tailwind: recovered . tailwind ?? false });
96
97
} catch {
97
98
alert (` Couldn't load the code from the URL. Make sure you copied the link correctly. ` );
98
99
}
155
156
async function update_hash() {
156
157
// Only change hash when necessary to avoid polluting everyone's browser history
157
158
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 });
159
161
await set_hash (json );
160
162
}
161
163
}
210
212
if (modified ) {
211
213
// we can't save to the hash because it's an async operation, so we use
212
214
// 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 });
214
217
sessionStorage .setItem (STORAGE_KEY , json );
215
218
}
216
219
}}
Original file line number Diff line number Diff line change 45
45
46
46
if (! hash ) {
47
47
repl ?.set ({
48
- files: data .gist .components .map (munge )
48
+ files: data .gist .components .map (munge ),
49
+ tailwind: false // TODO
49
50
});
50
51
51
52
return ;
52
53
}
53
54
54
55
try {
55
56
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 });
57
58
} catch {
58
59
alert (` Couldn't load the code from the URL. Make sure you copied the link correctly. ` );
59
60
}
Original file line number Diff line number Diff line change @@ -393,12 +393,14 @@ export class Workspace {
393
393
this . #onreset?.( this . #files) ;
394
394
}
395
395
396
- reset ( new_files : Item [ ] , selected ?: string ) {
396
+ reset ( new_files : Item [ ] , options : { tailwind : boolean } , selected ?: string ) {
397
397
this . states . clear ( ) ;
398
398
this . set ( new_files , selected ) ;
399
399
400
400
this . mark_saved ( ) ;
401
401
402
+ this . #tailwind = options . tailwind ;
403
+
402
404
this . #onreset( new_files ) ;
403
405
this . #reset_diagnostics( ) ;
404
406
}
@@ -471,7 +473,7 @@ export class Workspace {
471
473
472
474
set tailwind ( value ) {
473
475
this . #tailwind = value ;
474
- this . #onreset ( this . #files ) ;
476
+ this . #onupdate ( this . #current ) ;
475
477
}
476
478
477
479
get vim ( ) {
Original file line number Diff line number Diff line change 67
67
export function toJSON() {
68
68
return {
69
69
imports: $bundle ?.imports ?? [],
70
- files: workspace .files
70
+ files: workspace .files ,
71
+ tailwind: workspace .tailwind
71
72
};
72
73
}
73
74
74
75
// 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' );
77
78
}
78
79
79
80
// TODO get rid
You can’t perform that action at this time.
0 commit comments