@waline/client 2.4.2 → 2.6.0

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 (57) hide show
  1. package/dist/component.esm.js +1 -1
  2. package/dist/component.esm.js.map +1 -1
  3. package/dist/component.js +1 -1
  4. package/dist/component.js.map +1 -1
  5. package/dist/legacy.d.ts +42 -0
  6. package/dist/legacy.js +1 -1
  7. package/dist/legacy.js.map +1 -1
  8. package/dist/pageview.cjs.js +1 -1
  9. package/dist/pageview.cjs.js.map +1 -1
  10. package/dist/pageview.esm.js +1 -1
  11. package/dist/pageview.esm.js.map +1 -1
  12. package/dist/pageview.js +1 -1
  13. package/dist/pageview.js.map +1 -1
  14. package/dist/shim.d.ts +43 -1
  15. package/dist/shim.esm.d.ts +43 -1
  16. package/dist/shim.esm.js +1 -1
  17. package/dist/shim.esm.js.map +1 -1
  18. package/dist/shim.js +1 -1
  19. package/dist/shim.js.map +1 -1
  20. package/dist/waline.cjs.d.ts +43 -1
  21. package/dist/waline.cjs.js +1 -1
  22. package/dist/waline.cjs.js.map +1 -1
  23. package/dist/waline.css +1 -1
  24. package/dist/waline.css.map +1 -1
  25. package/dist/waline.d.ts +43 -1
  26. package/dist/waline.esm.d.ts +43 -1
  27. package/dist/waline.esm.js +1 -1
  28. package/dist/waline.esm.js.map +1 -1
  29. package/dist/waline.js +1 -1
  30. package/dist/waline.js.map +1 -1
  31. package/package.json +21 -22
  32. package/src/comment.ts +7 -2
  33. package/src/components/CommentBox.vue +121 -4
  34. package/src/components/CommentCard.vue +1 -1
  35. package/src/components/Icons.ts +20 -0
  36. package/src/components/ImageWall.vue +166 -0
  37. package/src/composables/like.ts +1 -1
  38. package/src/config/default.ts +91 -1
  39. package/src/config/i18n/en.ts +2 -0
  40. package/src/config/i18n/generate.ts +2 -0
  41. package/src/config/i18n/jp.ts +8 -0
  42. package/src/config/i18n/pt-BR.ts +8 -0
  43. package/src/config/i18n/ru.ts +8 -0
  44. package/src/config/i18n/vi-VN.ts +8 -0
  45. package/src/config/i18n/zh-CN.ts +2 -0
  46. package/src/config/i18n/zh-TW.ts +2 -0
  47. package/src/init.ts +0 -3
  48. package/src/pageview.ts +2 -1
  49. package/src/styles/card.scss +1 -0
  50. package/src/styles/emoji.scss +112 -94
  51. package/src/styles/gif.scss +70 -0
  52. package/src/styles/index.scss +3 -0
  53. package/src/styles/panel.scss +0 -4
  54. package/src/typings/base.ts +40 -0
  55. package/src/typings/locale.ts +2 -0
  56. package/src/typings/waline.ts +8 -0
  57. package/src/utils/config.ts +5 -2
@@ -33,4 +33,12 @@ export default generateLocale([
33
33
  'từ',
34
34
  'Please input comments between $0 and $1 words!\n Current word number: $2',
35
35
  'Vô danh',
36
+ 'Dwarves',
37
+ 'Hobbits',
38
+ 'Ents',
39
+ 'Wizards',
40
+ 'Elves',
41
+ 'Maiar',
42
+ 'GIF',
43
+ 'Tìm kiếm GIF',
36
44
  ]);
@@ -39,4 +39,6 @@ export default generateLocale([
39
39
  '活跃',
40
40
  '话痨',
41
41
  '传说',
42
+ '表情包',
43
+ '搜索表情包',
42
44
  ]);
@@ -39,4 +39,6 @@ export default generateLocale([
39
39
  '活躍',
40
40
  '話癆',
41
41
  '傳說',
42
+ '表情包',
43
+ '搜索表情包',
42
44
  ]);
