@waline/client 2.14.1 → 2.14.3

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 (81) hide show
  1. package/dist/api.cjs +1 -1
  2. package/dist/api.cjs.map +1 -1
  3. package/dist/api.d.cts +22 -20
  4. package/dist/api.d.mts +22 -20
  5. package/dist/api.d.ts +22 -20
  6. package/dist/api.mjs +1 -1
  7. package/dist/api.mjs.map +1 -1
  8. package/dist/comment.cjs +1 -1
  9. package/dist/comment.cjs.map +1 -1
  10. package/dist/comment.d.cts +1 -1
  11. package/dist/comment.d.mts +1 -1
  12. package/dist/comment.d.ts +1 -1
  13. package/dist/comment.js +1 -68
  14. package/dist/comment.js.map +1 -1
  15. package/dist/comment.mjs +1 -1
  16. package/dist/comment.mjs.map +1 -1
  17. package/dist/component.mjs +1 -1
  18. package/dist/component.mjs.map +1 -1
  19. package/dist/legacy.umd.d.ts +15 -6
  20. package/dist/legacy.umd.js +1 -1
  21. package/dist/legacy.umd.js.map +1 -1
  22. package/dist/pageview.cjs +1 -1
  23. package/dist/pageview.cjs.map +1 -1
  24. package/dist/pageview.d.cts +1 -1
  25. package/dist/pageview.d.mts +1 -1
  26. package/dist/pageview.d.ts +1 -1
  27. package/dist/pageview.js +1 -121
  28. package/dist/pageview.js.map +1 -1
  29. package/dist/pageview.mjs +1 -1
  30. package/dist/pageview.mjs.map +1 -1
  31. package/dist/shim.cjs +1 -1
  32. package/dist/shim.cjs.map +1 -1
  33. package/dist/shim.d.cts +20 -11
  34. package/dist/shim.d.mts +20 -11
  35. package/dist/shim.mjs +1 -1
  36. package/dist/shim.mjs.map +1 -1
  37. package/dist/waline.cjs +1 -1
  38. package/dist/waline.cjs.map +1 -1
  39. package/dist/waline.css +1 -1
  40. package/dist/waline.css.map +1 -1
  41. package/dist/waline.d.cts +20 -11
  42. package/dist/waline.d.mts +20 -11
  43. package/dist/waline.d.ts +20 -11
  44. package/dist/waline.js +1 -6787
  45. package/dist/waline.js.map +1 -1
  46. package/dist/waline.mjs +1 -1
  47. package/dist/waline.mjs.map +1 -1
  48. package/package.json +28 -27
  49. package/src/api/comment.ts +25 -24
  50. package/src/comment.ts +3 -4
  51. package/src/components/ArticleReaction.vue +120 -117
  52. package/src/components/CommentBox.vue +451 -488
  53. package/src/components/CommentCard.vue +109 -98
  54. package/src/components/ImageWall.vue +132 -131
  55. package/src/components/WalineComment.vue +683 -0
  56. package/src/composables/index.ts +1 -2
  57. package/src/composables/reaction.ts +16 -0
  58. package/src/composables/recaptchaV3.ts +4 -6
  59. package/src/config/default.ts +6 -1
  60. package/src/config/i18n/index.ts +1 -0
  61. package/src/{entrys → entries}/api.ts +0 -0
  62. package/src/{entrys → entries}/comment.ts +0 -0
  63. package/src/entries/components.ts +2 -0
  64. package/src/{entrys → entries}/full.ts +0 -0
  65. package/src/{entrys → entries}/init.ts +0 -0
  66. package/src/{entrys → entries}/legacy.ts +0 -0
  67. package/src/{entrys → entries}/pageview.ts +0 -0
  68. package/src/init.ts +1 -1
  69. package/src/pageview.ts +2 -2
  70. package/src/styles/reaction.scss +27 -16
  71. package/src/typings/base.ts +5 -0
  72. package/src/typings/waline.ts +15 -6
  73. package/src/utils/config.ts +28 -6
  74. package/src/utils/image.ts +1 -1
  75. package/src/widgets/recentComments.ts +2 -2
  76. package/src/widgets/userList.ts +2 -2
  77. package/LICENSE +0 -339
  78. package/src/components/Waline.vue +0 -509
  79. package/src/composables/timeAgo.ts +0 -15
  80. package/src/composables/vote.ts +0 -20
  81. package/src/entrys/components.ts +0 -2
