gitalk-react 1.0.0-beta.1
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.
- package/LICENSE +9 -0
- package/README-zh-CN.md +257 -0
- package/README.md +257 -0
- package/dist/gitalk-dark.css +1 -0
- package/dist/gitalk-light.css +1 -0
- package/dist/gitalk.d.ts +445 -0
- package/dist/gitalk.js +12560 -0
- package/dist/gitalk.umd.cjs +121 -0
- package/lib/assets/arrow-down.svg +1 -0
- package/lib/assets/edit.svg +3 -0
- package/lib/assets/github.svg +3 -0
- package/lib/assets/heart-filled.svg +3 -0
- package/lib/assets/heart.svg +3 -0
- package/lib/assets/reply.svg +3 -0
- package/lib/assets/tip.svg +8 -0
- package/lib/components/action.tsx +21 -0
- package/lib/components/avatar.tsx +42 -0
- package/lib/components/button.tsx +35 -0
- package/lib/components/comment.tsx +153 -0
- package/lib/components/svg.tsx +29 -0
- package/lib/constants/index.ts +43 -0
- package/lib/contexts/I18nContext.ts +18 -0
- package/lib/gitalk.tsx +1231 -0
- package/lib/i18n/de.json +20 -0
- package/lib/i18n/en.json +20 -0
- package/lib/i18n/es-ES.json +20 -0
- package/lib/i18n/fa.json +20 -0
- package/lib/i18n/fr.json +20 -0
- package/lib/i18n/index.ts +40 -0
- package/lib/i18n/ja.json +20 -0
- package/lib/i18n/ko.json +20 -0
- package/lib/i18n/pl.json +21 -0
- package/lib/i18n/ru.json +20 -0
- package/lib/i18n/zh-CN.json +20 -0
- package/lib/i18n/zh-TW.json +20 -0
- package/lib/interfaces/index.ts +30 -0
- package/lib/services/graphql/comment.ts +85 -0
- package/lib/services/request.ts +24 -0
- package/lib/services/user.ts +40 -0
- package/lib/themes/base.scss +592 -0
- package/lib/themes/gitalk-dark.scss +24 -0
- package/lib/themes/gitalk-light.scss +24 -0
- package/lib/utils/compatibility.ts +35 -0
- package/lib/utils/dom.ts +15 -0
- package/lib/utils/logger.ts +56 -0
- package/lib/utils/query.ts +19 -0
- package/package.json +83 -0
package/dist/gitalk.d.ts
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { default as default_3 } from 'react-flip-move';
|
|
3
|
+
import { Endpoints } from '@octokit/types';
|
|
4
|
+
|
|
5
|
+
declare type Comment_2 = Pick<CommentDefine, "id" | "body" | "body_html" | "created_at" | "html_url"> & {
|
|
6
|
+
user: Pick<NonNullable<CommentDefine["user"]>, "avatar_url" | "login" | "html_url">;
|
|
7
|
+
reactions: Pick<NonNullable<CommentDefine["reactions"]>, "heart">;
|
|
8
|
+
reactionsHeart: {
|
|
9
|
+
totalCount: number;
|
|
10
|
+
viewerHasReacted: boolean;
|
|
11
|
+
nodes: {
|
|
12
|
+
databaseId: number;
|
|
13
|
+
user: {
|
|
14
|
+
login: string;
|
|
15
|
+
};
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare type CommentDefine = Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}/comments"]["response"]["data"][number];
|
|
21
|
+
|
|
22
|
+
declare const Gitalk: default_2.FC<GitalkProps>;
|
|
23
|
+
export default Gitalk;
|
|
24
|
+
|
|
25
|
+
declare interface GitalkProps extends Omit<default_2.HTMLAttributes<HTMLDivElement>, "id" | "title"> {
|
|
26
|
+
/**
|
|
27
|
+
* GitHub Application Client ID.
|
|
28
|
+
*/
|
|
29
|
+
clientID: string;
|
|
30
|
+
/**
|
|
31
|
+
* GitHub Application Client Secret.
|
|
32
|
+
*/
|
|
33
|
+
clientSecret: string;
|
|
34
|
+
/**
|
|
35
|
+
* GitHub repository owner.
|
|
36
|
+
* Can be personal user or organization.
|
|
37
|
+
*/
|
|
38
|
+
owner: string;
|
|
39
|
+
/**
|
|
40
|
+
* Name of Github repository.
|
|
41
|
+
*/
|
|
42
|
+
repo: string;
|
|
43
|
+
/**
|
|
44
|
+
* GitHub repository owner and collaborators.
|
|
45
|
+
* (Users who having write access to this repository)
|
|
46
|
+
*/
|
|
47
|
+
admin: string[];
|
|
48
|
+
/**
|
|
49
|
+
* The unique id of the page.
|
|
50
|
+
* Length must less than 50.
|
|
51
|
+
*
|
|
52
|
+
* @default location.href
|
|
53
|
+
*/
|
|
54
|
+
id?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The issue ID of the page.
|
|
57
|
+
* If the number attribute is not defined, issue will be located using id.
|
|
58
|
+
*
|
|
59
|
+
* @default -1
|
|
60
|
+
*/
|
|
61
|
+
number?: number;
|
|
62
|
+
/**
|
|
63
|
+
* GitHub issue labels.
|
|
64
|
+
*
|
|
65
|
+
* @default ['Gitalk']
|
|
66
|
+
*/
|
|
67
|
+
labels?: string[];
|
|
68
|
+
/**
|
|
69
|
+
* GitHub issue title.
|
|
70
|
+
*
|
|
71
|
+
* @default document.title
|
|
72
|
+
*/
|
|
73
|
+
title?: string;
|
|
74
|
+
/**
|
|
75
|
+
* GitHub issue body.
|
|
76
|
+
*
|
|
77
|
+
* @default location.href + header.meta[description]
|
|
78
|
+
*/
|
|
79
|
+
body?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Localization language key.
|
|
82
|
+
*
|
|
83
|
+
* @default navigator.language
|
|
84
|
+
*/
|
|
85
|
+
language?: Lang;
|
|
86
|
+
/**
|
|
87
|
+
* Pagination size, with maximum 100.
|
|
88
|
+
*
|
|
89
|
+
* @default 10
|
|
90
|
+
*/
|
|
91
|
+
perPage?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Comment sorting direction.
|
|
94
|
+
* Available values are last and first.
|
|
95
|
+
*
|
|
96
|
+
* @default "last"
|
|
97
|
+
*/
|
|
98
|
+
pagerDirection?: "last" | "first";
|
|
99
|
+
/**
|
|
100
|
+
* By default, Gitalk will create a corresponding github issue for your every single page automatically when the logined user is belong to the admin users.
|
|
101
|
+
* You can create it manually by setting this option to true.
|
|
102
|
+
*
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
createIssueManually?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Enable hot key (cmd|ctrl + enter) submit comment.
|
|
108
|
+
*
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
enableHotKey?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Facebook-like distraction free mode.
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
distractionFreeMode?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Comment list animation.
|
|
120
|
+
*
|
|
121
|
+
* @default
|
|
122
|
+
* ```ts
|
|
123
|
+
* {
|
|
124
|
+
* staggerDelayBy: 150,
|
|
125
|
+
* appearAnimation: 'accordionVertical',
|
|
126
|
+
* enterAnimation: 'accordionVertical',
|
|
127
|
+
* leaveAnimation: 'accordionVertical',
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
* @link https://github.com/joshwcomeau/react-flip-move/blob/master/documentation/enter_leave_animations.md
|
|
131
|
+
*/
|
|
132
|
+
flipMoveOptions?: default_3.FlipMoveProps;
|
|
133
|
+
/**
|
|
134
|
+
* GitHub oauth request reverse proxy for CORS.
|
|
135
|
+
* [Why need this?](https://github.com/isaacs/github/issues/330)
|
|
136
|
+
*
|
|
137
|
+
* @default "https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token"
|
|
138
|
+
*/
|
|
139
|
+
proxy?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Default user field if comments' author is not provided
|
|
142
|
+
*
|
|
143
|
+
* @default
|
|
144
|
+
* ```ts
|
|
145
|
+
* {
|
|
146
|
+
* avatar_url: "//avatars1.githubusercontent.com/u/29697133?s=50",
|
|
147
|
+
* login: "null",
|
|
148
|
+
* html_url: ""
|
|
149
|
+
* }
|
|
150
|
+
*/
|
|
151
|
+
defaultUser?: Comment_2["user"];
|
|
152
|
+
/**
|
|
153
|
+
* Default user field if comments' author is not provided
|
|
154
|
+
*
|
|
155
|
+
* @deprecated use `defaultUser`
|
|
156
|
+
*/
|
|
157
|
+
defaultAuthor?: IssueCommentsQLResponse["repository"]["issue"]["comments"]["nodes"][number]["author"];
|
|
158
|
+
/**
|
|
159
|
+
* Callback method invoked when updating the number of comments.
|
|
160
|
+
*
|
|
161
|
+
* @param count comments number
|
|
162
|
+
*/
|
|
163
|
+
updateCountCallback?: (count: number) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Callback method invoked when a new comment is successfully created.
|
|
166
|
+
*
|
|
167
|
+
* @param comment created comment
|
|
168
|
+
*/
|
|
169
|
+
onCreateComment?: (comment: Comment_2) => void;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare const i18nMap: {
|
|
173
|
+
zh: {
|
|
174
|
+
init: string;
|
|
175
|
+
"no-found-related": string;
|
|
176
|
+
"please-contact": string;
|
|
177
|
+
"init-issue": string;
|
|
178
|
+
"leave-a-comment": string;
|
|
179
|
+
preview: string;
|
|
180
|
+
edit: string;
|
|
181
|
+
comment: string;
|
|
182
|
+
"support-markdown": string;
|
|
183
|
+
"login-with-github": string;
|
|
184
|
+
"first-comment-person": string;
|
|
185
|
+
commented: string;
|
|
186
|
+
"load-more": string;
|
|
187
|
+
counts: string;
|
|
188
|
+
"sort-asc": string;
|
|
189
|
+
"sort-desc": string;
|
|
190
|
+
logout: string;
|
|
191
|
+
anonymous: string;
|
|
192
|
+
};
|
|
193
|
+
"zh-CN": {
|
|
194
|
+
init: string;
|
|
195
|
+
"no-found-related": string;
|
|
196
|
+
"please-contact": string;
|
|
197
|
+
"init-issue": string;
|
|
198
|
+
"leave-a-comment": string;
|
|
199
|
+
preview: string;
|
|
200
|
+
edit: string;
|
|
201
|
+
comment: string;
|
|
202
|
+
"support-markdown": string;
|
|
203
|
+
"login-with-github": string;
|
|
204
|
+
"first-comment-person": string;
|
|
205
|
+
commented: string;
|
|
206
|
+
"load-more": string;
|
|
207
|
+
counts: string;
|
|
208
|
+
"sort-asc": string;
|
|
209
|
+
"sort-desc": string;
|
|
210
|
+
logout: string;
|
|
211
|
+
anonymous: string;
|
|
212
|
+
};
|
|
213
|
+
"zh-TW": {
|
|
214
|
+
init: string;
|
|
215
|
+
"no-found-related": string;
|
|
216
|
+
"please-contact": string;
|
|
217
|
+
"init-issue": string;
|
|
218
|
+
"leave-a-comment": string;
|
|
219
|
+
preview: string;
|
|
220
|
+
edit: string;
|
|
221
|
+
comment: string;
|
|
222
|
+
"support-markdown": string;
|
|
223
|
+
"login-with-github": string;
|
|
224
|
+
"first-comment-person": string;
|
|
225
|
+
commented: string;
|
|
226
|
+
"load-more": string;
|
|
227
|
+
counts: string;
|
|
228
|
+
"sort-asc": string;
|
|
229
|
+
"sort-desc": string;
|
|
230
|
+
logout: string;
|
|
231
|
+
anonymous: string;
|
|
232
|
+
};
|
|
233
|
+
en: {
|
|
234
|
+
init: string;
|
|
235
|
+
"no-found-related": string;
|
|
236
|
+
"please-contact": string;
|
|
237
|
+
"init-issue": string;
|
|
238
|
+
"leave-a-comment": string;
|
|
239
|
+
preview: string;
|
|
240
|
+
edit: string;
|
|
241
|
+
comment: string;
|
|
242
|
+
"support-markdown": string;
|
|
243
|
+
"login-with-github": string;
|
|
244
|
+
"first-comment-person": string;
|
|
245
|
+
commented: string;
|
|
246
|
+
"load-more": string;
|
|
247
|
+
counts: string;
|
|
248
|
+
"sort-asc": string;
|
|
249
|
+
"sort-desc": string;
|
|
250
|
+
logout: string;
|
|
251
|
+
anonymous: string;
|
|
252
|
+
};
|
|
253
|
+
"es-ES": {
|
|
254
|
+
init: string;
|
|
255
|
+
"no-found-related": string;
|
|
256
|
+
"please-contact": string;
|
|
257
|
+
"init-issue": string;
|
|
258
|
+
"leave-a-comment": string;
|
|
259
|
+
preview: string;
|
|
260
|
+
edit: string;
|
|
261
|
+
comment: string;
|
|
262
|
+
"support-markdown": string;
|
|
263
|
+
"login-with-github": string;
|
|
264
|
+
"first-comment-person": string;
|
|
265
|
+
commented: string;
|
|
266
|
+
"load-more": string;
|
|
267
|
+
counts: string;
|
|
268
|
+
"sort-asc": string;
|
|
269
|
+
"sort-desc": string;
|
|
270
|
+
logout: string;
|
|
271
|
+
anonymous: string;
|
|
272
|
+
};
|
|
273
|
+
fr: {
|
|
274
|
+
init: string;
|
|
275
|
+
"no-found-related": string;
|
|
276
|
+
"please-contact": string;
|
|
277
|
+
"init-issue": string;
|
|
278
|
+
"leave-a-comment": string;
|
|
279
|
+
preview: string;
|
|
280
|
+
edit: string;
|
|
281
|
+
comment: string;
|
|
282
|
+
"support-markdown": string;
|
|
283
|
+
"login-with-github": string;
|
|
284
|
+
"first-comment-person": string;
|
|
285
|
+
commented: string;
|
|
286
|
+
"load-more": string;
|
|
287
|
+
counts: string;
|
|
288
|
+
"sort-asc": string;
|
|
289
|
+
"sort-desc": string;
|
|
290
|
+
logout: string;
|
|
291
|
+
anonymous: string;
|
|
292
|
+
};
|
|
293
|
+
ru: {
|
|
294
|
+
init: string;
|
|
295
|
+
"no-found-related": string;
|
|
296
|
+
"please-contact": string;
|
|
297
|
+
"init-issue": string;
|
|
298
|
+
"leave-a-comment": string;
|
|
299
|
+
preview: string;
|
|
300
|
+
edit: string;
|
|
301
|
+
comment: string;
|
|
302
|
+
"support-markdown": string;
|
|
303
|
+
"login-with-github": string;
|
|
304
|
+
"first-comment-person": string;
|
|
305
|
+
commented: string;
|
|
306
|
+
"load-more": string;
|
|
307
|
+
counts: string;
|
|
308
|
+
"sort-asc": string;
|
|
309
|
+
"sort-desc": string;
|
|
310
|
+
logout: string;
|
|
311
|
+
anonymous: string;
|
|
312
|
+
};
|
|
313
|
+
de: {
|
|
314
|
+
init: string;
|
|
315
|
+
"no-found-related": string;
|
|
316
|
+
"please-contact": string;
|
|
317
|
+
"init-issue": string;
|
|
318
|
+
"leave-a-comment": string;
|
|
319
|
+
preview: string;
|
|
320
|
+
edit: string;
|
|
321
|
+
comment: string;
|
|
322
|
+
"support-markdown": string;
|
|
323
|
+
"login-with-github": string;
|
|
324
|
+
"first-comment-person": string;
|
|
325
|
+
commented: string;
|
|
326
|
+
"load-more": string;
|
|
327
|
+
counts: string;
|
|
328
|
+
"sort-asc": string;
|
|
329
|
+
"sort-desc": string;
|
|
330
|
+
logout: string;
|
|
331
|
+
anonymous: string;
|
|
332
|
+
};
|
|
333
|
+
pl: {
|
|
334
|
+
init: string;
|
|
335
|
+
"no-found-related": string;
|
|
336
|
+
"please-contact": string;
|
|
337
|
+
"init-issue": string;
|
|
338
|
+
"leave-a-comment": string;
|
|
339
|
+
preview: string;
|
|
340
|
+
edit: string;
|
|
341
|
+
comment: string;
|
|
342
|
+
"support-markdown": string;
|
|
343
|
+
"login-with-github": string;
|
|
344
|
+
"first-comment-person": string;
|
|
345
|
+
commented: string;
|
|
346
|
+
"load-more": string;
|
|
347
|
+
counts: string;
|
|
348
|
+
"sort-asc": string;
|
|
349
|
+
"sort-desc": string;
|
|
350
|
+
logout: string;
|
|
351
|
+
anonymous: string;
|
|
352
|
+
};
|
|
353
|
+
ko: {
|
|
354
|
+
init: string;
|
|
355
|
+
"no-found-related": string;
|
|
356
|
+
"please-contact": string;
|
|
357
|
+
"init-issue": string;
|
|
358
|
+
"leave-a-comment": string;
|
|
359
|
+
preview: string;
|
|
360
|
+
edit: string;
|
|
361
|
+
comment: string;
|
|
362
|
+
"support-markdown": string;
|
|
363
|
+
"login-with-github": string;
|
|
364
|
+
"first-comment-person": string;
|
|
365
|
+
commented: string;
|
|
366
|
+
"load-more": string;
|
|
367
|
+
counts: string;
|
|
368
|
+
"sort-asc": string;
|
|
369
|
+
"sort-desc": string;
|
|
370
|
+
logout: string;
|
|
371
|
+
anonymous: string;
|
|
372
|
+
};
|
|
373
|
+
fa: {
|
|
374
|
+
init: string;
|
|
375
|
+
"no-found-related": string;
|
|
376
|
+
"please-contact": string;
|
|
377
|
+
"init-issue": string;
|
|
378
|
+
"leave-a-comment": string;
|
|
379
|
+
preview: string;
|
|
380
|
+
edit: string;
|
|
381
|
+
comment: string;
|
|
382
|
+
"support-markdown": string;
|
|
383
|
+
"login-with-github": string;
|
|
384
|
+
"first-comment-person": string;
|
|
385
|
+
commented: string;
|
|
386
|
+
"load-more": string;
|
|
387
|
+
counts: string;
|
|
388
|
+
"sort-asc": string;
|
|
389
|
+
"sort-desc": string;
|
|
390
|
+
logout: string;
|
|
391
|
+
anonymous: string;
|
|
392
|
+
};
|
|
393
|
+
ja: {
|
|
394
|
+
init: string;
|
|
395
|
+
"no-found-related": string;
|
|
396
|
+
"please-contact": string;
|
|
397
|
+
"init-issue": string;
|
|
398
|
+
"leave-a-comment": string;
|
|
399
|
+
preview: string;
|
|
400
|
+
edit: string;
|
|
401
|
+
comment: string;
|
|
402
|
+
"support-markdown": string;
|
|
403
|
+
"login-with-github": string;
|
|
404
|
+
"first-comment-person": string;
|
|
405
|
+
commented: string;
|
|
406
|
+
"load-more": string;
|
|
407
|
+
counts: string;
|
|
408
|
+
"sort-asc": string;
|
|
409
|
+
"sort-desc": string;
|
|
410
|
+
logout: string;
|
|
411
|
+
anonymous: string;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
declare interface IssueCommentsQLResponse {
|
|
416
|
+
repository: {
|
|
417
|
+
issue: {
|
|
418
|
+
comments: {
|
|
419
|
+
totalCount: number;
|
|
420
|
+
pageInfo: {
|
|
421
|
+
hasPreviousPage?: boolean;
|
|
422
|
+
hasNextPage?: boolean;
|
|
423
|
+
startCursor?: string;
|
|
424
|
+
endCursor?: string;
|
|
425
|
+
};
|
|
426
|
+
nodes: (Pick<Comment_2, "body"> & {
|
|
427
|
+
databaseId: Comment_2["id"];
|
|
428
|
+
author: {
|
|
429
|
+
avatarUrl: Comment_2["user"]["avatar_url"];
|
|
430
|
+
login: Comment_2["user"]["login"];
|
|
431
|
+
url: Comment_2["user"]["html_url"];
|
|
432
|
+
};
|
|
433
|
+
bodyHTML: Comment_2["body_html"];
|
|
434
|
+
createdAt: Comment_2["created_at"];
|
|
435
|
+
resourcePath: Comment_2["html_url"];
|
|
436
|
+
reactions: Comment_2["reactionsHeart"];
|
|
437
|
+
})[];
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
declare type Lang = keyof typeof i18nMap;
|
|
444
|
+
|
|
445
|
+
export { }
|