@waline/client 1.6.0 → 2.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.
Files changed (94) hide show
  1. package/dist/component.js +2 -0
  2. package/dist/component.js.map +1 -0
  3. package/dist/pageview.cjs.js +2 -0
  4. package/dist/pageview.cjs.js.map +1 -0
  5. package/dist/pageview.d.ts +33 -0
  6. package/dist/pageview.esm.js +2 -0
  7. package/dist/pageview.esm.js.map +1 -0
  8. package/dist/pageview.js +2 -0
  9. package/dist/pageview.js.map +1 -0
  10. package/dist/{Waline.min.d.ts → shim.d.ts} +192 -261
  11. package/dist/{Waline.noStyle.d.ts → shim.esm.d.ts} +192 -261
  12. package/dist/shim.esm.js +2 -0
  13. package/dist/shim.esm.js.map +1 -0
  14. package/dist/shim.js +2 -0
  15. package/dist/shim.js.map +1 -0
  16. package/dist/waline.cjs.d.ts +388 -0
  17. package/dist/waline.cjs.js +2 -0
  18. package/dist/waline.cjs.js.map +1 -0
  19. package/dist/waline.css +1 -0
  20. package/dist/waline.css.map +1 -0
  21. package/dist/waline.d.ts +388 -0
  22. package/dist/waline.esm.d.ts +388 -0
  23. package/dist/waline.esm.js +2 -0
  24. package/dist/waline.esm.js.map +1 -0
  25. package/dist/waline.js +2 -0
  26. package/dist/waline.js.map +1 -0
  27. package/package.json +33 -18
  28. package/src/comment.ts +39 -0
  29. package/src/components/CommentBox.vue +667 -0
  30. package/src/components/CommentCard.vue +125 -0
  31. package/src/components/Icons.ts +124 -0
  32. package/src/components/Waline.vue +359 -0
  33. package/src/composables/index.ts +3 -0
  34. package/src/composables/inputs.ts +29 -0
  35. package/src/composables/store.ts +38 -0
  36. package/src/composables/userInfo.ts +27 -0
  37. package/src/config/default.ts +21 -0
  38. package/src/config/i18n/en.ts +34 -0
  39. package/src/config/i18n/generate.ts +39 -0
  40. package/src/config/i18n/index.ts +30 -0
  41. package/src/config/i18n/jp.ts +34 -0
  42. package/src/config/i18n/pt-BR.ts +34 -0
  43. package/src/config/i18n/ru.ts +34 -0
  44. package/src/config/i18n/vi-VN.ts +34 -0
  45. package/src/config/i18n/zh-CN.ts +34 -0
  46. package/src/config/i18n/zh-TW.ts +34 -0
  47. package/src/config/index.ts +2 -0
  48. package/src/entrys/components.ts +2 -0
  49. package/src/entrys/full.ts +7 -0
  50. package/src/entrys/init.ts +4 -0
  51. package/src/entrys/pageview.ts +2 -0
  52. package/src/init.ts +92 -0
  53. package/src/pageview.ts +100 -0
  54. package/src/shims-hanabi.d.ts +9 -0
  55. package/src/shims-vue.d.ts +5 -0
  56. package/src/styles/base.scss +67 -0
  57. package/src/styles/card.scss +223 -0
  58. package/src/styles/config.scss +52 -0
  59. package/src/styles/emoji.scss +118 -0
  60. package/src/styles/highlight.scss +135 -0
  61. package/src/styles/index.scss +12 -0
  62. package/src/styles/layout.scss +78 -0
  63. package/src/styles/nomalize.scss +112 -0
  64. package/src/styles/panel.scss +293 -0
  65. package/src/styles/recent.scss +3 -0
  66. package/src/typings/base.ts +54 -0
  67. package/src/typings/comment.ts +25 -0
  68. package/src/typings/index.ts +5 -0
  69. package/src/typings/locale.ts +32 -0
  70. package/src/typings/options.ts +41 -0
  71. package/src/typings/waline.ts +208 -0
  72. package/src/utils/config.ts +99 -0
  73. package/src/utils/darkmode.ts +11 -0
  74. package/src/utils/data.ts +10 -0
  75. package/src/utils/emoji.ts +75 -0
  76. package/src/utils/error.ts +3 -0
  77. package/src/utils/fetch.ts +177 -0
  78. package/src/utils/getRoot.ts +8 -0
  79. package/src/utils/index.ts +13 -0
  80. package/src/utils/markdown.ts +41 -0
  81. package/src/utils/markedMathExtension.ts +52 -0
  82. package/src/utils/path.ts +15 -0
  83. package/src/utils/query.ts +2 -0
  84. package/src/utils/timeAgo.ts +75 -0
  85. package/src/utils/userInfo.ts +26 -0
  86. package/src/utils/wordCount.ts +20 -0
  87. package/src/version.ts +3 -0
  88. package/src/widgets/index.ts +1 -0
  89. package/src/widgets/recentComments.ts +52 -0
  90. package/dist/Waline.min.js +0 -2
  91. package/dist/Waline.min.js.map +0 -1
  92. package/dist/Waline.noStyle.js +0 -2
  93. package/dist/Waline.noStyle.js.map +0 -1
  94. package/dist/index.html +0 -11
