gitalk-react 1.0.0-beta.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README-zh-CN.md +159 -57
  2. package/README.md +142 -40
  3. package/dist/gitalk-dark.css +1 -1
  4. package/dist/gitalk-light.css +1 -1
  5. package/dist/gitalk.browser.full.js +102 -0
  6. package/dist/gitalk.browser.js +94 -0
  7. package/dist/gitalk.cjs +94 -0
  8. package/dist/gitalk.d.cts +14 -0
  9. package/dist/gitalk.d.mts +174 -0
  10. package/dist/gitalk.js +7427 -12628
  11. package/package.json +67 -44
  12. package/proxy-server/.env.example +6 -0
  13. package/proxy-server/README.md +38 -0
  14. package/proxy-server/server.mjs +110 -0
  15. package/dist/gitalk.d.ts +0 -455
  16. package/dist/gitalk.umd.cjs +0 -123
  17. package/lib/assets/arrow-down.svg +0 -1
  18. package/lib/assets/edit.svg +0 -3
  19. package/lib/assets/github.svg +0 -3
  20. package/lib/assets/heart-filled.svg +0 -3
  21. package/lib/assets/heart.svg +0 -3
  22. package/lib/assets/reply.svg +0 -3
  23. package/lib/assets/tip.svg +0 -8
  24. package/lib/components/action.tsx +0 -21
  25. package/lib/components/avatar.tsx +0 -42
  26. package/lib/components/button.tsx +0 -35
  27. package/lib/components/comment-textarea.tsx +0 -164
  28. package/lib/components/comment.tsx +0 -185
  29. package/lib/components/comments-list.tsx +0 -106
  30. package/lib/components/meta.tsx +0 -129
  31. package/lib/components/svg.tsx +0 -29
  32. package/lib/constants/index.ts +0 -57
  33. package/lib/contexts/I18nContext.ts +0 -20
  34. package/lib/gitalk.tsx +0 -882
  35. package/lib/i18n/de.json +0 -20
  36. package/lib/i18n/en.json +0 -20
  37. package/lib/i18n/es-ES.json +0 -20
  38. package/lib/i18n/fa.json +0 -20
  39. package/lib/i18n/fr.json +0 -20
  40. package/lib/i18n/index.ts +0 -40
  41. package/lib/i18n/ja.json +0 -20
  42. package/lib/i18n/ko.json +0 -20
  43. package/lib/i18n/pl.json +0 -21
  44. package/lib/i18n/ru.json +0 -20
  45. package/lib/i18n/zh-CN.json +0 -20
  46. package/lib/i18n/zh-TW.json +0 -20
  47. package/lib/interfaces/index.ts +0 -196
  48. package/lib/services/graphql/comment.ts +0 -84
  49. package/lib/services/request.ts +0 -24
  50. package/lib/services/user.ts +0 -40
  51. package/lib/themes/base.scss +0 -628
  52. package/lib/themes/gitalk-dark.scss +0 -28
  53. package/lib/themes/gitalk-light.scss +0 -28
  54. package/lib/utils/compatibility.ts +0 -35
  55. package/lib/utils/dom.ts +0 -15
  56. package/lib/utils/logger.ts +0 -66
  57. package/lib/utils/query.ts +0 -19
  58. package/lib/vite-env.d.ts +0 -1
