-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1971 lines (1824 loc) · 79.8 KB
/
index.html
File metadata and controls
1971 lines (1824 loc) · 79.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SnapCode - ngode-ngide kode ngadi-ngadi</title>
<!-- SEO Meta Tags -->
<meta name="description" content="Capture Markdown & Code Beautifier - Create beautiful images of your markdown with Fira Code ligatures, Mermaid diagrams, and KaTeX math formulas">
<meta name="keywords" content="markdown, code beautifier, screenshot, carbon, fira code, mermaid, katex, code to image">
<meta name="author" content="@sandikodev">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://sandikodev.github.io/snapcode/">
<meta property="og:title" content="SnapCode - Capture Markdown & Code Beautifier">
<meta property="og:description" content="Create beautiful images of your markdown with Fira Code ligatures, Mermaid diagrams, and KaTeX math formulas">
<meta property="og:site_name" content="SnapCode.me">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://sandikodev.github.io/snapcode/">
<meta property="twitter:title" content="SnapCode - Capture Markdown & Code Beautifier">
<meta property="twitter:description" content="Create beautiful images of your markdown with Fira Code ligatures, Mermaid diagrams, and KaTeX math formulas">
<meta property="twitter:creator" content="@sandikodev">
<!-- Canonical URL -->
<link rel="canonical" href="https://sandikodev.github.io/snapcode/">
<!-- Structured Data (JSON-LD) -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "SnapCode",
"description": "Create beautiful images of your markdown with OS window simulations, Fira Code ligatures, Mermaid diagrams, and KaTeX math formulas",
"url": "https://sandikodev.github.io/snapcode",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Any",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
},
"author": {
"@type": "Person",
"name": "sandikodev",
"url": "https://github.com/sandikodev"
},
"datePublished": "2025-12-10",
"softwareVersion": "1.0.0"
}
</script>
<!-- Favicon & Icons -->
<link rel="icon" type="image/x-icon" href="static/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="static/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="static/favicon-32x32.png">
<link rel="apple-touch-icon" sizes="180x180" href="static/apple-touch-icon.png">
<link rel="manifest" href="static/site.webmanifest">
<meta name="theme-color" content="#8b5cf6">
<!-- Open Graph Image -->
<meta property="og:image" content="https://sandikodev.github.io/snapcode/static/brand.png">
<!-- DNS Prefetch & Preconnect for CDN -->
<link rel="dns-prefetch" href="https://cdn.jsdelivr.net">
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<!-- Fira Code Font with font-display swap -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- KaTeX - Lazy loaded when enabled -->
<!-- Moved to dynamic loading in script -->
<!-- Inline Prism CSS to avoid CORS -->
<style>
code[class*="language-"],
pre[class*="language-"] {
color: #ccc;
background: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
tab-size: 4;
hyphens: none;
}
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #2d2d2d;
}
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.block-comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #999;
}
.token.punctuation {
color: #ccc;
}
.token.tag,
.token.attr-name,
.token.namespace,
.token.deleted {
color: #e2777a;
}
.token.function-name {
color: #6196cc;
}
.token.boolean,
.token.number,
.token.function {
color: #f08d49;
}
.token.property,
.token.class-name,
.token.constant,
.token.symbol {
color: #f8c555;
}
.token.selector,
.token.important,
.token.atrule,
.token.keyword,
.token.builtin {
color: #cc99cd;
}
.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.variable {
color: #7ec699;
}
.token.operator,
.token.entity,
.token.url {
color: #67cdcc;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.token.inserted {
color: green;
}
/* GitHub Light Theme Override */
.theme-github code[class*="language-"],
.theme-github pre[class*="language-"] {
color: #24292e;
}
.theme-github :not(pre) > code[class*="language-"],
.theme-github pre[class*="language-"] {
background: #f6f8fa;
}
.theme-github .token.comment,
.theme-github .token.prolog,
.theme-github .token.doctype,
.theme-github .token.cdata {
color: #6a737d;
}
.theme-github .token.punctuation {
color: #24292e;
}
.theme-github .token.property,
.theme-github .token.tag,
.theme-github .token.boolean,
.theme-github .token.number,
.theme-github .token.constant,
.theme-github .token.symbol,
.theme-github .token.deleted {
color: #005cc5;
}
.theme-github .token.selector,
.theme-github .token.attr-name,
.theme-github .token.string,
.theme-github .token.char,
.theme-github .token.builtin,
.theme-github .token.inserted {
color: #032f62;
}
.theme-github .token.operator,
.theme-github .token.entity,
.theme-github .token.url,
.theme-github .language-css .token.string,
.theme-github .style .token.string {
color: #d73a49;
}
.theme-github .token.atrule,
.theme-github .token.attr-value,
.theme-github .token.keyword {
color: #d73a49;
}
.theme-github .token.function,
.theme-github .token.class-name {
color: #6f42c1;
}
.theme-github .token.regex,
.theme-github .token.important,
.theme-github .token.variable {
color: #e36209;
}
</style>
<!-- Tailwind CSS - CDN used intentionally for buildless architecture -->
<!-- Warning about production usage is expected - this is a single-file app -->
<script>window.tailwind = { config: {} }</script>
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<script>
// Suppress Tailwind CDN warning - intentional for buildless architecture
const originalWarn = console.warn;
console.warn = function(...args) {
if (args[0] && args[0].includes('should not be used in production')) return;
originalWarn.apply(console, args);
};
</script>
<!-- Preload critical scripts -->
<link rel="preload" href="https://cdn.jsdelivr.net/npm/alpinejs@3.13.3/dist/cdn.min.js" as="script">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/marked@11.1.1/marked.min.js" as="script">
<!-- Non-critical scripts (defer for non-blocking) -->
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-javascript.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-markup.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-css.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-java.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/marked@11.1.1/marked.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
<!-- Heavy dependencies - Lazy loaded when needed -->
<!-- Mermaid & KaTeX loaded dynamically -->
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.13.3/dist/cdn.min.js"></script>
<style>
/* Critical CSS - prevent FOUC */
body {
opacity: 0;
transition: opacity 0.3s ease;
}
body.loaded {
opacity: 1;
}
@keyframes gradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.animated-bg {
background: linear-gradient(-45deg, #1a1a2e, #16213e, #0f3460, #533483);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
}
/* Markdown bullet points fix - override Tailwind reset */
.preview-content ul,
.preview-content ol {
margin: 0.5em 0 !important;
padding-left: 2em !important;
}
.preview-content ul {
list-style: disc outside !important;
}
.preview-content ol {
list-style: decimal outside !important;
}
.preview-content li {
display: list-item !important;
margin: 0.25em 0 !important;
}
.preview-content ul ul { list-style-type: circle !important; }
.preview-content ol ol { list-style-type: lower-alpha !important; }
/* Focus indicators for accessibility */
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
outline: 2px solid #8b5cf6 !important;
outline-offset: 2px !important;
}
/* Skip to content link */
.skip-link {
position: absolute;
top: -40px;
left: 0;
background: #8b5cf6;
color: white;
padding: 8px 16px;
z-index: 100;
transition: top 0.3s;
}
.skip-link:focus {
top: 0;
}
/* Fullscreen mode */
.fullscreen-mode {
position: fixed !important;
top: 0; left: 0; right: 0; bottom: 0;
z-index: 9999;
background: #1a1a2e;
padding: 1rem;
overflow: auto;
}
.fullscreen-mode .preview-wrapper {
max-width: 100% !important;
height: calc(100vh - 2rem);
}
/* Print styles */
@media print {
body { background: white !important; }
.no-print { display: none !important; }
.preview-content { max-height: none !important; overflow: visible !important; }
}
/* Mobile responsive */
@media (max-width: 768px) {
.toolbar-buttons { flex-wrap: wrap; gap: 0.25rem; }
.toolbar-buttons button { padding: 0.375rem 0.5rem; font-size: 0.75rem; }
.toolbar-buttons button span { display: none; }
main { padding: 1rem !important; }
textarea { height: 200px !important; }
}
</style>
</head>
<body>
<!-- Skip to main content for accessibility -->
<a href="#main-content" class="skip-link">Skip to main content</a>
<div x-data="app()" x-init="init(); $nextTick(() => document.body.classList.add('loaded'))">
<style x-html="styles"></style>
<!-- Toast Notification -->
<div
x-show="toast.show"
x-transition
class="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg shadow-lg text-white text-sm"
:class="toast.type === 'error' ? 'bg-red-600' : 'bg-green-600'"
x-text="toast.message"
></div>
<!-- Loading Overlay -->
<div x-show="isExporting" class="fixed inset-0 bg-black/50 z-40 flex items-center justify-center">
<div class="bg-gray-800 px-6 py-4 rounded-lg text-white flex items-center gap-3">
<svg class="animate-spin w-5 h-5" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
</svg>
Exporting...
</div>
</div>
<main id="main-content" class="min-h-screen animated-bg p-8" role="main">
<div class="max-w-7xl mx-auto">
<div class="text-center mb-8">
<h1 class="text-4xl font-bold text-white mb-2">SnapCode</h1>
<p class="text-gray-300 text-lg italic">ngode-ngide kode ngadi-ngadi</p>
<p class="text-gray-400 text-sm mt-2">Create beautiful images of your markdown</p>
<p class="text-green-400/60 text-xs mt-1" x-show="history.length > 0">✓ Auto-saved locally</p>
</div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Editor -->
<div class="bg-gray-800 rounded-lg shadow-2xl p-6">
<!-- Tab Switcher -->
<div class="flex items-center gap-2 mb-4 border-b border-gray-700 pb-2">
<button
@click="editorMode = 'markdown'"
:class="editorMode === 'markdown' ? 'bg-gray-700 text-white' : 'text-gray-400 hover:text-white'"
class="px-4 py-2 rounded-t-lg transition text-sm font-medium"
>
Markdown
</button>
<button
@click="editorMode = 'explorer'"
:class="editorMode === 'explorer' ? 'bg-gray-700 text-white' : 'text-gray-400 hover:text-white'"
class="px-4 py-2 rounded-t-lg transition text-sm font-medium"
>
File Explorer
</button>
</div>
<!-- Markdown Editor -->
<div x-show="editorMode === 'markdown'">
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-white">Markdown Editor</h2>
<div class="flex gap-2">
<button
@click="loadSample"
class="px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Load sample content"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 0 1 2-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
Sample
</button>
<button
@click="copyText"
class="px-3 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Copy markdown text"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
Copy
</button>
</div>
</div>
<textarea
x-model="content"
@drop.prevent="handleDrop"
@dragover.prevent="$el.classList.add('ring-2', 'ring-purple-400')"
@dragleave="$el.classList.remove('ring-2', 'ring-purple-400')"
class="w-full h-96 bg-gray-900 text-gray-100 p-4 rounded-lg font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-purple-500"
placeholder="Start typing, paste content, or drop a file..."
aria-label="Markdown content editor"
role="textbox"
aria-multiline="true"
></textarea>
</div>
<!-- File Explorer -->
<div x-show="editorMode === 'explorer'">
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-white">File Explorer</h2>
<div class="flex gap-2">
<button
@click="loadFolder('content')"
:disabled="loadingFolder"
:class="loadingFolder ? 'opacity-50 cursor-not-allowed' : ''"
class="px-3 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Load content folder"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M3 7v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-6l-2-2H5a2 2 0 0 0-2 2z"></path>
</svg>
Content
</button>
<button
@click="loadFolder('docs')"
:disabled="loadingFolder"
:class="loadingFolder ? 'opacity-50 cursor-not-allowed' : ''"
class="px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Load docs folder"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M9 12h6m-6 4h6m2 5H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5.586a1 1 0 0 1.707.293l5.414 5.414a1 1 0 0 1.293.707V19a2 2 0 0 1-2 2z"></path>
</svg>
Docs
</button>
<button
@click="$refs.fileInput.click()"
:disabled="loadingFolder"
:class="loadingFolder ? 'opacity-50 cursor-not-allowed' : ''"
class="px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M12 4v16m8-8H4"></path>
</svg>
Add File
</button>
</div>
<input type="file" x-ref="fileInput" @change="addFile" class="hidden" accept=".md,.txt,.js,.html,.css,.json">
</div>
<div class="bg-gray-900 rounded-lg h-96 overflow-y-auto">
<!-- Loading State -->
<div x-show="loadingFolder" class="flex flex-col items-center justify-center h-full text-gray-400">
<svg class="w-12 h-12 animate-spin mb-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="10" stroke-opacity="0.25"></circle>
<path d="M12 2a10 10 0 0 1 10 10" stroke-opacity="0.75"></path>
</svg>
<p class="text-sm">Loading files...</p>
</div>
<!-- Empty State -->
<div x-show="!loadingFolder && files.length === 0" class="flex flex-col items-center justify-center h-full text-gray-500">
<svg class="w-16 h-16 mb-4" fill="none" stroke="currentColor" stroke-width="1" viewBox="0 0 24 24">
<path d="M3 7v10a2 2 0 0 02 2h14a2 2 0 0 02-2V9a2 2 0 0 0-2-2h-6l-2-2H5a2 2 0 0 0-2 2z"></path>
</svg>
<p>No files yet</p>
<p class="text-sm mt-2">Click "Content" or "Docs" to load files</p>
</div>
<!-- File List -->
<div x-show="!loadingFolder && files.length > 0" class="divide-y divide-gray-800">
<template x-for="(file, index) in files" :key="index">
<div
@click="selectFile(index)"
:class="selectedFileIndex === index ? 'bg-purple-600/20 border-l-4 border-purple-500' : 'hover:bg-gray-800'"
class="p-3 cursor-pointer transition flex items-center justify-between group"
>
<div class="flex items-center gap-3 flex-1 min-w-0">
<svg class="w-5 h-5 text-blue-400 flex-shrink-0" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 0 1 2-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
<div class="flex-1 min-w-0">
<p class="text-white text-sm font-medium truncate" x-text="file.name"></p>
<p class="text-gray-500 text-xs" x-text="formatFileSize(file.size)"></p>
</div>
</div>
<button
@click.stop="removeFile(index)"
class="opacity-0 group-hover:opacity-100 p-1 hover:bg-red-600/20 rounded transition"
>
<svg class="w-4 h-4 text-red-400" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
</template>
</div>
</div>
</div>
<div class="mt-4 space-y-4">
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-gray-300 mb-2">Window Style</label>
<select
x-model="windowStyle"
class="w-full bg-gray-700 text-white rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-purple-500"
>
<option value="macos-sequoia">macOS Sequoia</option>
<option value="macos-ventura">macOS Ventura</option>
<option value="windows-11">Windows 11</option>
<option value="windows-10">Windows 10</option>
<option value="chromeos">Chrome OS</option>
</select>
</div>
<div>
<label class="block text-sm text-gray-300 mb-2">Theme</label>
<select
x-model="theme"
class="w-full bg-gray-700 text-white rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-purple-500"
>
<option value="dracula">Dracula</option>
<option value="monokai">Monokai</option>
<option value="github">GitHub</option>
<option value="nord">Nord</option>
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-gray-300 mb-2">Font Size: <span x-text="fontSize"></span>px</label>
<input
type="range"
min="10"
max="24"
x-model="fontSize"
class="w-full"
/>
</div>
<div>
<label class="block text-sm text-gray-300 mb-2">Desktop Padding: <span x-text="padding"></span>px</label>
<input
type="range"
min="32"
max="128"
x-model="padding"
class="w-full"
/>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-gray-300 mb-2">Filename</label>
<input
type="text"
x-model="filename"
class="w-full bg-gray-700 text-white rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
placeholder="README.md"
/>
</div>
<div>
<label class="block text-sm text-gray-300 mb-2">Watermark</label>
<input
type="text"
x-model="watermark"
class="w-full bg-gray-700 text-white rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
placeholder="@username"
/>
</div>
</div>
<div x-show="watermark" class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-gray-300 mb-2">Watermark Size: <span x-text="watermarkSize"></span>px</label>
<input
type="range"
min="8"
max="24"
x-model="watermarkSize"
class="w-full"
/>
</div>
<div>
<label class="block text-sm text-gray-300 mb-2">Watermark Opacity: <span x-text="watermarkOpacity"></span>%</label>
<input
type="range"
min="10"
max="100"
x-model="watermarkOpacity"
class="w-full"
/>
</div>
</div>
<div>
<label class="flex items-center gap-2 text-gray-300 cursor-pointer">
<input
type="checkbox"
x-model="useFiraCode"
class="w-4 h-4"
/>
Use Fira Code font (ligatures)
</label>
</div>
<div>
<label class="flex items-center gap-2 text-gray-300 cursor-pointer">
<input
type="checkbox"
x-model="useMermaid"
class="w-4 h-4"
/>
Enable Mermaid diagrams
</label>
</div>
<div>
<label class="flex items-center gap-2 text-gray-300 cursor-pointer">
<input
type="checkbox"
x-model="useKatex"
class="w-4 h-4"
/>
Enable KaTeX math formulas
</label>
</div>
</div>
</div>
<!-- Preview -->
<div class="bg-gray-800 rounded-lg shadow-2xl p-6" :class="{ 'fullscreen-mode': isFullscreen }">
<div class="flex items-center justify-between mb-4 flex-wrap gap-2">
<h2 class="text-xl font-semibold text-white">Preview</h2>
<div class="flex gap-2 toolbar-buttons">
<button
@click="copyImage"
class="px-3 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Copy as image (Chrome/Edge only)"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
<circle cx="8.5" cy="8.5" r="1.5"></circle>
<polyline points="21 15 16 10 5 21"></polyline>
</svg>
<span>Copy Image</span>
</button>
<button
@click="exportImage"
class="px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
aria-label="Export as PNG image"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" aria-hidden="true">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="7 10 12 15 17 10"></polyline>
<line x1="12" y1="15" x2="12" y2="3"></line>
</svg>
<span>PNG</span>
</button>
<!-- Export SVG -->
<button
@click="exportSVG"
class="px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Export as SVG"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<path d="M14 2v6h6"></path>
</svg>
<span>SVG</span>
</button>
<!-- Copy HTML -->
<button
@click="copyHTML"
class="px-3 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Copy as HTML"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M16 18l6-6-6-6M8 6l-6 6 6 6"></path>
</svg>
<span>HTML</span>
</button>
<!-- Share URL -->
<button
@click="shareURL"
class="px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
title="Copy shareable URL"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<circle cx="18" cy="5" r="3"></circle>
<circle cx="6" cy="12" r="3"></circle>
<circle cx="18" cy="19" r="3"></circle>
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
</svg>
<span>Share</span>
</button>
<!-- Fullscreen -->
<button
@click="toggleFullscreen"
class="px-3 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
:aria-label="isFullscreen ? 'Exit fullscreen' : 'Enter fullscreen'"
:title="'Fullscreen (F11)'"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path x-show="!isFullscreen" d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path>
<path x-show="isFullscreen" d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"></path>
</svg>
</button>
<!-- Print -->
<button
@click="window.print()"
class="px-3 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition flex items-center gap-2 text-sm"
aria-label="Print preview"
title="Print"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path d="M6 9V2h12v7M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path>
<rect x="6" y="14" width="12" height="8"></rect>
</svg>
</button>
</div>
<!-- Undo/Redo row -->
<div class="flex items-center gap-2 no-print">
<button
@click="undo"
:disabled="historyIndex <= 0"
class="px-2 py-1 bg-gray-700 hover:bg-gray-600 disabled:opacity-40 text-white rounded text-xs flex items-center gap-1"
title="Undo (Ctrl+Z)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M3 10h10a5 5 0 0 1 5 5v2M3 10l4-4M3 10l4 4"></path></svg>
Undo
</button>
<button
@click="redo"
:disabled="historyIndex >= history.length - 1"
class="px-2 py-1 bg-gray-700 hover:bg-gray-600 disabled:opacity-40 text-white rounded text-xs flex items-center gap-1"
title="Redo (Ctrl+Y)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 10H11a5 5 0 0 0-5 5v2M21 10l-4-4M21 10l-4 4"></path></svg>
Redo
</button>
<span class="text-gray-500 text-xs ml-2" x-show="history.length > 1">
<span x-text="historyIndex + 1"></span>/<span x-text="history.length"></span>
</span>
<button
@click="if(confirm('Clear saved content?')) clearSaved()"
class="px-2 py-1 bg-red-700/50 hover:bg-red-600 text-white rounded text-xs ml-auto"
title="Clear saved data"
>
Clear
</button>
</div>
</div>
<!-- OS Background Wrapper -->
<div
class="rounded-lg"
:style="`${osBackground} padding: ${padding}px;`"
>
<!-- Window Container -->
<div
class="shadow-2xl overflow-hidden"
:class="windowBorderRadius"
:style="windowBorder"
>
<!-- macOS: Separate frame with title bar -->
<div x-show="windowStyle.includes('macos')" :style="windowFrameStyle">
<div :style="titleBarStyle">
<div class="flex items-center py-3 px-4">
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded-full bg-[#ff5f57] hover:bg-[#ff5f57]/90 cursor-pointer transition-all shadow-sm group relative">
<svg class="w-2 h-2 absolute inset-0 m-auto opacity-0 group-hover:opacity-100 transition" fill="none" stroke="#4d0000" stroke-width="2" viewBox="0 0 8 8">
<path d="M1.5 1.5l5 5m0-5l-5 5"/>
</svg>
</div>
<div class="w-3 h-3 rounded-full bg-[#febc2e] hover:bg-[#febc2e]/90 cursor-pointer transition-all shadow-sm group relative">
<svg class="w-2 h-2 absolute inset-0 m-auto opacity-0 group-hover:opacity-100 transition" fill="#995700" viewBox="0 0 8 8">
<rect x="1" y="3.5" width="6" height="1"/>
</svg>
</div>
<div class="w-3 h-3 rounded-full bg-[#28c840] hover:bg-[#28c840]/90 cursor-pointer transition-all shadow-sm group relative">
<svg class="w-2 h-2 absolute inset-0 m-auto opacity-0 group-hover:opacity-100 transition" fill="none" stroke="#004d0d" stroke-width="1.5" viewBox="0 0 8 8">
<path d="M1 3l1.5 1.5L6 1"/>
</svg>
</div>
</div>
<div class="flex-1 text-center">
<div class="text-xs font-medium text-gray-700">
<span x-text="filename || 'README.md'"></span>
</div>
</div>
<div class="w-[52px]"></div>
</div>
</div>
<!-- Content Area -->
<div
x-ref="preview"
class="content-scroll relative preview-content"
:class="theme === 'github' ? 'theme-github' : ''"
:style="`background-color: ${currentTheme.bg}; color: ${currentTheme.fg}; font-size: ${fontSize}px; padding: 24px 32px; max-height: 500px; overflow-y: auto;`"
>
<div class="markdown-content" x-html="parsedMarkdown"></div>
<!-- Watermark -->
<div
x-show="watermark"
class="absolute bottom-4 right-4 font-mono"
:style="`color: ${currentTheme.fg}; opacity: ${watermarkOpacity / 100}; font-size: ${watermarkSize}px;`"
x-text="watermark"
></div>
</div>
</div>
<!-- Windows/ChromeOS: No frame, title bar directly on content -->
<div x-show="!windowStyle.includes('macos')">
<!-- Title Bar -->
<div :style="titleBarStyle">
<!-- Windows 11 -->
<div x-show="windowStyle === 'windows-11'" class="flex items-center justify-between" style="padding: 0 16px 0 16px; height: 40px;">
<div class="flex items-center gap-3">
<svg class="w-4 h-4 text-gray-600" fill="currentColor" viewBox="0 0 16 16">
<path d="M1.75 1.75v5.5h5.5v-5.5h-5.5zm7 0v5.5h5.5v-5.5h-5.5zm-7 7v5.5h5.5v-5.5h-5.5zm7 0v5.5h5.5v-5.5h-5.5z"/>
</svg>
<div class="text-xs font-normal text-gray-700">
<span x-text="filename || 'README.md'"></span>
</div>
</div>
<div class="flex items-center h-full" style="margin-right: -16px;">
<button class="w-12 h-full flex items-center justify-center hover:bg-black/5 transition-colors">
<svg class="w-2.5 h-2.5 text-gray-700" fill="currentColor" viewBox="0 0 12 12">
<rect x="1" y="5.5" width="10" height="1"/>
</svg>
</button>
<button class="w-12 h-full flex items-center justify-center hover:bg-black/5 transition-colors">
<svg class="w-2.5 h-2.5 text-gray-700" fill="none" stroke="currentColor" stroke-width="1" viewBox="0 0 12 12">
<rect x="2.5" y="2.5" width="7" height="7"/>
</svg>
</button>
<button class="w-12 h-full flex items-center justify-center hover:bg-[#c42b1c] hover:text-white transition-colors">
<svg class="w-2.5 h-2.5" fill="none" stroke="currentColor" stroke-width="1.2" viewBox="0 0 12 12">
<path d="M2.5 2.5l7 7m0-7l-7 7"/>
</svg>
</button>
</div>
</div>
<!-- Windows 10 -->
<div x-show="windowStyle === 'windows-10'" class="flex items-center justify-between" style="padding: 0 8px 0 8px; height: 32px;">
<div class="flex items-center gap-2">
<svg class="w-4 h-4 text-gray-600" fill="currentColor" viewBox="0 0 16 16">
<path d="M14 2H2v12h12V2zM4 4h8v2H4V4zm0 3h8v2H4V7zm0 3h5v2H4v-2z"/>
</svg>
<div class="text-xs text-gray-700">
<span x-text="filename || 'README.md'"></span>
</div>
</div>
<div class="flex items-center h-full" style="margin-right: -8px;">
<button class="w-11 h-full flex items-center justify-center hover:bg-black/5 transition-colors">
<svg class="w-2.5 h-2.5 text-gray-700" fill="currentColor" viewBox="0 0 12 12">
<rect x="1" y="5.5" width="10" height="1"/>
</svg>
</button>
<button class="w-11 h-full flex items-center justify-center hover:bg-black/5 transition-colors">
<svg class="w-2.5 h-2.5 text-gray-700" fill="none" stroke="currentColor" stroke-width="1" viewBox="0 0 12 12">
<rect x="2.5" y="2.5" width="7" height="7"/>
</svg>
</button>
<button class="w-11 h-full flex items-center justify-center hover:bg-[#e81123] hover:text-white transition-colors">
<svg class="w-2.5 h-2.5" fill="none" stroke="currentColor" stroke-width="1.2" viewBox="0 0 12 12">
<path d="M2.5 2.5l7 7m0-7l-7 7"/>
</svg>
</button>
</div>
</div>
<!-- Chrome OS -->
<div x-show="windowStyle === 'chromeos'" class="flex items-center justify-between py-2 px-4">
<div class="flex items-center gap-3">
<svg class="w-4 h-4 text-gray-700" fill="currentColor" viewBox="0 0 16 16">
<circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.5"/>
<circle cx="8" cy="8" r="2.5"/>
</svg>
<div class="text-xs font-medium text-gray-700">
<span x-text="filename || 'README.md'"></span>
</div>
</div>
<div class="flex items-center gap-1">
<button class="w-8 h-8 rounded-full flex items-center justify-center hover:bg-black/10 transition">
<svg class="w-4 h-4 text-gray-700" fill="currentColor" viewBox="0 0 16 16">
<rect x="3" y="7.5" width="10" height="1"/>
</svg>
</button>
<button class="w-8 h-8 rounded-full flex items-center justify-center hover:bg-black/10 transition">
<svg class="w-4 h-4 text-gray-700" fill="currentColor" viewBox="0 0 16 16">
<rect x="4" y="4" width="8" height="8" fill="none" stroke="currentColor" stroke-width="1.5"/>
</svg>
</button>
<button class="w-8 h-8 rounded-full flex items-center justify-center hover:bg-black/10 transition">
<svg class="w-4 h-4 text-gray-700" fill="currentColor" viewBox="0 0 16 16">
<path d="M4 4l8 8m0-8l-8 8" stroke="currentColor" stroke-width="1.5" fill="none"/>
</svg>
</button>
</div>
</div>
</div>
<!-- Content Area -->
<div
x-ref="preview"
class="content-scroll relative preview-content"
:class="theme === 'github' ? 'theme-github' : ''"
:style="`background-color: ${currentTheme.bg}; color: ${currentTheme.fg}; font-size: ${fontSize}px; padding: 24px 32px; max-height: 500px; overflow-y: auto;`"
>
<div class="markdown-content" x-html="parsedMarkdown"></div>
<!-- Watermark -->
<div
x-show="watermark"
class="absolute bottom-4 right-4 font-mono"
:style="`color: ${currentTheme.fg}; opacity: ${watermarkOpacity / 100}; font-size: ${watermarkSize}px;`"
x-text="watermark"
></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<script>
// Lazy Loading Utilities
const loadedScripts = new Set();
const loadedStyles = new Set();
function loadScript(src) {
if (loadedScripts.has(src)) return Promise.resolve();