1 | type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
|
2 | type WalineEmojiPresets = `//${string}` | `http://${string}` | `https://${string}`;
|
3 | interface WalineEmojiInfo {
|
4 | /**
|
5 | * 选项卡上的 Emoji 名称
|
6 | *
|
7 | * Emoji name show on tab
|
8 | */
|
9 | name: string;
|
10 | /**
|
11 | * 所在文件夹链接
|
12 | *
|
13 | * Current folder link
|
14 | */
|
15 | folder?: string;
|
16 | /**
|
17 | * Emoji 通用路径前缀
|
18 | *
|
19 | * Common prefix of Emoji icons
|
20 | */
|
21 | prefix?: string;
|
22 | /**
|
23 | * Emoji 图片的类型,会作为文件扩展名使用
|
24 | *
|
25 | * Type of Emoji icons, will be regarded as file extension
|
26 | */
|
27 | type?: string;
|
28 | /**
|
29 | * 选项卡显示的 Emoji 图标
|
30 | *
|
31 | * Emoji icon show on tab
|
32 | */
|
33 | icon: string;
|
34 | /**
|
35 | * Emoji 图片列表
|
36 | *
|
37 | * Emoji image list
|
38 | */
|
39 | items: string[];
|
40 | }
|
41 | type WalineEmojiMaps = Record<string, string>;
|
42 | type WalineLoginStatus = 'enable' | 'disable' | 'force';
|
43 | interface WalineSearchImageData extends Record<string, unknown> {
|
44 | /**
|
45 | * 图片链接
|
46 | *
|
47 | * Image link
|
48 | */
|
49 | src: string;
|
50 | /**
|
51 | * 图片标题
|
52 | *
|
53 | * @description 用于图片的 alt 属性
|
54 | *
|
55 | * Image title
|
56 | *
|
57 | * @description Used for alt attribute of image
|
58 | */
|
59 | title?: string;
|
60 | /**
|
61 | * 图片缩略图
|
62 | *
|
63 | * @description 为了更好的加载性能,我们会优先在列表中使用此缩略图
|
64 | *
|
65 | * Image preview link
|
66 | *
|
67 | * @description For better loading performance, we will use this thumbnail first in the list
|
68 | *
|
69 | * @default src
|
70 | */
|
71 | preview?: string;
|
72 | }
|
73 | type WalineSearchResult = WalineSearchImageData[];
|
74 | interface WalineSearchOptions {
|
75 | /**
|
76 | * 搜索操作
|
77 | *
|
78 | * Search action
|
79 | */
|
80 | search: (word: string) => Promise<WalineSearchResult>;
|
81 | /**
|
82 | * 打开列表时展示的默认结果
|
83 | *
|
84 | * Default result when opening list
|
85 | *
|
86 | * @default () => search('')
|
87 | */
|
88 | default?: () => Promise<WalineSearchResult>;
|
89 | /**
|
90 | * 获取更多的操作
|
91 | *
|
92 | * @description 会在列表滚动到底部时触发,如果你的搜索服务支持分页功能,你应该设置此项实现无限滚动
|
93 | *
|
94 | * Fetch more action
|
95 | *
|
96 | * @description It will be triggered when the list scrolls to the bottom. If your search service supports paging, you should set this to achieve infinite scrolling
|
97 | *
|
98 | * @default (word) => search(word)
|
99 | */
|
100 | more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
|
101 | }
|
102 | type WalineMeta = 'nick' | 'mail' | 'link';
|
103 | type WalineImageUploader = (image: File) => Promise<string>;
|
104 | type WalineHighlighter = (code: string, lang: string) => string;
|
105 | type WalineTexRenderer = (blockMode: boolean, tex: string) => string;
|
106 |
|
107 | interface WalineCommentData {
|
108 | /**
|
109 | * User Nickname
|
110 | */
|
111 | nick: string;
|
112 | /**
|
113 | * User email
|
114 | */
|
115 | mail: string;
|
116 | /**
|
117 | * User link
|
118 | */
|
119 | link?: string;
|
120 | /**
|
121 | * Content of comment
|
122 | */
|
123 | comment: string;
|
124 | /**
|
125 | * User Agent
|
126 | */
|
127 | ua: string;
|
128 | /**
|
129 | * Parent comment id
|
130 | */
|
131 | pid?: string;
|
132 | /**
|
133 | * Root comment id
|
134 | */
|
135 | rid?: string;
|
136 | /**
|
137 | * User id being at
|
138 | */
|
139 | at?: string;
|
140 | /**
|
141 | * Comment link
|
142 | */
|
143 | url: string;
|
144 | /**
|
145 | * Recaptcha Token
|
146 | */
|
147 | recaptchaV3?: string;
|
148 | }
|
149 | type WalineCommentStatus = 'approved' | 'waiting' | 'spam';
|
150 | interface WalineComment extends Exclude<WalineCommentData, 'ua'> {
|
151 | /**
|
152 | * User avatar
|
153 | */
|
154 | avatar: string;
|
155 | /**
|
156 | * User type
|
157 | */
|
158 | type?: 'administrator' | 'guest' | `verify:${string}`;
|
159 | objectId: string;
|
160 | /**
|
161 | * Time ISOString when the comment is created
|
162 | */
|
163 | createdAt: string;
|
164 | insertedAt: string;
|
165 | updatedAt: string;
|
166 | children: WalineComment[];
|
167 | sticky?: boolean;
|
168 | browser?: string;
|
169 | os?: string;
|
170 | level?: number;
|
171 | addr?: string;
|
172 | label?: string;
|
173 | user_id?: string | number;
|
174 | status?: WalineCommentStatus;
|
175 | like?: number;
|
176 | orig?: string;
|
177 | }
|
178 |
|
179 | interface WalineDateLocale {
|
180 | seconds: string;
|
181 | minutes: string;
|
182 | hours: string;
|
183 | days: string;
|
184 | now: string;
|
185 | }
|
186 | type WalineLevelLocale = Record<`level${number}`, string>;
|
187 | interface WalineReactionLocale {
|
188 | reactionTitle: string;
|
189 | reaction0: string;
|
190 | reaction1: string;
|
191 | reaction2: string;
|
192 | reaction3: string;
|
193 | reaction4: string;
|
194 | reaction5: string;
|
195 | reaction6: string;
|
196 | reaction7: string;
|
197 | reaction8: string;
|
198 | }
|
199 | interface WalineLocale extends WalineDateLocale, WalineLevelLocale, WalineReactionLocale {
|
200 | nick: string;
|
201 | mail: string;
|
202 | link: string;
|
203 | optional: string;
|
204 | placeholder: string;
|
205 | sofa: string;
|
206 | submit: string;
|
207 | comment: string;
|
208 | refresh: string;
|
209 | more: string;
|
210 | uploading: string;
|
211 | login: string;
|
212 | admin: string;
|
213 | sticky: string;
|
214 | word: string;
|
215 | anonymous: string;
|
216 | gif: string;
|
217 | gifSearchPlaceholder: string;
|
218 | approved: string;
|
219 | waiting: string;
|
220 | spam: string;
|
221 | unsticky: string;
|
222 | oldest: string;
|
223 | latest: string;
|
224 | hottest: string;
|
225 | nickError: string;
|
226 | mailError: string;
|
227 | wordHint: string;
|
228 | like: string;
|
229 | cancelLike: string;
|
230 | reply: string;
|
231 | cancelReply: string;
|
232 | preview: string;
|
233 | emoji: string;
|
234 | uploadImage: string;
|
235 | profile: string;
|
236 | logout: string;
|
237 | }
|
238 |
|
239 | interface WalineProps {
|
240 | /**
|
241 | * Waline 的服务端地址
|
242 | *
|
243 | * Waline server address url
|
244 | */
|
245 | serverURL: string;
|
246 | /**
|
247 | * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
|
248 | *
|
249 | * 你可以将其设置为 `window.location.pathname`
|
250 | *
|
251 | * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
|
252 | *
|
253 | * You can set it to `window.location.pathname`
|
254 | */
|
255 | path: string;
|
256 | /**
|
257 | * 评论者相关属性
|
258 | *
|
259 | * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
|
260 | *
|
261 | * Reviewer attributes.
|
262 | *
|
263 | * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
|
264 | *
|
265 | * @default ['nick', 'mail', 'link']
|
266 | */
|
267 | meta?: WalineMeta[];
|
268 | /**
|
269 | * 设置**必填项**,默认昵称为匿名
|
270 | *
|
271 | * Set required fields, default anonymous with nickname
|
272 | *
|
273 | * @default []
|
274 | */
|
275 | requiredMeta?: WalineMeta[];
|
276 | /**
|
277 | * 评论字数限制。填入单个数字时为最大字数限制
|
278 | *
|
279 | * @more 设置为 `0` 时无限制
|
280 | *
|
281 | * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
|
282 | *
|
283 | * @more No limit when set to `0`.
|
284 | *
|
285 | * @default 0
|
286 | */
|
287 | wordLimit?: number | [number, number];
|
288 | /**
|
289 | * 评论列表分页,每页条数
|
290 | *
|
291 | * number of pages per page
|
292 | *
|
293 | * @default 10
|
294 | */
|
295 | pageSize?: number;
|
296 | /**
|
297 | * Waline 显示语言
|
298 | *
|
299 | * 可选值:
|
300 | *
|
301 | * - `'zh'`
|
302 | * - `'zh-cn'`
|
303 | * - `'zh-CN'`
|
304 | * - `'zh-tw'`
|
305 | * - `'zh-TW'`
|
306 | * - `'en'`
|
307 | * - `'en-US'`
|
308 | * - `'en-us'`
|
309 | * - `'jp'`
|
310 | * - `'jp-jp'`
|
311 | * - `'jp-JP'`
|
312 | * - `'pt-br'`
|
313 | * - `'pt-BR'`
|
314 | * - `'ru'`
|
315 | * - `'ru-ru'`
|
316 | * - `'ru-RU'`
|
317 | *
|
318 | * Display language for waline
|
319 | *
|
320 | * Optional value:
|
321 | *
|
322 | * - `'zh'`
|
323 | * - `'zh-cn'`
|
324 | * - `'zh-CN'`
|
325 | * - `'zh-tw'`
|
326 | * - `'zh-TW'`
|
327 | * - `'en'`
|
328 | * - `'en-US'`
|
329 | * - `'en-us'`
|
330 | * - `'jp'`
|
331 | * - `'jp-jp'`
|
332 | * - `'jp-JP'`
|
333 | * - `'pt-br'`
|
334 | * - `'pt-BR'`
|
335 | * - `'ru'`
|
336 | * - `'ru-ru'`
|
337 | * - `'ru-RU'`
|
338 | *
|
339 | * @default navigator.language
|
340 | */
|
341 | lang?: string;
|
342 | /**
|
343 | * 自定义 waline 语言显示
|
344 | *
|
345 | * @see [自定义语言](https://waline.js.org/client/i18n.html)
|
346 | *
|
347 | * Custom display language in waline
|
348 | *
|
349 | * @see [I18n](https://waline.js.org/en/client/i18n.html)
|
350 | */
|
351 | locale?: Partial<WalineLocale>;
|
352 | /**
|
353 | * 评论列表排序方式
|
354 | *
|
355 | * Sorting method for comment list
|
356 | *
|
357 | * @default 'latest'
|
358 | */
|
359 | commentSorting?: WalineCommentSorting;
|
360 | /**
|
361 | * 是否启用暗黑模式适配
|
362 | *
|
363 | * @more 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
|
364 | *
|
365 | * Whether to enable darkmode support
|
366 | *
|
367 | * @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.
|
368 | */
|
369 | dark?: string | boolean;
|
370 | /**
|
371 | * 设置表情包
|
372 | *
|
373 | * Set Emojis
|
374 | *
|
375 | * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
|
376 | */
|
377 | emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
|
378 | /**
|
379 | * 设置搜索功能
|
380 | *
|
381 | * Customize Search feature
|
382 | *
|
383 | * @default true
|
384 | */
|
385 | search?: WalineSearchOptions | boolean;
|
386 | /**
|
387 | * 代码高亮
|
388 | *
|
389 | * Code highlighting
|
390 | *
|
391 | * @default true
|
392 | */
|
393 | highlighter?: WalineHighlighter | boolean;
|
394 | /**
|
395 | * 自定义图片上传方法,方便更好的存储图片
|
396 | *
|
397 | * 方法执行时会将图片对象传入。
|
398 | *
|
399 | * Custom image upload callback to manage picture by yourself.
|
400 | *
|
401 | * We will pass a picture file object when execute it.
|
402 | *
|
403 | * @default true
|
404 | */
|
405 | imageUploader?: WalineImageUploader | boolean;
|
406 | /**
|
407 | * 自定义数学公式处理方法,用于预览。
|
408 | *
|
409 | * Custom math formula parse callback for preview.
|
410 | *
|
411 | * @default true
|
412 | */
|
413 | texRenderer?: WalineTexRenderer | boolean;
|
414 | /**
|
415 | *
|
416 | * 登录模式状态,可选值:
|
417 | *
|
418 | * - `'enable'`: 启用登录 (默认)
|
419 | * - `'disable'`: 禁用登录,用户只能填写信息评论
|
420 | * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
|
421 | *
|
422 | * Login mode status, optional values:
|
423 | *
|
424 | * - `'enable'`: enable login (default)
|
425 | * - `'disable'`: Login is disabled, users should fill in information to comment
|
426 | * - `'force'`: Forced login, users must login to comment
|
427 | *
|
428 | * @default 'enable'
|
429 | */
|
430 | login?: WalineLoginStatus;
|
431 | /**
|
432 | * 是否在页脚展示版权信息
|
433 | *
|
434 | * 为了支持 Waline,我们强烈建议你开启它
|
435 | *
|
436 | * Whether show copyright in footer
|
437 | *
|
438 | * We strongly recommended you to keep it on to support waline
|
439 | *
|
440 | * @default true
|
441 | */
|
442 | copyright?: boolean;
|
443 | /**
|
444 | * recaptcha v3 client key
|
445 | */
|
446 | recaptchaV3Key?: string;
|
447 | /**
|
448 | * reaction
|
449 | */
|
450 | reaction?: string[] | boolean;
|
451 | }
|
452 |
|
453 | interface WalineInitOptions extends Omit<WalineProps, 'path'> {
|
454 | /**
|
455 | * Waline 的初始化挂载器。必须是一个**有效的** CSS 选择器 或 HTML 元素
|
456 | *
|
457 | * The DOM element to be mounted on initialization. It must be a **valid** CSS selector string or HTML Element.
|
458 | */
|
459 | el?: string | HTMLElement | null;
|
460 | /**
|
461 | * 评论数统计
|
462 | *
|
463 | * Comment number support
|
464 | *
|
465 | * @default false
|
466 | */
|
467 | comment?: string | boolean;
|
468 | /**
|
469 | * 页面访问量统计
|
470 | *
|
471 | * Pageview number support
|
472 | *
|
473 | * @default false
|
474 | */
|
475 | pageview?: string | boolean;
|
476 | /**
|
477 | * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
|
478 | *
|
479 | * 你可以将其设置为 `window.location.pathname`
|
480 | *
|
481 | * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
|
482 | *
|
483 | * You can set it to `window.location.pathname`
|
484 | *
|
485 | * @default window.location.pathname
|
486 | */
|
487 | path?: string;
|
488 | }
|
489 | type WalineAbort = (reason?: any) => void;
|
490 |
|
491 | type Locales = Record<string, WalineLocale>;
|
492 | declare const defaultLocales: Locales;
|
493 |
|
494 | interface WalineCommentCountOptions {
|
495 | /**
|
496 | * Waline 服务端地址
|
497 | *
|
498 | * Waline server url
|
499 | */
|
500 | serverURL: string;
|
501 | /**
|
502 | * 评论数 CSS 选择器
|
503 | *
|
504 | * Comment count CSS selector
|
505 | *
|
506 | * @default '.waline-comment-count'
|
507 | */
|
508 | selector?: string;
|
509 | /**
|
510 | * 需要获取的默认路径
|
511 | *
|
512 | * Path to be fetched by default
|
513 | *
|
514 | * @default window.location.pathname
|
515 | */
|
516 | path?: string;
|
517 | /**
|
518 | * 错误提示消息所使用的语言
|
519 | *
|
520 | * Language of error message
|
521 | *
|
522 | * @default navigator.language
|
523 | */
|
524 | lang?: string;
|
525 | }
|
526 | declare const commentCount: ({ serverURL, path, selector, lang, }: WalineCommentCountOptions) => WalineAbort;
|
527 |
|
528 | interface WalineInstance {
|
529 | /**
|
530 | * Waline 被挂载到的元素
|
531 | *
|
532 | * @description 当通过 `el: null` 初始化,值为 `null`
|
533 | *
|
534 | * Element where Waline is mounted
|
535 | *
|
536 | * @description when initialized with `el: null`, it will be `null`
|
537 | */
|
538 | el: HTMLElement | null;
|
539 | /**
|
540 | * 更新 Waline 实例
|
541 | *
|
542 | * @description 只要不设置`path` 选项,更新时它就会被重置为 `windows.location.pathname`
|
543 | *
|
544 | * Update Waline instance
|
545 | *
|
546 | * @description when not setting `path` option, it will be reset to `window.location.pathname`
|
547 | */
|
548 | update: (newOptions?: Partial<Omit<WalineInitOptions, 'el'>>) => void;
|
549 | /**
|
550 | * 取消挂载并摧毁 Waline 实例
|
551 | *
|
552 | * Unmount and destroy Waline instance
|
553 | */
|
554 | destroy: () => void;
|
555 | }
|
556 | declare const init: ({ el, path, comment, pageview, ...initProps }: WalineInitOptions) => WalineInstance | null;
|
557 |
|
558 | interface WalinePageviewCountOptions {
|
559 | /**
|
560 | * Waline 服务端地址
|
561 | *
|
562 | * Waline server url
|
563 | */
|
564 | serverURL: string;
|
565 | /**
|
566 | * 浏览量 CSS 选择器
|
567 | *
|
568 | * Pageview CSS selector
|
569 | *
|
570 | * @default '.waline-pageview-count'
|
571 | */
|
572 | selector?: string;
|
573 | /**
|
574 | * 需要更新和获取的路径
|
575 | *
|
576 | * Path to be fetched and updated
|
577 | *
|
578 | * @default window.location.pathname
|
579 | */
|
580 | path?: string;
|
581 | /**
|
582 | * 是否在查询时更新 path 的浏览量
|
583 | *
|
584 | * Whether update pageviews when fetching path result
|
585 | *
|
586 | * @default true
|
587 | */
|
588 | update?: boolean;
|
589 | /**
|
590 | * 错误提示消息所使用的语言
|
591 | *
|
592 | * Language of error message
|
593 | *
|
594 | * @default navigator.language
|
595 | */
|
596 | lang?: string;
|
597 | }
|
598 | declare const pageviewCount: ({ serverURL, path, selector, update, lang, }: WalinePageviewCountOptions) => WalineAbort;
|
599 |
|
600 | declare const version: string;
|
601 |
|
602 | interface WalineRecentCommentsOptions {
|
603 | /**
|
604 | * Waline 服务端地址
|
605 | *
|
606 | * Waline serverURL
|
607 | */
|
608 | serverURL: string;
|
609 | /**
|
610 | * 获取最新评论的数量
|
611 | *
|
612 | * fetch number of latest comments
|
613 | */
|
614 | count: number;
|
615 | /**
|
616 | * 需要挂载的元素
|
617 | *
|
618 | * Element to be mounted
|
619 | */
|
620 | el?: string | HTMLElement;
|
621 | /**
|
622 | * 错误提示消息所使用的语言
|
623 | *
|
624 | * Language of error message
|
625 | *
|
626 | * @default navigator.language
|
627 | */
|
628 | lang?: string;
|
629 | }
|
630 | interface WalineRecentCommentsResult {
|
631 | /**
|
632 | * 评论数据
|
633 | *
|
634 | * Comment Data
|
635 | */
|
636 | comments: WalineComment[];
|
637 | /**
|
638 | * 取消挂载挂件
|
639 | *
|
640 | * Umount widget
|
641 | */
|
642 | destroy: () => void;
|
643 | }
|
644 | declare const RecentComments: ({ el, serverURL, count, lang, }: WalineRecentCommentsOptions) => Promise<WalineRecentCommentsResult>;
|
645 |
|
646 | interface WalineUser extends Pick<WalineComment, 'nick' | 'link' | 'avatar' | 'label' | 'level'> {
|
647 | count: number;
|
648 | }
|
649 |
|
650 | interface WalineUserListOptions {
|
651 | /**
|
652 | * Waline 服务端地址
|
653 | *
|
654 | * Waline serverURL
|
655 | */
|
656 | serverURL: string;
|
657 | /**
|
658 | * 获取用户列表的数量
|
659 | *
|
660 | * fetch number of user list
|
661 | */
|
662 | count: number;
|
663 | /**
|
664 | * 需要挂载的元素
|
665 | *
|
666 | * Element to be mounted
|
667 | */
|
668 | el?: string | HTMLElement;
|
669 | /**
|
670 | * 错误提示消息所使用的语言
|
671 | *
|
672 | * Language of error message
|
673 | *
|
674 | * @default navigator.language
|
675 | */
|
676 | lang?: string;
|
677 | /**
|
678 | * 自定义 waline 语言显示
|
679 | *
|
680 | * @see [自定义语言](https://waline.js.org/client/i18n.html)
|
681 | *
|
682 | * Custom display language in waline
|
683 | *
|
684 | * @see [I18n](https://waline.js.org/en/client/i18n.html)
|
685 | */
|
686 | locale?: WalineLocale;
|
687 | /**
|
688 | * 列表模式还是头像墙模式
|
689 | *
|
690 | * list mode or avatar wall mode
|
691 | */
|
692 | mode: 'list' | 'wall';
|
693 | }
|
694 | interface WalineUserListResult {
|
695 | /**
|
696 | * 用户数据
|
697 | *
|
698 | * User Data
|
699 | */
|
700 | users: WalineUser[];
|
701 | /**
|
702 | * 取消挂载挂件
|
703 | *
|
704 | * Umount widget
|
705 | */
|
706 | destroy: () => void;
|
707 | }
|
708 | declare const UserList: ({ el, serverURL, count, locale, lang, mode, }: WalineUserListOptions) => Promise<WalineUserListResult>;
|
709 |
|
710 | export { RecentComments, UserList, WalineAbort, WalineComment, WalineCommentCountOptions, WalineCommentData, WalineCommentSorting, WalineCommentStatus, WalineDateLocale, WalineEmojiInfo, WalineEmojiMaps, WalineEmojiPresets, WalineHighlighter, WalineImageUploader, WalineInitOptions, WalineInstance, WalineLevelLocale, WalineLocale, WalineLoginStatus, WalineMeta, WalinePageviewCountOptions, WalineProps, WalineReactionLocale, WalineRecentCommentsOptions, WalineRecentCommentsResult, WalineSearchImageData, WalineSearchOptions, WalineSearchResult, WalineTexRenderer, WalineUserListOptions, WalineUserListResult, commentCount, defaultLocales, init, pageviewCount, version };
|