package/src/init.ts CHANGED
@@ -83,9 +83,6 @@ export const init = ({
83
83
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
84
84
  if (app) app.mount(root!);
85
85
 
86
- updateCommentCount();
87
- updatePageviewCount();
88
-
89
86
  const stopComment = watchEffect(updateCommentCount);
90
87
  const stopPageview = watchEffect(updatePageviewCount);
91
88
 
package/src/pageview.ts CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  errorHandler,
3
3
  fetchPageviews,
4
4
  getQuery,
5
+ getServerURL,
5
6
  updatePageviews,
6
7
  } from './utils';
7
8
 
@@ -83,7 +84,7 @@ export const pageviewCount = ({
83
84
 
84
85
  const fetch = (elements: HTMLElement[]): Promise<void> =>
85
86
  fetchPageviews({
86
- serverURL,
87
+ serverURL: getServerURL(serverURL),
87
88
  paths: elements.map((element) => getQuery(element) || path),
88
89
  lang,
89
90
  signal: controller.signal,
@@ -137,6 +137,7 @@
137
137
  .wl-reply {
138
138
  display: inline-flex;
139
139
  align-items: center;
140
+
140
141
  padding: 4px;
141
142
  border: none;
142
143
 
@@ -1,118 +1,136 @@
1
- @mixin emoji() {
2
- .wl-emoji-popup {
3
- position: absolute;
4
- top: 100%;
5
- left: 1.25em;
6
- z-index: 10;
7
-
8
- max-width: 526px;
9
- border: var(--waline-border);
10
- border-radius: 6px;
11
-
12
- background: var(--waline-bgcolor);
13
- box-shadow: var(--waline-box-shadow);
14
-
15
- opacity: 0;
16
- visibility: hidden;
17
-
18
- transition: transform 0.2s ease-out, opacity 0.2s ease-out;
19
- transform: scale(0.9, 0.9);
20
- transform-origin: 0 0;
21
-
22
- &.display {
23
- opacity: 1;
24
- visibility: visible;
25
- transform: none;
26
- }
1
+ .wl-emoji-popup {
2
+ position: absolute;
3
+ top: 100%;
4
+ left: 1.25em;
5
+ z-index: 10;
6
+
7
+ max-width: 526px;
8
+ border: var(--waline-border);
9
+ border-radius: 6px;
10
+
11
+ background: var(--waline-bgcolor);
12
+ box-shadow: var(--waline-box-shadow);
13
+
14
+ opacity: 0;
15
+ visibility: hidden;
16
+
17
+ transition: transform 0.2s ease-out, opacity 0.2s ease-out;
18
+ transform: scale(0.9, 0.9);
19
+ transform-origin: 0 0;
20
+
21
+ &.display {
22
+ opacity: 1;
23
+ visibility: visible;
24
+ transform: none;
25
+ }
26
+
27
+ button {
28
+ display: inline-block;
29
+ vertical-align: middle;
30
+
31
+ width: 2em;
32
+ margin: 0.125em;
33
+ padding: 0;
34
+ border-width: 0;
27
35
 
28
- button {
29
- display: inline-block;
30
- vertical-align: middle;
36
+ background: transparent;
31
37
 
32
- width: 2em;
33
- margin: 0.125em;
34
- padding: 0;
35
- border-width: 0;
38
+ font-size: inherit;
39
+ line-height: 2;
40
+ text-align: center;
36
41
 
37
- background: transparent;
42
+ cursor: pointer;
38
43
 
39
- font-size: inherit;
40
- line-height: 2;
41
- text-align: center;
44
+ &:hover {
45
+ background: var(--waline-bgcolor-hover);
46
+ }
47
+ }
48
+
49
+ .wl-emoji {
50
+ display: inline-block;
51
+ vertical-align: middle;
52
+ max-width: 1.5em;
53
+ max-height: 1.5em;
54
+ }
42
55
 
43
- cursor: pointer;
56
+ .wl-tab-wrapper {
57
+ overflow-y: auto;
58
+ max-height: 145px;
59
+ padding: 0.5em;
44
60
 
45
- &:hover {
46
- background: var(--waline-bgcolor-hover);
47
- }
61
+ &::-webkit-scrollbar {
62
+ width: 6px;
63
+ height: 6px;
48
64
  }
49
65
 
50
- .wl-emoji {
51
- display: inline-block;
52
- vertical-align: middle;
53
- max-width: 1.5em;
54
- max-height: 1.5em;
66
+ &::-webkit-scrollbar-track-piece:vertical {
67
+ -webkit-border-radius: 6px;
68
+ border-radius: 6px;
69
+ background: rgb(0 0 0 / 10%);
55
70
  }
56
71
 
57
- .wl-tab-wrapper {
58
- overflow-y: auto;
59
- max-height: 145px;
60
- padding: 0.5em;
61
-
62
- &::-webkit-scrollbar {
63
- width: 6px;
64
- height: 6px;
65
- }
66
-
67
- &::-webkit-scrollbar-track-piece:vertical {
68
- -webkit-border-radius: 6px;
69
- border-radius: 6px;
70
- background: rgb(0 0 0 / 10%);
71
- }
72
-
73
- &::-webkit-scrollbar-thumb:vertical {
74
- width: 6px;
75
- -webkit-border-radius: 6px;
76
- border-radius: 6px;
77
- background: var(--waline-theme-color);
78
- }
72
+ &::-webkit-scrollbar-thumb:vertical {
73
+ width: 6px;
74
+ -webkit-border-radius: 6px;
75
+ border-radius: 6px;
76
+ background: var(--waline-theme-color);
79
77
  }
78
+ }
79
+
80
+ .wl-tabs {
81
+ position: relative;
82
+ height: 2em;
83
+ padding: 0 6px 1px;
84
+ overflow-x: scroll;
85
+ white-space: nowrap;
86
+
87
+ &::before {
88
+ content: ' ';
89
+
90
+ position: absolute;
91
+ top: 0;
92
+ right: 0;
93
+ left: 0;
94
+ z-index: 2;
80
95
 
81
- .wl-tabs {
82
- position: relative;
83
- height: 2em;
84
- padding: 0 6px 1px;
96
+ height: 1px;
85
97
 
86
- &::before {
87
- content: ' ';
98
+ background: var(--waline-border-color);
99
+ }
88
100
 
89
- position: absolute;
90
- top: 0;
91
- right: 0;
92
- left: 0;
93
- z-index: 2;
101
+ &::-webkit-scrollbar {
102
+ width: 6px;
103
+ height: 6px;
104
+ }
94
105
 
95
- height: 1px;
106
+ &::-webkit-scrollbar-track-piece:horizontal {
107
+ -webkit-border-radius: 6px;
108
+ border-radius: 6px;
109
+ background: rgb(0 0 0 / 10%);
110
+ }
96
111
 
97
- background: var(--waline-border-color);
98
- }
112
+ &::-webkit-scrollbar-thumb:horizontal {
113
+ height: 6px;
114
+ -webkit-border-radius: 6px;
115
+ border-radius: 6px;
116
+ background: var(--waline-theme-color);
99
117
  }
118
+ }
100
119
 
101
- .wl-tab {
102
- position: relative;
103
- margin: 0;
104
- padding: 0 0.5em;
120
+ .wl-tab {
121
+ position: relative;
122
+ margin: 0;
123
+ padding: 0 0.5em;
105
124
 
106
- &.active {
107
- z-index: 3;
125
+ &.active {
126
+ z-index: 3;
108
127
 
109
- border: 1px solid var(--waline-border-color);
110
- border-top-width: 0;
111
- border-bottom-right-radius: 6px;
112
- border-bottom-left-radius: 6px;
128
+ border: 1px solid var(--waline-border-color);
129
+ border-top-width: 0;
130
+ border-bottom-right-radius: 6px;
131
+ border-bottom-left-radius: 6px;
113
132
 
114
- background: var(--waline-bgcolor);
115
- }
133
+ background: var(--waline-bgcolor);
116
134
  }
117
135
  }
118
136
  }
@@ -0,0 +1,70 @@
1
+ .wl-gif-popup {
2
+ position: absolute;
3
+ top: 100%;
4
+ left: 1.25em;
5
+ z-index: 10;
6
+
7
+ width: calc(100% - 3em);
8
+ padding: 0.75em 0.75em 0.25em;
9
+ border: var(--waline-border);
10
+ border-radius: 6px;
11
+
12
+ background: var(--waline-bgcolor);
13
+ box-shadow: var(--waline-box-shadow);
14
+
15
+ opacity: 0;
16
+ visibility: hidden;
17
+
18
+ transition: transform 0.2s ease-out, opacity 0.2s ease-out;
19
+ transform: scale(0.9, 0.9);
20
+ transform-origin: 0 0;
21
+
22
+ &.display {
23
+ opacity: 1;
24
+ visibility: visible;
25
+ transform: none;
26
+ }
27
+
28
+ input {
29
+ box-sizing: border-box;
30
+
31
+ width: 100%;
32
+ margin-bottom: 10px;
33
+ padding: 3px 5px;
34
+ border: var(--waline-border);
35
+ }
36
+
37
+ img {
38
+ display: block;
39
+
40
+ box-sizing: border-box;
41
+
42
+ width: 100%;
43
+ border-width: 2px;
44
+ border-style: solid;
45
+ border-color: #fff;
46
+
47
+ cursor: pointer;
48
+
49
+ &:hover {
50
+ border-color: var(--waline-theme-color);
51
+ border-radius: 2px;
52
+ }
53
+ }
54
+ }
55
+
56
+ .wl-gallery {
57
+ max-height: 80vh;
58
+ display: flex;
59
+ overflow-y: auto;
60
+ }
61
+
62
+ .wl-gallery-column {
63
+ height: -webkit-max-content;
64
+ height: -moz-max-content;
65
+ height: max-content;
66
+
67
+ flex: 1;
68
+ display: flex;
69
+ flex-direction: column;
70
+ }
@@ -4,6 +4,9 @@
4
4
  @use 'base';
5
5
 
6
6
  @use 'panel';
7
+ @use 'emoji';
8
+ @use 'gif';
9
+
7
10
  @use 'card';
8
11
  @use 'layout';
9
12
 
@@ -1,5 +1,3 @@
1
- @use 'emoji';
2
-
3
1
  .wl-comment {
4
2
  position: relative;
5
3
  display: flex;
@@ -286,5 +284,3 @@
286
284
  }
287
285
  }
288
286
  }
289
-
290
- @include emoji.emoji;
@@ -39,6 +39,46 @@ export interface WalineEmojiInfo {
39
39
 
40
40
  export type WalineEmojiMaps = Record<string, string>;
41
41
 
42
+ export interface WalineSearchResult extends Record<string, unknown> {
43
+ /**
44
+ * Image link
45
+ */
46
+ src: string;
47
+
48
+ /**
49
+ * Image title, optional
50
+ */
51
+ title?: string;
52
+
53
+ /**
54
+ * Image preview link, optional
55
+ *
56
+ * @default src
57
+ */
58
+ preview?: string;
59
+ }
60
+
61
+ export interface WalineSearchOptions {
62
+ /**
63
+ * Search action
64
+ */
65
+ search: (word: string) => Promise<WalineSearchResult[]>;
66
+
67
+ /**
68
+ * Default search action
69
+ *
70
+ * @default () => search('')
71
+ */
72
+ default?: () => Promise<WalineSearchResult[]>;
73
+
74
+ /**
75
+ * Fetch more action
76
+ *
77
+ * @default (word) => search(word)
78
+ */
79
+ more?: (word: string, currectCount: number) => Promise<WalineSearchResult[]>;
80
+ }
81
+
42
82
  export type WalineMeta = 'nick' | 'mail' | 'link';
43
83
 
44
84
  export type WalineImageUploader = (image: File) => Promise<string>;
@@ -36,4 +36,6 @@ export interface WalineLocale extends WalineDateLocale, WalineLevelLocale {
36
36
  word: string;
37
37
  wordHint: string;
38
38
  anonymous: string;
39
+ gif: string;
40
+ gifSearchPlaceholder: string;
39
41
  }
@@ -4,6 +4,7 @@ import type {
4
4
  WalineImageUploader,
5
5
  WalineMeta,
6
6
  WalineTexRenderer,
7
+ WalineSearchOptions,
7
8
  } from './base';
8
9
  import type { WalineLocale } from './locale';
9
10
 
@@ -148,6 +149,13 @@ export interface WalineProps {
148
149
  */
149
150
  emoji?: (string | WalineEmojiInfo)[] | false;
150
151
 
152
+ /**
153
+ * 设置搜索功能
154
+ *
155
+ * Customize Search feature
156
+ */
157
+ search?: WalineSearchOptions | false;
158
+
151
159
  /**
152
160
  * 代码高亮
153
161
  *
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  defaultLang,
3
+ defaultLocales,
3
4
  defaultUploadImage,
4
5
  defaultHighlighter,
5
6
  defaultTexRenderer,
7
+ getDefaultSearchOptions,
6
8
  getMeta,
7
- defaultLocales,
8
9
  } from '../config';
9
10
 
10
11
  import { decodePath, isLinkHttp, removeEndingSplash } from './path';
@@ -27,7 +28,7 @@ export interface WalineConfig extends Required<Omit<WalineProps, 'wordLimit'>> {
27
28
  // emoji: Promise<EmojiConfig>;
28
29
  }
29
30
 
30
- const getServerURL = (serverURL: string): string => {
31
+ export const getServerURL = (serverURL: string): string => {
31
32
  const result = removeEndingSplash(serverURL);
32
33
 
33
34
  return isLinkHttp(result) ? result : `https://${result}`;
@@ -61,6 +62,7 @@ export const getConfig = ({
61
62
  texRenderer,
62
63
  copyright = true,
63
64
  login = 'enable',
65
+ search = getDefaultSearchOptions(),
64
66
  ...more
65
67
  }: WalineProps): WalineConfig => ({
66
68
  serverURL: getServerURL(serverURL),
@@ -81,5 +83,6 @@ export const getConfig = ({
81
83
  pageSize,
82
84
  login,
83
85
  copyright,
86
+ search,
84
87
  ...more,
85
88
  });