@waline/client 2.15.8 → 3.0.0-alpha.2
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/dist/comment.cjs +1 -1
- package/dist/comment.cjs.map +1 -1
- package/dist/comment.d.cts +2 -1
- package/dist/comment.d.mts +2 -1
- package/dist/comment.d.ts +2 -1
- package/dist/comment.js +1 -1
- package/dist/comment.js.map +1 -1
- package/dist/comment.mjs +1 -1
- package/dist/comment.mjs.map +1 -1
- package/dist/component.mjs +8 -1
- package/dist/component.mjs.map +1 -1
- package/dist/pageview.cjs +1 -1
- package/dist/pageview.cjs.map +1 -1
- package/dist/pageview.d.cts +2 -1
- package/dist/pageview.d.mts +2 -1
- package/dist/pageview.d.ts +2 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/pageview.mjs +1 -1
- package/dist/pageview.mjs.map +1 -1
- package/dist/shim.cjs +8 -1
- package/dist/shim.cjs.map +1 -1
- package/dist/shim.d.cts +7 -82
- package/dist/shim.d.mts +7 -82
- package/dist/shim.mjs +8 -1
- package/dist/shim.mjs.map +1 -1
- package/dist/waline.cjs +53 -1
- package/dist/waline.cjs.map +1 -1
- package/dist/waline.css +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.cts +7 -82
- package/dist/waline.d.mts +7 -82
- package/dist/waline.d.ts +7 -82
- package/dist/waline.js +53 -1
- package/dist/waline.js.map +1 -1
- package/dist/waline.mjs +53 -1
- package/dist/waline.mjs.map +1 -1
- package/package.json +20 -53
- package/dist/api.cjs +0 -2
- package/dist/api.cjs.map +0 -1
- package/dist/api.d.cts +0 -445
- package/dist/api.d.mts +0 -445
- package/dist/api.d.ts +0 -445
- package/dist/api.mjs +0 -2
- package/dist/api.mjs.map +0 -1
- package/dist/legacy.umd.d.ts +0 -628
- package/dist/legacy.umd.js +0 -2
- package/dist/legacy.umd.js.map +0 -1
- package/src/api/articleCounter.ts +0 -82
- package/src/api/comment.ts +0 -258
- package/src/api/commentCount.ts +0 -33
- package/src/api/index.ts +0 -7
- package/src/api/login.ts +0 -96
- package/src/api/pageview.ts +0 -54
- package/src/api/recentComment.ts +0 -42
- package/src/api/user.ts +0 -44
- package/src/api/utils.ts +0 -46
- package/src/comment.ts +0 -69
- package/src/compact/convert.ts +0 -80
- package/src/compact/dropped.ts +0 -35
- package/src/compact/index.ts +0 -4
- package/src/compact/logger.ts +0 -5
- package/src/compact/v1.ts +0 -103
- package/src/compact/valine.ts +0 -132
- package/src/components/ArticleReaction.vue +0 -159
- package/src/components/CommentBox.vue +0 -807
- package/src/components/CommentCard.vue +0 -271
- package/src/components/Icons.ts +0 -181
- package/src/components/ImageWall.vue +0 -169
- package/src/components/WalineComment.vue +0 -353
- package/src/composables/index.ts +0 -6
- package/src/composables/inputs.ts +0 -17
- package/src/composables/like.ts +0 -13
- package/src/composables/reaction.ts +0 -15
- package/src/composables/recaptchaV3.ts +0 -19
- package/src/composables/turnstile.ts +0 -50
- package/src/composables/userInfo.ts +0 -16
- package/src/config/default.ts +0 -93
- package/src/config/highlighter.ts +0 -74
- package/src/config/i18n/en.ts +0 -53
- package/src/config/i18n/generate.ts +0 -58
- package/src/config/i18n/index.ts +0 -30
- package/src/config/i18n/jp.ts +0 -53
- package/src/config/i18n/pt-BR.ts +0 -53
- package/src/config/i18n/ru.ts +0 -53
- package/src/config/i18n/vi-VN.ts +0 -53
- package/src/config/i18n/zh-CN.ts +0 -53
- package/src/config/i18n/zh-TW.ts +0 -53
- package/src/config/index.ts +0 -3
- package/src/entries/api.ts +0 -1
- package/src/entries/comment.ts +0 -2
- package/src/entries/components.ts +0 -2
- package/src/entries/full.ts +0 -7
- package/src/entries/init.ts +0 -4
- package/src/entries/legacy.ts +0 -31
- package/src/entries/pageview.ts +0 -2
- package/src/init.ts +0 -112
- package/src/pageview.ts +0 -116
- package/src/shims-vue.d.ts +0 -6
- package/src/styles/base.scss +0 -67
- package/src/styles/card.scss +0 -258
- package/src/styles/config.scss +0 -52
- package/src/styles/emoji.scss +0 -137
- package/src/styles/gif.scss +0 -73
- package/src/styles/helpers/_svg.scss +0 -51
- package/src/styles/highlight.scss +0 -138
- package/src/styles/index.scss +0 -12
- package/src/styles/layout.scss +0 -105
- package/src/styles/meta.scss +0 -82
- package/src/styles/normalize.scss +0 -117
- package/src/styles/panel.scss +0 -286
- package/src/styles/reaction.scss +0 -103
- package/src/styles/recent.scss +0 -3
- package/src/styles/user-list.scss +0 -159
- package/src/typings/base.ts +0 -123
- package/src/typings/comment.ts +0 -94
- package/src/typings/index.ts +0 -5
- package/src/typings/locale.ts +0 -73
- package/src/typings/options.ts +0 -44
- package/src/typings/waline.ts +0 -251
- package/src/utils/config.ts +0 -122
- package/src/utils/darkmode.ts +0 -11
- package/src/utils/date.ts +0 -71
- package/src/utils/email.ts +0 -8
- package/src/utils/emoji.ts +0 -73
- package/src/utils/error.ts +0 -3
- package/src/utils/getRoot.ts +0 -8
- package/src/utils/image.ts +0 -10
- package/src/utils/index.ts +0 -13
- package/src/utils/markdown.ts +0 -41
- package/src/utils/markedMathExtension.ts +0 -54
- package/src/utils/path.ts +0 -15
- package/src/utils/query.ts +0 -2
- package/src/utils/userAgent.ts +0 -31
- package/src/utils/wordCount.ts +0 -31
- package/src/version.ts +0 -3
- package/src/widgets/index.ts +0 -2
- package/src/widgets/recentComments.ts +0 -93
- package/src/widgets/userList.ts +0 -136
package/src/typings/comment.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
export interface WalineCommentData {
|
|
2
|
-
/**
|
|
3
|
-
* User Nickname
|
|
4
|
-
*/
|
|
5
|
-
nick: string;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* User email
|
|
9
|
-
*/
|
|
10
|
-
mail: string;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* User link
|
|
14
|
-
*/
|
|
15
|
-
link?: string;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Content of comment
|
|
19
|
-
*/
|
|
20
|
-
comment: string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* User Agent
|
|
24
|
-
*/
|
|
25
|
-
ua: string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Parent comment id
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
pid?: string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Root comment id
|
|
35
|
-
*/
|
|
36
|
-
rid?: string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* User id being at
|
|
40
|
-
*/
|
|
41
|
-
at?: string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Comment link
|
|
45
|
-
*/
|
|
46
|
-
url: string;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Recaptcha Token
|
|
50
|
-
*/
|
|
51
|
-
recaptchaV3?: string;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Turnstile Token
|
|
55
|
-
*/
|
|
56
|
-
turnstile?: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type WalineCommentStatus = 'approved' | 'waiting' | 'spam';
|
|
60
|
-
|
|
61
|
-
export interface WalineComment extends Exclude<WalineCommentData, 'ua'> {
|
|
62
|
-
/**
|
|
63
|
-
* User avatar
|
|
64
|
-
*/
|
|
65
|
-
avatar: string;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* User type
|
|
69
|
-
*/
|
|
70
|
-
type?: 'administrator' | 'guest' | `verify:${string}`;
|
|
71
|
-
|
|
72
|
-
objectId: string;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Time ISOString when the comment is created
|
|
76
|
-
*/
|
|
77
|
-
createdAt: string;
|
|
78
|
-
|
|
79
|
-
insertedAt: string;
|
|
80
|
-
updatedAt: string;
|
|
81
|
-
children: WalineComment[];
|
|
82
|
-
sticky?: boolean;
|
|
83
|
-
browser?: string;
|
|
84
|
-
os?: string;
|
|
85
|
-
level?: number;
|
|
86
|
-
addr?: string;
|
|
87
|
-
label?: string;
|
|
88
|
-
// TODO: Rename it to `userId` in next major version
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
90
|
-
user_id?: string | number;
|
|
91
|
-
status?: WalineCommentStatus;
|
|
92
|
-
like?: number;
|
|
93
|
-
orig?: string;
|
|
94
|
-
}
|
package/src/typings/index.ts
DELETED
package/src/typings/locale.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export interface WalineDateLocale {
|
|
2
|
-
seconds: string;
|
|
3
|
-
minutes: string;
|
|
4
|
-
hours: string;
|
|
5
|
-
days: string;
|
|
6
|
-
now: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type WalineLevelLocale = Record<`level${number}`, string>;
|
|
10
|
-
|
|
11
|
-
export interface WalineReactionLocale {
|
|
12
|
-
reactionTitle: string;
|
|
13
|
-
reaction0: string;
|
|
14
|
-
reaction1: string;
|
|
15
|
-
reaction2: string;
|
|
16
|
-
reaction3: string;
|
|
17
|
-
reaction4: string;
|
|
18
|
-
reaction5: string;
|
|
19
|
-
reaction6: string;
|
|
20
|
-
reaction7: string;
|
|
21
|
-
reaction8: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface WalineLocale
|
|
25
|
-
extends WalineDateLocale,
|
|
26
|
-
WalineLevelLocale,
|
|
27
|
-
WalineReactionLocale {
|
|
28
|
-
nick: string;
|
|
29
|
-
mail: string;
|
|
30
|
-
link: string;
|
|
31
|
-
optional: string;
|
|
32
|
-
placeholder: string;
|
|
33
|
-
sofa: string;
|
|
34
|
-
submit: string;
|
|
35
|
-
comment: string;
|
|
36
|
-
refresh: string;
|
|
37
|
-
more: string;
|
|
38
|
-
uploading: string;
|
|
39
|
-
login: string;
|
|
40
|
-
admin: string;
|
|
41
|
-
sticky: string;
|
|
42
|
-
word: string;
|
|
43
|
-
anonymous: string;
|
|
44
|
-
gif: string;
|
|
45
|
-
gifSearchPlaceholder: string;
|
|
46
|
-
|
|
47
|
-
// manage
|
|
48
|
-
approved: string;
|
|
49
|
-
waiting: string;
|
|
50
|
-
spam: string;
|
|
51
|
-
unsticky: string;
|
|
52
|
-
|
|
53
|
-
// sorting
|
|
54
|
-
oldest: string;
|
|
55
|
-
latest: string;
|
|
56
|
-
hottest: string;
|
|
57
|
-
|
|
58
|
-
// hint
|
|
59
|
-
nickError: string;
|
|
60
|
-
mailError: string;
|
|
61
|
-
wordHint: string;
|
|
62
|
-
|
|
63
|
-
// i18n
|
|
64
|
-
like: string;
|
|
65
|
-
cancelLike: string;
|
|
66
|
-
reply: string;
|
|
67
|
-
cancelReply: string;
|
|
68
|
-
preview: string;
|
|
69
|
-
emoji: string;
|
|
70
|
-
uploadImage: string;
|
|
71
|
-
profile: string;
|
|
72
|
-
logout: string;
|
|
73
|
-
}
|
package/src/typings/options.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type WalineProps } from './waline.js';
|
|
2
|
-
|
|
3
|
-
export interface WalineInitOptions extends Omit<WalineProps, 'path'> {
|
|
4
|
-
/**
|
|
5
|
-
* Waline 的初始化挂载器。必须是一个**有效的** CSS 选择器 或 HTML 元素
|
|
6
|
-
*
|
|
7
|
-
* The DOM element to be mounted on initialization. It must be a **valid** CSS selector string or HTML Element.
|
|
8
|
-
*/
|
|
9
|
-
el?: string | HTMLElement | null;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 评论数统计
|
|
13
|
-
*
|
|
14
|
-
* Comment number support
|
|
15
|
-
*
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
comment?: string | boolean;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 页面访问量统计
|
|
22
|
-
*
|
|
23
|
-
* Pageview number support
|
|
24
|
-
*
|
|
25
|
-
* @default false
|
|
26
|
-
*/
|
|
27
|
-
pageview?: string | boolean;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
|
|
31
|
-
*
|
|
32
|
-
* 你可以将其设置为 `window.location.pathname`
|
|
33
|
-
*
|
|
34
|
-
* Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
|
|
35
|
-
*
|
|
36
|
-
* You can set it to `window.location.pathname`
|
|
37
|
-
*
|
|
38
|
-
* @default window.location.pathname
|
|
39
|
-
*/
|
|
40
|
-
path?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
export type WalineAbort = (reason?: any) => void;
|
package/src/typings/waline.ts
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type WalineCommentSorting,
|
|
3
|
-
type WalineHighlighter,
|
|
4
|
-
type WalineEmojiInfo,
|
|
5
|
-
type WalineEmojiPresets,
|
|
6
|
-
type WalineImageUploader,
|
|
7
|
-
type WalineLoginStatus,
|
|
8
|
-
type WalineMeta,
|
|
9
|
-
type WalineTeXRenderer,
|
|
10
|
-
type WalineSearchOptions,
|
|
11
|
-
} from './base.js';
|
|
12
|
-
import { type WalineLocale } from './locale.js';
|
|
13
|
-
|
|
14
|
-
export interface WalineProps {
|
|
15
|
-
/**
|
|
16
|
-
* Waline 的服务端地址
|
|
17
|
-
*
|
|
18
|
-
* Waline server address url
|
|
19
|
-
*/
|
|
20
|
-
serverURL: string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
|
|
24
|
-
*
|
|
25
|
-
* 你可以将其设置为 `window.location.pathname`
|
|
26
|
-
*
|
|
27
|
-
* Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
|
|
28
|
-
*
|
|
29
|
-
* You can set it to `window.location.pathname`
|
|
30
|
-
*/
|
|
31
|
-
path: string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 评论者相关属性
|
|
35
|
-
*
|
|
36
|
-
* `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
|
|
37
|
-
*
|
|
38
|
-
* Reviewer attributes.
|
|
39
|
-
*
|
|
40
|
-
* Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
|
|
41
|
-
*
|
|
42
|
-
* @default ['nick', 'mail', 'link']
|
|
43
|
-
*/
|
|
44
|
-
meta?: WalineMeta[];
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 设置**必填项**,默认昵称为匿名
|
|
48
|
-
*
|
|
49
|
-
* Set required fields, default anonymous with nickname
|
|
50
|
-
*
|
|
51
|
-
* @default []
|
|
52
|
-
*/
|
|
53
|
-
requiredMeta?: WalineMeta[];
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 评论字数限制。填入单个数字时为最大字数限制
|
|
57
|
-
*
|
|
58
|
-
* @more 设置为 `0` 时无限制
|
|
59
|
-
*
|
|
60
|
-
* Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
|
|
61
|
-
*
|
|
62
|
-
* @more No limit when set to `0`.
|
|
63
|
-
*
|
|
64
|
-
* @default 0
|
|
65
|
-
*/
|
|
66
|
-
wordLimit?: number | [number, number];
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 评论列表分页,每页条数
|
|
70
|
-
*
|
|
71
|
-
* number of pages per page
|
|
72
|
-
*
|
|
73
|
-
* @default 10
|
|
74
|
-
*/
|
|
75
|
-
pageSize?: number;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Waline 显示语言
|
|
79
|
-
*
|
|
80
|
-
* 可选值:
|
|
81
|
-
*
|
|
82
|
-
* - `'zh'`
|
|
83
|
-
* - `'zh-cn'`
|
|
84
|
-
* - `'zh-CN'`
|
|
85
|
-
* - `'zh-tw'`
|
|
86
|
-
* - `'zh-TW'`
|
|
87
|
-
* - `'en'`
|
|
88
|
-
* - `'en-US'`
|
|
89
|
-
* - `'en-us'`
|
|
90
|
-
* - `'jp'`
|
|
91
|
-
* - `'jp-jp'`
|
|
92
|
-
* - `'jp-JP'`
|
|
93
|
-
* - `'pt-br'`
|
|
94
|
-
* - `'pt-BR'`
|
|
95
|
-
* - `'ru'`
|
|
96
|
-
* - `'ru-ru'`
|
|
97
|
-
* - `'ru-RU'`
|
|
98
|
-
*
|
|
99
|
-
* Display language for waline
|
|
100
|
-
*
|
|
101
|
-
* Optional value:
|
|
102
|
-
*
|
|
103
|
-
* - `'zh'`
|
|
104
|
-
* - `'zh-cn'`
|
|
105
|
-
* - `'zh-CN'`
|
|
106
|
-
* - `'zh-tw'`
|
|
107
|
-
* - `'zh-TW'`
|
|
108
|
-
* - `'en'`
|
|
109
|
-
* - `'en-US'`
|
|
110
|
-
* - `'en-us'`
|
|
111
|
-
* - `'jp'`
|
|
112
|
-
* - `'jp-jp'`
|
|
113
|
-
* - `'jp-JP'`
|
|
114
|
-
* - `'pt-br'`
|
|
115
|
-
* - `'pt-BR'`
|
|
116
|
-
* - `'ru'`
|
|
117
|
-
* - `'ru-ru'`
|
|
118
|
-
* - `'ru-RU'`
|
|
119
|
-
*
|
|
120
|
-
* @default navigator.language
|
|
121
|
-
*/
|
|
122
|
-
lang?: string;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* 自定义 waline 语言显示
|
|
126
|
-
*
|
|
127
|
-
* @see [自定义语言](https://waline.js.org/client/i18n.html)
|
|
128
|
-
*
|
|
129
|
-
* Custom display language in waline
|
|
130
|
-
*
|
|
131
|
-
* @see [I18n](https://waline.js.org/en/client/i18n.html)
|
|
132
|
-
*/
|
|
133
|
-
locale?: Partial<WalineLocale>;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 评论列表排序方式
|
|
137
|
-
*
|
|
138
|
-
* Sorting method for comment list
|
|
139
|
-
*
|
|
140
|
-
* @default 'latest'
|
|
141
|
-
*/
|
|
142
|
-
commentSorting?: WalineCommentSorting;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 是否启用暗黑模式适配
|
|
146
|
-
*
|
|
147
|
-
* @more 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
|
|
148
|
-
*
|
|
149
|
-
* Whether to enable darkmode support
|
|
150
|
-
*
|
|
151
|
-
* @more Setting `'auto'` will display darkmode due to device settings. Filling in CSS selector will enable darkmode only when the selector match waline ancestor nodes.
|
|
152
|
-
*/
|
|
153
|
-
dark?: string | boolean;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* 设置表情包
|
|
157
|
-
*
|
|
158
|
-
* Set Emojis
|
|
159
|
-
*
|
|
160
|
-
* @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
|
|
161
|
-
*/
|
|
162
|
-
emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* 设置搜索功能
|
|
166
|
-
*
|
|
167
|
-
* Customize Search feature
|
|
168
|
-
*
|
|
169
|
-
* @default true
|
|
170
|
-
*/
|
|
171
|
-
search?: WalineSearchOptions | boolean;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* 代码高亮
|
|
175
|
-
*
|
|
176
|
-
* Code highlighting
|
|
177
|
-
*
|
|
178
|
-
* @default true
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
highlighter?: WalineHighlighter | boolean;
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* 自定义图片上传方法,方便更好的存储图片
|
|
185
|
-
*
|
|
186
|
-
* 方法执行时会将图片对象传入。
|
|
187
|
-
*
|
|
188
|
-
* Custom image upload callback to manage picture by yourself.
|
|
189
|
-
*
|
|
190
|
-
* We will pass a picture file object when execute it.
|
|
191
|
-
*
|
|
192
|
-
* @default true
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
imageUploader?: WalineImageUploader | boolean;
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* 自定义数学公式处理方法,用于预览。
|
|
199
|
-
*
|
|
200
|
-
* Custom math formula parse callback for preview.
|
|
201
|
-
*
|
|
202
|
-
* @default true
|
|
203
|
-
*/
|
|
204
|
-
texRenderer?: WalineTeXRenderer | boolean;
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
* 登录模式状态,可选值:
|
|
209
|
-
*
|
|
210
|
-
* - `'enable'`: 启用登录 (默认)
|
|
211
|
-
* - `'disable'`: 禁用登录,用户只能填写信息评论
|
|
212
|
-
* - `'force'`: 强制登录,用户必须注册并登录才可发布评论
|
|
213
|
-
*
|
|
214
|
-
* Login mode status, optional values:
|
|
215
|
-
*
|
|
216
|
-
* - `'enable'`: enable login (default)
|
|
217
|
-
* - `'disable'`: Login is disabled, users should fill in information to comment
|
|
218
|
-
* - `'force'`: Forced login, users must login to comment
|
|
219
|
-
*
|
|
220
|
-
* @default 'enable'
|
|
221
|
-
*/
|
|
222
|
-
login?: WalineLoginStatus;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* 是否在页脚展示版权信息
|
|
226
|
-
*
|
|
227
|
-
* 为了支持 Waline,我们强烈建议你开启它
|
|
228
|
-
*
|
|
229
|
-
* Whether show copyright in footer
|
|
230
|
-
*
|
|
231
|
-
* We strongly recommended you to keep it on to support waline
|
|
232
|
-
*
|
|
233
|
-
* @default true
|
|
234
|
-
*/
|
|
235
|
-
copyright?: boolean;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* recaptcha v3 client key
|
|
239
|
-
*/
|
|
240
|
-
recaptchaV3Key?: string;
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* turnstile client key
|
|
244
|
-
*/
|
|
245
|
-
turnstileKey?: string;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* reaction
|
|
249
|
-
*/
|
|
250
|
-
reaction?: string[] | boolean;
|
|
251
|
-
}
|
package/src/utils/config.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { decodePath, isLinkHttp, removeEndingSplash } from './path.js';
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_EMOJI,
|
|
4
|
-
DEFAULT_LANG,
|
|
5
|
-
DEFAULT_LOCALES,
|
|
6
|
-
DEFAULT_REACTION,
|
|
7
|
-
defaultUploadImage,
|
|
8
|
-
defaultHighlighter,
|
|
9
|
-
defaultTeXRenderer,
|
|
10
|
-
getDefaultSearchOptions,
|
|
11
|
-
getMeta,
|
|
12
|
-
} from '../config/index.js';
|
|
13
|
-
import {
|
|
14
|
-
type WalineEmojiInfo,
|
|
15
|
-
type WalineEmojiMaps,
|
|
16
|
-
type WalineLocale,
|
|
17
|
-
type WalineProps,
|
|
18
|
-
} from '../typings/index.js';
|
|
19
|
-
|
|
20
|
-
export interface WalineEmojiConfig {
|
|
21
|
-
tabs: Pick<WalineEmojiInfo, 'name' | 'icon' | 'items'>[];
|
|
22
|
-
map: WalineEmojiMaps;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface WalineConfig
|
|
26
|
-
extends Required<
|
|
27
|
-
Omit<
|
|
28
|
-
WalineProps,
|
|
29
|
-
| 'emoji'
|
|
30
|
-
| 'imageUploader'
|
|
31
|
-
| 'highlighter'
|
|
32
|
-
| 'texRenderer'
|
|
33
|
-
| 'wordLimit'
|
|
34
|
-
| 'reaction'
|
|
35
|
-
| 'search'
|
|
36
|
-
>
|
|
37
|
-
> {
|
|
38
|
-
locale: WalineLocale;
|
|
39
|
-
wordLimit: [number, number] | false;
|
|
40
|
-
reaction: string[];
|
|
41
|
-
emoji: Exclude<WalineProps['emoji'], boolean | undefined>;
|
|
42
|
-
highlighter: Exclude<WalineProps['highlighter'], true | undefined>;
|
|
43
|
-
imageUploader: Exclude<WalineProps['imageUploader'], true | undefined>;
|
|
44
|
-
texRenderer: Exclude<WalineProps['texRenderer'], true | undefined>;
|
|
45
|
-
search: Exclude<WalineProps['search'], true | undefined>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const getServerURL = (serverURL: string): string => {
|
|
49
|
-
const result = removeEndingSplash(serverURL);
|
|
50
|
-
|
|
51
|
-
return isLinkHttp(result) ? result : `https://${result}`;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const getWordLimit = (
|
|
55
|
-
wordLimit: WalineProps['wordLimit'],
|
|
56
|
-
): [number, number] | false =>
|
|
57
|
-
Array.isArray(wordLimit) ? wordLimit : wordLimit ? [0, wordLimit] : false;
|
|
58
|
-
|
|
59
|
-
const fallback = <T = unknown>(
|
|
60
|
-
value: T | boolean | undefined,
|
|
61
|
-
fallback: T,
|
|
62
|
-
): T | false =>
|
|
63
|
-
typeof value === 'function' ? value : value === false ? false : fallback;
|
|
64
|
-
|
|
65
|
-
export const getConfig = ({
|
|
66
|
-
serverURL,
|
|
67
|
-
|
|
68
|
-
path = location.pathname,
|
|
69
|
-
lang = typeof navigator === 'undefined' ? 'en-US' : navigator.language,
|
|
70
|
-
locale,
|
|
71
|
-
emoji = DEFAULT_EMOJI,
|
|
72
|
-
meta = ['nick', 'mail', 'link'],
|
|
73
|
-
requiredMeta = [],
|
|
74
|
-
dark = false,
|
|
75
|
-
pageSize = 10,
|
|
76
|
-
wordLimit,
|
|
77
|
-
imageUploader,
|
|
78
|
-
highlighter,
|
|
79
|
-
texRenderer,
|
|
80
|
-
copyright = true,
|
|
81
|
-
login = 'enable',
|
|
82
|
-
search,
|
|
83
|
-
reaction,
|
|
84
|
-
recaptchaV3Key = '',
|
|
85
|
-
turnstileKey = '',
|
|
86
|
-
commentSorting = 'latest',
|
|
87
|
-
...more
|
|
88
|
-
}: WalineProps): WalineConfig => ({
|
|
89
|
-
serverURL: getServerURL(serverURL),
|
|
90
|
-
path: decodePath(path),
|
|
91
|
-
locale: {
|
|
92
|
-
...(DEFAULT_LOCALES[lang] || DEFAULT_LOCALES[DEFAULT_LANG]),
|
|
93
|
-
...(typeof locale === 'object' ? locale : {}),
|
|
94
|
-
} as WalineLocale,
|
|
95
|
-
wordLimit: getWordLimit(wordLimit),
|
|
96
|
-
meta: getMeta(meta),
|
|
97
|
-
requiredMeta: getMeta(requiredMeta),
|
|
98
|
-
imageUploader: fallback(imageUploader, defaultUploadImage),
|
|
99
|
-
highlighter: fallback(highlighter, defaultHighlighter),
|
|
100
|
-
texRenderer: fallback(texRenderer, defaultTeXRenderer),
|
|
101
|
-
lang: Object.keys(DEFAULT_LOCALES).includes(lang) ? lang : 'en-US',
|
|
102
|
-
dark,
|
|
103
|
-
emoji: typeof emoji === 'boolean' ? (emoji ? DEFAULT_EMOJI : []) : emoji,
|
|
104
|
-
pageSize,
|
|
105
|
-
login,
|
|
106
|
-
copyright,
|
|
107
|
-
search:
|
|
108
|
-
search === false
|
|
109
|
-
? false
|
|
110
|
-
: typeof search === 'object'
|
|
111
|
-
? search
|
|
112
|
-
: getDefaultSearchOptions(lang),
|
|
113
|
-
recaptchaV3Key,
|
|
114
|
-
turnstileKey,
|
|
115
|
-
reaction: Array.isArray(reaction)
|
|
116
|
-
? reaction
|
|
117
|
-
: reaction === true
|
|
118
|
-
? DEFAULT_REACTION
|
|
119
|
-
: [],
|
|
120
|
-
commentSorting,
|
|
121
|
-
...more,
|
|
122
|
-
});
|
package/src/utils/darkmode.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const style = `{--waline-white:#000;--waline-light-grey:#666;--waline-dark-grey:#999;--waline-color:#888;--waline-bgcolor:#1e1e1e;--waline-bgcolor-light:#272727;--waline-bgcolor-hover: #444;--waline-border-color:#333;--waline-disable-bgcolor:#444;--waline-disable-color:#272727;--waline-bq-color:#272727;--waline-info-bgcolor:#272727;--waline-info-color:#666}`;
|
|
2
|
-
|
|
3
|
-
export const getDarkStyle = (selector?: string | boolean): string => {
|
|
4
|
-
if (typeof selector === 'string') {
|
|
5
|
-
return selector === 'auto'
|
|
6
|
-
? `@media(prefers-color-scheme:dark){body${style}}`
|
|
7
|
-
: `${selector}${style}`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return selector === true ? `:root${style}` : '';
|
|
11
|
-
};
|
package/src/utils/date.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { WalineDateLocale } from '../typings';
|
|
2
|
-
|
|
3
|
-
const padWithZeros = (vNumber: number, width: number): string => {
|
|
4
|
-
let numAsString = vNumber.toString();
|
|
5
|
-
|
|
6
|
-
while (numAsString.length < width) {
|
|
7
|
-
numAsString = '0' + numAsString;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return numAsString;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const dateFormat = (date: Date): string => {
|
|
14
|
-
const vDay = padWithZeros(date.getDate(), 2);
|
|
15
|
-
const vMonth = padWithZeros(date.getMonth() + 1, 2);
|
|
16
|
-
const vYear = padWithZeros(date.getFullYear(), 2);
|
|
17
|
-
|
|
18
|
-
return `${vYear}-${vMonth}-${vDay}`;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const getTimeAgo = (
|
|
22
|
-
date: Date | string,
|
|
23
|
-
now: Date,
|
|
24
|
-
locale: WalineDateLocale,
|
|
25
|
-
): string => {
|
|
26
|
-
if (!date) return '';
|
|
27
|
-
|
|
28
|
-
const time =
|
|
29
|
-
typeof date === 'string'
|
|
30
|
-
? new Date(date.indexOf(' ') !== -1 ? date.replace(/-/g, '/') : date)
|
|
31
|
-
: date;
|
|
32
|
-
|
|
33
|
-
const timePassed = now.getTime() - time.getTime();
|
|
34
|
-
|
|
35
|
-
const days = Math.floor(timePassed / (24 * 3600 * 1000));
|
|
36
|
-
|
|
37
|
-
if (days === 0) {
|
|
38
|
-
// 计算相差小时数
|
|
39
|
-
|
|
40
|
-
// 计算天数后剩余的毫秒数
|
|
41
|
-
const leave1 = timePassed % (24 * 3600 * 1000);
|
|
42
|
-
const hours = Math.floor(leave1 / (3600 * 1000));
|
|
43
|
-
|
|
44
|
-
if (hours === 0) {
|
|
45
|
-
//计算相差分钟数
|
|
46
|
-
|
|
47
|
-
// 计算小时数后剩余的毫秒数
|
|
48
|
-
const leave2 = leave1 % (3600 * 1000);
|
|
49
|
-
const minutes = Math.floor(leave2 / (60 * 1000));
|
|
50
|
-
|
|
51
|
-
// 计算相差秒数
|
|
52
|
-
if (minutes === 0) {
|
|
53
|
-
// 计算分钟数后剩余的毫秒数
|
|
54
|
-
const leave3 = leave2 % (60 * 1000);
|
|
55
|
-
const seconds = Math.round(leave3 / 1000);
|
|
56
|
-
|
|
57
|
-
return `${seconds} ${locale.seconds}`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return `${minutes} ${locale.minutes}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return `${hours} ${locale.hours}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (days < 0) return locale.now;
|
|
67
|
-
|
|
68
|
-
if (days < 8) return `${days} ${locale.days}`;
|
|
69
|
-
|
|
70
|
-
return dateFormat(time);
|
|
71
|
-
};
|
package/src/utils/email.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @ref https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
|
|
3
|
-
*/
|
|
4
|
-
const EMAIL_REG_EXP =
|
|
5
|
-
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
6
|
-
|
|
7
|
-
export const isValidEmail = (email: string): boolean =>
|
|
8
|
-
EMAIL_REG_EXP.test(email);
|