@@ -0,0 +1,293 @@
1
+ @use 'emoji';
2
+
3
+ .wl-comment {
4
+ position: relative;
5
+ display: flex;
6
+ margin-bottom: 0.75em;
7
+ }
8
+
9
+ .wl-close {
10
+ position: absolute;
11
+ top: -4px;
12
+ right: -4px;
13
+
14
+ padding: 0;
15
+ border: none;
16
+
17
+ background: transparent;
18
+
19
+ line-height: 1;
20
+
21
+ cursor: pointer;
22
+ }
23
+
24
+ .wl-login-info {
25
+ max-width: 80px;
26
+ margin-top: 0.75em;
27
+ text-align: center;
28
+ }
29
+
30
+ .wl-logout-btn {
31
+ position: absolute;
32
+ top: -10px;
33
+ right: -10px;
34
+
35
+ padding: 3px;
36
+ border: none;
37
+
38
+ background: transparent;
39
+
40
+ line-height: 0;
41
+
42
+ cursor: pointer;
43
+ }
44
+
45
+ .wl-avatar {
46
+ position: relative;
47
+
48
+ width: var(--waline-avatar-size);
49
+ height: var(--waline-avatar-size);
50
+ margin: 0 auto;
51
+ border: var(--waline-border);
52
+ border-radius: var(--waline-avatar-radius);
53
+
54
+ @media (max-width: 720px) {
55
+ width: var(--waline-m-avatar-size);
56
+ height: var(--waline-m-avatar-size);
57
+ }
58
+
59
+ img {
60
+ width: 100%;
61
+ height: 100%;
62
+ border-radius: var(--waline-avatar-radius);
63
+ }
64
+ }
65
+
66
+ .wl-login-nick {
67
+ display: block;
68
+ color: var(--waline-theme-color);
69
+ font-size: 0.75em;
70
+ word-break: break-all;
71
+ }
72
+
73
+ .wl-panel {
74
+ position: relative;
75
+
76
+ flex-shrink: 1;
77
+
78
+ width: 100%;
79
+ margin: 0.5em;
80
+ border: var(--waline-border);
81
+ border-radius: 0.75em;
82
+
83
+ background: var(--waline-bgcolor);
84
+ box-shadow: var(--waline-box-shadow);
85
+ }
86
+
87
+ .wl-header {
88
+ display: flex;
89
+
90
+ overflow: hidden;
91
+
92
+ padding: 0 4px;
93
+ border-bottom: 2px dashed var(--waline-border-color);
94
+ border-top-left-radius: 0.75em;
95
+ border-top-right-radius: 0.75em;
96
+
97
+ @media (max-width: 580px) {
98
+ display: block;
99
+ }
100
+
101
+ label {
102
+ min-width: 40px;
103
+ padding: 0.75em 0.5em;
104
+
105
+ color: var(--waline-color);
106
+
107
+ font-size: 0.75em;
108
+ text-align: center;
109
+ }
110
+
111
+ input {
112
+ flex: 1;
113
+
114
+ width: 0;
115
+ padding: 0.5em;
116
+
117
+ background: transparent;
118
+
119
+ font-size: 0.625em;
120
+
121
+ resize: none;
122
+ }
123
+ }
124
+
125
+ .wl-header-item {
126
+ display: flex;
127
+ flex: 1;
128
+
129
+ &:not(:last-child) {
130
+ @media (max-width: 580px) {
131
+ border-bottom: 2px dashed var(--waline-border-color);
132
+ }
133
+ }
134
+
135
+ .wl-header-1 & {
136
+ width: 100%;
137
+ }
138
+
139
+ .wl-header-2 & {
140
+ width: 50%;
141
+
142
+ @media (max-width: 580px) {
143
+ flex: 0;
144
+ width: 100%;
145
+ }
146
+ }
147
+
148
+ .wl-header-3 & {
149
+ width: 33.33%;
150
+
151
+ @media (max-width: 580px) {
152
+ width: 100%;
153
+ }
154
+ }
155
+ }
156
+
157
+ .wl-editor,
158
+ .wl-input {
159
+ max-width: 100%;
160
+ border: none;
161
+
162
+ color: var(--waline-color);
163
+ outline: none;
164
+
165
+ transition: all 0.25s ease;
166
+
167
+ &:focus {
168
+ background: var(--waline-bgcolor-light);
169
+ }
170
+ }
171
+
172
+ .wl-editor {
173
+ position: relative;
174
+
175
+ width: calc(100% - 1em);
176
+ min-height: 8.75em;
177
+ margin: 0.75em 0.5em;
178
+ border-radius: 0.5em;
179
+
180
+ background: transparent;
181
+
182
+ font-size: 0.875em;
183
+
184
+ resize: vertical;
185
+ }
186
+
187
+ .wl-preview {
188
+ padding: 0 0.5em 0.5em;
189
+
190
+ h4 {
191
+ margin: 0.25em;
192
+ font-weight: bold;
193
+ font-size: 0.9375em;
194
+ }
195
+
196
+ .wl-content {
197
+ min-height: 1.25em;
198
+ padding: 0.25em;
199
+ border: var(--waline-border);
200
+ border-radius: 0.25em;
201
+
202
+ word-break: break-word;
203
+ hyphens: auto;
204
+
205
+ > *:first-child {
206
+ margin-top: 0;
207
+ }
208
+
209
+ > *:last-child {
210
+ margin-bottom: 0;
211
+ }
212
+ }
213
+ }
214
+
215
+ .wl-footer {
216
+ position: relative;
217
+ display: flex;
218
+ flex-wrap: wrap;
219
+ margin: 0.5em 0.75em;
220
+ }
221
+
222
+ .wl-actions {
223
+ display: flex;
224
+ flex: 2;
225
+ align-items: center;
226
+ }
227
+
228
+ .wl-action {
229
+ display: inline-flex;
230
+ align-items: center;
231
+ justify-content: center;
232
+
233
+ width: 1.5em;
234
+ height: 1.5em;
235
+ margin: 2px;
236
+ padding: 0;
237
+ border: none;
238
+
239
+ background: transparent;
240
+ color: var(--waline-color);
241
+
242
+ font-size: 16px;
243
+
244
+ cursor: pointer;
245
+
246
+ &:hover {
247
+ color: var(--waline-theme-color);
248
+ }
249
+
250
+ &.actived {
251
+ color: var(--waline-active-color);
252
+ }
253
+ }
254
+
255
+ #wl-image-upload {
256
+ display: none;
257
+
258
+ &:focus + label {
259
+ color: var(--waline-color);
260
+ }
261
+
262
+ &:focus-visible + label {
263
+ outline: -webkit-focus-ring-color auto 1px;
264
+ }
265
+ }
266
+
267
+ .wl-info {
268
+ display: flex;
269
+ flex: 3;
270
+ align-items: center;
271
+ justify-content: flex-end;
272
+
273
+ .wl-text-number {
274
+ color: var(--waline-info-color);
275
+ font-size: 0.75em;
276
+
277
+ .illegal {
278
+ color: #f00;
279
+ }
280
+ }
281
+
282
+ button {
283
+ margin-left: 0.75em;
284
+
285
+ svg {
286
+ display: block;
287
+ margin: 0 auto;
288
+ line-height: 18px;
289
+ }
290
+ }
291
+ }
292
+
293
+ @include emoji.emoji;
@@ -0,0 +1,3 @@
1
+ .wl-recent-item p {
2
+ display: inline;
3
+ }
@@ -0,0 +1,54 @@
1
+ export interface WalineEmojiInfo {
2
+ /**
3
+ * 选项卡上的 Emoji 名称
4
+ *
5
+ * Emoji name show on tab
6
+ */
7
+ name: string;
8
+ /**
9
+ * 所在文件夹链接
10
+ *
11
+ * Current folder link
12
+ */
13
+ folder: string;
14
+ /**
15
+ * Emoji 通用路径前缀
16
+ *
17
+ * Common prefix of Emoji icons
18
+ */
19
+ prefix?: string;
20
+ /**
21
+ * Emoji 图片的类型,会作为文件扩展名使用
22
+ *
23
+ * Type of Emoji icons, will be regarded as file extension
24
+ */
25
+ type?: string;
26
+ /**
27
+ * 选项卡显示的 Emoji 图标
28
+ *
29
+ * Emoji icon show on tab
30
+ */
31
+ icon: string;
32
+ /**
33
+ * Emoji 图片列表
34
+ *
35
+ * Emoji image list
36
+ */
37
+ items: string[];
38
+ }
39
+
40
+ export type WalineEmojiMaps = Record<string, string>;
41
+
42
+ export type WalineMeta = 'nick' | 'mail' | 'link';
43
+
44
+ export type WalineImageUploader = (image: File) => Promise<string>;
45
+
46
+ export type WalineHighlighter =
47
+ | ((code: string, lang: string) => string)
48
+ | ((
49
+ code: string,
50
+ lang: string,
51
+ callback?: (error: unknown | undefined, code?: string) => void
52
+ ) => void);
53
+
54
+ export type WalineTexRenderer = (blockMode: boolean, tex: string) => string;
@@ -0,0 +1,25 @@
1
+ export interface WalineCommentData {
2
+ nick: string;
3
+ mail: string;
4
+ link?: string;
5
+ comment: string;
6
+ ua: string;
7
+
8
+ pid?: string;
9
+ rid?: string;
10
+ at?: string;
11
+ url: string;
12
+ }
13
+
14
+ export interface WalineComment extends Exclude<WalineCommentData, 'ua'> {
15
+ avatar: string;
16
+ type?: string;
17
+ objectId: string;
18
+ createdAt: string;
19
+ insertedAt: string;
20
+ updatedAt: string;
21
+ children: WalineComment[];
22
+ sticky?: boolean;
23
+ browser?: string;
24
+ os?: string;
25
+ }
@@ -0,0 +1,5 @@
1
+ export * from './base';
2
+ export * from './comment';
3
+ export * from './locale';
4
+ export * from './waline';
5
+ export * from './options';
@@ -0,0 +1,32 @@
1
+ export interface WalineLocale {
2
+ nick: string;
3
+ nickError: string;
4
+ mail: string;
5
+ mailError: string;
6
+ link: string;
7
+ optional: string;
8
+ placeholder: string;
9
+ sofa: string;
10
+ submit: string;
11
+ reply: string;
12
+ cancelReply: string;
13
+ comment: string;
14
+ refresh: string;
15
+ more: string;
16
+ preview: string;
17
+ emoji: string;
18
+ uploadImage: string;
19
+ seconds: string;
20
+ minutes: string;
21
+ hours: string;
22
+ days: string;
23
+ now: string;
24
+ uploading: string;
25
+ login: string;
26
+ logout: string;
27
+ admin: string;
28
+ sticky: string;
29
+ word: string;
30
+ wordHint: string;
31
+ anonymous: string;
32
+ }
@@ -0,0 +1,41 @@
1
+ import type { WalineProps } from './waline';
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
+ }
@@ -0,0 +1,208 @@
1
+ import type {
2
+ WalineHighlighter,
3
+ WalineEmojiInfo,
4
+ WalineImageUploader,
5
+ WalineMeta,
6
+ WalineTexRenderer,
7
+ } from './base';
8
+ import type { WalineLocale } from './locale';
9
+
10
+ export interface WalineProps {
11
+ /**
12
+ * Waline 的服务端地址
13
+ *
14
+ * Waline server address url
15
+ */
16
+ serverURL: string;
17
+
18
+ /**
19
+ * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
20
+ *
21
+ * 你可以将其设置为 `window.location.pathname`
22
+ *
23
+ * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
24
+ *
25
+ * You can set it to `window.location.pathname`
26
+ */
27
+ path: string;
28
+
29
+ /**
30
+ * 评论者相关属性
31
+ *
32
+ * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
33
+ *
34
+ * Reviewer attributes.
35
+ *
36
+ * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
37
+ *
38
+ * @default ['nick', 'mail', 'link']
39
+ */
40
+ meta?: WalineMeta[];
41
+
42
+ /**
43
+ * 设置**必填项**,默认昵称为匿名
44
+ *
45
+ * Set required fields, default anonymous with nickname
46
+ *
47
+ * @default []
48
+ */
49
+ requiredMeta?: WalineMeta[];
50
+
51
+ /**
52
+ * 评论字数限制。填入单个数字时为最大字数限制
53
+ *
54
+ * @more 设置为 `0` 时无限制
55
+ *
56
+ * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
57
+ *
58
+ * @more No limit when set to `0`.
59
+ *
60
+ * @default 0
61
+ */
62
+ wordLimit?: number | [number, number];
63
+
64
+ /**
65
+ * 评论列表分页,每页条数
66
+ *
67
+ * number of pages per page
68
+ *
69
+ * @default 10
70
+ */
71
+ pageSize?: number;
72
+
73
+ /**
74
+ * Waline 显示语言
75
+ *
76
+ * 可选值:
77
+ *
78
+ * - `'zh'`
79
+ * - `'zh-cn'`
80
+ * - `'zh-CN'`
81
+ * - `'zh-tw'`
82
+ * - `'zh-TW'`
83
+ * - `'en'`
84
+ * - `'en-US'`
85
+ * - `'en-us'`
86
+ * - `'jp'`
87
+ * - `'jp-jp'`
88
+ * - `'jp-JP'`
89
+ * - `'pt-br'`
90
+ * - `'pt-BR'`
91
+ * - `'ru'`
92
+ * - `'ru-ru'`
93
+ * - `'ru-RU'`
94
+ *
95
+ * Display language for waline
96
+ *
97
+ * Optional value:
98
+ *
99
+ * - `'zh'`
100
+ * - `'zh-cn'`
101
+ * - `'zh-CN'`
102
+ * - `'zh-tw'`
103
+ * - `'zh-TW'`
104
+ * - `'en'`
105
+ * - `'en-US'`
106
+ * - `'en-us'`
107
+ * - `'jp'`
108
+ * - `'jp-jp'`
109
+ * - `'jp-JP'`
110
+ * - `'pt-br'`
111
+ * - `'pt-BR'`
112
+ * - `'ru'`
113
+ * - `'ru-ru'`
114
+ * - `'ru-RU'`
115
+ *
116
+ * @default 'zh-CN'
117
+ */
118
+ lang?: string;
119
+
120
+ /**
121
+ * 自定义 waline 语言显示
122
+ *
123
+ * @see [自定义语言](https://waline.js.org/client/i18n.html)
124
+ *
125
+ * Custom display language in waline
126
+ *
127
+ * @see [I18n](https://waline.js.org/en/client/i18n.html)
128
+ */
129
+ locale?: Partial<WalineLocale>;
130
+
131
+ /**
132
+ * 是否启用暗黑模式适配
133
+ *
134
+ * @more 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
135
+ *
136
+ * Whether to enable darkmode support
137
+ *
138
+ * @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.
139
+ */
140
+ dark?: string | boolean;
141
+
142
+ /**
143
+ * 设置表情包
144
+ *
145
+ * Set Emojis
146
+ *
147
+ * @default ['https://cdn.jsdelivr.net/gh/walinejs/emojis/weibo']
148
+ */
149
+ emoji?: (string | WalineEmojiInfo)[];
150
+
151
+ /**
152
+ * 代码高亮
153
+ *
154
+ * Code highlighting
155
+ */
156
+
157
+ highlighter?: WalineHighlighter | false;
158
+
159
+ /**
160
+ * 自定义图片上传方法,方便更好的存储图片
161
+ *
162
+ * 方法执行时会将图片对象传入。
163
+ *
164
+ * Custom image upload callback to manage picture by yourself.
165
+ *
166
+ * We will pass a picture file object when execute it.
167
+ */
168
+
169
+ imageUploader?: WalineImageUploader | false;
170
+
171
+ /**
172
+ * 自定义数学公式处理方法,用于预览。
173
+ *
174
+ * Custom math formula parse callback for preview.
175
+ */
176
+ texRenderer?: WalineTexRenderer | false;
177
+
178
+ /**
179
+ *
180
+ * 登录模式状态,可选值:
181
+ *
182
+ * - `'enable'`: 启用登录 (默认)
183
+ * - `'disable'`: 禁用登录,用户只能填写信息评论
184
+ * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
185
+ *
186
+ * Login mode status, optional values:
187
+ *
188
+ * - `'enable'`: enable login (default)
189
+ * - `'disable'`: Login is disabled, users should fill in infomation to comment
190
+ * - `'force'`: Forced login, users must login to comment
191
+ *
192
+ * @default 'enable'
193
+ */
194
+ login?: 'enable' | 'disable' | 'force';
195
+
196
+ /**
197
+ * 是否在页脚展示版权信息
198
+ *
199
+ * 为了支持 Waline,我们强烈建议你开启它
200
+ *
201
+ * Whether show copyright in footer
202
+ *
203
+ * We strongly recommended you to keep it on to support waline
204
+ *
205
+ * @default true
206
+ */
207
+ copyright?: boolean;
208
+ }