@@ -8,7 +8,6 @@ import { Env, PID } from 'src/api'
8
8
import { GistrSettings } from 'src/settings/settings'
9
9
import { lng } from 'src/lang'
10
10
import { SaturynHandleSyntax } from 'src/api/Saturyn'
11
- import { nanoid } from 'nanoid'
12
11
13
12
/*
14
13
Basic Declrations
@@ -177,7 +176,7 @@ zoom: ${n_zoom}
177
176
compile url to gist
178
177
*/
179
178
180
- let gistSrcURL = ! bIsEmpty ( file ) ? `https://${ host } ${ username } /${ uuid } .json?file=${ file } ` : `https://${ host } ${ username } /${ uuid } .json`
179
+ let gistSrcURL = ! bIsEmpty ( file ) ? `https://${ host } ${ username } /${ uuid } .json?file=${ file } ` : `https://${ host } ${ username } /${ uuid } .json`
181
180
182
181
/*
183
182
This should be a theme specified by the user in the codeblock; NOT their theme setting
@@ -206,11 +205,11 @@ zoom: ${n_zoom}
206
205
const req = await request ( reqUrlParams )
207
206
const json = JSON . parse ( req ) as ItemJSON
208
207
209
- return this . GistGenerate ( el , host , uuid , json , bMatchGithub , styles )
208
+ return this . GistGenerate ( plugin , el , host , uuid , json , bMatchGithub , styles )
210
209
}
211
210
catch ( err )
212
211
{
213
- return this . ThrowError ( el , data , `Invalid gist url ${ gistSrcURL } ( ${ err } )` )
212
+ return this . ThrowError ( el , data , `Invalid gist url ${ gistSrcURL } ( ${ err } )` )
214
213
}
215
214
}
216
215
@@ -243,14 +242,14 @@ zoom: ${n_zoom}
243
242
create new iframe for each gist, assign it a uid, set the needed attributes, and generate the css, js
244
243
*/
245
244
246
- private async GistGenerate ( el : HTMLElement , host : string , uuid : string , json : ItemJSON , bGithub : boolean , style : StyleProperties )
245
+ private async GistGenerate ( plugin : GistrPlugin , el : HTMLElement , host : string , uuid : string , json : ItemJSON , bGithub : boolean , style : StyleProperties )
247
246
{
248
247
249
248
/*
250
249
create uuid and iframe
251
250
*/
252
251
253
- const gid = `${ sender } -${ uuid } -${ nanoid ( ) } `
252
+ const gid = `${ sender } -${ uuid } -${ plugin . generateUuid ( ) } `
254
253
const ct_iframe = document . createElement ( 'iframe' )
255
254
ct_iframe . id = gid
256
255
@@ -265,26 +264,26 @@ zoom: ${n_zoom}
265
264
policy directive error if certain attributes arent used. doesnt affect the plugin, but erors are bad
266
265
*/
267
266
268
- ct_iframe . setAttribute ( 'csp' , "default-src * data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';" )
267
+ ct_iframe . setAttribute ( 'csp' , "default-src * data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';" )
269
268
270
269
/*
271
270
assign css, body, js
272
271
*/
273
272
274
- let css_theme_ovr = ( style . theme !== "" ) ? style . theme . toLowerCase ( ) : ""
275
- let css_theme_sel = ( css_theme_ovr !== "" ) ? css_theme_ovr : ( this . settings . theme . toLowerCase ( ) == "dark" ) ? "dark" : ( this . settings . theme . toLowerCase ( ) == "light" ) ? "light" : "light"
276
- let css_og = ""
277
- let css_gh = ""
273
+ let css_theme_ovr = ( style . theme !== "" ) ? style . theme . toLowerCase ( ) : ""
274
+ let css_theme_sel = ( css_theme_ovr !== "" ) ? css_theme_ovr : ( this . settings . theme . toLowerCase ( ) == "dark" ) ? "dark" : ( this . settings . theme . toLowerCase ( ) == "light" ) ? "light" : "light"
275
+ let css_og = ""
276
+ let css_gh = ""
278
277
279
- const content_css = await this . GetCSS ( el , uuid , ( bGithub ? json . stylesheet : json . embed . css ) )
280
- const content_body = ( bGithub ? json . div : "" )
281
- const content_js = ( bGithub ? "" : await this . GetJavascript ( el , uuid , ( css_theme_sel == "dark" ? json . embed . js_dark : json . embed . js ) ) )
278
+ const content_css = await this . GetCSS ( el , uuid , ( bGithub ? json . stylesheet : json . embed . css ) )
279
+ const content_body = ( bGithub ? json . div : "" )
280
+ const content_js = ( bGithub ? "" : await this . GetJavascript ( el , uuid , ( css_theme_sel == "dark" ? json . embed . js_dark : json . embed . js ) ) )
282
281
283
282
/*
284
283
Declare custom css override
285
284
*/
286
285
287
- const css_override = ( ( bGithub && this . settings . css_gh && this . settings . css_gh . length > 0 ) ? ( this . settings . css_gh ) : ( this . settings . css_og && this . settings . css_og . length > 0 && this . settings . css_og ) ) || ""
286
+ const css_override = ( ( bGithub && this . settings . css_gh && this . settings . css_gh . length > 0 ) ? ( this . settings . css_gh ) : ( this . settings . css_og && this . settings . css_og . length > 0 && this . settings . css_og ) ) || ""
288
287
289
288
/*
290
289
Update style theme value
@@ -348,7 +347,7 @@ zoom: ${n_zoom}
348
347
349
348
</head>
350
349
351
- <body class="gistr-theme-${ css_theme_sel } ">
350
+ <body class="gistr-theme-${ css_theme_sel } ">
352
351
${ content_body }
353
352
</body>
354
353
</html>
@@ -379,64 +378,64 @@ zoom: ${n_zoom}
379
378
return `
380
379
::-webkit-scrollbar
381
380
{
382
- width: 6px;
383
- height: 10px;
381
+ width: 6px;
382
+ height: 10px;
384
383
}
385
384
386
385
::-webkit-scrollbar-track
387
386
{
388
- background-color: transparent;
389
- border-radius: 5px;
390
- margin: 1px;
387
+ background-color: transparent;
388
+ border-radius: 5px;
389
+ margin: 1px;
391
390
}
392
391
393
392
::-webkit-scrollbar-thumb
394
393
{
395
- border-radius: 10px;
396
- background-color: ${ css_og_sb_color } ;
394
+ border-radius: 10px;
395
+ background-color: ${ css_og_sb_color } ;
397
396
}
398
397
399
398
.opengist-embed .code
400
399
{
401
- padding-top: ${ this . settings . blk_pad_t } px;
402
- padding-bottom: ${ this . settings . blk_pad_b } px;
403
- border-top: ${ css_og_bg_header_bor } ;
404
- background-color: ${ css_og_bg_color } ;
405
- width: fit-content;
406
- margin-top: -1px;
407
- background: ${ css_og_bg } ;
408
- background-size: cover;
400
+ padding-top: ${ this . settings . blk_pad_t } px;
401
+ padding-bottom: ${ this . settings . blk_pad_b } px;
402
+ border-top: ${ css_og_bg_header_bor } ;
403
+ background-color: ${ css_og_bg_color } ;
404
+ width: fit-content;
405
+ margin-top: -1px;
406
+ background: ${ css_og_bg } ;
407
+ background-size: cover;
409
408
}
410
409
411
410
.opengist-embed .mb-4
412
411
{
413
- margin-bottom: 1rem;
414
- backdrop-filter: opacity(0);
415
- --tw-bg-opacity: 1;
416
- background-color: ${ css_og_bg_header_bg } ;
417
- opacity: ${ css_og_opacity } ;
412
+ margin-bottom: 1rem;
413
+ backdrop-filter: opacity(0);
414
+ --tw-bg-opacity: 1;
415
+ background-color: ${ css_og_bg_header_bg } ;
416
+ opacity: ${ css_og_opacity } ;
418
417
}
419
418
420
419
.opengist-embed .line-code
421
420
{
422
- color: #${ css_og_tx_color_user } ;
421
+ color: #${ css_og_tx_color_user } ;
423
422
}
424
423
425
424
.opengist-embed .code .line-num
426
425
{
427
- color: #${ css_og_tx_color_user } ;
428
- opacity: 0.5;
426
+ color: #${ css_og_tx_color_user } ;
427
+ opacity: 0.5;
429
428
}
430
429
431
430
.opengist-embed .code .line-num:hover
432
431
{
433
- color: #${ css_og_tx_color_user } ;
434
- opacity: 1;
432
+ color: #${ css_og_tx_color_user } ;
433
+ opacity: 1;
435
434
}
436
435
437
436
.opengist-embed .whitespace-pre
438
437
{
439
- white-space: ${ css_og_wrap } ;
438
+ white-space: ${ css_og_wrap } ;
440
439
}
441
440
`
442
441
}
@@ -476,7 +475,7 @@ zoom: ${n_zoom}
476
475
::-webkit-scrollbar-thumb
477
476
{
478
477
border-radius: 10px;
479
- background-color: ${ css_gh_sb_color } ;
478
+ background-color: ${ css_gh_sb_color } ;
480
479
}
481
480
482
481
body
@@ -490,7 +489,7 @@ zoom: ${n_zoom}
490
489
backdrop-filter: opacity( 0 );
491
490
background-color: rgb( 35 36 41/var( --tw-bg-opacity ) );
492
491
border: 2px solid rgba( 255, 255, 255, 0.1 );
493
- opacity: ${ css_gh_opacity } ;
492
+ opacity: ${ css_gh_opacity } ;
494
493
}
495
494
496
495
body .gist .gist-data
@@ -499,9 +498,9 @@ zoom: ${n_zoom}
499
498
padding-right: 12px;
500
499
padding-top: 15px;
501
500
padding-bottom: 6px;
502
- border-color: ${ css_gh_bg_header_bor } ;
503
- background-color: ${ css_gh_bg_color } ;
504
- background: ${ css_gh_bg } ;
501
+ border-color: ${ css_gh_bg_header_bor } ;
502
+ background-color: ${ css_gh_bg_color } ;
503
+ background: ${ css_gh_bg } ;
505
504
background-size: cover;
506
505
background-size: cover;
507
506
}
@@ -514,7 +513,7 @@ zoom: ${n_zoom}
514
513
515
514
body .gist .markdown-body
516
515
{
517
- color: ${ css_gh_tx_color } ;
516
+ color: ${ css_gh_tx_color } ;
518
517
line-height: 18.2px;
519
518
font-size: 0.8em;
520
519
border-spacing: 0;
@@ -525,8 +524,8 @@ zoom: ${n_zoom}
525
524
body .gist .gist-meta
526
525
{
527
526
color: #6b869f;
528
- border-top: ${ css_gh_bg_header_bor } ;
529
- background-color: ${ css_gh_bg_header_bg } ;
527
+ border-top: ${ css_gh_bg_header_bor } ;
528
+ background-color: ${ css_gh_bg_header_bg } ;
530
529
padding-left: 22px;
531
530
padding-right: 16px;
532
531
padding-top: 8px;
@@ -541,15 +540,15 @@ zoom: ${n_zoom}
541
540
542
541
body .gist .gist-meta a.Link--inTextBlock:hover
543
542
{
544
- color: ${ css_gh_tx_color } ;
543
+ color: ${ css_gh_tx_color } ;
545
544
opacity: 0.5;
546
545
}
547
546
548
547
body .gist .gist-meta a.Link--inTextBlock
549
548
{
550
549
padding-left: 0px;
551
550
padding-right: 7px;
552
- color: ${ css_gh_tx_color } ;
551
+ color: ${ css_gh_tx_color } ;
553
552
}
554
553
555
554
body .gist .gist-meta > a:nth-child( 3 )
@@ -575,29 +574,29 @@ zoom: ${n_zoom}
575
574
body .gist .pl-s2, body .gist .pl-stj, body .gist .pl-vo,
576
575
body .gist .pl-id, body .gist .pl-ii
577
576
{
578
- color: #${ css_gh_tx_color_user } ;
577
+ color: #${ css_gh_tx_color_user } ;
579
578
}
580
579
581
580
body .gist .blob-code
582
581
{
583
- color: #${ css_gh_tx_color_user } ;
582
+ color: #${ css_gh_tx_color_user } ;
584
583
}
585
584
586
585
body .gist .blob-num, body .gist .blob-code-inner,
587
586
{
588
- color: #${ css_gh_tx_color_user } ;
587
+ color: #${ css_gh_tx_color_user } ;
589
588
opacity: 0.5;
590
589
}
591
590
592
591
body .gist .blob-num:hover
593
592
{
594
- color: #${ css_gh_tx_color_user } ;
593
+ color: #${ css_gh_tx_color_user } ;
595
594
opacity: 1;
596
595
}
597
596
598
597
body .gist .blob-wrapper tr:first-child td
599
598
{
600
- text-wrap: ${ css_gh_wrap } ;
599
+ text-wrap: ${ css_gh_wrap } ;
601
600
}
602
601
603
602
body.gistr-theme-dark .gist .pl-s1
@@ -788,7 +787,7 @@ zoom: ${n_zoom}
788
787
789
788
const uuid = evn . data . gid
790
789
const scrollHeight = evn . data . scrollHeight
791
-
790
+
792
791
const gist_Container : HTMLElement = document . querySelector ( 'iframe#' + uuid )
793
792
794
793
gist_Container . setAttribute ( 'height' , scrollHeight )
0 commit comments