gitalk-react 1.0.0 → 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.
- package/README-zh-CN.md +152 -53
- package/README.md +132 -34
- package/dist/gitalk-dark.css +1 -1
- package/dist/gitalk-light.css +1 -1
- package/dist/gitalk.browser.full.js +102 -0
- package/dist/gitalk.browser.js +94 -0
- package/dist/gitalk.cjs +94 -0
- package/dist/gitalk.d.cts +14 -0
- package/dist/gitalk.d.mts +174 -0
- package/dist/gitalk.js +2737 -10382
- package/package.json +61 -41
- package/proxy-server/.env.example +6 -0
- package/proxy-server/README.md +38 -0
- package/proxy-server/server.mjs +110 -0
- package/dist/gitalk.d.ts +0 -623
- package/dist/gitalk.umd.cjs +0 -126
- package/lib/assets/arrow-down.svg +0 -1
- package/lib/assets/edit.svg +0 -3
- package/lib/assets/github.svg +0 -3
- package/lib/assets/heart-filled.svg +0 -3
- package/lib/assets/heart.svg +0 -3
- package/lib/assets/reply.svg +0 -3
- package/lib/assets/tip.svg +0 -8
- package/lib/components/action.tsx +0 -21
- package/lib/components/avatar.tsx +0 -42
- package/lib/components/button.tsx +0 -35
- package/lib/components/comment-textarea.tsx +0 -166
- package/lib/components/comment.tsx +0 -204
- package/lib/components/comments-list.tsx +0 -112
- package/lib/components/meta.tsx +0 -133
- package/lib/components/svg.tsx +0 -29
- package/lib/constants/index.ts +0 -71
- package/lib/contexts/I18nContext.ts +0 -20
- package/lib/gitalk.tsx +0 -891
- package/lib/i18n/ar.json +0 -20
- package/lib/i18n/bn.json +0 -20
- package/lib/i18n/de.json +0 -20
- package/lib/i18n/en.json +0 -20
- package/lib/i18n/es.json +0 -20
- package/lib/i18n/fa.json +0 -20
- package/lib/i18n/fr.json +0 -20
- package/lib/i18n/hi.json +0 -20
- package/lib/i18n/index.ts +0 -53
- package/lib/i18n/ja.json +0 -20
- package/lib/i18n/ko.json +0 -20
- package/lib/i18n/pl.json +0 -21
- package/lib/i18n/pt.json +0 -20
- package/lib/i18n/ru.json +0 -20
- package/lib/i18n/ur.json +0 -20
- package/lib/i18n/zh-CN.json +0 -20
- package/lib/i18n/zh-TW.json +0 -20
- package/lib/interfaces/index.ts +0 -198
- package/lib/services/graphql/comment.ts +0 -84
- package/lib/services/request.ts +0 -24
- package/lib/services/user.ts +0 -40
- package/lib/themes/base.scss +0 -630
- package/lib/themes/gitalk-dark.scss +0 -28
- package/lib/themes/gitalk-light.scss +0 -28
- package/lib/utils/compatibility.ts +0 -35
- package/lib/utils/dom.ts +0 -15
- package/lib/utils/logger.ts +0 -66
- package/lib/utils/query.ts +0 -19
- package/lib/vite-env.d.ts +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Gitalk as Component,
|
|
3
|
+
GitalkProps as Props,
|
|
4
|
+
} from "./gitalk.d.mts" with { "resolution-mode": "import" };
|
|
5
|
+
|
|
6
|
+
declare const Gitalk: typeof Component & {
|
|
7
|
+
Gitalk: typeof Component;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
declare namespace Gitalk {
|
|
11
|
+
type GitalkProps = Props;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export = Gitalk;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { Endpoints } from '@octokit/types';
|
|
3
|
+
|
|
4
|
+
declare type Comment_2 = Pick<CommentDefine, "id" | "node_id" | "body" | "body_html" | "created_at" | "html_url"> & {
|
|
5
|
+
user: Pick<NonNullable<CommentDefine["user"]>, "avatar_url" | "login" | "html_url">;
|
|
6
|
+
reactions: Pick<NonNullable<CommentDefine["reactions"]>, "heart">;
|
|
7
|
+
reactionsHeart: {
|
|
8
|
+
totalCount: number;
|
|
9
|
+
viewerHasReacted: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare type CommentDefine = Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}/comments"]["response"]["data"][number];
|
|
14
|
+
|
|
15
|
+
declare const Gitalk: default_2.FC<GitalkProps>;
|
|
16
|
+
export { Gitalk }
|
|
17
|
+
export default Gitalk;
|
|
18
|
+
|
|
19
|
+
export declare interface GitalkProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id" | "title"> {
|
|
20
|
+
/**
|
|
21
|
+
* GitHub Application Client ID.
|
|
22
|
+
*/
|
|
23
|
+
clientID: string;
|
|
24
|
+
/**
|
|
25
|
+
* GitHub Application Client Secret.
|
|
26
|
+
* When provided, exchange credentials through the selected CORS proxy.
|
|
27
|
+
* Exposed in browser code; omit it to use a server-side `proxy`.
|
|
28
|
+
*/
|
|
29
|
+
clientSecret?: string;
|
|
30
|
+
/**
|
|
31
|
+
* GitHub repository owner.
|
|
32
|
+
* Can be personal user or organization.
|
|
33
|
+
*/
|
|
34
|
+
owner: string;
|
|
35
|
+
/**
|
|
36
|
+
* Name of Github repository.
|
|
37
|
+
*/
|
|
38
|
+
repo: string;
|
|
39
|
+
/**
|
|
40
|
+
* GitHub repository owner and collaborators.
|
|
41
|
+
* (Users who having write access to this repository)
|
|
42
|
+
*/
|
|
43
|
+
admin: string[];
|
|
44
|
+
/**
|
|
45
|
+
* The unique id of the page.
|
|
46
|
+
* Length must less than 50.
|
|
47
|
+
*
|
|
48
|
+
* @default location.host + location.pathname
|
|
49
|
+
*/
|
|
50
|
+
id?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The issue ID of the page.
|
|
53
|
+
* If the number attribute is not defined, issue will be located using id.
|
|
54
|
+
*/
|
|
55
|
+
number?: number;
|
|
56
|
+
/**
|
|
57
|
+
* GitHub issue labels.
|
|
58
|
+
*
|
|
59
|
+
* @default ['Gitalk']
|
|
60
|
+
*/
|
|
61
|
+
labels?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* GitHub issue title.
|
|
64
|
+
*
|
|
65
|
+
* @default document.title
|
|
66
|
+
*/
|
|
67
|
+
title?: string;
|
|
68
|
+
/**
|
|
69
|
+
* GitHub issue body.
|
|
70
|
+
*
|
|
71
|
+
* @default location.href + header.meta[description]
|
|
72
|
+
*/
|
|
73
|
+
body?: string;
|
|
74
|
+
/**
|
|
75
|
+
* BCP 47 language tag. Regional tags use the available base translation;
|
|
76
|
+
* Chinese tags preserve simplified/traditional script differences.
|
|
77
|
+
*
|
|
78
|
+
* @default navigator.language
|
|
79
|
+
*/
|
|
80
|
+
language?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Pagination size, with maximum 100.
|
|
83
|
+
*
|
|
84
|
+
* @default 10
|
|
85
|
+
*/
|
|
86
|
+
perPage?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Comment sorting direction.
|
|
89
|
+
* Available values are `last` and `first`.
|
|
90
|
+
*
|
|
91
|
+
* @default "last"
|
|
92
|
+
*/
|
|
93
|
+
pagerDirection?: "last" | "first";
|
|
94
|
+
/**
|
|
95
|
+
* 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.
|
|
96
|
+
* You can create it manually by setting this option to true.
|
|
97
|
+
*
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
createIssueManually?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Enable hot key (cmd|ctrl + enter) submit comment.
|
|
103
|
+
*
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
enableHotKey?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Facebook-like distraction free mode.
|
|
109
|
+
*
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
distractionFreeMode?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* With `clientSecret`: optional CORS relay, defaulting to `https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token`.
|
|
115
|
+
* Without `clientSecret`: required server-side OAuth exchange endpoint.
|
|
116
|
+
* Server-side mode receives GET requests with only `code` and returns
|
|
117
|
+
* `{ access_token: string }`; credentials stay on the server.
|
|
118
|
+
*/
|
|
119
|
+
proxy?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Default user field if comments' author is not provided
|
|
122
|
+
*
|
|
123
|
+
* @default
|
|
124
|
+
* ```ts
|
|
125
|
+
* {
|
|
126
|
+
* avatar_url: "//avatars1.githubusercontent.com/u/29697133?s=50",
|
|
127
|
+
* login: "null",
|
|
128
|
+
* html_url: ""
|
|
129
|
+
* }
|
|
130
|
+
*/
|
|
131
|
+
defaultUser?: Comment_2["user"];
|
|
132
|
+
/**
|
|
133
|
+
* Default user field if comments' author is not provided
|
|
134
|
+
*
|
|
135
|
+
* @deprecated use `defaultUser`
|
|
136
|
+
*/
|
|
137
|
+
defaultAuthor?: {
|
|
138
|
+
avatarUrl: Comment_2["user"]["avatar_url"];
|
|
139
|
+
login: Comment_2["user"]["login"];
|
|
140
|
+
url: Comment_2["user"]["html_url"];
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Default collapse the comment if meets the height (px)
|
|
144
|
+
*/
|
|
145
|
+
collapsedHeight?: number;
|
|
146
|
+
/**
|
|
147
|
+
* Whether to highlight the comment created by admin users.
|
|
148
|
+
*
|
|
149
|
+
* @default true
|
|
150
|
+
*/
|
|
151
|
+
highlightAdminComment?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Callback method invoked when updating the number of comments.
|
|
154
|
+
*
|
|
155
|
+
* @param count comments number
|
|
156
|
+
*/
|
|
157
|
+
updateCountCallback?: (count: number) => void;
|
|
158
|
+
/**
|
|
159
|
+
* Callback method invoked when a new issue is successfully created.
|
|
160
|
+
*
|
|
161
|
+
* @param issue created issue
|
|
162
|
+
*/
|
|
163
|
+
onCreateIssue?: (issue: Issue) => 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 type Issue = Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}"]["response"]["data"];
|
|
173
|
+
|
|
174
|
+
export { }
|