@@ -1,5 +1,6 @@
1
1
  import type { IGif } from '@giphy/js-types';
2
2
  import type {
3
+ WalineEmojiPresets,
3
4
  WalineMeta,
4
5
  WalineSearchOptions,
5
6
  WalineSearchResult,
@@ -10,7 +11,11 @@ const availableMeta: WalineMeta[] = ['nick', 'mail', 'link'];
10
11
  export const getMeta = (meta: WalineMeta[]): WalineMeta[] =>
11
12
  meta.filter((item) => availableMeta.includes(item));
12
13
 
13
- export const defaultLang = 'zh-CN';
14
+ export const defaultEmoji: WalineEmojiPresets[] = [
15
+ '//unpkg.com/@waline/emojis@1.1.0/weibo',
16
+ ];
17
+
18
+ export const defaultLang = 'en-US';
14
19
 
15
20
  export const defaultUploadImage = (file: File): Promise<string> =>
16
21
  new Promise((resolve, reject) => {
@@ -20,6 +20,7 @@ export const defaultLocales: Locales = {
20
20
  'en-US': en,
21
21
  'en-us': en,
22
22
  jp: jp,
23
+ ja: jp,
23
24
  'jp-jp': jp,
24
25
  'jp-JP': jp,
25
26
  'pt-br': ptBR,
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ export { default as Waline } from '../components/WalineComment.vue';
2
+ export * from '../version';
File without changes
File without changes
File without changes
File without changes
package/src/init.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createApp, h, reactive, watchEffect } from 'vue';
2
2
 
3
- import Waline from './components/Waline.vue';
3
+ import Waline from './components/WalineComment.vue';
4
4
  import { commentCount } from './comment';
5
5
  import { pageviewCount } from './pageview';
6
6
  import { getRoot } from './utils';
package/src/pageview.ts CHANGED
@@ -43,7 +43,7 @@ export interface WalinePageviewCountOptions {
43
43
  *
44
44
  * Language of error message
45
45
  *
46
- * @default 'zh-CN'
46
+ * @default navigator.language
47
47
  */
48
48
  lang?: string;
49
49
  }
@@ -62,7 +62,7 @@ export const pageviewCount = ({
62
62
  path = window.location.pathname,
63
63
  selector = '.waline-pageview-count',
64
64
  update = true,
65
- lang = 'zh-CN',
65
+ lang = navigator.language,
66
66
  }: WalinePageviewCountOptions): WalineAbort => {
67
67
  const controller = new AbortController();
68
68
 
@@ -2,7 +2,13 @@
2
2
  margin-bottom: 1.75em;
3
3
  text-align: center;
4
4
 
5
- ul {
5
+ img {
6
+ width: 100%;
7
+ height: 100%;
8
+ transition: all 250ms ease-in-out;
9
+ }
10
+
11
+ &-list {
6
12
  display: flex;
7
13
  flex-direction: row;
8
14
  gap: 16px;
@@ -13,7 +19,7 @@
13
19
  list-style-type: none;
14
20
  }
15
21
 
16
- li {
22
+ &-item {
17
23
  display: flex;
18
24
  flex-direction: column;
19
25
  align-items: center;
@@ -23,31 +29,36 @@
23
29
  &.active img {
24
30
  transform: scale(1.15);
25
31
  }
26
- }
27
32
 
28
- li.active .wl-reaction {
29
- &-votes {
30
- background: var(--waline-theme-color);
31
- color: var(--waline-bgcolor);
32
- }
33
+ &.active .wl-reaction {
34
+ &-votes {
35
+ background: var(--waline-theme-color);
36
+ color: var(--waline-bgcolor);
37
+ }
33
38
 
34
- &-text {
35
- color: var(--waline-theme-color);
39
+ &-text {
40
+ color: var(--waline-theme-color);
41
+ }
36
42
  }
37
43
  }
38
44
 
39
- img {
40
- width: 100%;
41
- height: 100%;
42
- transition: all 250ms ease-in-out;
43
- }
44
-
45
45
  &-img {
46
46
  position: relative;
47
47
  width: 42px;
48
48
  height: 42px;
49
49
  }
50
50
 
51
+ &-loading {
52
+ position: absolute;
53
+ top: -4px;
54
+ right: -5px;
55
+
56
+ width: 18px;
57
+ height: 18px;
58
+
59
+ color: var(--waline-theme-color);
60
+ }
61
+
51
62
  &-votes {
52
63
  position: absolute;
53
64
  top: -4px;
@@ -1,5 +1,10 @@
1
1
  export type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
2
2
 
3
+ export type WalineEmojiPresets =
4
+ | `//${string}`
5
+ | `http://${string}`
6
+ | `https://${string}`;
7
+
3
8
  export interface WalineEmojiInfo {
4
9
  /**
5
10
  * 选项卡上的 Emoji 名称
@@ -2,6 +2,7 @@ import type {
2
2
  WalineCommentSorting,
3
3
  WalineHighlighter,
4
4
  WalineEmojiInfo,
5
+ WalineEmojiPresets,
5
6
  WalineImageUploader,
6
7
  WalineLoginStatus,
7
8
  WalineMeta,
@@ -116,7 +117,7 @@ export interface WalineProps {
116
117
  * - `'ru-ru'`
117
118
  * - `'ru-RU'`
118
119
  *
119
- * @default 'zh-CN'
120
+ * @default navigator.language
120
121
  */
121
122
  lang?: string;
122
123
 
@@ -158,22 +159,26 @@ export interface WalineProps {
158
159
  *
159
160
  * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
160
161
  */
161
- emoji?: (string | WalineEmojiInfo)[] | false;
162
+ emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
162
163
 
163
164
  /**
164
165
  * 设置搜索功能
165
166
  *
166
167
  * Customize Search feature
168
+ *
169
+ * @default true
167
170
  */
168
- search?: WalineSearchOptions | false;
171
+ search?: WalineSearchOptions | boolean;
169
172
 
170
173
  /**
171
174
  * 代码高亮
172
175
  *
173
176
  * Code highlighting
177
+ *
178
+ * @default true
174
179
  */
175
180
 
176
- highlighter?: WalineHighlighter | false;
181
+ highlighter?: WalineHighlighter | boolean;
177
182
 
178
183
  /**
179
184
  * 自定义图片上传方法,方便更好的存储图片
@@ -183,16 +188,20 @@ export interface WalineProps {
183
188
  * Custom image upload callback to manage picture by yourself.
184
189
  *
185
190
  * We will pass a picture file object when execute it.
191
+ *
192
+ * @default true
186
193
  */
187
194
 
188
- imageUploader?: WalineImageUploader | false;
195
+ imageUploader?: WalineImageUploader | boolean;
189
196
 
190
197
  /**
191
198
  * 自定义数学公式处理方法,用于预览。
192
199
  *
193
200
  * Custom math formula parse callback for preview.
201
+ *
202
+ * @default true
194
203
  */
195
- texRenderer?: WalineTexRenderer | false;
204
+ texRenderer?: WalineTexRenderer | boolean;
196
205
 
197
206
  /**
198
207
  *
@@ -1,4 +1,5 @@
1
1
  import {
2
+ defaultEmoji,
2
3
  defaultLang,
3
4
  defaultLocales,
4
5
  defaultReaction,
@@ -24,10 +25,26 @@ export interface WalineEmojiConfig {
24
25
  }
25
26
 
26
27
  export interface WalineConfig
27
- extends Required<Omit<WalineProps, 'wordLimit' | 'reaction'>> {
28
+ extends Required<
29
+ Omit<
30
+ WalineProps,
31
+ | 'emoji'
32
+ | 'imageUploader'
33
+ | 'highlighter'
34
+ | 'texRenderer'
35
+ | 'wordLimit'
36
+ | 'reaction'
37
+ | 'search'
38
+ >
39
+ > {
28
40
  locale: WalineLocale;
29
41
  wordLimit: [number, number] | false;
30
42
  reaction: string[];
43
+ emoji: Exclude<WalineProps['emoji'], boolean | undefined>;
44
+ highlighter: Exclude<WalineProps['highlighter'], true | undefined>;
45
+ imageUploader: Exclude<WalineProps['imageUploader'], true | undefined>;
46
+ texRenderer: Exclude<WalineProps['texRenderer'], true | undefined>;
47
+ search: Exclude<WalineProps['search'], true | undefined>;
31
48
  }
32
49
 
33
50
  export const getServerURL = (serverURL: string): string => {
@@ -42,7 +59,7 @@ const getWordLimit = (
42
59
  Array.isArray(wordLimit) ? wordLimit : wordLimit ? [0, wordLimit] : false;
43
60
 
44
61
  const fallback = <T = unknown>(
45
- value: T | false | undefined,
62
+ value: T | boolean | undefined,
46
63
  fallback: T
47
64
  ): T | false =>
48
65
  typeof value === 'function' ? value : value === false ? false : fallback;
@@ -51,9 +68,9 @@ export const getConfig = ({
51
68
  serverURL,
52
69
 
53
70
  path = location.pathname,
54
- lang = defaultLang,
71
+ lang = navigator.language,
55
72
  locale,
56
- emoji = ['//unpkg.com/@waline/emojis@1.1.0/weibo'],
73
+ emoji = defaultEmoji,
57
74
  meta = ['nick', 'mail', 'link'],
58
75
  requiredMeta = [],
59
76
  dark = false,
@@ -84,11 +101,16 @@ export const getConfig = ({
84
101
  texRenderer: fallback(texRenderer, defaultTexRenderer),
85
102
  lang,
86
103
  dark,
87
- emoji,
104
+ emoji: typeof emoji === 'boolean' ? (emoji ? defaultEmoji : []) : emoji,
88
105
  pageSize,
89
106
  login,
90
107
  copyright,
91
- search: search ?? getDefaultSearchOptions(lang),
108
+ search:
109
+ search === false
110
+ ? false
111
+ : typeof search === 'object'
112
+ ? search
113
+ : getDefaultSearchOptions(lang),
92
114
  recaptchaV3Key,
93
115
  reaction: Array.isArray(reaction)
94
116
  ? reaction
@@ -1,7 +1,7 @@
1
1
  const isImage = (item: DataTransferItem): boolean =>
2
2
  item.type.includes('image');
3
3
 
4
- export const getImagefromDataTransfer = (
4
+ export const getImageFromDataTransfer = (
5
5
  items: DataTransferItemList
6
6
  ): File | null => {
7
7
  const image = Array.from(items).find(isImage);
@@ -31,7 +31,7 @@ export interface WalineRecentCommentsOptions {
31
31
  *
32
32
  * Language of error message
33
33
  *
34
- * @default 'zh-CN'
34
+ * @default navigator.language
35
35
  */
36
36
  lang?: string;
37
37
  }
@@ -56,7 +56,7 @@ export const RecentComments = ({
56
56
  el,
57
57
  serverURL,
58
58
  count,
59
- lang = 'zh-CN',
59
+ lang = navigator.language,
60
60
  }: WalineRecentCommentsOptions): Promise<WalineRecentCommentsResult> => {
61
61
  const userInfo = useUserInfo();
62
62
  const root = getRoot(el);
@@ -30,7 +30,7 @@ export interface WalineUserListOptions {
30
30
  *
31
31
  * Language of error message
32
32
  *
33
- * @default 'zh-CN'
33
+ * @default navigator.language
34
34
  */
35
35
  lang?: string;
36
36
 
@@ -74,7 +74,7 @@ export const UserList = ({
74
74
  serverURL,
75
75
  count,
76
76
  locale,
77
- lang = defaultLang,
77
+ lang = navigator.language,
78
78
  mode = 'list',
79
79
  }: WalineUserListOptions): Promise<WalineUserListResult> => {
80
80
  const root = getRoot(el);