@@ -1,628 +0,0 @@
1
- @function em($px, $base-size: $gt-size-base) {
2
- @return calc($px / $base-size * 1em);
3
- }
4
-
5
- @mixin clearfix() {
6
- &::before,
7
- &::after {
8
- display: table;
9
- content: '';
10
- }
11
-
12
- &::after {
13
- clear: both;
14
- }
15
- }
16
-
17
- @mixin mobile() {
18
- @media (max-width: $gt-breakpoint-mobile) {
19
- @content;
20
- }
21
- }
22
-
23
- @keyframes gt-kf-rotate {
24
- 0% {
25
- transform: rotate(0);
26
- }
27
-
28
- 100% {
29
- transform: rotate(360deg);
30
- }
31
- }
32
-
33
- $gt-size-base: 16px;
34
- $gt-size-border-radius: em(5px);
35
- $gt-size-loader-dot: em(6px);
36
- $gt-size-loader: em(28px);
37
- $gt-size-avatar: em(50px);
38
- $gt-size-avatar-mobi: em(32px);
39
- $gt-size-textarea-min-height: em(82px);
40
- $gt-size-textarea-max-height: em(240px);
41
- $gt-mask-z-index: 9999;
42
- $gt-breakpoint-mobile: 480px;
43
-
44
- .gt-container {
45
- box-sizing: border-box;
46
- font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
47
- font-size: $gt-size-base;
48
- font-weight: 400;
49
- line-height: 1.5;
50
- color: var(--gt-color-text);
51
- font-synthesis: none;
52
- text-rendering: optimizelegibility;
53
- -webkit-font-smoothing: antialiased;
54
- -moz-osx-font-smoothing: grayscale;
55
-
56
- * {
57
- box-sizing: border-box;
58
- }
59
-
60
- a {
61
- color: var(--gt-color-main);
62
-
63
- &:hover {
64
- color: var(--gt-color-main-lighter);
65
- border-color: var(--gt-color-main-lighter);
66
- }
67
-
68
- &.is--active {
69
- color: var(--gt-color-link-active);
70
- cursor: default;
71
-
72
- &:hover {
73
- color: var(--gt-color-link-active);
74
- }
75
- }
76
- }
77
-
78
- .hide {
79
- display: none;
80
- }
81
-
82
- .gt {
83
- &-svg {
84
- display: inline-block;
85
- width: em(16px);
86
- height: em(16px);
87
- vertical-align: sub;
88
-
89
- svg {
90
- width: 100%;
91
- height: 100%;
92
- fill: var(--gt-color-main);
93
- }
94
- }
95
-
96
- &-ico {
97
- display: inline-block;
98
-
99
- &-text {
100
- margin-left: em(5px);
101
- }
102
-
103
- &-github {
104
- width: 100%;
105
- height: 100%;
106
-
107
- .gt-svg {
108
- width: 100%;
109
- height: 100%;
110
- }
111
-
112
- svg {
113
- fill: var(--gt-color-text);
114
- }
115
- }
116
- }
117
-
118
- &-spinner {
119
- position: relative;
120
-
121
- &::before {
122
- position: absolute;
123
- top: em(3px);
124
- box-sizing: border-box;
125
- width: em(12px);
126
- height: em(12px);
127
- margin-top: em(-3px);
128
- margin-left: em(-6px);
129
- content: '';
130
- border: 1px solid var(--gt-color-btn);
131
- border-top-color: var(--gt-color-main);
132
- border-radius: 50%;
133
- animation: gt-kf-rotate 0.6s linear infinite;
134
- }
135
- }
136
-
137
- &-loader {
138
- position: relative;
139
- display: inline-block;
140
- width: $gt-size-loader;
141
- height: $gt-size-loader;
142
- font-style: normal;
143
- line-height: $gt-size-loader;
144
- border: 1px solid var(--gt-color-loader);
145
- border-radius: 50%;
146
- animation: ease gt-kf-rotate 1.5s infinite;
147
-
148
- &::before {
149
- position: absolute;
150
- top: 0;
151
- left: 50%;
152
- display: block;
153
- width: $gt-size-loader-dot;
154
- height: $gt-size-loader-dot;
155
- margin-top: -(calc($gt-size-loader-dot / 2));
156
- margin-left: -(calc($gt-size-loader-dot / 2));
157
- content: '';
158
- background-color: var(--gt-color-loader);
159
- border-radius: 50%;
160
- }
161
- }
162
-
163
- &-avatar {
164
- display: inline-block;
165
- width: $gt-size-avatar;
166
- height: $gt-size-avatar;
167
-
168
- @include mobile {
169
- width: $gt-size-avatar-mobi;
170
- height: $gt-size-avatar-mobi;
171
- }
172
-
173
- img {
174
- width: 100%;
175
- height: auto;
176
- border-radius: em(3px);
177
- }
178
-
179
- &-github {
180
- width: $gt-size-avatar - em(2px);
181
- height: $gt-size-avatar - em(2px);
182
- cursor: pointer;
183
-
184
- @include mobile {
185
- width: $gt-size-avatar-mobi - em(2px);
186
- height: $gt-size-avatar-mobi - em(2px);
187
- }
188
- }
189
- }
190
-
191
- &-btn {
192
- display: inline-block;
193
- padding: em(12px) em(20px);
194
- font-size: em(12px);
195
- line-height: 1;
196
- color: var(--gt-color-btn);
197
- white-space: nowrap;
198
- text-decoration: none;
199
- cursor: pointer;
200
- outline: none;
201
- background-color: var(--gt-color-main);
202
- border: 1px solid var(--gt-color-main);
203
- border-radius: $gt-size-border-radius;
204
- transition: all ease 0.25s;
205
-
206
- &:hover {
207
- background-color: var(--gt-color-main-lighter);
208
- border-color: var(--gt-color-main-lighter);
209
- }
210
-
211
- &--secondary {
212
- color: var(--gt-color-main-lighter);
213
- background-color: transparent;
214
- border-color: var(--gt-color-main-lighter);
215
-
216
- &:hover {
217
- color: var(--gt-color-main);
218
- background-color: transparent;
219
- border-color: var(--gt-color-main);
220
- }
221
- }
222
-
223
- &-text {
224
- font-weight: 400;
225
- }
226
-
227
- &-loading {
228
- position: relative;
229
- display: inline-block;
230
- width: em(12px);
231
- height: em(16px);
232
- margin-left: em(8px);
233
- vertical-align: top;
234
- }
235
-
236
- &.is--disable {
237
- cursor: not-allowed;
238
- opacity: 0.5;
239
- }
240
-
241
- &-login {
242
- margin-right: 0;
243
- }
244
- }
245
-
246
- &-error {
247
- margin: em(10px);
248
- color: var(--gt-color-error);
249
- text-align: center;
250
- }
251
-
252
- &-initing {
253
- padding: em(20px) 0;
254
- text-align: center;
255
-
256
- &-text {
257
- margin: em(10px) auto;
258
- font-size: 92%;
259
- }
260
- }
261
-
262
- &-no-init {
263
- padding: em(20px) 0;
264
- text-align: center;
265
- }
266
-
267
- &-link {
268
- border-bottom: 1px dotted var(--gt-color-main);
269
-
270
- &-counts,
271
- &-project {
272
- text-decoration: none;
273
- }
274
- }
275
-
276
- &-meta {
277
- position: relative;
278
- z-index: 10;
279
- padding: em(16px) 0;
280
- margin: em(20px) 0;
281
- font-size: em(16px);
282
- border-bottom: 1px solid var(--gt-color-hr);
283
-
284
- @include clearfix;
285
- }
286
-
287
- &-counts {
288
- margin: 0 em(10px) 0 0;
289
- }
290
-
291
- &-user {
292
- float: right;
293
- margin: 0;
294
- font-size: 92%;
295
-
296
- &-pic {
297
- width: em(16px);
298
- height: em(16px);
299
- margin-right: em(8px);
300
- vertical-align: top;
301
- }
302
-
303
- &-inner {
304
- display: inline-block;
305
- cursor: pointer;
306
- }
307
-
308
- .gt-ico {
309
- margin: 0 0 0 em(5px);
310
-
311
- svg {
312
- fill: var(--gt-color-text);
313
- }
314
- }
315
-
316
- .is--poping {
317
- .gt-ico {
318
- svg {
319
- fill: var(--gt-color-main);
320
- }
321
- }
322
- }
323
- }
324
-
325
- &-version {
326
- margin-left: em(6px);
327
- color: var(--gt-color-sub);
328
- }
329
-
330
- &-copyright {
331
- padding-top: em(8px);
332
- margin: 0 em(15px) em(8px);
333
- border-top: 1px solid var(--gt-color-hr);
334
- }
335
-
336
- &-popup {
337
- position: absolute;
338
- top: em(38px);
339
- right: 0;
340
- display: inline-block;
341
- padding: em(10px) 0;
342
- font-size: em(14px);
343
- letter-spacing: 0.5px;
344
- background: var(--gt-color-popbg);
345
- border: 1px solid var(--gt-color-hr);
346
-
347
- .gt-action {
348
- position: relative;
349
- display: block;
350
- padding: 0 em(18px);
351
- margin: em(8px) 0;
352
- text-decoration: none;
353
- cursor: pointer;
354
-
355
- &.is--active {
356
- &::before {
357
- position: absolute;
358
- top: em(7px);
359
- left: em(8px);
360
- width: em(4px);
361
- height: em(4px);
362
- content: '';
363
- background: var(--gt-color-main);
364
- }
365
- }
366
- }
367
- }
368
-
369
- &-header {
370
- position: relative;
371
- display: flex;
372
-
373
- &-comment {
374
- flex: 1;
375
- margin-left: em(20px);
376
-
377
- @include mobile {
378
- margin-left: em(14px);
379
- }
380
- }
381
-
382
- &-textarea {
383
- box-sizing: border-box;
384
- display: block;
385
- width: 100%;
386
- min-height: $gt-size-textarea-min-height;
387
- max-height: $gt-size-textarea-max-height;
388
- padding: em(12px);
389
- font-size: em(14px);
390
- color: inherit;
391
- word-wrap: break-word;
392
- resize: none;
393
- outline: none;
394
- background-color: var(--gt-color-input-bg);
395
- border: 1px solid var(--gt-color-input-border);
396
- border-radius: $gt-size-border-radius;
397
- transition: background-color ease 0.25s;
398
-
399
- &:hover,
400
- &:focus {
401
- background-color: var(--gt-color-input-bg-lighter);
402
- }
403
- }
404
-
405
- &-preview {
406
- min-height: $gt-size-textarea-min-height;
407
- padding: em(12px);
408
- background-color: var(--gt-color-input-bg);
409
- border: 1px solid var(--gt-color-input-border);
410
- border-radius: $gt-size-border-radius;
411
- }
412
-
413
- &-controls {
414
- position: relative;
415
- display: flex;
416
- align-items: center;
417
- margin: em(12px) 0 0;
418
-
419
- &-tip {
420
- margin-right: auto;
421
- font-size: em(14px);
422
- color: var(--gt-color-main);
423
- text-decoration: none;
424
-
425
- @include mobile {
426
- display: none;
427
- }
428
- }
429
-
430
- .gt-btn {
431
- margin-left: em(12px);
432
-
433
- @include mobile {
434
- width: 100%;
435
-
436
- &:first-of-type {
437
- margin-left: 0;
438
- }
439
- }
440
- }
441
- }
442
- }
443
-
444
- &-comments {
445
- padding-top: em(20px);
446
-
447
- &-null {
448
- text-align: center;
449
- }
450
-
451
- &-controls {
452
- margin: em(20px) 0;
453
- text-align: center;
454
- }
455
- }
456
-
457
- &-comment {
458
- position: relative;
459
- display: flex;
460
- padding: em(10px) 0;
461
-
462
- &-content {
463
- position: relative;
464
- flex: 1;
465
- padding: em(12px) em(16px);
466
- margin-left: em(20px);
467
- overflow: auto;
468
- background-color: var(--gt-color-comment-bg);
469
- transition: all ease 0.25s;
470
-
471
- &:hover {
472
- box-shadow: 0 em(2px) em(24px) 0 var(--gt-color-comment-shadow);
473
- }
474
-
475
- @include mobile {
476
- padding: em(10px) em(12px);
477
- margin-left: em(14px);
478
- }
479
- }
480
-
481
- &-collapse {
482
- position: absolute;
483
- right: 0;
484
- bottom: 0;
485
- left: 0;
486
- display: flex;
487
- align-items: center;
488
- justify-content: center;
489
- padding: em(6px);
490
- cursor: pointer;
491
- background: var(--gt-color-comment-collapse-bg);
492
-
493
- .gt-ico-collapse {
494
- .gt-svg {
495
- svg {
496
- fill: var(--gt-color-text);
497
- scale: 1.2;
498
- }
499
- }
500
- }
501
- }
502
-
503
- &-header {
504
- position: relative;
505
- display: flex;
506
- margin-bottom: em(8px);
507
- font-size: em(14px);
508
- }
509
-
510
- &-username {
511
- font-weight: 500;
512
- color: var(--gt-color-main);
513
- text-decoration: none;
514
-
515
- &:hover {
516
- text-decoration: underline;
517
- }
518
- }
519
-
520
- &-date {
521
- margin-left: em(8px);
522
- color: var(--gt-color-sub);
523
-
524
- &__prefix {
525
- margin-right: em(4px);
526
-
527
- @include mobile {
528
- display: none;
529
- }
530
- }
531
-
532
- &__time {
533
- @include mobile {
534
- font-size: $gt-size-base * 0.7;
535
- }
536
- }
537
- }
538
-
539
- &-actions {
540
- display: flex;
541
- gap: em(12px);
542
- margin-left: auto;
543
- }
544
-
545
- &-like,
546
- &-edit,
547
- &-reply {
548
- height: em(22px);
549
-
550
- &:hover {
551
- cursor: pointer;
552
- }
553
- }
554
-
555
- &-body {
556
- color: var(--gt-color-comment-txt);
557
- background-color: inherit;
558
-
559
- .email-hidden-toggle a {
560
- display: inline-block;
561
- height: em(12px);
562
- padding: 0 em(9px);
563
- font-size: em(12px);
564
- font-weight: 600;
565
- line-height: em(6px);
566
- vertical-align: middle;
567
- color: #444d56;
568
- text-decoration: none;
569
- background: #dfe2e5;
570
- border-radius: 1px;
571
-
572
- &:hover {
573
- background-color: #c6cbd1;
574
- }
575
- }
576
-
577
- .email-hidden-reply {
578
- display: none;
579
- white-space: pre-wrap;
580
-
581
- &.expanded {
582
- display: block;
583
- }
584
-
585
- .email-signature-reply {
586
- padding: 0 em(15px);
587
- margin: em(15px) 0;
588
- color: #586069;
589
- border-left: em(4px) solid #dfe2e5;
590
- }
591
- }
592
- }
593
-
594
- &-admin {
595
- .gt-comment-content {
596
- box-shadow: 0 em(2px) em(12px) 0 var(--gt-color-comment-shadow);
597
-
598
- &:hover {
599
- box-shadow: 0 em(2px) em(24px) 0
600
- var(--gt-color-comment-shadow-admin);
601
- }
602
- }
603
- }
604
- }
605
- }
606
-
607
- &::after {
608
- position: fixed;
609
- content: '';
610
- opacity: 0;
611
- }
612
-
613
- &.gt-input-focused {
614
- position: relative;
615
-
616
- &::after {
617
- inset: 0;
618
- z-index: $gt-mask-z-index;
619
- background: #171717;
620
- opacity: 0.8;
621
- transition: opacity ease 0.3s;
622
- }
623
-
624
- .gt-header-comment {
625
- z-index: $gt-mask-z-index + 1;
626
- }
627
- }
628
- }
@@ -1,28 +0,0 @@
1
- @use 'sass:color';
2
- @use './base';
3
- @import 'github-markdown-css/github-markdown-dark.css';
4
-
5
- .gt-container {
6
- --gt-theme-mode: dark;
7
- --gt-color-text: #e9e9e9;
8
- --gt-color-main: #6366f1;
9
- --gt-color-main-lighter: #{color.adjust(#6366f1, $lightness: 5%)};
10
- --gt-color-sub: #9e9e9e;
11
- --gt-color-loader: #777;
12
- --gt-color-error: #ef4444;
13
- --gt-color-hr: #555;
14
- --gt-color-input-border: rgb(255 255 255 / 10%);
15
- --gt-color-input-bg: #212121;
16
- --gt-color-input-bg-lighter: #{color.adjust(#212121, $lightness: 6%)};
17
- --gt-color-comment-bg: #212121;
18
- --gt-color-comment-shadow: #{color.adjust(#212121, $lightness: 18%)};
19
- --gt-color-comment-shadow-admin: #{color.adjust(#212121, $lightness: 24%)};
20
- --gt-color-comment-txt: #fafafa;
21
- --gt-color-comment-collapse-bg: linear-gradient(
22
- rgb(20 20 20 / 10%),
23
- rgb(20 20 20 / 90%)
24
- );
25
- --gt-color-link-active: #fafafa;
26
- --gt-color-btn: #eee;
27
- --gt-color-popbg: #171717;
28
- }
@@ -1,28 +0,0 @@
1
- @use 'sass:color';
2
- @use './base';
3
- @import 'github-markdown-css/github-markdown-light.css';
4
-
5
- .gt-container {
6
- --gt-theme-mode: light;
7
- --gt-color-text: #171717;
8
- --gt-color-main: #3b82f6;
9
- --gt-color-main-lighter: #{color.adjust(#3b82f6, $lightness: 10%)};
10
- --gt-color-sub: #a1a1a1;
11
- --gt-color-loader: #999;
12
- --gt-color-error: #ff3860;
13
- --gt-color-hr: #e9e9e9;
14
- --gt-color-input-border: rgb(0 0 0 / 10%);
15
- --gt-color-input-bg: #f6f6f6;
16
- --gt-color-input-bg-lighter: #{color.adjust(#f6f6f6, $lightness: 50%)};
17
- --gt-color-comment-bg: #f9f9f9;
18
- --gt-color-comment-shadow: #{color.adjust(#f9f9f9, $lightness: -12%)};
19
- --gt-color-comment-shadow-admin: #{color.adjust(#f9f9f9, $lightness: -18%)};
20
- --gt-color-comment-txt: #333;
21
- --gt-color-comment-collapse-bg: linear-gradient(
22
- rgb(245 245 245 / 10%),
23
- rgb(245 245 245 / 90%)
24
- );
25
- --gt-color-link-active: #333;
26
- --gt-color-btn: #fff;
27
- --gt-color-popbg: #fff;
28
- }
@@ -1,35 +0,0 @@
1
- import logger from "./logger";
2
-
3
- export const supportsCSSVariables = () => {
4
- const testKey = "--supports-css-variables";
5
- const testValue = "1rem";
6
-
7
- try {
8
- const testElement = document.createElement("div");
9
- testElement.style.setProperty(testKey, testValue);
10
-
11
- return testElement.style.getPropertyValue(testKey) === testValue;
12
- } catch (error) {
13
- logger.e(
14
- `An error occurred while checking browser compatibility with CSS variables:`,
15
- error,
16
- );
17
- return false;
18
- }
19
- };
20
-
21
- export const supportsES2020 = () => {
22
- try {
23
- return (
24
- typeof BigInt !== "undefined" &&
25
- typeof Promise.allSettled === "function" &&
26
- typeof String.prototype.matchAll === "function"
27
- );
28
- } catch (error) {
29
- logger.e(
30
- `An error occurred while checking browser compatibility with ES2020:`,
31
- error,
32
- );
33
- return false;
34
- }
35
- };