@waline/client 2.14.1 → 2.14.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 (62) hide show
  1. package/dist/comment.cjs +1 -1
  2. package/dist/comment.cjs.map +1 -1
  3. package/dist/comment.js +1 -68
  4. package/dist/comment.js.map +1 -1
  5. package/dist/comment.mjs +1 -1
  6. package/dist/comment.mjs.map +1 -1
  7. package/dist/component.mjs +1 -1
  8. package/dist/component.mjs.map +1 -1
  9. package/dist/legacy.umd.d.ts +14 -5
  10. package/dist/legacy.umd.js +1 -1
  11. package/dist/legacy.umd.js.map +1 -1
  12. package/dist/pageview.cjs +1 -1
  13. package/dist/pageview.cjs.map +1 -1
  14. package/dist/pageview.js +1 -121
  15. package/dist/pageview.js.map +1 -1
  16. package/dist/pageview.mjs +1 -1
  17. package/dist/pageview.mjs.map +1 -1
  18. package/dist/shim.cjs +1 -1
  19. package/dist/shim.cjs.map +1 -1
  20. package/dist/shim.d.cts +15 -6
  21. package/dist/shim.d.mts +15 -6
  22. package/dist/shim.mjs +1 -1
  23. package/dist/shim.mjs.map +1 -1
  24. package/dist/waline.cjs +1 -1
  25. package/dist/waline.cjs.map +1 -1
  26. package/dist/waline.css +1 -1
  27. package/dist/waline.css.map +1 -1
  28. package/dist/waline.d.cts +15 -6
  29. package/dist/waline.d.mts +15 -6
  30. package/dist/waline.d.ts +15 -6
  31. package/dist/waline.js +1 -6787
  32. package/dist/waline.js.map +1 -1
  33. package/dist/waline.mjs +1 -1
  34. package/dist/waline.mjs.map +1 -1
  35. package/package.json +18 -18
  36. package/src/comment.ts +1 -2
  37. package/src/components/ArticleReaction.vue +120 -117
  38. package/src/components/CommentBox.vue +451 -488
  39. package/src/components/CommentCard.vue +109 -98
  40. package/src/components/ImageWall.vue +132 -131
  41. package/src/components/WalineComment.vue +683 -0
  42. package/src/composables/index.ts +1 -2
  43. package/src/composables/reaction.ts +16 -0
  44. package/src/composables/recaptchaV3.ts +4 -6
  45. package/src/config/default.ts +5 -0
  46. package/src/{entrys → entries}/api.ts +0 -0
  47. package/src/{entrys → entries}/comment.ts +0 -0
  48. package/src/entries/components.ts +2 -0
  49. package/src/{entrys → entries}/full.ts +0 -0
  50. package/src/{entrys → entries}/init.ts +0 -0
  51. package/src/{entrys → entries}/legacy.ts +0 -0
  52. package/src/{entrys → entries}/pageview.ts +0 -0
  53. package/src/init.ts +1 -1
  54. package/src/styles/reaction.scss +27 -16
  55. package/src/typings/base.ts +5 -0
  56. package/src/typings/waline.ts +14 -5
  57. package/src/utils/config.ts +27 -5
  58. package/src/utils/image.ts +1 -1
  59. package/src/components/Waline.vue +0 -509
  60. package/src/composables/timeAgo.ts +0 -15
  61. package/src/composables/vote.ts +0 -20
  62. 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,6 +11,10 @@ const availableMeta: WalineMeta[] = ['nick', 'mail', 'link'];
10
11
  export const getMeta = (meta: WalineMeta[]): WalineMeta[] =>
11
12
  meta.filter((item) => availableMeta.includes(item));
12
13
 
14
+ export const defaultEmoji: WalineEmojiPresets[] = [
15
+ '//unpkg.com/@waline/emojis@1.1.0/weibo',
16
+ ];
17
+
13
18
  export const defaultLang = 'zh-CN';
14
19
 
15
20
  export const defaultUploadImage = (file: File): Promise<string> =>
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';
@@ -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,
@@ -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;
@@ -53,7 +70,7 @@ export const getConfig = ({
53
70
  path = location.pathname,
54
71
  lang = defaultLang,
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);